babylon.module.d.ts 5.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254
  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. */
  7835. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7836. /**
  7837. * Delays loading of the cube texture
  7838. * @param forcedExtension defines the extension to use
  7839. */
  7840. delayLoad(forcedExtension?: string): void;
  7841. /**
  7842. * Returns the reflection texture matrix
  7843. * @returns the reflection texture matrix
  7844. */
  7845. getReflectionTextureMatrix(): Matrix;
  7846. /**
  7847. * Sets the reflection texture matrix
  7848. * @param value Reflection texture matrix
  7849. */
  7850. setReflectionTextureMatrix(value: Matrix): void;
  7851. /**
  7852. * Parses text to create a cube texture
  7853. * @param parsedTexture define the serialized text to read from
  7854. * @param scene defines the hosting scene
  7855. * @param rootUrl defines the root url of the cube texture
  7856. * @returns a cube texture
  7857. */
  7858. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7859. /**
  7860. * Makes a clone, or deep copy, of the cube texture
  7861. * @returns a new cube texture
  7862. */
  7863. clone(): CubeTexture;
  7864. }
  7865. }
  7866. declare module "babylonjs/Materials/materialDefines" {
  7867. /**
  7868. * Manages the defines for the Material
  7869. */
  7870. export class MaterialDefines {
  7871. /** @hidden */
  7872. protected _keys: string[];
  7873. private _isDirty;
  7874. /** @hidden */
  7875. _renderId: number;
  7876. /** @hidden */
  7877. _areLightsDirty: boolean;
  7878. /** @hidden */
  7879. _areLightsDisposed: boolean;
  7880. /** @hidden */
  7881. _areAttributesDirty: boolean;
  7882. /** @hidden */
  7883. _areTexturesDirty: boolean;
  7884. /** @hidden */
  7885. _areFresnelDirty: boolean;
  7886. /** @hidden */
  7887. _areMiscDirty: boolean;
  7888. /** @hidden */
  7889. _areImageProcessingDirty: boolean;
  7890. /** @hidden */
  7891. _normals: boolean;
  7892. /** @hidden */
  7893. _uvs: boolean;
  7894. /** @hidden */
  7895. _needNormals: boolean;
  7896. /** @hidden */
  7897. _needUVs: boolean;
  7898. [id: string]: any;
  7899. /**
  7900. * Specifies if the material needs to be re-calculated
  7901. */
  7902. get isDirty(): boolean;
  7903. /**
  7904. * Marks the material to indicate that it has been re-calculated
  7905. */
  7906. markAsProcessed(): void;
  7907. /**
  7908. * Marks the material to indicate that it needs to be re-calculated
  7909. */
  7910. markAsUnprocessed(): void;
  7911. /**
  7912. * Marks the material to indicate all of its defines need to be re-calculated
  7913. */
  7914. markAllAsDirty(): void;
  7915. /**
  7916. * Marks the material to indicate that image processing needs to be re-calculated
  7917. */
  7918. markAsImageProcessingDirty(): void;
  7919. /**
  7920. * Marks the material to indicate the lights need to be re-calculated
  7921. * @param disposed Defines whether the light is dirty due to dispose or not
  7922. */
  7923. markAsLightDirty(disposed?: boolean): void;
  7924. /**
  7925. * Marks the attribute state as changed
  7926. */
  7927. markAsAttributesDirty(): void;
  7928. /**
  7929. * Marks the texture state as changed
  7930. */
  7931. markAsTexturesDirty(): void;
  7932. /**
  7933. * Marks the fresnel state as changed
  7934. */
  7935. markAsFresnelDirty(): void;
  7936. /**
  7937. * Marks the misc state as changed
  7938. */
  7939. markAsMiscDirty(): void;
  7940. /**
  7941. * Rebuilds the material defines
  7942. */
  7943. rebuild(): void;
  7944. /**
  7945. * Specifies if two material defines are equal
  7946. * @param other - A material define instance to compare to
  7947. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7948. */
  7949. isEqual(other: MaterialDefines): boolean;
  7950. /**
  7951. * Clones this instance's defines to another instance
  7952. * @param other - material defines to clone values to
  7953. */
  7954. cloneTo(other: MaterialDefines): void;
  7955. /**
  7956. * Resets the material define values
  7957. */
  7958. reset(): void;
  7959. /**
  7960. * Converts the material define values to a string
  7961. * @returns - String of material define information
  7962. */
  7963. toString(): string;
  7964. }
  7965. }
  7966. declare module "babylonjs/Materials/colorCurves" {
  7967. import { Effect } from "babylonjs/Materials/effect";
  7968. /**
  7969. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7970. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7971. * 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;
  7972. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7973. */
  7974. export class ColorCurves {
  7975. private _dirty;
  7976. private _tempColor;
  7977. private _globalCurve;
  7978. private _highlightsCurve;
  7979. private _midtonesCurve;
  7980. private _shadowsCurve;
  7981. private _positiveCurve;
  7982. private _negativeCurve;
  7983. private _globalHue;
  7984. private _globalDensity;
  7985. private _globalSaturation;
  7986. private _globalExposure;
  7987. /**
  7988. * Gets the global Hue value.
  7989. * 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).
  7990. */
  7991. get globalHue(): number;
  7992. /**
  7993. * Sets the global Hue value.
  7994. * 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).
  7995. */
  7996. set globalHue(value: number);
  7997. /**
  7998. * Gets the global Density value.
  7999. * 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.
  8000. * Values less than zero provide a filter of opposite hue.
  8001. */
  8002. get globalDensity(): number;
  8003. /**
  8004. * Sets the global Density value.
  8005. * 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.
  8006. * Values less than zero provide a filter of opposite hue.
  8007. */
  8008. set globalDensity(value: number);
  8009. /**
  8010. * Gets the global Saturation value.
  8011. * 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.
  8012. */
  8013. get globalSaturation(): number;
  8014. /**
  8015. * Sets the global Saturation value.
  8016. * 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.
  8017. */
  8018. set globalSaturation(value: number);
  8019. /**
  8020. * Gets the global Exposure value.
  8021. * 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.
  8022. */
  8023. get globalExposure(): number;
  8024. /**
  8025. * Sets the global Exposure value.
  8026. * 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.
  8027. */
  8028. set globalExposure(value: number);
  8029. private _highlightsHue;
  8030. private _highlightsDensity;
  8031. private _highlightsSaturation;
  8032. private _highlightsExposure;
  8033. /**
  8034. * Gets the highlights Hue value.
  8035. * 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).
  8036. */
  8037. get highlightsHue(): number;
  8038. /**
  8039. * Sets the highlights Hue value.
  8040. * 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).
  8041. */
  8042. set highlightsHue(value: number);
  8043. /**
  8044. * Gets the highlights Density value.
  8045. * 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.
  8046. * Values less than zero provide a filter of opposite hue.
  8047. */
  8048. get highlightsDensity(): number;
  8049. /**
  8050. * Sets the highlights Density value.
  8051. * 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.
  8052. * Values less than zero provide a filter of opposite hue.
  8053. */
  8054. set highlightsDensity(value: number);
  8055. /**
  8056. * Gets the highlights Saturation value.
  8057. * 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.
  8058. */
  8059. get highlightsSaturation(): number;
  8060. /**
  8061. * Sets the highlights Saturation value.
  8062. * 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.
  8063. */
  8064. set highlightsSaturation(value: number);
  8065. /**
  8066. * Gets the highlights Exposure value.
  8067. * 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.
  8068. */
  8069. get highlightsExposure(): number;
  8070. /**
  8071. * Sets the highlights Exposure value.
  8072. * 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.
  8073. */
  8074. set highlightsExposure(value: number);
  8075. private _midtonesHue;
  8076. private _midtonesDensity;
  8077. private _midtonesSaturation;
  8078. private _midtonesExposure;
  8079. /**
  8080. * Gets the midtones Hue value.
  8081. * 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).
  8082. */
  8083. get midtonesHue(): number;
  8084. /**
  8085. * Sets the midtones Hue value.
  8086. * 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).
  8087. */
  8088. set midtonesHue(value: number);
  8089. /**
  8090. * Gets the midtones Density value.
  8091. * 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.
  8092. * Values less than zero provide a filter of opposite hue.
  8093. */
  8094. get midtonesDensity(): number;
  8095. /**
  8096. * Sets the midtones Density value.
  8097. * 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.
  8098. * Values less than zero provide a filter of opposite hue.
  8099. */
  8100. set midtonesDensity(value: number);
  8101. /**
  8102. * Gets the midtones Saturation value.
  8103. * 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.
  8104. */
  8105. get midtonesSaturation(): number;
  8106. /**
  8107. * Sets the midtones Saturation value.
  8108. * 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.
  8109. */
  8110. set midtonesSaturation(value: number);
  8111. /**
  8112. * Gets the midtones Exposure value.
  8113. * 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.
  8114. */
  8115. get midtonesExposure(): number;
  8116. /**
  8117. * Sets the midtones Exposure value.
  8118. * 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.
  8119. */
  8120. set midtonesExposure(value: number);
  8121. private _shadowsHue;
  8122. private _shadowsDensity;
  8123. private _shadowsSaturation;
  8124. private _shadowsExposure;
  8125. /**
  8126. * Gets the shadows Hue value.
  8127. * 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).
  8128. */
  8129. get shadowsHue(): number;
  8130. /**
  8131. * Sets the shadows Hue value.
  8132. * 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).
  8133. */
  8134. set shadowsHue(value: number);
  8135. /**
  8136. * Gets the shadows Density value.
  8137. * 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.
  8138. * Values less than zero provide a filter of opposite hue.
  8139. */
  8140. get shadowsDensity(): number;
  8141. /**
  8142. * Sets the shadows Density value.
  8143. * 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.
  8144. * Values less than zero provide a filter of opposite hue.
  8145. */
  8146. set shadowsDensity(value: number);
  8147. /**
  8148. * Gets the shadows Saturation value.
  8149. * 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.
  8150. */
  8151. get shadowsSaturation(): number;
  8152. /**
  8153. * Sets the shadows Saturation value.
  8154. * 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.
  8155. */
  8156. set shadowsSaturation(value: number);
  8157. /**
  8158. * Gets the shadows Exposure value.
  8159. * 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.
  8160. */
  8161. get shadowsExposure(): number;
  8162. /**
  8163. * Sets the shadows Exposure value.
  8164. * 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.
  8165. */
  8166. set shadowsExposure(value: number);
  8167. /**
  8168. * Returns the class name
  8169. * @returns The class name
  8170. */
  8171. getClassName(): string;
  8172. /**
  8173. * Binds the color curves to the shader.
  8174. * @param colorCurves The color curve to bind
  8175. * @param effect The effect to bind to
  8176. * @param positiveUniform The positive uniform shader parameter
  8177. * @param neutralUniform The neutral uniform shader parameter
  8178. * @param negativeUniform The negative uniform shader parameter
  8179. */
  8180. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8181. /**
  8182. * Prepare the list of uniforms associated with the ColorCurves effects.
  8183. * @param uniformsList The list of uniforms used in the effect
  8184. */
  8185. static PrepareUniforms(uniformsList: string[]): void;
  8186. /**
  8187. * Returns color grading data based on a hue, density, saturation and exposure value.
  8188. * @param filterHue The hue of the color filter.
  8189. * @param filterDensity The density of the color filter.
  8190. * @param saturation The saturation.
  8191. * @param exposure The exposure.
  8192. * @param result The result data container.
  8193. */
  8194. private getColorGradingDataToRef;
  8195. /**
  8196. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8197. * @param value The input slider value in range [-100,100].
  8198. * @returns Adjusted value.
  8199. */
  8200. private static applyColorGradingSliderNonlinear;
  8201. /**
  8202. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8203. * @param hue The hue (H) input.
  8204. * @param saturation The saturation (S) input.
  8205. * @param brightness The brightness (B) input.
  8206. * @result An RGBA color represented as Vector4.
  8207. */
  8208. private static fromHSBToRef;
  8209. /**
  8210. * Returns a value clamped between min and max
  8211. * @param value The value to clamp
  8212. * @param min The minimum of value
  8213. * @param max The maximum of value
  8214. * @returns The clamped value.
  8215. */
  8216. private static clamp;
  8217. /**
  8218. * Clones the current color curve instance.
  8219. * @return The cloned curves
  8220. */
  8221. clone(): ColorCurves;
  8222. /**
  8223. * Serializes the current color curve instance to a json representation.
  8224. * @return a JSON representation
  8225. */
  8226. serialize(): any;
  8227. /**
  8228. * Parses the color curve from a json representation.
  8229. * @param source the JSON source to parse
  8230. * @return The parsed curves
  8231. */
  8232. static Parse(source: any): ColorCurves;
  8233. }
  8234. }
  8235. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8236. import { Observable } from "babylonjs/Misc/observable";
  8237. import { Nullable } from "babylonjs/types";
  8238. import { Color4 } from "babylonjs/Maths/math.color";
  8239. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8240. import { Effect } from "babylonjs/Materials/effect";
  8241. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8242. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8243. /**
  8244. * Interface to follow in your material defines to integrate easily the
  8245. * Image proccessing functions.
  8246. * @hidden
  8247. */
  8248. export interface IImageProcessingConfigurationDefines {
  8249. IMAGEPROCESSING: boolean;
  8250. VIGNETTE: boolean;
  8251. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8252. VIGNETTEBLENDMODEOPAQUE: boolean;
  8253. TONEMAPPING: boolean;
  8254. TONEMAPPING_ACES: boolean;
  8255. CONTRAST: boolean;
  8256. EXPOSURE: boolean;
  8257. COLORCURVES: boolean;
  8258. COLORGRADING: boolean;
  8259. COLORGRADING3D: boolean;
  8260. SAMPLER3DGREENDEPTH: boolean;
  8261. SAMPLER3DBGRMAP: boolean;
  8262. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8263. }
  8264. /**
  8265. * @hidden
  8266. */
  8267. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8268. IMAGEPROCESSING: boolean;
  8269. VIGNETTE: boolean;
  8270. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8271. VIGNETTEBLENDMODEOPAQUE: boolean;
  8272. TONEMAPPING: boolean;
  8273. TONEMAPPING_ACES: boolean;
  8274. CONTRAST: boolean;
  8275. COLORCURVES: boolean;
  8276. COLORGRADING: boolean;
  8277. COLORGRADING3D: boolean;
  8278. SAMPLER3DGREENDEPTH: boolean;
  8279. SAMPLER3DBGRMAP: boolean;
  8280. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8281. EXPOSURE: boolean;
  8282. constructor();
  8283. }
  8284. /**
  8285. * This groups together the common properties used for image processing either in direct forward pass
  8286. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8287. * or not.
  8288. */
  8289. export class ImageProcessingConfiguration {
  8290. /**
  8291. * Default tone mapping applied in BabylonJS.
  8292. */
  8293. static readonly TONEMAPPING_STANDARD: number;
  8294. /**
  8295. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8296. * to other engines rendering to increase portability.
  8297. */
  8298. static readonly TONEMAPPING_ACES: number;
  8299. /**
  8300. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8301. */
  8302. colorCurves: Nullable<ColorCurves>;
  8303. private _colorCurvesEnabled;
  8304. /**
  8305. * Gets wether the color curves effect is enabled.
  8306. */
  8307. get colorCurvesEnabled(): boolean;
  8308. /**
  8309. * Sets wether the color curves effect is enabled.
  8310. */
  8311. set colorCurvesEnabled(value: boolean);
  8312. private _colorGradingTexture;
  8313. /**
  8314. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8315. */
  8316. get colorGradingTexture(): Nullable<BaseTexture>;
  8317. /**
  8318. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8319. */
  8320. set colorGradingTexture(value: Nullable<BaseTexture>);
  8321. private _colorGradingEnabled;
  8322. /**
  8323. * Gets wether the color grading effect is enabled.
  8324. */
  8325. get colorGradingEnabled(): boolean;
  8326. /**
  8327. * Sets wether the color grading effect is enabled.
  8328. */
  8329. set colorGradingEnabled(value: boolean);
  8330. private _colorGradingWithGreenDepth;
  8331. /**
  8332. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8333. */
  8334. get colorGradingWithGreenDepth(): boolean;
  8335. /**
  8336. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8337. */
  8338. set colorGradingWithGreenDepth(value: boolean);
  8339. private _colorGradingBGR;
  8340. /**
  8341. * Gets wether the color grading texture contains BGR values.
  8342. */
  8343. get colorGradingBGR(): boolean;
  8344. /**
  8345. * Sets wether the color grading texture contains BGR values.
  8346. */
  8347. set colorGradingBGR(value: boolean);
  8348. /** @hidden */
  8349. _exposure: number;
  8350. /**
  8351. * Gets the Exposure used in the effect.
  8352. */
  8353. get exposure(): number;
  8354. /**
  8355. * Sets the Exposure used in the effect.
  8356. */
  8357. set exposure(value: number);
  8358. private _toneMappingEnabled;
  8359. /**
  8360. * Gets wether the tone mapping effect is enabled.
  8361. */
  8362. get toneMappingEnabled(): boolean;
  8363. /**
  8364. * Sets wether the tone mapping effect is enabled.
  8365. */
  8366. set toneMappingEnabled(value: boolean);
  8367. private _toneMappingType;
  8368. /**
  8369. * Gets the type of tone mapping effect.
  8370. */
  8371. get toneMappingType(): number;
  8372. /**
  8373. * Sets the type of tone mapping effect used in BabylonJS.
  8374. */
  8375. set toneMappingType(value: number);
  8376. protected _contrast: number;
  8377. /**
  8378. * Gets the contrast used in the effect.
  8379. */
  8380. get contrast(): number;
  8381. /**
  8382. * Sets the contrast used in the effect.
  8383. */
  8384. set contrast(value: number);
  8385. /**
  8386. * Vignette stretch size.
  8387. */
  8388. vignetteStretch: number;
  8389. /**
  8390. * Vignette centre X Offset.
  8391. */
  8392. vignetteCentreX: number;
  8393. /**
  8394. * Vignette centre Y Offset.
  8395. */
  8396. vignetteCentreY: number;
  8397. /**
  8398. * Vignette weight or intensity of the vignette effect.
  8399. */
  8400. vignetteWeight: number;
  8401. /**
  8402. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8403. * if vignetteEnabled is set to true.
  8404. */
  8405. vignetteColor: Color4;
  8406. /**
  8407. * Camera field of view used by the Vignette effect.
  8408. */
  8409. vignetteCameraFov: number;
  8410. private _vignetteBlendMode;
  8411. /**
  8412. * Gets the vignette blend mode allowing different kind of effect.
  8413. */
  8414. get vignetteBlendMode(): number;
  8415. /**
  8416. * Sets the vignette blend mode allowing different kind of effect.
  8417. */
  8418. set vignetteBlendMode(value: number);
  8419. private _vignetteEnabled;
  8420. /**
  8421. * Gets wether the vignette effect is enabled.
  8422. */
  8423. get vignetteEnabled(): boolean;
  8424. /**
  8425. * Sets wether the vignette effect is enabled.
  8426. */
  8427. set vignetteEnabled(value: boolean);
  8428. private _applyByPostProcess;
  8429. /**
  8430. * Gets wether the image processing is applied through a post process or not.
  8431. */
  8432. get applyByPostProcess(): boolean;
  8433. /**
  8434. * Sets wether the image processing is applied through a post process or not.
  8435. */
  8436. set applyByPostProcess(value: boolean);
  8437. private _isEnabled;
  8438. /**
  8439. * Gets wether the image processing is enabled or not.
  8440. */
  8441. get isEnabled(): boolean;
  8442. /**
  8443. * Sets wether the image processing is enabled or not.
  8444. */
  8445. set isEnabled(value: boolean);
  8446. /**
  8447. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8448. */
  8449. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8450. /**
  8451. * Method called each time the image processing information changes requires to recompile the effect.
  8452. */
  8453. protected _updateParameters(): void;
  8454. /**
  8455. * Gets the current class name.
  8456. * @return "ImageProcessingConfiguration"
  8457. */
  8458. getClassName(): string;
  8459. /**
  8460. * Prepare the list of uniforms associated with the Image Processing effects.
  8461. * @param uniforms The list of uniforms used in the effect
  8462. * @param defines the list of defines currently in use
  8463. */
  8464. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8465. /**
  8466. * Prepare the list of samplers associated with the Image Processing effects.
  8467. * @param samplersList The list of uniforms used in the effect
  8468. * @param defines the list of defines currently in use
  8469. */
  8470. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8471. /**
  8472. * Prepare the list of defines associated to the shader.
  8473. * @param defines the list of defines to complete
  8474. * @param forPostProcess Define if we are currently in post process mode or not
  8475. */
  8476. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8477. /**
  8478. * Returns true if all the image processing information are ready.
  8479. * @returns True if ready, otherwise, false
  8480. */
  8481. isReady(): boolean;
  8482. /**
  8483. * Binds the image processing to the shader.
  8484. * @param effect The effect to bind to
  8485. * @param overrideAspectRatio Override the aspect ratio of the effect
  8486. */
  8487. bind(effect: Effect, overrideAspectRatio?: number): void;
  8488. /**
  8489. * Clones the current image processing instance.
  8490. * @return The cloned image processing
  8491. */
  8492. clone(): ImageProcessingConfiguration;
  8493. /**
  8494. * Serializes the current image processing instance to a json representation.
  8495. * @return a JSON representation
  8496. */
  8497. serialize(): any;
  8498. /**
  8499. * Parses the image processing from a json representation.
  8500. * @param source the JSON source to parse
  8501. * @return The parsed image processing
  8502. */
  8503. static Parse(source: any): ImageProcessingConfiguration;
  8504. private static _VIGNETTEMODE_MULTIPLY;
  8505. private static _VIGNETTEMODE_OPAQUE;
  8506. /**
  8507. * Used to apply the vignette as a mix with the pixel color.
  8508. */
  8509. static get VIGNETTEMODE_MULTIPLY(): number;
  8510. /**
  8511. * Used to apply the vignette as a replacement of the pixel color.
  8512. */
  8513. static get VIGNETTEMODE_OPAQUE(): number;
  8514. }
  8515. }
  8516. declare module "babylonjs/Shaders/postprocess.vertex" {
  8517. /** @hidden */
  8518. export var postprocessVertexShader: {
  8519. name: string;
  8520. shader: string;
  8521. };
  8522. }
  8523. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8524. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8525. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8526. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8527. module "babylonjs/Engines/thinEngine" {
  8528. interface ThinEngine {
  8529. /**
  8530. * Creates a new render target texture
  8531. * @param size defines the size of the texture
  8532. * @param options defines the options used to create the texture
  8533. * @returns a new render target texture stored in an InternalTexture
  8534. */
  8535. createRenderTargetTexture(size: number | {
  8536. width: number;
  8537. height: number;
  8538. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8539. /**
  8540. * Creates a depth stencil texture.
  8541. * This is only available in WebGL 2 or with the depth texture extension available.
  8542. * @param size The size of face edge in the texture.
  8543. * @param options The options defining the texture.
  8544. * @returns The texture
  8545. */
  8546. createDepthStencilTexture(size: number | {
  8547. width: number;
  8548. height: number;
  8549. }, options: DepthTextureCreationOptions): InternalTexture;
  8550. /** @hidden */
  8551. _createDepthStencilTexture(size: number | {
  8552. width: number;
  8553. height: number;
  8554. }, options: DepthTextureCreationOptions): InternalTexture;
  8555. }
  8556. }
  8557. }
  8558. declare module "babylonjs/Maths/math.axis" {
  8559. import { Vector3 } from "babylonjs/Maths/math.vector";
  8560. /** Defines supported spaces */
  8561. export enum Space {
  8562. /** Local (object) space */
  8563. LOCAL = 0,
  8564. /** World space */
  8565. WORLD = 1,
  8566. /** Bone space */
  8567. BONE = 2
  8568. }
  8569. /** Defines the 3 main axes */
  8570. export class Axis {
  8571. /** X axis */
  8572. static X: Vector3;
  8573. /** Y axis */
  8574. static Y: Vector3;
  8575. /** Z axis */
  8576. static Z: Vector3;
  8577. }
  8578. }
  8579. declare module "babylonjs/Cameras/targetCamera" {
  8580. import { Nullable } from "babylonjs/types";
  8581. import { Camera } from "babylonjs/Cameras/camera";
  8582. import { Scene } from "babylonjs/scene";
  8583. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8584. /**
  8585. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8586. * This is the base of the follow, arc rotate cameras and Free camera
  8587. * @see http://doc.babylonjs.com/features/cameras
  8588. */
  8589. export class TargetCamera extends Camera {
  8590. private static _RigCamTransformMatrix;
  8591. private static _TargetTransformMatrix;
  8592. private static _TargetFocalPoint;
  8593. /**
  8594. * Define the current direction the camera is moving to
  8595. */
  8596. cameraDirection: Vector3;
  8597. /**
  8598. * Define the current rotation the camera is rotating to
  8599. */
  8600. cameraRotation: Vector2;
  8601. /**
  8602. * When set, the up vector of the camera will be updated by the rotation of the camera
  8603. */
  8604. updateUpVectorFromRotation: boolean;
  8605. private _tmpQuaternion;
  8606. /**
  8607. * Define the current rotation of the camera
  8608. */
  8609. rotation: Vector3;
  8610. /**
  8611. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8612. */
  8613. rotationQuaternion: Quaternion;
  8614. /**
  8615. * Define the current speed of the camera
  8616. */
  8617. speed: number;
  8618. /**
  8619. * Add constraint to the camera to prevent it to move freely in all directions and
  8620. * around all axis.
  8621. */
  8622. noRotationConstraint: boolean;
  8623. /**
  8624. * Define the current target of the camera as an object or a position.
  8625. */
  8626. lockedTarget: any;
  8627. /** @hidden */
  8628. _currentTarget: Vector3;
  8629. /** @hidden */
  8630. _initialFocalDistance: number;
  8631. /** @hidden */
  8632. _viewMatrix: Matrix;
  8633. /** @hidden */
  8634. _camMatrix: Matrix;
  8635. /** @hidden */
  8636. _cameraTransformMatrix: Matrix;
  8637. /** @hidden */
  8638. _cameraRotationMatrix: Matrix;
  8639. /** @hidden */
  8640. _referencePoint: Vector3;
  8641. /** @hidden */
  8642. _transformedReferencePoint: Vector3;
  8643. protected _globalCurrentTarget: Vector3;
  8644. protected _globalCurrentUpVector: Vector3;
  8645. /** @hidden */
  8646. _reset: () => void;
  8647. private _defaultUp;
  8648. /**
  8649. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8650. * This is the base of the follow, arc rotate cameras and Free camera
  8651. * @see http://doc.babylonjs.com/features/cameras
  8652. * @param name Defines the name of the camera in the scene
  8653. * @param position Defines the start position of the camera in the scene
  8654. * @param scene Defines the scene the camera belongs to
  8655. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8656. */
  8657. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8658. /**
  8659. * Gets the position in front of the camera at a given distance.
  8660. * @param distance The distance from the camera we want the position to be
  8661. * @returns the position
  8662. */
  8663. getFrontPosition(distance: number): Vector3;
  8664. /** @hidden */
  8665. _getLockedTargetPosition(): Nullable<Vector3>;
  8666. private _storedPosition;
  8667. private _storedRotation;
  8668. private _storedRotationQuaternion;
  8669. /**
  8670. * Store current camera state of the camera (fov, position, rotation, etc..)
  8671. * @returns the camera
  8672. */
  8673. storeState(): Camera;
  8674. /**
  8675. * Restored camera state. You must call storeState() first
  8676. * @returns whether it was successful or not
  8677. * @hidden
  8678. */
  8679. _restoreStateValues(): boolean;
  8680. /** @hidden */
  8681. _initCache(): void;
  8682. /** @hidden */
  8683. _updateCache(ignoreParentClass?: boolean): void;
  8684. /** @hidden */
  8685. _isSynchronizedViewMatrix(): boolean;
  8686. /** @hidden */
  8687. _computeLocalCameraSpeed(): number;
  8688. /**
  8689. * Defines the target the camera should look at.
  8690. * @param target Defines the new target as a Vector or a mesh
  8691. */
  8692. setTarget(target: Vector3): void;
  8693. /**
  8694. * Return the current target position of the camera. This value is expressed in local space.
  8695. * @returns the target position
  8696. */
  8697. getTarget(): Vector3;
  8698. /** @hidden */
  8699. _decideIfNeedsToMove(): boolean;
  8700. /** @hidden */
  8701. _updatePosition(): void;
  8702. /** @hidden */
  8703. _checkInputs(): void;
  8704. protected _updateCameraRotationMatrix(): void;
  8705. /**
  8706. * 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)
  8707. * @returns the current camera
  8708. */
  8709. private _rotateUpVectorWithCameraRotationMatrix;
  8710. private _cachedRotationZ;
  8711. private _cachedQuaternionRotationZ;
  8712. /** @hidden */
  8713. _getViewMatrix(): Matrix;
  8714. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8715. /**
  8716. * @hidden
  8717. */
  8718. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8719. /**
  8720. * @hidden
  8721. */
  8722. _updateRigCameras(): void;
  8723. private _getRigCamPositionAndTarget;
  8724. /**
  8725. * Gets the current object class name.
  8726. * @return the class name
  8727. */
  8728. getClassName(): string;
  8729. }
  8730. }
  8731. declare module "babylonjs/Events/keyboardEvents" {
  8732. /**
  8733. * Gather the list of keyboard event types as constants.
  8734. */
  8735. export class KeyboardEventTypes {
  8736. /**
  8737. * The keydown event is fired when a key becomes active (pressed).
  8738. */
  8739. static readonly KEYDOWN: number;
  8740. /**
  8741. * The keyup event is fired when a key has been released.
  8742. */
  8743. static readonly KEYUP: number;
  8744. }
  8745. /**
  8746. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8747. */
  8748. export class KeyboardInfo {
  8749. /**
  8750. * Defines the type of event (KeyboardEventTypes)
  8751. */
  8752. type: number;
  8753. /**
  8754. * Defines the related dom event
  8755. */
  8756. event: KeyboardEvent;
  8757. /**
  8758. * Instantiates a new keyboard info.
  8759. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8760. * @param type Defines the type of event (KeyboardEventTypes)
  8761. * @param event Defines the related dom event
  8762. */
  8763. constructor(
  8764. /**
  8765. * Defines the type of event (KeyboardEventTypes)
  8766. */
  8767. type: number,
  8768. /**
  8769. * Defines the related dom event
  8770. */
  8771. event: KeyboardEvent);
  8772. }
  8773. /**
  8774. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8775. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8776. */
  8777. export class KeyboardInfoPre extends KeyboardInfo {
  8778. /**
  8779. * Defines the type of event (KeyboardEventTypes)
  8780. */
  8781. type: number;
  8782. /**
  8783. * Defines the related dom event
  8784. */
  8785. event: KeyboardEvent;
  8786. /**
  8787. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8788. */
  8789. skipOnPointerObservable: boolean;
  8790. /**
  8791. * Instantiates a new keyboard pre info.
  8792. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8793. * @param type Defines the type of event (KeyboardEventTypes)
  8794. * @param event Defines the related dom event
  8795. */
  8796. constructor(
  8797. /**
  8798. * Defines the type of event (KeyboardEventTypes)
  8799. */
  8800. type: number,
  8801. /**
  8802. * Defines the related dom event
  8803. */
  8804. event: KeyboardEvent);
  8805. }
  8806. }
  8807. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8808. import { Nullable } from "babylonjs/types";
  8809. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8810. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8811. /**
  8812. * Manage the keyboard inputs to control the movement of a free camera.
  8813. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8814. */
  8815. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8816. /**
  8817. * Defines the camera the input is attached to.
  8818. */
  8819. camera: FreeCamera;
  8820. /**
  8821. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8822. */
  8823. keysUp: number[];
  8824. /**
  8825. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8826. */
  8827. keysDown: number[];
  8828. /**
  8829. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8830. */
  8831. keysLeft: number[];
  8832. /**
  8833. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8834. */
  8835. keysRight: number[];
  8836. private _keys;
  8837. private _onCanvasBlurObserver;
  8838. private _onKeyboardObserver;
  8839. private _engine;
  8840. private _scene;
  8841. /**
  8842. * Attach the input controls to a specific dom element to get the input from.
  8843. * @param element Defines the element the controls should be listened from
  8844. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8845. */
  8846. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8847. /**
  8848. * Detach the current controls from the specified dom element.
  8849. * @param element Defines the element to stop listening the inputs from
  8850. */
  8851. detachControl(element: Nullable<HTMLElement>): void;
  8852. /**
  8853. * Update the current camera state depending on the inputs that have been used this frame.
  8854. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8855. */
  8856. checkInputs(): void;
  8857. /**
  8858. * Gets the class name of the current intput.
  8859. * @returns the class name
  8860. */
  8861. getClassName(): string;
  8862. /** @hidden */
  8863. _onLostFocus(): void;
  8864. /**
  8865. * Get the friendly name associated with the input class.
  8866. * @returns the input friendly name
  8867. */
  8868. getSimpleName(): string;
  8869. }
  8870. }
  8871. declare module "babylonjs/Lights/shadowLight" {
  8872. import { Camera } from "babylonjs/Cameras/camera";
  8873. import { Scene } from "babylonjs/scene";
  8874. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8875. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8876. import { Light } from "babylonjs/Lights/light";
  8877. /**
  8878. * Interface describing all the common properties and methods a shadow light needs to implement.
  8879. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8880. * as well as binding the different shadow properties to the effects.
  8881. */
  8882. export interface IShadowLight extends Light {
  8883. /**
  8884. * The light id in the scene (used in scene.findLighById for instance)
  8885. */
  8886. id: string;
  8887. /**
  8888. * The position the shdow will be casted from.
  8889. */
  8890. position: Vector3;
  8891. /**
  8892. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8893. */
  8894. direction: Vector3;
  8895. /**
  8896. * The transformed position. Position of the light in world space taking parenting in account.
  8897. */
  8898. transformedPosition: Vector3;
  8899. /**
  8900. * The transformed direction. Direction of the light in world space taking parenting in account.
  8901. */
  8902. transformedDirection: Vector3;
  8903. /**
  8904. * The friendly name of the light in the scene.
  8905. */
  8906. name: string;
  8907. /**
  8908. * Defines the shadow projection clipping minimum z value.
  8909. */
  8910. shadowMinZ: number;
  8911. /**
  8912. * Defines the shadow projection clipping maximum z value.
  8913. */
  8914. shadowMaxZ: number;
  8915. /**
  8916. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8917. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8918. */
  8919. computeTransformedInformation(): boolean;
  8920. /**
  8921. * Gets the scene the light belongs to.
  8922. * @returns The scene
  8923. */
  8924. getScene(): Scene;
  8925. /**
  8926. * Callback defining a custom Projection Matrix Builder.
  8927. * This can be used to override the default projection matrix computation.
  8928. */
  8929. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8930. /**
  8931. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8932. * @param matrix The materix to updated with the projection information
  8933. * @param viewMatrix The transform matrix of the light
  8934. * @param renderList The list of mesh to render in the map
  8935. * @returns The current light
  8936. */
  8937. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8938. /**
  8939. * Gets the current depth scale used in ESM.
  8940. * @returns The scale
  8941. */
  8942. getDepthScale(): number;
  8943. /**
  8944. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8945. * @returns true if a cube texture needs to be use
  8946. */
  8947. needCube(): boolean;
  8948. /**
  8949. * Detects if the projection matrix requires to be recomputed this frame.
  8950. * @returns true if it requires to be recomputed otherwise, false.
  8951. */
  8952. needProjectionMatrixCompute(): boolean;
  8953. /**
  8954. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8955. */
  8956. forceProjectionMatrixCompute(): void;
  8957. /**
  8958. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8959. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8960. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8961. */
  8962. getShadowDirection(faceIndex?: number): Vector3;
  8963. /**
  8964. * Gets the minZ used for shadow according to both the scene and the light.
  8965. * @param activeCamera The camera we are returning the min for
  8966. * @returns the depth min z
  8967. */
  8968. getDepthMinZ(activeCamera: Camera): number;
  8969. /**
  8970. * Gets the maxZ used for shadow according to both the scene and the light.
  8971. * @param activeCamera The camera we are returning the max for
  8972. * @returns the depth max z
  8973. */
  8974. getDepthMaxZ(activeCamera: Camera): number;
  8975. }
  8976. /**
  8977. * Base implementation IShadowLight
  8978. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8979. */
  8980. export abstract class ShadowLight extends Light implements IShadowLight {
  8981. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8982. protected _position: Vector3;
  8983. protected _setPosition(value: Vector3): void;
  8984. /**
  8985. * Sets the position the shadow will be casted from. Also use as the light position for both
  8986. * point and spot lights.
  8987. */
  8988. get position(): Vector3;
  8989. /**
  8990. * Sets the position the shadow will be casted from. Also use as the light position for both
  8991. * point and spot lights.
  8992. */
  8993. set position(value: Vector3);
  8994. protected _direction: Vector3;
  8995. protected _setDirection(value: Vector3): void;
  8996. /**
  8997. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8998. * Also use as the light direction on spot and directional lights.
  8999. */
  9000. get direction(): Vector3;
  9001. /**
  9002. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9003. * Also use as the light direction on spot and directional lights.
  9004. */
  9005. set direction(value: Vector3);
  9006. private _shadowMinZ;
  9007. /**
  9008. * Gets the shadow projection clipping minimum z value.
  9009. */
  9010. get shadowMinZ(): number;
  9011. /**
  9012. * Sets the shadow projection clipping minimum z value.
  9013. */
  9014. set shadowMinZ(value: number);
  9015. private _shadowMaxZ;
  9016. /**
  9017. * Sets the shadow projection clipping maximum z value.
  9018. */
  9019. get shadowMaxZ(): number;
  9020. /**
  9021. * Gets the shadow projection clipping maximum z value.
  9022. */
  9023. set shadowMaxZ(value: number);
  9024. /**
  9025. * Callback defining a custom Projection Matrix Builder.
  9026. * This can be used to override the default projection matrix computation.
  9027. */
  9028. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9029. /**
  9030. * The transformed position. Position of the light in world space taking parenting in account.
  9031. */
  9032. transformedPosition: Vector3;
  9033. /**
  9034. * The transformed direction. Direction of the light in world space taking parenting in account.
  9035. */
  9036. transformedDirection: Vector3;
  9037. private _needProjectionMatrixCompute;
  9038. /**
  9039. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9040. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9041. */
  9042. computeTransformedInformation(): boolean;
  9043. /**
  9044. * Return the depth scale used for the shadow map.
  9045. * @returns the depth scale.
  9046. */
  9047. getDepthScale(): number;
  9048. /**
  9049. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9050. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9051. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9052. */
  9053. getShadowDirection(faceIndex?: number): Vector3;
  9054. /**
  9055. * Returns the ShadowLight absolute position in the World.
  9056. * @returns the position vector in world space
  9057. */
  9058. getAbsolutePosition(): Vector3;
  9059. /**
  9060. * Sets the ShadowLight direction toward the passed target.
  9061. * @param target The point to target in local space
  9062. * @returns the updated ShadowLight direction
  9063. */
  9064. setDirectionToTarget(target: Vector3): Vector3;
  9065. /**
  9066. * Returns the light rotation in euler definition.
  9067. * @returns the x y z rotation in local space.
  9068. */
  9069. getRotation(): Vector3;
  9070. /**
  9071. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9072. * @returns true if a cube texture needs to be use
  9073. */
  9074. needCube(): boolean;
  9075. /**
  9076. * Detects if the projection matrix requires to be recomputed this frame.
  9077. * @returns true if it requires to be recomputed otherwise, false.
  9078. */
  9079. needProjectionMatrixCompute(): boolean;
  9080. /**
  9081. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9082. */
  9083. forceProjectionMatrixCompute(): void;
  9084. /** @hidden */
  9085. _initCache(): void;
  9086. /** @hidden */
  9087. _isSynchronized(): boolean;
  9088. /**
  9089. * Computes the world matrix of the node
  9090. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9091. * @returns the world matrix
  9092. */
  9093. computeWorldMatrix(force?: boolean): Matrix;
  9094. /**
  9095. * Gets the minZ used for shadow according to both the scene and the light.
  9096. * @param activeCamera The camera we are returning the min for
  9097. * @returns the depth min z
  9098. */
  9099. getDepthMinZ(activeCamera: Camera): number;
  9100. /**
  9101. * Gets the maxZ used for shadow according to both the scene and the light.
  9102. * @param activeCamera The camera we are returning the max for
  9103. * @returns the depth max z
  9104. */
  9105. getDepthMaxZ(activeCamera: Camera): number;
  9106. /**
  9107. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9108. * @param matrix The materix to updated with the projection information
  9109. * @param viewMatrix The transform matrix of the light
  9110. * @param renderList The list of mesh to render in the map
  9111. * @returns The current light
  9112. */
  9113. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9114. }
  9115. }
  9116. declare module "babylonjs/Materials/effectFallbacks" {
  9117. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9118. import { Effect } from "babylonjs/Materials/effect";
  9119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9120. /**
  9121. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9122. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9123. */
  9124. export class EffectFallbacks implements IEffectFallbacks {
  9125. private _defines;
  9126. private _currentRank;
  9127. private _maxRank;
  9128. private _mesh;
  9129. /**
  9130. * Removes the fallback from the bound mesh.
  9131. */
  9132. unBindMesh(): void;
  9133. /**
  9134. * Adds a fallback on the specified property.
  9135. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9136. * @param define The name of the define in the shader
  9137. */
  9138. addFallback(rank: number, define: string): void;
  9139. /**
  9140. * Sets the mesh to use CPU skinning when needing to fallback.
  9141. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9142. * @param mesh The mesh to use the fallbacks.
  9143. */
  9144. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9145. /**
  9146. * Checks to see if more fallbacks are still availible.
  9147. */
  9148. get hasMoreFallbacks(): boolean;
  9149. /**
  9150. * Removes the defines that should be removed when falling back.
  9151. * @param currentDefines defines the current define statements for the shader.
  9152. * @param effect defines the current effect we try to compile
  9153. * @returns The resulting defines with defines of the current rank removed.
  9154. */
  9155. reduce(currentDefines: string, effect: Effect): string;
  9156. }
  9157. }
  9158. declare module "babylonjs/Materials/materialHelper" {
  9159. import { Nullable } from "babylonjs/types";
  9160. import { Scene } from "babylonjs/scene";
  9161. import { Engine } from "babylonjs/Engines/engine";
  9162. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9163. import { Light } from "babylonjs/Lights/light";
  9164. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9165. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9166. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9167. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9168. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9169. /**
  9170. * "Static Class" containing the most commonly used helper while dealing with material for
  9171. * rendering purpose.
  9172. *
  9173. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9174. *
  9175. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9176. */
  9177. export class MaterialHelper {
  9178. /**
  9179. * Bind the current view position to an effect.
  9180. * @param effect The effect to be bound
  9181. * @param scene The scene the eyes position is used from
  9182. */
  9183. static BindEyePosition(effect: Effect, scene: Scene): void;
  9184. /**
  9185. * Helps preparing the defines values about the UVs in used in the effect.
  9186. * UVs are shared as much as we can accross channels in the shaders.
  9187. * @param texture The texture we are preparing the UVs for
  9188. * @param defines The defines to update
  9189. * @param key The channel key "diffuse", "specular"... used in the shader
  9190. */
  9191. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9192. /**
  9193. * Binds a texture matrix value to its corrsponding uniform
  9194. * @param texture The texture to bind the matrix for
  9195. * @param uniformBuffer The uniform buffer receivin the data
  9196. * @param key The channel key "diffuse", "specular"... used in the shader
  9197. */
  9198. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9199. /**
  9200. * Gets the current status of the fog (should it be enabled?)
  9201. * @param mesh defines the mesh to evaluate for fog support
  9202. * @param scene defines the hosting scene
  9203. * @returns true if fog must be enabled
  9204. */
  9205. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9206. /**
  9207. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9208. * @param mesh defines the current mesh
  9209. * @param scene defines the current scene
  9210. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9211. * @param pointsCloud defines if point cloud rendering has to be turned on
  9212. * @param fogEnabled defines if fog has to be turned on
  9213. * @param alphaTest defines if alpha testing has to be turned on
  9214. * @param defines defines the current list of defines
  9215. */
  9216. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9217. /**
  9218. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9219. * @param scene defines the current scene
  9220. * @param engine defines the current engine
  9221. * @param defines specifies the list of active defines
  9222. * @param useInstances defines if instances have to be turned on
  9223. * @param useClipPlane defines if clip plane have to be turned on
  9224. */
  9225. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9226. /**
  9227. * Prepares the defines for bones
  9228. * @param mesh The mesh containing the geometry data we will draw
  9229. * @param defines The defines to update
  9230. */
  9231. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9232. /**
  9233. * Prepares the defines for morph targets
  9234. * @param mesh The mesh containing the geometry data we will draw
  9235. * @param defines The defines to update
  9236. */
  9237. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9238. /**
  9239. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9240. * @param mesh The mesh containing the geometry data we will draw
  9241. * @param defines The defines to update
  9242. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9243. * @param useBones Precise whether bones should be used or not (override mesh info)
  9244. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9245. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9246. * @returns false if defines are considered not dirty and have not been checked
  9247. */
  9248. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9249. /**
  9250. * Prepares the defines related to multiview
  9251. * @param scene The scene we are intending to draw
  9252. * @param defines The defines to update
  9253. */
  9254. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9255. /**
  9256. * Prepares the defines related to the light information passed in parameter
  9257. * @param scene The scene we are intending to draw
  9258. * @param mesh The mesh the effect is compiling for
  9259. * @param light The light the effect is compiling for
  9260. * @param lightIndex The index of the light
  9261. * @param defines The defines to update
  9262. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9263. * @param state Defines the current state regarding what is needed (normals, etc...)
  9264. */
  9265. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9266. needNormals: boolean;
  9267. needRebuild: boolean;
  9268. shadowEnabled: boolean;
  9269. specularEnabled: boolean;
  9270. lightmapMode: boolean;
  9271. }): void;
  9272. /**
  9273. * Prepares the defines related to the light information passed in parameter
  9274. * @param scene The scene we are intending to draw
  9275. * @param mesh The mesh the effect is compiling for
  9276. * @param defines The defines to update
  9277. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9278. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9279. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9280. * @returns true if normals will be required for the rest of the effect
  9281. */
  9282. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9283. /**
  9284. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9285. * @param lightIndex defines the light index
  9286. * @param uniformsList The uniform list
  9287. * @param samplersList The sampler list
  9288. * @param projectedLightTexture defines if projected texture must be used
  9289. * @param uniformBuffersList defines an optional list of uniform buffers
  9290. */
  9291. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9292. /**
  9293. * Prepares the uniforms and samplers list to be used in the effect
  9294. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9295. * @param samplersList The sampler list
  9296. * @param defines The defines helping in the list generation
  9297. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9298. */
  9299. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9300. /**
  9301. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9302. * @param defines The defines to update while falling back
  9303. * @param fallbacks The authorized effect fallbacks
  9304. * @param maxSimultaneousLights The maximum number of lights allowed
  9305. * @param rank the current rank of the Effect
  9306. * @returns The newly affected rank
  9307. */
  9308. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9309. private static _TmpMorphInfluencers;
  9310. /**
  9311. * Prepares the list of attributes required for morph targets according to the effect defines.
  9312. * @param attribs The current list of supported attribs
  9313. * @param mesh The mesh to prepare the morph targets attributes for
  9314. * @param influencers The number of influencers
  9315. */
  9316. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9317. /**
  9318. * Prepares the list of attributes required for morph targets according to the effect defines.
  9319. * @param attribs The current list of supported attribs
  9320. * @param mesh The mesh to prepare the morph targets attributes for
  9321. * @param defines The current Defines of the effect
  9322. */
  9323. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9324. /**
  9325. * Prepares the list of attributes required for bones according to the effect defines.
  9326. * @param attribs The current list of supported attribs
  9327. * @param mesh The mesh to prepare the bones attributes for
  9328. * @param defines The current Defines of the effect
  9329. * @param fallbacks The current efffect fallback strategy
  9330. */
  9331. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9332. /**
  9333. * Check and prepare the list of attributes required for instances according to the effect defines.
  9334. * @param attribs The current list of supported attribs
  9335. * @param defines The current MaterialDefines of the effect
  9336. */
  9337. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9338. /**
  9339. * Add the list of attributes required for instances to the attribs array.
  9340. * @param attribs The current list of supported attribs
  9341. */
  9342. static PushAttributesForInstances(attribs: string[]): void;
  9343. /**
  9344. * Binds the light information to the effect.
  9345. * @param light The light containing the generator
  9346. * @param effect The effect we are binding the data to
  9347. * @param lightIndex The light index in the effect used to render
  9348. */
  9349. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9350. /**
  9351. * Binds the lights information from the scene to the effect for the given mesh.
  9352. * @param light Light to bind
  9353. * @param lightIndex Light index
  9354. * @param scene The scene where the light belongs to
  9355. * @param effect The effect we are binding the data to
  9356. * @param useSpecular Defines if specular is supported
  9357. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9358. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9359. */
  9360. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9361. /**
  9362. * Binds the lights information from the scene to the effect for the given mesh.
  9363. * @param scene The scene the lights belongs to
  9364. * @param mesh The mesh we are binding the information to render
  9365. * @param effect The effect we are binding the data to
  9366. * @param defines The generated defines for the effect
  9367. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9368. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9369. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9370. */
  9371. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9372. private static _tempFogColor;
  9373. /**
  9374. * Binds the fog information from the scene to the effect for the given mesh.
  9375. * @param scene The scene the lights belongs to
  9376. * @param mesh The mesh we are binding the information to render
  9377. * @param effect The effect we are binding the data to
  9378. * @param linearSpace Defines if the fog effect is applied in linear space
  9379. */
  9380. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9381. /**
  9382. * Binds the bones information from the mesh to the effect.
  9383. * @param mesh The mesh we are binding the information to render
  9384. * @param effect The effect we are binding the data to
  9385. */
  9386. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9387. /**
  9388. * Binds the morph targets information from the mesh to the effect.
  9389. * @param abstractMesh The mesh we are binding the information to render
  9390. * @param effect The effect we are binding the data to
  9391. */
  9392. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9393. /**
  9394. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9395. * @param defines The generated defines used in the effect
  9396. * @param effect The effect we are binding the data to
  9397. * @param scene The scene we are willing to render with logarithmic scale for
  9398. */
  9399. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9400. /**
  9401. * Binds the clip plane information from the scene to the effect.
  9402. * @param scene The scene the clip plane information are extracted from
  9403. * @param effect The effect we are binding the data to
  9404. */
  9405. static BindClipPlane(effect: Effect, scene: Scene): void;
  9406. }
  9407. }
  9408. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9409. /** @hidden */
  9410. export var packingFunctions: {
  9411. name: string;
  9412. shader: string;
  9413. };
  9414. }
  9415. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9416. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9417. /** @hidden */
  9418. export var shadowMapPixelShader: {
  9419. name: string;
  9420. shader: string;
  9421. };
  9422. }
  9423. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9424. /** @hidden */
  9425. export var bonesDeclaration: {
  9426. name: string;
  9427. shader: string;
  9428. };
  9429. }
  9430. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9431. /** @hidden */
  9432. export var morphTargetsVertexGlobalDeclaration: {
  9433. name: string;
  9434. shader: string;
  9435. };
  9436. }
  9437. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9438. /** @hidden */
  9439. export var morphTargetsVertexDeclaration: {
  9440. name: string;
  9441. shader: string;
  9442. };
  9443. }
  9444. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9445. /** @hidden */
  9446. export var instancesDeclaration: {
  9447. name: string;
  9448. shader: string;
  9449. };
  9450. }
  9451. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9452. /** @hidden */
  9453. export var helperFunctions: {
  9454. name: string;
  9455. shader: string;
  9456. };
  9457. }
  9458. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9459. /** @hidden */
  9460. export var morphTargetsVertex: {
  9461. name: string;
  9462. shader: string;
  9463. };
  9464. }
  9465. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9466. /** @hidden */
  9467. export var instancesVertex: {
  9468. name: string;
  9469. shader: string;
  9470. };
  9471. }
  9472. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9473. /** @hidden */
  9474. export var bonesVertex: {
  9475. name: string;
  9476. shader: string;
  9477. };
  9478. }
  9479. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9480. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9481. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9482. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9483. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9484. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9485. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9486. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9487. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9488. /** @hidden */
  9489. export var shadowMapVertexShader: {
  9490. name: string;
  9491. shader: string;
  9492. };
  9493. }
  9494. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9495. /** @hidden */
  9496. export var depthBoxBlurPixelShader: {
  9497. name: string;
  9498. shader: string;
  9499. };
  9500. }
  9501. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9502. import { Nullable } from "babylonjs/types";
  9503. import { Scene } from "babylonjs/scene";
  9504. import { Matrix } from "babylonjs/Maths/math.vector";
  9505. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9507. import { Mesh } from "babylonjs/Meshes/mesh";
  9508. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9509. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9510. import { Effect } from "babylonjs/Materials/effect";
  9511. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9512. import "babylonjs/Shaders/shadowMap.fragment";
  9513. import "babylonjs/Shaders/shadowMap.vertex";
  9514. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9515. import { Observable } from "babylonjs/Misc/observable";
  9516. /**
  9517. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9518. */
  9519. export interface ICustomShaderOptions {
  9520. /**
  9521. * Gets or sets the custom shader name to use
  9522. */
  9523. shaderName: string;
  9524. /**
  9525. * The list of attribute names used in the shader
  9526. */
  9527. attributes?: string[];
  9528. /**
  9529. * The list of unifrom names used in the shader
  9530. */
  9531. uniforms?: string[];
  9532. /**
  9533. * The list of sampler names used in the shader
  9534. */
  9535. samplers?: string[];
  9536. /**
  9537. * The list of defines used in the shader
  9538. */
  9539. defines?: string[];
  9540. }
  9541. /**
  9542. * Interface to implement to create a shadow generator compatible with BJS.
  9543. */
  9544. export interface IShadowGenerator {
  9545. /**
  9546. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9547. * @returns The render target texture if present otherwise, null
  9548. */
  9549. getShadowMap(): Nullable<RenderTargetTexture>;
  9550. /**
  9551. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9552. * @returns The render target texture if the shadow map is present otherwise, null
  9553. */
  9554. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9555. /**
  9556. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9557. * @param subMesh The submesh we want to render in the shadow map
  9558. * @param useInstances Defines wether will draw in the map using instances
  9559. * @returns true if ready otherwise, false
  9560. */
  9561. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9562. /**
  9563. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9564. * @param defines Defines of the material we want to update
  9565. * @param lightIndex Index of the light in the enabled light list of the material
  9566. */
  9567. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9568. /**
  9569. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9570. * defined in the generator but impacting the effect).
  9571. * It implies the unifroms available on the materials are the standard BJS ones.
  9572. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9573. * @param effect The effect we are binfing the information for
  9574. */
  9575. bindShadowLight(lightIndex: string, effect: Effect): void;
  9576. /**
  9577. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9578. * (eq to shadow prjection matrix * light transform matrix)
  9579. * @returns The transform matrix used to create the shadow map
  9580. */
  9581. getTransformMatrix(): Matrix;
  9582. /**
  9583. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9584. * Cube and 2D textures for instance.
  9585. */
  9586. recreateShadowMap(): void;
  9587. /**
  9588. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9589. * @param onCompiled Callback triggered at the and of the effects compilation
  9590. * @param options Sets of optional options forcing the compilation with different modes
  9591. */
  9592. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9593. useInstances: boolean;
  9594. }>): void;
  9595. /**
  9596. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9597. * @param options Sets of optional options forcing the compilation with different modes
  9598. * @returns A promise that resolves when the compilation completes
  9599. */
  9600. forceCompilationAsync(options?: Partial<{
  9601. useInstances: boolean;
  9602. }>): Promise<void>;
  9603. /**
  9604. * Serializes the shadow generator setup to a json object.
  9605. * @returns The serialized JSON object
  9606. */
  9607. serialize(): any;
  9608. /**
  9609. * Disposes the Shadow map and related Textures and effects.
  9610. */
  9611. dispose(): void;
  9612. }
  9613. /**
  9614. * Default implementation IShadowGenerator.
  9615. * This is the main object responsible of generating shadows in the framework.
  9616. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9617. */
  9618. export class ShadowGenerator implements IShadowGenerator {
  9619. /**
  9620. * Shadow generator mode None: no filtering applied.
  9621. */
  9622. static readonly FILTER_NONE: number;
  9623. /**
  9624. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9625. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9626. */
  9627. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9628. /**
  9629. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9630. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9631. */
  9632. static readonly FILTER_POISSONSAMPLING: number;
  9633. /**
  9634. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9635. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9636. */
  9637. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9638. /**
  9639. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9640. * edge artifacts on steep falloff.
  9641. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9642. */
  9643. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9644. /**
  9645. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9646. * edge artifacts on steep falloff.
  9647. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9648. */
  9649. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9650. /**
  9651. * Shadow generator mode PCF: Percentage Closer Filtering
  9652. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9653. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9654. */
  9655. static readonly FILTER_PCF: number;
  9656. /**
  9657. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9658. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9659. * Contact Hardening
  9660. */
  9661. static readonly FILTER_PCSS: number;
  9662. /**
  9663. * Reserved for PCF and PCSS
  9664. * Highest Quality.
  9665. *
  9666. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9667. *
  9668. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9669. */
  9670. static readonly QUALITY_HIGH: number;
  9671. /**
  9672. * Reserved for PCF and PCSS
  9673. * Good tradeoff for quality/perf cross devices
  9674. *
  9675. * Execute PCF on a 3*3 kernel.
  9676. *
  9677. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9678. */
  9679. static readonly QUALITY_MEDIUM: number;
  9680. /**
  9681. * Reserved for PCF and PCSS
  9682. * The lowest quality but the fastest.
  9683. *
  9684. * Execute PCF on a 1*1 kernel.
  9685. *
  9686. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9687. */
  9688. static readonly QUALITY_LOW: number;
  9689. /** Gets or sets the custom shader name to use */
  9690. customShaderOptions: ICustomShaderOptions;
  9691. /**
  9692. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9693. */
  9694. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9695. /**
  9696. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9697. */
  9698. onAfterShadowMapRenderObservable: Observable<Effect>;
  9699. /**
  9700. * Observable triggered before a mesh is rendered in the shadow map.
  9701. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9702. */
  9703. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9704. /**
  9705. * Observable triggered after a mesh is rendered in the shadow map.
  9706. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9707. */
  9708. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9709. private _bias;
  9710. /**
  9711. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9712. */
  9713. get bias(): number;
  9714. /**
  9715. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9716. */
  9717. set bias(bias: number);
  9718. private _normalBias;
  9719. /**
  9720. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9721. */
  9722. get normalBias(): number;
  9723. /**
  9724. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9725. */
  9726. set normalBias(normalBias: number);
  9727. private _blurBoxOffset;
  9728. /**
  9729. * Gets the blur box offset: offset applied during the blur pass.
  9730. * Only useful if useKernelBlur = false
  9731. */
  9732. get blurBoxOffset(): number;
  9733. /**
  9734. * Sets the blur box offset: offset applied during the blur pass.
  9735. * Only useful if useKernelBlur = false
  9736. */
  9737. set blurBoxOffset(value: number);
  9738. private _blurScale;
  9739. /**
  9740. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9741. * 2 means half of the size.
  9742. */
  9743. get blurScale(): number;
  9744. /**
  9745. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9746. * 2 means half of the size.
  9747. */
  9748. set blurScale(value: number);
  9749. private _blurKernel;
  9750. /**
  9751. * Gets the blur kernel: kernel size of the blur pass.
  9752. * Only useful if useKernelBlur = true
  9753. */
  9754. get blurKernel(): number;
  9755. /**
  9756. * Sets the blur kernel: kernel size of the blur pass.
  9757. * Only useful if useKernelBlur = true
  9758. */
  9759. set blurKernel(value: number);
  9760. private _useKernelBlur;
  9761. /**
  9762. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9763. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9764. */
  9765. get useKernelBlur(): boolean;
  9766. /**
  9767. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9768. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9769. */
  9770. set useKernelBlur(value: boolean);
  9771. private _depthScale;
  9772. /**
  9773. * Gets the depth scale used in ESM mode.
  9774. */
  9775. get depthScale(): number;
  9776. /**
  9777. * Sets the depth scale used in ESM mode.
  9778. * This can override the scale stored on the light.
  9779. */
  9780. set depthScale(value: number);
  9781. private _filter;
  9782. /**
  9783. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9784. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9785. */
  9786. get filter(): number;
  9787. /**
  9788. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9789. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9790. */
  9791. set filter(value: number);
  9792. /**
  9793. * Gets if the current filter is set to Poisson Sampling.
  9794. */
  9795. get usePoissonSampling(): boolean;
  9796. /**
  9797. * Sets the current filter to Poisson Sampling.
  9798. */
  9799. set usePoissonSampling(value: boolean);
  9800. /**
  9801. * Gets if the current filter is set to ESM.
  9802. */
  9803. get useExponentialShadowMap(): boolean;
  9804. /**
  9805. * Sets the current filter is to ESM.
  9806. */
  9807. set useExponentialShadowMap(value: boolean);
  9808. /**
  9809. * Gets if the current filter is set to filtered ESM.
  9810. */
  9811. get useBlurExponentialShadowMap(): boolean;
  9812. /**
  9813. * Gets if the current filter is set to filtered ESM.
  9814. */
  9815. set useBlurExponentialShadowMap(value: boolean);
  9816. /**
  9817. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9818. * exponential to prevent steep falloff artifacts).
  9819. */
  9820. get useCloseExponentialShadowMap(): boolean;
  9821. /**
  9822. * Sets the current filter to "close ESM" (using the inverse of the
  9823. * exponential to prevent steep falloff artifacts).
  9824. */
  9825. set useCloseExponentialShadowMap(value: boolean);
  9826. /**
  9827. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9828. * exponential to prevent steep falloff artifacts).
  9829. */
  9830. get useBlurCloseExponentialShadowMap(): boolean;
  9831. /**
  9832. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9833. * exponential to prevent steep falloff artifacts).
  9834. */
  9835. set useBlurCloseExponentialShadowMap(value: boolean);
  9836. /**
  9837. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9838. */
  9839. get usePercentageCloserFiltering(): boolean;
  9840. /**
  9841. * Sets the current filter to "PCF" (percentage closer filtering).
  9842. */
  9843. set usePercentageCloserFiltering(value: boolean);
  9844. private _filteringQuality;
  9845. /**
  9846. * Gets the PCF or PCSS Quality.
  9847. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9848. */
  9849. get filteringQuality(): number;
  9850. /**
  9851. * Sets the PCF or PCSS Quality.
  9852. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9853. */
  9854. set filteringQuality(filteringQuality: number);
  9855. /**
  9856. * Gets if the current filter is set to "PCSS" (contact hardening).
  9857. */
  9858. get useContactHardeningShadow(): boolean;
  9859. /**
  9860. * Sets the current filter to "PCSS" (contact hardening).
  9861. */
  9862. set useContactHardeningShadow(value: boolean);
  9863. private _contactHardeningLightSizeUVRatio;
  9864. /**
  9865. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9866. * Using a ratio helps keeping shape stability independently of the map size.
  9867. *
  9868. * It does not account for the light projection as it was having too much
  9869. * instability during the light setup or during light position changes.
  9870. *
  9871. * Only valid if useContactHardeningShadow is true.
  9872. */
  9873. get contactHardeningLightSizeUVRatio(): number;
  9874. /**
  9875. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9876. * Using a ratio helps keeping shape stability independently of the map size.
  9877. *
  9878. * It does not account for the light projection as it was having too much
  9879. * instability during the light setup or during light position changes.
  9880. *
  9881. * Only valid if useContactHardeningShadow is true.
  9882. */
  9883. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  9884. private _darkness;
  9885. /** Gets or sets the actual darkness of a shadow */
  9886. get darkness(): number;
  9887. set darkness(value: number);
  9888. /**
  9889. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9890. * 0 means strongest and 1 would means no shadow.
  9891. * @returns the darkness.
  9892. */
  9893. getDarkness(): number;
  9894. /**
  9895. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9896. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9897. * @returns the shadow generator allowing fluent coding.
  9898. */
  9899. setDarkness(darkness: number): ShadowGenerator;
  9900. private _transparencyShadow;
  9901. /** Gets or sets the ability to have transparent shadow */
  9902. get transparencyShadow(): boolean;
  9903. set transparencyShadow(value: boolean);
  9904. /**
  9905. * Sets the ability to have transparent shadow (boolean).
  9906. * @param transparent True if transparent else False
  9907. * @returns the shadow generator allowing fluent coding
  9908. */
  9909. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9910. private _shadowMap;
  9911. private _shadowMap2;
  9912. /**
  9913. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9914. * @returns The render target texture if present otherwise, null
  9915. */
  9916. getShadowMap(): Nullable<RenderTargetTexture>;
  9917. /**
  9918. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9919. * @returns The render target texture if the shadow map is present otherwise, null
  9920. */
  9921. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9922. /**
  9923. * Gets the class name of that object
  9924. * @returns "ShadowGenerator"
  9925. */
  9926. getClassName(): string;
  9927. /**
  9928. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9929. * @param mesh Mesh to add
  9930. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9931. * @returns the Shadow Generator itself
  9932. */
  9933. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9934. /**
  9935. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9936. * @param mesh Mesh to remove
  9937. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9938. * @returns the Shadow Generator itself
  9939. */
  9940. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9941. /**
  9942. * Controls the extent to which the shadows fade out at the edge of the frustum
  9943. * Used only by directionals and spots
  9944. */
  9945. frustumEdgeFalloff: number;
  9946. private _light;
  9947. /**
  9948. * Returns the associated light object.
  9949. * @returns the light generating the shadow
  9950. */
  9951. getLight(): IShadowLight;
  9952. /**
  9953. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9954. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9955. * It might on the other hand introduce peter panning.
  9956. */
  9957. forceBackFacesOnly: boolean;
  9958. private _scene;
  9959. private _lightDirection;
  9960. private _effect;
  9961. private _viewMatrix;
  9962. private _projectionMatrix;
  9963. private _transformMatrix;
  9964. private _cachedPosition;
  9965. private _cachedDirection;
  9966. private _cachedDefines;
  9967. private _currentRenderID;
  9968. private _boxBlurPostprocess;
  9969. private _kernelBlurXPostprocess;
  9970. private _kernelBlurYPostprocess;
  9971. private _blurPostProcesses;
  9972. private _mapSize;
  9973. private _currentFaceIndex;
  9974. private _currentFaceIndexCache;
  9975. private _textureType;
  9976. private _defaultTextureMatrix;
  9977. private _storedUniqueId;
  9978. /** @hidden */
  9979. static _SceneComponentInitialization: (scene: Scene) => void;
  9980. /**
  9981. * Creates a ShadowGenerator object.
  9982. * A ShadowGenerator is the required tool to use the shadows.
  9983. * Each light casting shadows needs to use its own ShadowGenerator.
  9984. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9985. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9986. * @param light The light object generating the shadows.
  9987. * @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.
  9988. */
  9989. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9990. private _initializeGenerator;
  9991. private _initializeShadowMap;
  9992. private _initializeBlurRTTAndPostProcesses;
  9993. private _renderForShadowMap;
  9994. private _renderSubMeshForShadowMap;
  9995. private _applyFilterValues;
  9996. /**
  9997. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9998. * @param onCompiled Callback triggered at the and of the effects compilation
  9999. * @param options Sets of optional options forcing the compilation with different modes
  10000. */
  10001. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10002. useInstances: boolean;
  10003. }>): void;
  10004. /**
  10005. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10006. * @param options Sets of optional options forcing the compilation with different modes
  10007. * @returns A promise that resolves when the compilation completes
  10008. */
  10009. forceCompilationAsync(options?: Partial<{
  10010. useInstances: boolean;
  10011. }>): Promise<void>;
  10012. /**
  10013. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10014. * @param subMesh The submesh we want to render in the shadow map
  10015. * @param useInstances Defines wether will draw in the map using instances
  10016. * @returns true if ready otherwise, false
  10017. */
  10018. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10019. /**
  10020. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10021. * @param defines Defines of the material we want to update
  10022. * @param lightIndex Index of the light in the enabled light list of the material
  10023. */
  10024. prepareDefines(defines: any, lightIndex: number): void;
  10025. /**
  10026. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10027. * defined in the generator but impacting the effect).
  10028. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10029. * @param effect The effect we are binfing the information for
  10030. */
  10031. bindShadowLight(lightIndex: string, effect: Effect): void;
  10032. /**
  10033. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10034. * (eq to shadow prjection matrix * light transform matrix)
  10035. * @returns The transform matrix used to create the shadow map
  10036. */
  10037. getTransformMatrix(): Matrix;
  10038. /**
  10039. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10040. * Cube and 2D textures for instance.
  10041. */
  10042. recreateShadowMap(): void;
  10043. private _disposeBlurPostProcesses;
  10044. private _disposeRTTandPostProcesses;
  10045. /**
  10046. * Disposes the ShadowGenerator.
  10047. * Returns nothing.
  10048. */
  10049. dispose(): void;
  10050. /**
  10051. * Serializes the shadow generator setup to a json object.
  10052. * @returns The serialized JSON object
  10053. */
  10054. serialize(): any;
  10055. /**
  10056. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10057. * @param parsedShadowGenerator The JSON object to parse
  10058. * @param scene The scene to create the shadow map for
  10059. * @returns The parsed shadow generator
  10060. */
  10061. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10062. }
  10063. }
  10064. declare module "babylonjs/Lights/light" {
  10065. import { Nullable } from "babylonjs/types";
  10066. import { Scene } from "babylonjs/scene";
  10067. import { Vector3 } from "babylonjs/Maths/math.vector";
  10068. import { Color3 } from "babylonjs/Maths/math.color";
  10069. import { Node } from "babylonjs/node";
  10070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10071. import { Effect } from "babylonjs/Materials/effect";
  10072. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10073. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10074. /**
  10075. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10076. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10077. * 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.
  10078. */
  10079. export abstract class Light extends Node {
  10080. /**
  10081. * Falloff Default: light is falling off following the material specification:
  10082. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10083. */
  10084. static readonly FALLOFF_DEFAULT: number;
  10085. /**
  10086. * Falloff Physical: light is falling off following the inverse squared distance law.
  10087. */
  10088. static readonly FALLOFF_PHYSICAL: number;
  10089. /**
  10090. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10091. * to enhance interoperability with other engines.
  10092. */
  10093. static readonly FALLOFF_GLTF: number;
  10094. /**
  10095. * Falloff Standard: light is falling off like in the standard material
  10096. * to enhance interoperability with other materials.
  10097. */
  10098. static readonly FALLOFF_STANDARD: number;
  10099. /**
  10100. * If every light affecting the material is in this lightmapMode,
  10101. * material.lightmapTexture adds or multiplies
  10102. * (depends on material.useLightmapAsShadowmap)
  10103. * after every other light calculations.
  10104. */
  10105. static readonly LIGHTMAP_DEFAULT: number;
  10106. /**
  10107. * material.lightmapTexture as only diffuse lighting from this light
  10108. * adds only specular lighting from this light
  10109. * adds dynamic shadows
  10110. */
  10111. static readonly LIGHTMAP_SPECULAR: number;
  10112. /**
  10113. * material.lightmapTexture as only lighting
  10114. * no light calculation from this light
  10115. * only adds dynamic shadows from this light
  10116. */
  10117. static readonly LIGHTMAP_SHADOWSONLY: number;
  10118. /**
  10119. * Each light type uses the default quantity according to its type:
  10120. * point/spot lights use luminous intensity
  10121. * directional lights use illuminance
  10122. */
  10123. static readonly INTENSITYMODE_AUTOMATIC: number;
  10124. /**
  10125. * lumen (lm)
  10126. */
  10127. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10128. /**
  10129. * candela (lm/sr)
  10130. */
  10131. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10132. /**
  10133. * lux (lm/m^2)
  10134. */
  10135. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10136. /**
  10137. * nit (cd/m^2)
  10138. */
  10139. static readonly INTENSITYMODE_LUMINANCE: number;
  10140. /**
  10141. * Light type const id of the point light.
  10142. */
  10143. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10144. /**
  10145. * Light type const id of the directional light.
  10146. */
  10147. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10148. /**
  10149. * Light type const id of the spot light.
  10150. */
  10151. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10152. /**
  10153. * Light type const id of the hemispheric light.
  10154. */
  10155. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10156. /**
  10157. * Diffuse gives the basic color to an object.
  10158. */
  10159. diffuse: Color3;
  10160. /**
  10161. * Specular produces a highlight color on an object.
  10162. * Note: This is note affecting PBR materials.
  10163. */
  10164. specular: Color3;
  10165. /**
  10166. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10167. * falling off base on range or angle.
  10168. * This can be set to any values in Light.FALLOFF_x.
  10169. *
  10170. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10171. * other types of materials.
  10172. */
  10173. falloffType: number;
  10174. /**
  10175. * Strength of the light.
  10176. * Note: By default it is define in the framework own unit.
  10177. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10178. */
  10179. intensity: number;
  10180. private _range;
  10181. protected _inverseSquaredRange: number;
  10182. /**
  10183. * Defines how far from the source the light is impacting in scene units.
  10184. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10185. */
  10186. get range(): number;
  10187. /**
  10188. * Defines how far from the source the light is impacting in scene units.
  10189. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10190. */
  10191. set range(value: number);
  10192. /**
  10193. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10194. * of light.
  10195. */
  10196. private _photometricScale;
  10197. private _intensityMode;
  10198. /**
  10199. * Gets the photometric scale used to interpret the intensity.
  10200. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10201. */
  10202. get intensityMode(): number;
  10203. /**
  10204. * Sets the photometric scale used to interpret the intensity.
  10205. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10206. */
  10207. set intensityMode(value: number);
  10208. private _radius;
  10209. /**
  10210. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10211. */
  10212. get radius(): number;
  10213. /**
  10214. * sets the light radius used by PBR Materials to simulate soft area lights.
  10215. */
  10216. set radius(value: number);
  10217. private _renderPriority;
  10218. /**
  10219. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10220. * exceeding the number allowed of the materials.
  10221. */
  10222. renderPriority: number;
  10223. private _shadowEnabled;
  10224. /**
  10225. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10226. * the current shadow generator.
  10227. */
  10228. get shadowEnabled(): boolean;
  10229. /**
  10230. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10231. * the current shadow generator.
  10232. */
  10233. set shadowEnabled(value: boolean);
  10234. private _includedOnlyMeshes;
  10235. /**
  10236. * Gets the only meshes impacted by this light.
  10237. */
  10238. get includedOnlyMeshes(): AbstractMesh[];
  10239. /**
  10240. * Sets the only meshes impacted by this light.
  10241. */
  10242. set includedOnlyMeshes(value: AbstractMesh[]);
  10243. private _excludedMeshes;
  10244. /**
  10245. * Gets the meshes not impacted by this light.
  10246. */
  10247. get excludedMeshes(): AbstractMesh[];
  10248. /**
  10249. * Sets the meshes not impacted by this light.
  10250. */
  10251. set excludedMeshes(value: AbstractMesh[]);
  10252. private _excludeWithLayerMask;
  10253. /**
  10254. * Gets the layer id use to find what meshes are not impacted by the light.
  10255. * Inactive if 0
  10256. */
  10257. get excludeWithLayerMask(): number;
  10258. /**
  10259. * Sets the layer id use to find what meshes are not impacted by the light.
  10260. * Inactive if 0
  10261. */
  10262. set excludeWithLayerMask(value: number);
  10263. private _includeOnlyWithLayerMask;
  10264. /**
  10265. * Gets the layer id use to find what meshes are impacted by the light.
  10266. * Inactive if 0
  10267. */
  10268. get includeOnlyWithLayerMask(): number;
  10269. /**
  10270. * Sets the layer id use to find what meshes are impacted by the light.
  10271. * Inactive if 0
  10272. */
  10273. set includeOnlyWithLayerMask(value: number);
  10274. private _lightmapMode;
  10275. /**
  10276. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10277. */
  10278. get lightmapMode(): number;
  10279. /**
  10280. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10281. */
  10282. set lightmapMode(value: number);
  10283. /**
  10284. * Shadow generator associted to the light.
  10285. * @hidden Internal use only.
  10286. */
  10287. _shadowGenerator: Nullable<IShadowGenerator>;
  10288. /**
  10289. * @hidden Internal use only.
  10290. */
  10291. _excludedMeshesIds: string[];
  10292. /**
  10293. * @hidden Internal use only.
  10294. */
  10295. _includedOnlyMeshesIds: string[];
  10296. /**
  10297. * The current light unifom buffer.
  10298. * @hidden Internal use only.
  10299. */
  10300. _uniformBuffer: UniformBuffer;
  10301. /** @hidden */
  10302. _renderId: number;
  10303. /**
  10304. * Creates a Light object in the scene.
  10305. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10306. * @param name The firendly name of the light
  10307. * @param scene The scene the light belongs too
  10308. */
  10309. constructor(name: string, scene: Scene);
  10310. protected abstract _buildUniformLayout(): void;
  10311. /**
  10312. * Sets the passed Effect "effect" with the Light information.
  10313. * @param effect The effect to update
  10314. * @param lightIndex The index of the light in the effect to update
  10315. * @returns The light
  10316. */
  10317. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10318. /**
  10319. * Sets the passed Effect "effect" with the Light textures.
  10320. * @param effect The effect to update
  10321. * @param lightIndex The index of the light in the effect to update
  10322. * @returns The light
  10323. */
  10324. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10325. /**
  10326. * Binds the lights information from the scene to the effect for the given mesh.
  10327. * @param lightIndex Light index
  10328. * @param scene The scene where the light belongs to
  10329. * @param effect The effect we are binding the data to
  10330. * @param useSpecular Defines if specular is supported
  10331. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10332. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10333. */
  10334. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  10335. /**
  10336. * Sets the passed Effect "effect" with the Light information.
  10337. * @param effect The effect to update
  10338. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10339. * @returns The light
  10340. */
  10341. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10342. /**
  10343. * Returns the string "Light".
  10344. * @returns the class name
  10345. */
  10346. getClassName(): string;
  10347. /** @hidden */
  10348. readonly _isLight: boolean;
  10349. /**
  10350. * Converts the light information to a readable string for debug purpose.
  10351. * @param fullDetails Supports for multiple levels of logging within scene loading
  10352. * @returns the human readable light info
  10353. */
  10354. toString(fullDetails?: boolean): string;
  10355. /** @hidden */
  10356. protected _syncParentEnabledState(): void;
  10357. /**
  10358. * Set the enabled state of this node.
  10359. * @param value - the new enabled state
  10360. */
  10361. setEnabled(value: boolean): void;
  10362. /**
  10363. * Returns the Light associated shadow generator if any.
  10364. * @return the associated shadow generator.
  10365. */
  10366. getShadowGenerator(): Nullable<IShadowGenerator>;
  10367. /**
  10368. * Returns a Vector3, the absolute light position in the World.
  10369. * @returns the world space position of the light
  10370. */
  10371. getAbsolutePosition(): Vector3;
  10372. /**
  10373. * Specifies if the light will affect the passed mesh.
  10374. * @param mesh The mesh to test against the light
  10375. * @return true the mesh is affected otherwise, false.
  10376. */
  10377. canAffectMesh(mesh: AbstractMesh): boolean;
  10378. /**
  10379. * Sort function to order lights for rendering.
  10380. * @param a First Light object to compare to second.
  10381. * @param b Second Light object to compare first.
  10382. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10383. */
  10384. static CompareLightsPriority(a: Light, b: Light): number;
  10385. /**
  10386. * Releases resources associated with this node.
  10387. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10388. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10389. */
  10390. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10391. /**
  10392. * Returns the light type ID (integer).
  10393. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10394. */
  10395. getTypeID(): number;
  10396. /**
  10397. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10398. * @returns the scaled intensity in intensity mode unit
  10399. */
  10400. getScaledIntensity(): number;
  10401. /**
  10402. * Returns a new Light object, named "name", from the current one.
  10403. * @param name The name of the cloned light
  10404. * @returns the new created light
  10405. */
  10406. clone(name: string): Nullable<Light>;
  10407. /**
  10408. * Serializes the current light into a Serialization object.
  10409. * @returns the serialized object.
  10410. */
  10411. serialize(): any;
  10412. /**
  10413. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10414. * This new light is named "name" and added to the passed scene.
  10415. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10416. * @param name The friendly name of the light
  10417. * @param scene The scene the new light will belong to
  10418. * @returns the constructor function
  10419. */
  10420. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10421. /**
  10422. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10423. * @param parsedLight The JSON representation of the light
  10424. * @param scene The scene to create the parsed light in
  10425. * @returns the created light after parsing
  10426. */
  10427. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10428. private _hookArrayForExcluded;
  10429. private _hookArrayForIncludedOnly;
  10430. private _resyncMeshes;
  10431. /**
  10432. * Forces the meshes to update their light related information in their rendering used effects
  10433. * @hidden Internal Use Only
  10434. */
  10435. _markMeshesAsLightDirty(): void;
  10436. /**
  10437. * Recomputes the cached photometric scale if needed.
  10438. */
  10439. private _computePhotometricScale;
  10440. /**
  10441. * Returns the Photometric Scale according to the light type and intensity mode.
  10442. */
  10443. private _getPhotometricScale;
  10444. /**
  10445. * Reorder the light in the scene according to their defined priority.
  10446. * @hidden Internal Use Only
  10447. */
  10448. _reorderLightsInScene(): void;
  10449. /**
  10450. * Prepares the list of defines specific to the light type.
  10451. * @param defines the list of defines
  10452. * @param lightIndex defines the index of the light for the effect
  10453. */
  10454. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10455. }
  10456. }
  10457. declare module "babylonjs/Actions/action" {
  10458. import { Observable } from "babylonjs/Misc/observable";
  10459. import { Condition } from "babylonjs/Actions/condition";
  10460. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10461. import { ActionManager } from "babylonjs/Actions/actionManager";
  10462. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10463. /**
  10464. * Interface used to define Action
  10465. */
  10466. export interface IAction {
  10467. /**
  10468. * Trigger for the action
  10469. */
  10470. trigger: number;
  10471. /** Options of the trigger */
  10472. triggerOptions: any;
  10473. /**
  10474. * Gets the trigger parameters
  10475. * @returns the trigger parameters
  10476. */
  10477. getTriggerParameter(): any;
  10478. /**
  10479. * Internal only - executes current action event
  10480. * @hidden
  10481. */
  10482. _executeCurrent(evt?: ActionEvent): void;
  10483. /**
  10484. * Serialize placeholder for child classes
  10485. * @param parent of child
  10486. * @returns the serialized object
  10487. */
  10488. serialize(parent: any): any;
  10489. /**
  10490. * Internal only
  10491. * @hidden
  10492. */
  10493. _prepare(): void;
  10494. /**
  10495. * Internal only - manager for action
  10496. * @hidden
  10497. */
  10498. _actionManager: AbstractActionManager;
  10499. /**
  10500. * Adds action to chain of actions, may be a DoNothingAction
  10501. * @param action defines the next action to execute
  10502. * @returns The action passed in
  10503. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10504. */
  10505. then(action: IAction): IAction;
  10506. }
  10507. /**
  10508. * The action to be carried out following a trigger
  10509. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10510. */
  10511. export class Action implements IAction {
  10512. /** the trigger, with or without parameters, for the action */
  10513. triggerOptions: any;
  10514. /**
  10515. * Trigger for the action
  10516. */
  10517. trigger: number;
  10518. /**
  10519. * Internal only - manager for action
  10520. * @hidden
  10521. */
  10522. _actionManager: ActionManager;
  10523. private _nextActiveAction;
  10524. private _child;
  10525. private _condition?;
  10526. private _triggerParameter;
  10527. /**
  10528. * An event triggered prior to action being executed.
  10529. */
  10530. onBeforeExecuteObservable: Observable<Action>;
  10531. /**
  10532. * Creates a new Action
  10533. * @param triggerOptions the trigger, with or without parameters, for the action
  10534. * @param condition an optional determinant of action
  10535. */
  10536. constructor(
  10537. /** the trigger, with or without parameters, for the action */
  10538. triggerOptions: any, condition?: Condition);
  10539. /**
  10540. * Internal only
  10541. * @hidden
  10542. */
  10543. _prepare(): void;
  10544. /**
  10545. * Gets the trigger parameters
  10546. * @returns the trigger parameters
  10547. */
  10548. getTriggerParameter(): any;
  10549. /**
  10550. * Internal only - executes current action event
  10551. * @hidden
  10552. */
  10553. _executeCurrent(evt?: ActionEvent): void;
  10554. /**
  10555. * Execute placeholder for child classes
  10556. * @param evt optional action event
  10557. */
  10558. execute(evt?: ActionEvent): void;
  10559. /**
  10560. * Skips to next active action
  10561. */
  10562. skipToNextActiveAction(): void;
  10563. /**
  10564. * Adds action to chain of actions, may be a DoNothingAction
  10565. * @param action defines the next action to execute
  10566. * @returns The action passed in
  10567. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10568. */
  10569. then(action: Action): Action;
  10570. /**
  10571. * Internal only
  10572. * @hidden
  10573. */
  10574. _getProperty(propertyPath: string): string;
  10575. /**
  10576. * Internal only
  10577. * @hidden
  10578. */
  10579. _getEffectiveTarget(target: any, propertyPath: string): any;
  10580. /**
  10581. * Serialize placeholder for child classes
  10582. * @param parent of child
  10583. * @returns the serialized object
  10584. */
  10585. serialize(parent: any): any;
  10586. /**
  10587. * Internal only called by serialize
  10588. * @hidden
  10589. */
  10590. protected _serialize(serializedAction: any, parent?: any): any;
  10591. /**
  10592. * Internal only
  10593. * @hidden
  10594. */
  10595. static _SerializeValueAsString: (value: any) => string;
  10596. /**
  10597. * Internal only
  10598. * @hidden
  10599. */
  10600. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10601. name: string;
  10602. targetType: string;
  10603. value: string;
  10604. };
  10605. }
  10606. }
  10607. declare module "babylonjs/Actions/condition" {
  10608. import { ActionManager } from "babylonjs/Actions/actionManager";
  10609. /**
  10610. * A Condition applied to an Action
  10611. */
  10612. export class Condition {
  10613. /**
  10614. * Internal only - manager for action
  10615. * @hidden
  10616. */
  10617. _actionManager: ActionManager;
  10618. /**
  10619. * Internal only
  10620. * @hidden
  10621. */
  10622. _evaluationId: number;
  10623. /**
  10624. * Internal only
  10625. * @hidden
  10626. */
  10627. _currentResult: boolean;
  10628. /**
  10629. * Creates a new Condition
  10630. * @param actionManager the manager of the action the condition is applied to
  10631. */
  10632. constructor(actionManager: ActionManager);
  10633. /**
  10634. * Check if the current condition is valid
  10635. * @returns a boolean
  10636. */
  10637. isValid(): boolean;
  10638. /**
  10639. * Internal only
  10640. * @hidden
  10641. */
  10642. _getProperty(propertyPath: string): string;
  10643. /**
  10644. * Internal only
  10645. * @hidden
  10646. */
  10647. _getEffectiveTarget(target: any, propertyPath: string): any;
  10648. /**
  10649. * Serialize placeholder for child classes
  10650. * @returns the serialized object
  10651. */
  10652. serialize(): any;
  10653. /**
  10654. * Internal only
  10655. * @hidden
  10656. */
  10657. protected _serialize(serializedCondition: any): any;
  10658. }
  10659. /**
  10660. * Defines specific conditional operators as extensions of Condition
  10661. */
  10662. export class ValueCondition extends Condition {
  10663. /** path to specify the property of the target the conditional operator uses */
  10664. propertyPath: string;
  10665. /** the value compared by the conditional operator against the current value of the property */
  10666. value: any;
  10667. /** the conditional operator, default ValueCondition.IsEqual */
  10668. operator: number;
  10669. /**
  10670. * Internal only
  10671. * @hidden
  10672. */
  10673. private static _IsEqual;
  10674. /**
  10675. * Internal only
  10676. * @hidden
  10677. */
  10678. private static _IsDifferent;
  10679. /**
  10680. * Internal only
  10681. * @hidden
  10682. */
  10683. private static _IsGreater;
  10684. /**
  10685. * Internal only
  10686. * @hidden
  10687. */
  10688. private static _IsLesser;
  10689. /**
  10690. * returns the number for IsEqual
  10691. */
  10692. static get IsEqual(): number;
  10693. /**
  10694. * Returns the number for IsDifferent
  10695. */
  10696. static get IsDifferent(): number;
  10697. /**
  10698. * Returns the number for IsGreater
  10699. */
  10700. static get IsGreater(): number;
  10701. /**
  10702. * Returns the number for IsLesser
  10703. */
  10704. static get IsLesser(): number;
  10705. /**
  10706. * Internal only The action manager for the condition
  10707. * @hidden
  10708. */
  10709. _actionManager: ActionManager;
  10710. /**
  10711. * Internal only
  10712. * @hidden
  10713. */
  10714. private _target;
  10715. /**
  10716. * Internal only
  10717. * @hidden
  10718. */
  10719. private _effectiveTarget;
  10720. /**
  10721. * Internal only
  10722. * @hidden
  10723. */
  10724. private _property;
  10725. /**
  10726. * Creates a new ValueCondition
  10727. * @param actionManager manager for the action the condition applies to
  10728. * @param target for the action
  10729. * @param propertyPath path to specify the property of the target the conditional operator uses
  10730. * @param value the value compared by the conditional operator against the current value of the property
  10731. * @param operator the conditional operator, default ValueCondition.IsEqual
  10732. */
  10733. constructor(actionManager: ActionManager, target: any,
  10734. /** path to specify the property of the target the conditional operator uses */
  10735. propertyPath: string,
  10736. /** the value compared by the conditional operator against the current value of the property */
  10737. value: any,
  10738. /** the conditional operator, default ValueCondition.IsEqual */
  10739. operator?: number);
  10740. /**
  10741. * Compares the given value with the property value for the specified conditional operator
  10742. * @returns the result of the comparison
  10743. */
  10744. isValid(): boolean;
  10745. /**
  10746. * Serialize the ValueCondition into a JSON compatible object
  10747. * @returns serialization object
  10748. */
  10749. serialize(): any;
  10750. /**
  10751. * Gets the name of the conditional operator for the ValueCondition
  10752. * @param operator the conditional operator
  10753. * @returns the name
  10754. */
  10755. static GetOperatorName(operator: number): string;
  10756. }
  10757. /**
  10758. * Defines a predicate condition as an extension of Condition
  10759. */
  10760. export class PredicateCondition extends Condition {
  10761. /** defines the predicate function used to validate the condition */
  10762. predicate: () => boolean;
  10763. /**
  10764. * Internal only - manager for action
  10765. * @hidden
  10766. */
  10767. _actionManager: ActionManager;
  10768. /**
  10769. * Creates a new PredicateCondition
  10770. * @param actionManager manager for the action the condition applies to
  10771. * @param predicate defines the predicate function used to validate the condition
  10772. */
  10773. constructor(actionManager: ActionManager,
  10774. /** defines the predicate function used to validate the condition */
  10775. predicate: () => boolean);
  10776. /**
  10777. * @returns the validity of the predicate condition
  10778. */
  10779. isValid(): boolean;
  10780. }
  10781. /**
  10782. * Defines a state condition as an extension of Condition
  10783. */
  10784. export class StateCondition extends Condition {
  10785. /** Value to compare with target state */
  10786. value: string;
  10787. /**
  10788. * Internal only - manager for action
  10789. * @hidden
  10790. */
  10791. _actionManager: ActionManager;
  10792. /**
  10793. * Internal only
  10794. * @hidden
  10795. */
  10796. private _target;
  10797. /**
  10798. * Creates a new StateCondition
  10799. * @param actionManager manager for the action the condition applies to
  10800. * @param target of the condition
  10801. * @param value to compare with target state
  10802. */
  10803. constructor(actionManager: ActionManager, target: any,
  10804. /** Value to compare with target state */
  10805. value: string);
  10806. /**
  10807. * Gets a boolean indicating if the current condition is met
  10808. * @returns the validity of the state
  10809. */
  10810. isValid(): boolean;
  10811. /**
  10812. * Serialize the StateCondition into a JSON compatible object
  10813. * @returns serialization object
  10814. */
  10815. serialize(): any;
  10816. }
  10817. }
  10818. declare module "babylonjs/Actions/directActions" {
  10819. import { Action } from "babylonjs/Actions/action";
  10820. import { Condition } from "babylonjs/Actions/condition";
  10821. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10822. /**
  10823. * This defines an action responsible to toggle a boolean once triggered.
  10824. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10825. */
  10826. export class SwitchBooleanAction extends Action {
  10827. /**
  10828. * The path to the boolean property in the target object
  10829. */
  10830. propertyPath: string;
  10831. private _target;
  10832. private _effectiveTarget;
  10833. private _property;
  10834. /**
  10835. * Instantiate the action
  10836. * @param triggerOptions defines the trigger options
  10837. * @param target defines the object containing the boolean
  10838. * @param propertyPath defines the path to the boolean property in the target object
  10839. * @param condition defines the trigger related conditions
  10840. */
  10841. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10842. /** @hidden */
  10843. _prepare(): void;
  10844. /**
  10845. * Execute the action toggle the boolean value.
  10846. */
  10847. execute(): void;
  10848. /**
  10849. * Serializes the actions and its related information.
  10850. * @param parent defines the object to serialize in
  10851. * @returns the serialized object
  10852. */
  10853. serialize(parent: any): any;
  10854. }
  10855. /**
  10856. * This defines an action responsible to set a the state field of the target
  10857. * to a desired value once triggered.
  10858. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10859. */
  10860. export class SetStateAction extends Action {
  10861. /**
  10862. * The value to store in the state field.
  10863. */
  10864. value: string;
  10865. private _target;
  10866. /**
  10867. * Instantiate the action
  10868. * @param triggerOptions defines the trigger options
  10869. * @param target defines the object containing the state property
  10870. * @param value defines the value to store in the state field
  10871. * @param condition defines the trigger related conditions
  10872. */
  10873. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10874. /**
  10875. * Execute the action and store the value on the target state property.
  10876. */
  10877. execute(): void;
  10878. /**
  10879. * Serializes the actions and its related information.
  10880. * @param parent defines the object to serialize in
  10881. * @returns the serialized object
  10882. */
  10883. serialize(parent: any): any;
  10884. }
  10885. /**
  10886. * This defines an action responsible to set a property of the target
  10887. * to a desired value once triggered.
  10888. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10889. */
  10890. export class SetValueAction extends Action {
  10891. /**
  10892. * The path of the property to set in the target.
  10893. */
  10894. propertyPath: string;
  10895. /**
  10896. * The value to set in the property
  10897. */
  10898. value: any;
  10899. private _target;
  10900. private _effectiveTarget;
  10901. private _property;
  10902. /**
  10903. * Instantiate the action
  10904. * @param triggerOptions defines the trigger options
  10905. * @param target defines the object containing the property
  10906. * @param propertyPath defines the path of the property to set in the target
  10907. * @param value defines the value to set in the property
  10908. * @param condition defines the trigger related conditions
  10909. */
  10910. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10911. /** @hidden */
  10912. _prepare(): void;
  10913. /**
  10914. * Execute the action and set the targetted property to the desired value.
  10915. */
  10916. execute(): void;
  10917. /**
  10918. * Serializes the actions and its related information.
  10919. * @param parent defines the object to serialize in
  10920. * @returns the serialized object
  10921. */
  10922. serialize(parent: any): any;
  10923. }
  10924. /**
  10925. * This defines an action responsible to increment the target value
  10926. * to a desired value once triggered.
  10927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10928. */
  10929. export class IncrementValueAction extends Action {
  10930. /**
  10931. * The path of the property to increment in the target.
  10932. */
  10933. propertyPath: string;
  10934. /**
  10935. * The value we should increment the property by.
  10936. */
  10937. value: any;
  10938. private _target;
  10939. private _effectiveTarget;
  10940. private _property;
  10941. /**
  10942. * Instantiate the action
  10943. * @param triggerOptions defines the trigger options
  10944. * @param target defines the object containing the property
  10945. * @param propertyPath defines the path of the property to increment in the target
  10946. * @param value defines the value value we should increment the property by
  10947. * @param condition defines the trigger related conditions
  10948. */
  10949. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10950. /** @hidden */
  10951. _prepare(): void;
  10952. /**
  10953. * Execute the action and increment the target of the value amount.
  10954. */
  10955. execute(): void;
  10956. /**
  10957. * Serializes the actions and its related information.
  10958. * @param parent defines the object to serialize in
  10959. * @returns the serialized object
  10960. */
  10961. serialize(parent: any): any;
  10962. }
  10963. /**
  10964. * This defines an action responsible to start an animation once triggered.
  10965. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10966. */
  10967. export class PlayAnimationAction extends Action {
  10968. /**
  10969. * Where the animation should start (animation frame)
  10970. */
  10971. from: number;
  10972. /**
  10973. * Where the animation should stop (animation frame)
  10974. */
  10975. to: number;
  10976. /**
  10977. * Define if the animation should loop or stop after the first play.
  10978. */
  10979. loop?: boolean;
  10980. private _target;
  10981. /**
  10982. * Instantiate the action
  10983. * @param triggerOptions defines the trigger options
  10984. * @param target defines the target animation or animation name
  10985. * @param from defines from where the animation should start (animation frame)
  10986. * @param end defines where the animation should stop (animation frame)
  10987. * @param loop defines if the animation should loop or stop after the first play
  10988. * @param condition defines the trigger related conditions
  10989. */
  10990. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10991. /** @hidden */
  10992. _prepare(): void;
  10993. /**
  10994. * Execute the action and play the animation.
  10995. */
  10996. execute(): void;
  10997. /**
  10998. * Serializes the actions and its related information.
  10999. * @param parent defines the object to serialize in
  11000. * @returns the serialized object
  11001. */
  11002. serialize(parent: any): any;
  11003. }
  11004. /**
  11005. * This defines an action responsible to stop an animation once triggered.
  11006. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11007. */
  11008. export class StopAnimationAction extends Action {
  11009. private _target;
  11010. /**
  11011. * Instantiate the action
  11012. * @param triggerOptions defines the trigger options
  11013. * @param target defines the target animation or animation name
  11014. * @param condition defines the trigger related conditions
  11015. */
  11016. constructor(triggerOptions: any, target: any, condition?: Condition);
  11017. /** @hidden */
  11018. _prepare(): void;
  11019. /**
  11020. * Execute the action and stop the animation.
  11021. */
  11022. execute(): void;
  11023. /**
  11024. * Serializes the actions and its related information.
  11025. * @param parent defines the object to serialize in
  11026. * @returns the serialized object
  11027. */
  11028. serialize(parent: any): any;
  11029. }
  11030. /**
  11031. * This defines an action responsible that does nothing once triggered.
  11032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11033. */
  11034. export class DoNothingAction extends Action {
  11035. /**
  11036. * Instantiate the action
  11037. * @param triggerOptions defines the trigger options
  11038. * @param condition defines the trigger related conditions
  11039. */
  11040. constructor(triggerOptions?: any, condition?: Condition);
  11041. /**
  11042. * Execute the action and do nothing.
  11043. */
  11044. execute(): void;
  11045. /**
  11046. * Serializes the actions and its related information.
  11047. * @param parent defines the object to serialize in
  11048. * @returns the serialized object
  11049. */
  11050. serialize(parent: any): any;
  11051. }
  11052. /**
  11053. * This defines an action responsible to trigger several actions once triggered.
  11054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11055. */
  11056. export class CombineAction extends Action {
  11057. /**
  11058. * The list of aggregated animations to run.
  11059. */
  11060. children: Action[];
  11061. /**
  11062. * Instantiate the action
  11063. * @param triggerOptions defines the trigger options
  11064. * @param children defines the list of aggregated animations to run
  11065. * @param condition defines the trigger related conditions
  11066. */
  11067. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11068. /** @hidden */
  11069. _prepare(): void;
  11070. /**
  11071. * Execute the action and executes all the aggregated actions.
  11072. */
  11073. execute(evt: ActionEvent): void;
  11074. /**
  11075. * Serializes the actions and its related information.
  11076. * @param parent defines the object to serialize in
  11077. * @returns the serialized object
  11078. */
  11079. serialize(parent: any): any;
  11080. }
  11081. /**
  11082. * This defines an action responsible to run code (external event) once triggered.
  11083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11084. */
  11085. export class ExecuteCodeAction extends Action {
  11086. /**
  11087. * The callback function to run.
  11088. */
  11089. func: (evt: ActionEvent) => void;
  11090. /**
  11091. * Instantiate the action
  11092. * @param triggerOptions defines the trigger options
  11093. * @param func defines the callback function to run
  11094. * @param condition defines the trigger related conditions
  11095. */
  11096. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11097. /**
  11098. * Execute the action and run the attached code.
  11099. */
  11100. execute(evt: ActionEvent): void;
  11101. }
  11102. /**
  11103. * This defines an action responsible to set the parent property of the target once triggered.
  11104. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11105. */
  11106. export class SetParentAction extends Action {
  11107. private _parent;
  11108. private _target;
  11109. /**
  11110. * Instantiate the action
  11111. * @param triggerOptions defines the trigger options
  11112. * @param target defines the target containing the parent property
  11113. * @param parent defines from where the animation should start (animation frame)
  11114. * @param condition defines the trigger related conditions
  11115. */
  11116. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11117. /** @hidden */
  11118. _prepare(): void;
  11119. /**
  11120. * Execute the action and set the parent property.
  11121. */
  11122. execute(): void;
  11123. /**
  11124. * Serializes the actions and its related information.
  11125. * @param parent defines the object to serialize in
  11126. * @returns the serialized object
  11127. */
  11128. serialize(parent: any): any;
  11129. }
  11130. }
  11131. declare module "babylonjs/Actions/actionManager" {
  11132. import { Nullable } from "babylonjs/types";
  11133. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11134. import { Scene } from "babylonjs/scene";
  11135. import { IAction } from "babylonjs/Actions/action";
  11136. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11137. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11138. /**
  11139. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11140. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11141. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11142. */
  11143. export class ActionManager extends AbstractActionManager {
  11144. /**
  11145. * Nothing
  11146. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11147. */
  11148. static readonly NothingTrigger: number;
  11149. /**
  11150. * On pick
  11151. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11152. */
  11153. static readonly OnPickTrigger: number;
  11154. /**
  11155. * On left pick
  11156. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11157. */
  11158. static readonly OnLeftPickTrigger: number;
  11159. /**
  11160. * On right pick
  11161. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11162. */
  11163. static readonly OnRightPickTrigger: number;
  11164. /**
  11165. * On center pick
  11166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11167. */
  11168. static readonly OnCenterPickTrigger: number;
  11169. /**
  11170. * On pick down
  11171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11172. */
  11173. static readonly OnPickDownTrigger: number;
  11174. /**
  11175. * On double pick
  11176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11177. */
  11178. static readonly OnDoublePickTrigger: number;
  11179. /**
  11180. * On pick up
  11181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11182. */
  11183. static readonly OnPickUpTrigger: number;
  11184. /**
  11185. * On pick out.
  11186. * This trigger will only be raised if you also declared a OnPickDown
  11187. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11188. */
  11189. static readonly OnPickOutTrigger: number;
  11190. /**
  11191. * On long press
  11192. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11193. */
  11194. static readonly OnLongPressTrigger: number;
  11195. /**
  11196. * On pointer over
  11197. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11198. */
  11199. static readonly OnPointerOverTrigger: number;
  11200. /**
  11201. * On pointer out
  11202. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11203. */
  11204. static readonly OnPointerOutTrigger: number;
  11205. /**
  11206. * On every frame
  11207. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11208. */
  11209. static readonly OnEveryFrameTrigger: number;
  11210. /**
  11211. * On intersection enter
  11212. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11213. */
  11214. static readonly OnIntersectionEnterTrigger: number;
  11215. /**
  11216. * On intersection exit
  11217. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11218. */
  11219. static readonly OnIntersectionExitTrigger: number;
  11220. /**
  11221. * On key down
  11222. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11223. */
  11224. static readonly OnKeyDownTrigger: number;
  11225. /**
  11226. * On key up
  11227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11228. */
  11229. static readonly OnKeyUpTrigger: number;
  11230. private _scene;
  11231. /**
  11232. * Creates a new action manager
  11233. * @param scene defines the hosting scene
  11234. */
  11235. constructor(scene: Scene);
  11236. /**
  11237. * Releases all associated resources
  11238. */
  11239. dispose(): void;
  11240. /**
  11241. * Gets hosting scene
  11242. * @returns the hosting scene
  11243. */
  11244. getScene(): Scene;
  11245. /**
  11246. * Does this action manager handles actions of any of the given triggers
  11247. * @param triggers defines the triggers to be tested
  11248. * @return a boolean indicating whether one (or more) of the triggers is handled
  11249. */
  11250. hasSpecificTriggers(triggers: number[]): boolean;
  11251. /**
  11252. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11253. * speed.
  11254. * @param triggerA defines the trigger to be tested
  11255. * @param triggerB defines the trigger to be tested
  11256. * @return a boolean indicating whether one (or more) of the triggers is handled
  11257. */
  11258. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11259. /**
  11260. * Does this action manager handles actions of a given trigger
  11261. * @param trigger defines the trigger to be tested
  11262. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11263. * @return whether the trigger is handled
  11264. */
  11265. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11266. /**
  11267. * Does this action manager has pointer triggers
  11268. */
  11269. get hasPointerTriggers(): boolean;
  11270. /**
  11271. * Does this action manager has pick triggers
  11272. */
  11273. get hasPickTriggers(): boolean;
  11274. /**
  11275. * Registers an action to this action manager
  11276. * @param action defines the action to be registered
  11277. * @return the action amended (prepared) after registration
  11278. */
  11279. registerAction(action: IAction): Nullable<IAction>;
  11280. /**
  11281. * Unregisters an action to this action manager
  11282. * @param action defines the action to be unregistered
  11283. * @return a boolean indicating whether the action has been unregistered
  11284. */
  11285. unregisterAction(action: IAction): Boolean;
  11286. /**
  11287. * Process a specific trigger
  11288. * @param trigger defines the trigger to process
  11289. * @param evt defines the event details to be processed
  11290. */
  11291. processTrigger(trigger: number, evt?: IActionEvent): void;
  11292. /** @hidden */
  11293. _getEffectiveTarget(target: any, propertyPath: string): any;
  11294. /** @hidden */
  11295. _getProperty(propertyPath: string): string;
  11296. /**
  11297. * Serialize this manager to a JSON object
  11298. * @param name defines the property name to store this manager
  11299. * @returns a JSON representation of this manager
  11300. */
  11301. serialize(name: string): any;
  11302. /**
  11303. * Creates a new ActionManager from a JSON data
  11304. * @param parsedActions defines the JSON data to read from
  11305. * @param object defines the hosting mesh
  11306. * @param scene defines the hosting scene
  11307. */
  11308. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11309. /**
  11310. * Get a trigger name by index
  11311. * @param trigger defines the trigger index
  11312. * @returns a trigger name
  11313. */
  11314. static GetTriggerName(trigger: number): string;
  11315. }
  11316. }
  11317. declare module "babylonjs/Culling/ray" {
  11318. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11319. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11320. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11321. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11322. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11323. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11324. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11325. import { Plane } from "babylonjs/Maths/math.plane";
  11326. /**
  11327. * Class representing a ray with position and direction
  11328. */
  11329. export class Ray {
  11330. /** origin point */
  11331. origin: Vector3;
  11332. /** direction */
  11333. direction: Vector3;
  11334. /** length of the ray */
  11335. length: number;
  11336. private static readonly TmpVector3;
  11337. private _tmpRay;
  11338. /**
  11339. * Creates a new ray
  11340. * @param origin origin point
  11341. * @param direction direction
  11342. * @param length length of the ray
  11343. */
  11344. constructor(
  11345. /** origin point */
  11346. origin: Vector3,
  11347. /** direction */
  11348. direction: Vector3,
  11349. /** length of the ray */
  11350. length?: number);
  11351. /**
  11352. * Checks if the ray intersects a box
  11353. * @param minimum bound of the box
  11354. * @param maximum bound of the box
  11355. * @param intersectionTreshold extra extend to be added to the box in all direction
  11356. * @returns if the box was hit
  11357. */
  11358. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11359. /**
  11360. * Checks if the ray intersects a box
  11361. * @param box the bounding box to check
  11362. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11363. * @returns if the box was hit
  11364. */
  11365. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11366. /**
  11367. * If the ray hits a sphere
  11368. * @param sphere the bounding sphere to check
  11369. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11370. * @returns true if it hits the sphere
  11371. */
  11372. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11373. /**
  11374. * If the ray hits a triange
  11375. * @param vertex0 triangle vertex
  11376. * @param vertex1 triangle vertex
  11377. * @param vertex2 triangle vertex
  11378. * @returns intersection information if hit
  11379. */
  11380. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11381. /**
  11382. * Checks if ray intersects a plane
  11383. * @param plane the plane to check
  11384. * @returns the distance away it was hit
  11385. */
  11386. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11387. /**
  11388. * Calculate the intercept of a ray on a given axis
  11389. * @param axis to check 'x' | 'y' | 'z'
  11390. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11391. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11392. */
  11393. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11394. /**
  11395. * Checks if ray intersects a mesh
  11396. * @param mesh the mesh to check
  11397. * @param fastCheck if only the bounding box should checked
  11398. * @returns picking info of the intersecton
  11399. */
  11400. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11401. /**
  11402. * Checks if ray intersects a mesh
  11403. * @param meshes the meshes to check
  11404. * @param fastCheck if only the bounding box should checked
  11405. * @param results array to store result in
  11406. * @returns Array of picking infos
  11407. */
  11408. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11409. private _comparePickingInfo;
  11410. private static smallnum;
  11411. private static rayl;
  11412. /**
  11413. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11414. * @param sega the first point of the segment to test the intersection against
  11415. * @param segb the second point of the segment to test the intersection against
  11416. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11417. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11418. */
  11419. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11420. /**
  11421. * Update the ray from viewport position
  11422. * @param x position
  11423. * @param y y position
  11424. * @param viewportWidth viewport width
  11425. * @param viewportHeight viewport height
  11426. * @param world world matrix
  11427. * @param view view matrix
  11428. * @param projection projection matrix
  11429. * @returns this ray updated
  11430. */
  11431. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11432. /**
  11433. * Creates a ray with origin and direction of 0,0,0
  11434. * @returns the new ray
  11435. */
  11436. static Zero(): Ray;
  11437. /**
  11438. * Creates a new ray from screen space and viewport
  11439. * @param x position
  11440. * @param y y position
  11441. * @param viewportWidth viewport width
  11442. * @param viewportHeight viewport height
  11443. * @param world world matrix
  11444. * @param view view matrix
  11445. * @param projection projection matrix
  11446. * @returns new ray
  11447. */
  11448. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11449. /**
  11450. * 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
  11451. * transformed to the given world matrix.
  11452. * @param origin The origin point
  11453. * @param end The end point
  11454. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11455. * @returns the new ray
  11456. */
  11457. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11458. /**
  11459. * Transforms a ray by a matrix
  11460. * @param ray ray to transform
  11461. * @param matrix matrix to apply
  11462. * @returns the resulting new ray
  11463. */
  11464. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11465. /**
  11466. * Transforms a ray by a matrix
  11467. * @param ray ray to transform
  11468. * @param matrix matrix to apply
  11469. * @param result ray to store result in
  11470. */
  11471. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11472. /**
  11473. * Unproject a ray from screen space to object space
  11474. * @param sourceX defines the screen space x coordinate to use
  11475. * @param sourceY defines the screen space y coordinate to use
  11476. * @param viewportWidth defines the current width of the viewport
  11477. * @param viewportHeight defines the current height of the viewport
  11478. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11479. * @param view defines the view matrix to use
  11480. * @param projection defines the projection matrix to use
  11481. */
  11482. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11483. }
  11484. /**
  11485. * Type used to define predicate used to select faces when a mesh intersection is detected
  11486. */
  11487. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11488. module "babylonjs/scene" {
  11489. interface Scene {
  11490. /** @hidden */
  11491. _tempPickingRay: Nullable<Ray>;
  11492. /** @hidden */
  11493. _cachedRayForTransform: Ray;
  11494. /** @hidden */
  11495. _pickWithRayInverseMatrix: Matrix;
  11496. /** @hidden */
  11497. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11498. /** @hidden */
  11499. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11500. }
  11501. }
  11502. }
  11503. declare module "babylonjs/sceneComponent" {
  11504. import { Scene } from "babylonjs/scene";
  11505. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11506. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11507. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11508. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11509. import { Nullable } from "babylonjs/types";
  11510. import { Camera } from "babylonjs/Cameras/camera";
  11511. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11512. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11513. import { AbstractScene } from "babylonjs/abstractScene";
  11514. import { Mesh } from "babylonjs/Meshes/mesh";
  11515. /**
  11516. * Groups all the scene component constants in one place to ease maintenance.
  11517. * @hidden
  11518. */
  11519. export class SceneComponentConstants {
  11520. static readonly NAME_EFFECTLAYER: string;
  11521. static readonly NAME_LAYER: string;
  11522. static readonly NAME_LENSFLARESYSTEM: string;
  11523. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11524. static readonly NAME_PARTICLESYSTEM: string;
  11525. static readonly NAME_GAMEPAD: string;
  11526. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11527. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11528. static readonly NAME_DEPTHRENDERER: string;
  11529. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11530. static readonly NAME_SPRITE: string;
  11531. static readonly NAME_OUTLINERENDERER: string;
  11532. static readonly NAME_PROCEDURALTEXTURE: string;
  11533. static readonly NAME_SHADOWGENERATOR: string;
  11534. static readonly NAME_OCTREE: string;
  11535. static readonly NAME_PHYSICSENGINE: string;
  11536. static readonly NAME_AUDIO: string;
  11537. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11538. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11539. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11540. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11541. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11542. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11543. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11544. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11545. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11546. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11547. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11548. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11549. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11550. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11551. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11552. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11553. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11554. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11555. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11556. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11557. static readonly STEP_AFTERRENDER_AUDIO: number;
  11558. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11559. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11560. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11561. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11562. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11563. static readonly STEP_POINTERMOVE_SPRITE: number;
  11564. static readonly STEP_POINTERDOWN_SPRITE: number;
  11565. static readonly STEP_POINTERUP_SPRITE: number;
  11566. }
  11567. /**
  11568. * This represents a scene component.
  11569. *
  11570. * This is used to decouple the dependency the scene is having on the different workloads like
  11571. * layers, post processes...
  11572. */
  11573. export interface ISceneComponent {
  11574. /**
  11575. * The name of the component. Each component must have a unique name.
  11576. */
  11577. name: string;
  11578. /**
  11579. * The scene the component belongs to.
  11580. */
  11581. scene: Scene;
  11582. /**
  11583. * Register the component to one instance of a scene.
  11584. */
  11585. register(): void;
  11586. /**
  11587. * Rebuilds the elements related to this component in case of
  11588. * context lost for instance.
  11589. */
  11590. rebuild(): void;
  11591. /**
  11592. * Disposes the component and the associated ressources.
  11593. */
  11594. dispose(): void;
  11595. }
  11596. /**
  11597. * This represents a SERIALIZABLE scene component.
  11598. *
  11599. * This extends Scene Component to add Serialization methods on top.
  11600. */
  11601. export interface ISceneSerializableComponent extends ISceneComponent {
  11602. /**
  11603. * Adds all the elements from the container to the scene
  11604. * @param container the container holding the elements
  11605. */
  11606. addFromContainer(container: AbstractScene): void;
  11607. /**
  11608. * Removes all the elements in the container from the scene
  11609. * @param container contains the elements to remove
  11610. * @param dispose if the removed element should be disposed (default: false)
  11611. */
  11612. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11613. /**
  11614. * Serializes the component data to the specified json object
  11615. * @param serializationObject The object to serialize to
  11616. */
  11617. serialize(serializationObject: any): void;
  11618. }
  11619. /**
  11620. * Strong typing of a Mesh related stage step action
  11621. */
  11622. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11623. /**
  11624. * Strong typing of a Evaluate Sub Mesh related stage step action
  11625. */
  11626. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11627. /**
  11628. * Strong typing of a Active Mesh related stage step action
  11629. */
  11630. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11631. /**
  11632. * Strong typing of a Camera related stage step action
  11633. */
  11634. export type CameraStageAction = (camera: Camera) => void;
  11635. /**
  11636. * Strong typing of a Camera Frame buffer related stage step action
  11637. */
  11638. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11639. /**
  11640. * Strong typing of a Render Target related stage step action
  11641. */
  11642. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11643. /**
  11644. * Strong typing of a RenderingGroup related stage step action
  11645. */
  11646. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11647. /**
  11648. * Strong typing of a Mesh Render related stage step action
  11649. */
  11650. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11651. /**
  11652. * Strong typing of a simple stage step action
  11653. */
  11654. export type SimpleStageAction = () => void;
  11655. /**
  11656. * Strong typing of a render target action.
  11657. */
  11658. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11659. /**
  11660. * Strong typing of a pointer move action.
  11661. */
  11662. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11663. /**
  11664. * Strong typing of a pointer up/down action.
  11665. */
  11666. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11667. /**
  11668. * Representation of a stage in the scene (Basically a list of ordered steps)
  11669. * @hidden
  11670. */
  11671. export class Stage<T extends Function> extends Array<{
  11672. index: number;
  11673. component: ISceneComponent;
  11674. action: T;
  11675. }> {
  11676. /**
  11677. * Hide ctor from the rest of the world.
  11678. * @param items The items to add.
  11679. */
  11680. private constructor();
  11681. /**
  11682. * Creates a new Stage.
  11683. * @returns A new instance of a Stage
  11684. */
  11685. static Create<T extends Function>(): Stage<T>;
  11686. /**
  11687. * Registers a step in an ordered way in the targeted stage.
  11688. * @param index Defines the position to register the step in
  11689. * @param component Defines the component attached to the step
  11690. * @param action Defines the action to launch during the step
  11691. */
  11692. registerStep(index: number, component: ISceneComponent, action: T): void;
  11693. /**
  11694. * Clears all the steps from the stage.
  11695. */
  11696. clear(): void;
  11697. }
  11698. }
  11699. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11700. import { Nullable } from "babylonjs/types";
  11701. import { Observable } from "babylonjs/Misc/observable";
  11702. import { Scene } from "babylonjs/scene";
  11703. import { Sprite } from "babylonjs/Sprites/sprite";
  11704. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11705. import { Ray } from "babylonjs/Culling/ray";
  11706. import { Camera } from "babylonjs/Cameras/camera";
  11707. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11708. import { ISceneComponent } from "babylonjs/sceneComponent";
  11709. module "babylonjs/scene" {
  11710. interface Scene {
  11711. /** @hidden */
  11712. _pointerOverSprite: Nullable<Sprite>;
  11713. /** @hidden */
  11714. _pickedDownSprite: Nullable<Sprite>;
  11715. /** @hidden */
  11716. _tempSpritePickingRay: Nullable<Ray>;
  11717. /**
  11718. * All of the sprite managers added to this scene
  11719. * @see http://doc.babylonjs.com/babylon101/sprites
  11720. */
  11721. spriteManagers: Array<ISpriteManager>;
  11722. /**
  11723. * An event triggered when sprites rendering is about to start
  11724. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11725. */
  11726. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11727. /**
  11728. * An event triggered when sprites rendering is done
  11729. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11730. */
  11731. onAfterSpritesRenderingObservable: Observable<Scene>;
  11732. /** @hidden */
  11733. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11734. /** Launch a ray to try to pick a sprite in the scene
  11735. * @param x position on screen
  11736. * @param y position on screen
  11737. * @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
  11738. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11739. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11740. * @returns a PickingInfo
  11741. */
  11742. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11743. /** Use the given ray to pick a sprite in the scene
  11744. * @param ray The ray (in world space) to use to pick meshes
  11745. * @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
  11746. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11747. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11748. * @returns a PickingInfo
  11749. */
  11750. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11751. /** @hidden */
  11752. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11753. /** Launch a ray to try to pick sprites in the scene
  11754. * @param x position on screen
  11755. * @param y position on screen
  11756. * @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
  11757. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11758. * @returns a PickingInfo array
  11759. */
  11760. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11761. /** Use the given ray to pick sprites in the scene
  11762. * @param ray The ray (in world space) to use to pick meshes
  11763. * @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
  11764. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11765. * @returns a PickingInfo array
  11766. */
  11767. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11768. /**
  11769. * Force the sprite under the pointer
  11770. * @param sprite defines the sprite to use
  11771. */
  11772. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11773. /**
  11774. * Gets the sprite under the pointer
  11775. * @returns a Sprite or null if no sprite is under the pointer
  11776. */
  11777. getPointerOverSprite(): Nullable<Sprite>;
  11778. }
  11779. }
  11780. /**
  11781. * Defines the sprite scene component responsible to manage sprites
  11782. * in a given scene.
  11783. */
  11784. export class SpriteSceneComponent implements ISceneComponent {
  11785. /**
  11786. * The component name helpfull to identify the component in the list of scene components.
  11787. */
  11788. readonly name: string;
  11789. /**
  11790. * The scene the component belongs to.
  11791. */
  11792. scene: Scene;
  11793. /** @hidden */
  11794. private _spritePredicate;
  11795. /**
  11796. * Creates a new instance of the component for the given scene
  11797. * @param scene Defines the scene to register the component in
  11798. */
  11799. constructor(scene: Scene);
  11800. /**
  11801. * Registers the component in a given scene
  11802. */
  11803. register(): void;
  11804. /**
  11805. * Rebuilds the elements related to this component in case of
  11806. * context lost for instance.
  11807. */
  11808. rebuild(): void;
  11809. /**
  11810. * Disposes the component and the associated ressources.
  11811. */
  11812. dispose(): void;
  11813. private _pickSpriteButKeepRay;
  11814. private _pointerMove;
  11815. private _pointerDown;
  11816. private _pointerUp;
  11817. }
  11818. }
  11819. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11820. /** @hidden */
  11821. export var fogFragmentDeclaration: {
  11822. name: string;
  11823. shader: string;
  11824. };
  11825. }
  11826. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11827. /** @hidden */
  11828. export var fogFragment: {
  11829. name: string;
  11830. shader: string;
  11831. };
  11832. }
  11833. declare module "babylonjs/Shaders/sprites.fragment" {
  11834. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11835. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11836. /** @hidden */
  11837. export var spritesPixelShader: {
  11838. name: string;
  11839. shader: string;
  11840. };
  11841. }
  11842. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11843. /** @hidden */
  11844. export var fogVertexDeclaration: {
  11845. name: string;
  11846. shader: string;
  11847. };
  11848. }
  11849. declare module "babylonjs/Shaders/sprites.vertex" {
  11850. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11851. /** @hidden */
  11852. export var spritesVertexShader: {
  11853. name: string;
  11854. shader: string;
  11855. };
  11856. }
  11857. declare module "babylonjs/Sprites/spriteManager" {
  11858. import { IDisposable, Scene } from "babylonjs/scene";
  11859. import { Nullable } from "babylonjs/types";
  11860. import { Observable } from "babylonjs/Misc/observable";
  11861. import { Sprite } from "babylonjs/Sprites/sprite";
  11862. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11863. import { Camera } from "babylonjs/Cameras/camera";
  11864. import { Texture } from "babylonjs/Materials/Textures/texture";
  11865. import "babylonjs/Shaders/sprites.fragment";
  11866. import "babylonjs/Shaders/sprites.vertex";
  11867. import { Ray } from "babylonjs/Culling/ray";
  11868. /**
  11869. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11870. */
  11871. export interface ISpriteManager extends IDisposable {
  11872. /**
  11873. * Restricts the camera to viewing objects with the same layerMask.
  11874. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11875. */
  11876. layerMask: number;
  11877. /**
  11878. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11879. */
  11880. isPickable: boolean;
  11881. /**
  11882. * Specifies the rendering group id for this mesh (0 by default)
  11883. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11884. */
  11885. renderingGroupId: number;
  11886. /**
  11887. * Defines the list of sprites managed by the manager.
  11888. */
  11889. sprites: Array<Sprite>;
  11890. /**
  11891. * Tests the intersection of a sprite with a specific ray.
  11892. * @param ray The ray we are sending to test the collision
  11893. * @param camera The camera space we are sending rays in
  11894. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11895. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11896. * @returns picking info or null.
  11897. */
  11898. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11899. /**
  11900. * Intersects the sprites with a ray
  11901. * @param ray defines the ray to intersect with
  11902. * @param camera defines the current active camera
  11903. * @param predicate defines a predicate used to select candidate sprites
  11904. * @returns null if no hit or a PickingInfo array
  11905. */
  11906. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11907. /**
  11908. * Renders the list of sprites on screen.
  11909. */
  11910. render(): void;
  11911. }
  11912. /**
  11913. * Class used to manage multiple sprites on the same spritesheet
  11914. * @see http://doc.babylonjs.com/babylon101/sprites
  11915. */
  11916. export class SpriteManager implements ISpriteManager {
  11917. /** defines the manager's name */
  11918. name: string;
  11919. /** Gets the list of sprites */
  11920. sprites: Sprite[];
  11921. /** Gets or sets the rendering group id (0 by default) */
  11922. renderingGroupId: number;
  11923. /** Gets or sets camera layer mask */
  11924. layerMask: number;
  11925. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11926. fogEnabled: boolean;
  11927. /** Gets or sets a boolean indicating if the sprites are pickable */
  11928. isPickable: boolean;
  11929. /** Defines the default width of a cell in the spritesheet */
  11930. cellWidth: number;
  11931. /** Defines the default height of a cell in the spritesheet */
  11932. cellHeight: number;
  11933. /** Associative array from JSON sprite data file */
  11934. private _cellData;
  11935. /** Array of sprite names from JSON sprite data file */
  11936. private _spriteMap;
  11937. /** True when packed cell data from JSON file is ready*/
  11938. private _packedAndReady;
  11939. /**
  11940. * An event triggered when the manager is disposed.
  11941. */
  11942. onDisposeObservable: Observable<SpriteManager>;
  11943. private _onDisposeObserver;
  11944. /**
  11945. * Callback called when the manager is disposed
  11946. */
  11947. set onDispose(callback: () => void);
  11948. private _capacity;
  11949. private _fromPacked;
  11950. private _spriteTexture;
  11951. private _epsilon;
  11952. private _scene;
  11953. private _vertexData;
  11954. private _buffer;
  11955. private _vertexBuffers;
  11956. private _indexBuffer;
  11957. private _effectBase;
  11958. private _effectFog;
  11959. /**
  11960. * Gets or sets the spritesheet texture
  11961. */
  11962. get texture(): Texture;
  11963. set texture(value: Texture);
  11964. /**
  11965. * Creates a new sprite manager
  11966. * @param name defines the manager's name
  11967. * @param imgUrl defines the sprite sheet url
  11968. * @param capacity defines the maximum allowed number of sprites
  11969. * @param cellSize defines the size of a sprite cell
  11970. * @param scene defines the hosting scene
  11971. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11972. * @param samplingMode defines the smapling mode to use with spritesheet
  11973. * @param fromPacked set to false; do not alter
  11974. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11975. */
  11976. constructor(
  11977. /** defines the manager's name */
  11978. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11979. private _makePacked;
  11980. private _appendSpriteVertex;
  11981. /**
  11982. * Intersects the sprites with a ray
  11983. * @param ray defines the ray to intersect with
  11984. * @param camera defines the current active camera
  11985. * @param predicate defines a predicate used to select candidate sprites
  11986. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11987. * @returns null if no hit or a PickingInfo
  11988. */
  11989. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11990. /**
  11991. * Intersects the sprites with a ray
  11992. * @param ray defines the ray to intersect with
  11993. * @param camera defines the current active camera
  11994. * @param predicate defines a predicate used to select candidate sprites
  11995. * @returns null if no hit or a PickingInfo array
  11996. */
  11997. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11998. /**
  11999. * Render all child sprites
  12000. */
  12001. render(): void;
  12002. /**
  12003. * Release associated resources
  12004. */
  12005. dispose(): void;
  12006. }
  12007. }
  12008. declare module "babylonjs/Sprites/sprite" {
  12009. import { Vector3 } from "babylonjs/Maths/math.vector";
  12010. import { Nullable } from "babylonjs/types";
  12011. import { ActionManager } from "babylonjs/Actions/actionManager";
  12012. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12013. import { Color4 } from "babylonjs/Maths/math.color";
  12014. /**
  12015. * Class used to represent a sprite
  12016. * @see http://doc.babylonjs.com/babylon101/sprites
  12017. */
  12018. export class Sprite {
  12019. /** defines the name */
  12020. name: string;
  12021. /** Gets or sets the current world position */
  12022. position: Vector3;
  12023. /** Gets or sets the main color */
  12024. color: Color4;
  12025. /** Gets or sets the width */
  12026. width: number;
  12027. /** Gets or sets the height */
  12028. height: number;
  12029. /** Gets or sets rotation angle */
  12030. angle: number;
  12031. /** Gets or sets the cell index in the sprite sheet */
  12032. cellIndex: number;
  12033. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  12034. cellRef: string;
  12035. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12036. invertU: number;
  12037. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12038. invertV: number;
  12039. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12040. disposeWhenFinishedAnimating: boolean;
  12041. /** Gets the list of attached animations */
  12042. animations: Animation[];
  12043. /** Gets or sets a boolean indicating if the sprite can be picked */
  12044. isPickable: boolean;
  12045. /**
  12046. * Gets or sets the associated action manager
  12047. */
  12048. actionManager: Nullable<ActionManager>;
  12049. private _animationStarted;
  12050. private _loopAnimation;
  12051. private _fromIndex;
  12052. private _toIndex;
  12053. private _delay;
  12054. private _direction;
  12055. private _manager;
  12056. private _time;
  12057. private _onAnimationEnd;
  12058. /**
  12059. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12060. */
  12061. isVisible: boolean;
  12062. /**
  12063. * Gets or sets the sprite size
  12064. */
  12065. get size(): number;
  12066. set size(value: number);
  12067. /**
  12068. * Creates a new Sprite
  12069. * @param name defines the name
  12070. * @param manager defines the manager
  12071. */
  12072. constructor(
  12073. /** defines the name */
  12074. name: string, manager: ISpriteManager);
  12075. /**
  12076. * Starts an animation
  12077. * @param from defines the initial key
  12078. * @param to defines the end key
  12079. * @param loop defines if the animation must loop
  12080. * @param delay defines the start delay (in ms)
  12081. * @param onAnimationEnd defines a callback to call when animation ends
  12082. */
  12083. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12084. /** Stops current animation (if any) */
  12085. stopAnimation(): void;
  12086. /** @hidden */
  12087. _animate(deltaTime: number): void;
  12088. /** Release associated resources */
  12089. dispose(): void;
  12090. }
  12091. }
  12092. declare module "babylonjs/Collisions/pickingInfo" {
  12093. import { Nullable } from "babylonjs/types";
  12094. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  12095. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12096. import { Sprite } from "babylonjs/Sprites/sprite";
  12097. import { Ray } from "babylonjs/Culling/ray";
  12098. /**
  12099. * Information about the result of picking within a scene
  12100. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12101. */
  12102. export class PickingInfo {
  12103. /** @hidden */
  12104. _pickingUnavailable: boolean;
  12105. /**
  12106. * If the pick collided with an object
  12107. */
  12108. hit: boolean;
  12109. /**
  12110. * Distance away where the pick collided
  12111. */
  12112. distance: number;
  12113. /**
  12114. * The location of pick collision
  12115. */
  12116. pickedPoint: Nullable<Vector3>;
  12117. /**
  12118. * The mesh corresponding the the pick collision
  12119. */
  12120. pickedMesh: Nullable<AbstractMesh>;
  12121. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  12122. bu: number;
  12123. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  12124. bv: number;
  12125. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12126. faceId: number;
  12127. /** Id of the the submesh that was picked */
  12128. subMeshId: number;
  12129. /** If a sprite was picked, this will be the sprite the pick collided with */
  12130. pickedSprite: Nullable<Sprite>;
  12131. /**
  12132. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12133. */
  12134. originMesh: Nullable<AbstractMesh>;
  12135. /**
  12136. * The ray that was used to perform the picking.
  12137. */
  12138. ray: Nullable<Ray>;
  12139. /**
  12140. * Gets the normal correspodning to the face the pick collided with
  12141. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12142. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12143. * @returns The normal correspodning to the face the pick collided with
  12144. */
  12145. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12146. /**
  12147. * Gets the texture coordinates of where the pick occured
  12148. * @returns the vector containing the coordnates of the texture
  12149. */
  12150. getTextureCoordinates(): Nullable<Vector2>;
  12151. }
  12152. }
  12153. declare module "babylonjs/Events/pointerEvents" {
  12154. import { Nullable } from "babylonjs/types";
  12155. import { Vector2 } from "babylonjs/Maths/math.vector";
  12156. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12157. import { Ray } from "babylonjs/Culling/ray";
  12158. /**
  12159. * Gather the list of pointer event types as constants.
  12160. */
  12161. export class PointerEventTypes {
  12162. /**
  12163. * 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.
  12164. */
  12165. static readonly POINTERDOWN: number;
  12166. /**
  12167. * The pointerup event is fired when a pointer is no longer active.
  12168. */
  12169. static readonly POINTERUP: number;
  12170. /**
  12171. * The pointermove event is fired when a pointer changes coordinates.
  12172. */
  12173. static readonly POINTERMOVE: number;
  12174. /**
  12175. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12176. */
  12177. static readonly POINTERWHEEL: number;
  12178. /**
  12179. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12180. */
  12181. static readonly POINTERPICK: number;
  12182. /**
  12183. * The pointertap event is fired when a the object has been touched and released without drag.
  12184. */
  12185. static readonly POINTERTAP: number;
  12186. /**
  12187. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12188. */
  12189. static readonly POINTERDOUBLETAP: number;
  12190. }
  12191. /**
  12192. * Base class of pointer info types.
  12193. */
  12194. export class PointerInfoBase {
  12195. /**
  12196. * Defines the type of event (PointerEventTypes)
  12197. */
  12198. type: number;
  12199. /**
  12200. * Defines the related dom event
  12201. */
  12202. event: PointerEvent | MouseWheelEvent;
  12203. /**
  12204. * Instantiates the base class of pointers info.
  12205. * @param type Defines the type of event (PointerEventTypes)
  12206. * @param event Defines the related dom event
  12207. */
  12208. constructor(
  12209. /**
  12210. * Defines the type of event (PointerEventTypes)
  12211. */
  12212. type: number,
  12213. /**
  12214. * Defines the related dom event
  12215. */
  12216. event: PointerEvent | MouseWheelEvent);
  12217. }
  12218. /**
  12219. * This class is used to store pointer related info for the onPrePointerObservable event.
  12220. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12221. */
  12222. export class PointerInfoPre extends PointerInfoBase {
  12223. /**
  12224. * Ray from a pointer if availible (eg. 6dof controller)
  12225. */
  12226. ray: Nullable<Ray>;
  12227. /**
  12228. * Defines the local position of the pointer on the canvas.
  12229. */
  12230. localPosition: Vector2;
  12231. /**
  12232. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12233. */
  12234. skipOnPointerObservable: boolean;
  12235. /**
  12236. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12237. * @param type Defines the type of event (PointerEventTypes)
  12238. * @param event Defines the related dom event
  12239. * @param localX Defines the local x coordinates of the pointer when the event occured
  12240. * @param localY Defines the local y coordinates of the pointer when the event occured
  12241. */
  12242. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12243. }
  12244. /**
  12245. * This type contains all the data related to a pointer event in Babylon.js.
  12246. * 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.
  12247. */
  12248. export class PointerInfo extends PointerInfoBase {
  12249. /**
  12250. * Defines the picking info associated to the info (if any)\
  12251. */
  12252. pickInfo: Nullable<PickingInfo>;
  12253. /**
  12254. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12255. * @param type Defines the type of event (PointerEventTypes)
  12256. * @param event Defines the related dom event
  12257. * @param pickInfo Defines the picking info associated to the info (if any)\
  12258. */
  12259. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12260. /**
  12261. * Defines the picking info associated to the info (if any)\
  12262. */
  12263. pickInfo: Nullable<PickingInfo>);
  12264. }
  12265. /**
  12266. * Data relating to a touch event on the screen.
  12267. */
  12268. export interface PointerTouch {
  12269. /**
  12270. * X coordinate of touch.
  12271. */
  12272. x: number;
  12273. /**
  12274. * Y coordinate of touch.
  12275. */
  12276. y: number;
  12277. /**
  12278. * Id of touch. Unique for each finger.
  12279. */
  12280. pointerId: number;
  12281. /**
  12282. * Event type passed from DOM.
  12283. */
  12284. type: any;
  12285. }
  12286. }
  12287. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12288. import { Observable } from "babylonjs/Misc/observable";
  12289. import { Nullable } from "babylonjs/types";
  12290. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12291. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12292. /**
  12293. * Manage the mouse inputs to control the movement of a free camera.
  12294. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12295. */
  12296. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12297. /**
  12298. * Define if touch is enabled in the mouse input
  12299. */
  12300. touchEnabled: boolean;
  12301. /**
  12302. * Defines the camera the input is attached to.
  12303. */
  12304. camera: FreeCamera;
  12305. /**
  12306. * Defines the buttons associated with the input to handle camera move.
  12307. */
  12308. buttons: number[];
  12309. /**
  12310. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12311. */
  12312. angularSensibility: number;
  12313. private _pointerInput;
  12314. private _onMouseMove;
  12315. private _observer;
  12316. private previousPosition;
  12317. /**
  12318. * Observable for when a pointer move event occurs containing the move offset
  12319. */
  12320. onPointerMovedObservable: Observable<{
  12321. offsetX: number;
  12322. offsetY: number;
  12323. }>;
  12324. /**
  12325. * @hidden
  12326. * If the camera should be rotated automatically based on pointer movement
  12327. */
  12328. _allowCameraRotation: boolean;
  12329. /**
  12330. * Manage the mouse inputs to control the movement of a free camera.
  12331. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12332. * @param touchEnabled Defines if touch is enabled or not
  12333. */
  12334. constructor(
  12335. /**
  12336. * Define if touch is enabled in the mouse input
  12337. */
  12338. touchEnabled?: boolean);
  12339. /**
  12340. * Attach the input controls to a specific dom element to get the input from.
  12341. * @param element Defines the element the controls should be listened from
  12342. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12343. */
  12344. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12345. /**
  12346. * Called on JS contextmenu event.
  12347. * Override this method to provide functionality.
  12348. */
  12349. protected onContextMenu(evt: PointerEvent): void;
  12350. /**
  12351. * Detach the current controls from the specified dom element.
  12352. * @param element Defines the element to stop listening the inputs from
  12353. */
  12354. detachControl(element: Nullable<HTMLElement>): void;
  12355. /**
  12356. * Gets the class name of the current intput.
  12357. * @returns the class name
  12358. */
  12359. getClassName(): string;
  12360. /**
  12361. * Get the friendly name associated with the input class.
  12362. * @returns the input friendly name
  12363. */
  12364. getSimpleName(): string;
  12365. }
  12366. }
  12367. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12368. import { Nullable } from "babylonjs/types";
  12369. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12370. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12371. /**
  12372. * Manage the touch inputs to control the movement of a free camera.
  12373. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12374. */
  12375. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12376. /**
  12377. * Defines the camera the input is attached to.
  12378. */
  12379. camera: FreeCamera;
  12380. /**
  12381. * Defines the touch sensibility for rotation.
  12382. * The higher the faster.
  12383. */
  12384. touchAngularSensibility: number;
  12385. /**
  12386. * Defines the touch sensibility for move.
  12387. * The higher the faster.
  12388. */
  12389. touchMoveSensibility: number;
  12390. private _offsetX;
  12391. private _offsetY;
  12392. private _pointerPressed;
  12393. private _pointerInput;
  12394. private _observer;
  12395. private _onLostFocus;
  12396. /**
  12397. * Attach the input controls to a specific dom element to get the input from.
  12398. * @param element Defines the element the controls should be listened from
  12399. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12400. */
  12401. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12402. /**
  12403. * Detach the current controls from the specified dom element.
  12404. * @param element Defines the element to stop listening the inputs from
  12405. */
  12406. detachControl(element: Nullable<HTMLElement>): void;
  12407. /**
  12408. * Update the current camera state depending on the inputs that have been used this frame.
  12409. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12410. */
  12411. checkInputs(): void;
  12412. /**
  12413. * Gets the class name of the current intput.
  12414. * @returns the class name
  12415. */
  12416. getClassName(): string;
  12417. /**
  12418. * Get the friendly name associated with the input class.
  12419. * @returns the input friendly name
  12420. */
  12421. getSimpleName(): string;
  12422. }
  12423. }
  12424. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12425. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12426. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12427. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12428. import { Nullable } from "babylonjs/types";
  12429. /**
  12430. * Default Inputs manager for the FreeCamera.
  12431. * It groups all the default supported inputs for ease of use.
  12432. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12433. */
  12434. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12435. /**
  12436. * @hidden
  12437. */
  12438. _mouseInput: Nullable<FreeCameraMouseInput>;
  12439. /**
  12440. * Instantiates a new FreeCameraInputsManager.
  12441. * @param camera Defines the camera the inputs belong to
  12442. */
  12443. constructor(camera: FreeCamera);
  12444. /**
  12445. * Add keyboard input support to the input manager.
  12446. * @returns the current input manager
  12447. */
  12448. addKeyboard(): FreeCameraInputsManager;
  12449. /**
  12450. * Add mouse input support to the input manager.
  12451. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12452. * @returns the current input manager
  12453. */
  12454. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12455. /**
  12456. * Removes the mouse input support from the manager
  12457. * @returns the current input manager
  12458. */
  12459. removeMouse(): FreeCameraInputsManager;
  12460. /**
  12461. * Add touch input support to the input manager.
  12462. * @returns the current input manager
  12463. */
  12464. addTouch(): FreeCameraInputsManager;
  12465. /**
  12466. * Remove all attached input methods from a camera
  12467. */
  12468. clear(): void;
  12469. }
  12470. }
  12471. declare module "babylonjs/Cameras/freeCamera" {
  12472. import { Vector3 } from "babylonjs/Maths/math.vector";
  12473. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12474. import { Scene } from "babylonjs/scene";
  12475. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12476. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12477. /**
  12478. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12479. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12480. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12481. */
  12482. export class FreeCamera extends TargetCamera {
  12483. /**
  12484. * Define the collision ellipsoid of the camera.
  12485. * This is helpful to simulate a camera body like the player body around the camera
  12486. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12487. */
  12488. ellipsoid: Vector3;
  12489. /**
  12490. * Define an offset for the position of the ellipsoid around the camera.
  12491. * This can be helpful to determine the center of the body near the gravity center of the body
  12492. * instead of its head.
  12493. */
  12494. ellipsoidOffset: Vector3;
  12495. /**
  12496. * Enable or disable collisions of the camera with the rest of the scene objects.
  12497. */
  12498. checkCollisions: boolean;
  12499. /**
  12500. * Enable or disable gravity on the camera.
  12501. */
  12502. applyGravity: boolean;
  12503. /**
  12504. * Define the input manager associated to the camera.
  12505. */
  12506. inputs: FreeCameraInputsManager;
  12507. /**
  12508. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12509. * Higher values reduce sensitivity.
  12510. */
  12511. get angularSensibility(): number;
  12512. /**
  12513. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12514. * Higher values reduce sensitivity.
  12515. */
  12516. set angularSensibility(value: number);
  12517. /**
  12518. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12519. */
  12520. get keysUp(): number[];
  12521. set keysUp(value: number[]);
  12522. /**
  12523. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12524. */
  12525. get keysDown(): number[];
  12526. set keysDown(value: number[]);
  12527. /**
  12528. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12529. */
  12530. get keysLeft(): number[];
  12531. set keysLeft(value: number[]);
  12532. /**
  12533. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12534. */
  12535. get keysRight(): number[];
  12536. set keysRight(value: number[]);
  12537. /**
  12538. * Event raised when the camera collide with a mesh in the scene.
  12539. */
  12540. onCollide: (collidedMesh: AbstractMesh) => void;
  12541. private _collider;
  12542. private _needMoveForGravity;
  12543. private _oldPosition;
  12544. private _diffPosition;
  12545. private _newPosition;
  12546. /** @hidden */
  12547. _localDirection: Vector3;
  12548. /** @hidden */
  12549. _transformedDirection: Vector3;
  12550. /**
  12551. * Instantiates a Free Camera.
  12552. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12553. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12554. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12555. * @param name Define the name of the camera in the scene
  12556. * @param position Define the start position of the camera in the scene
  12557. * @param scene Define the scene the camera belongs to
  12558. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12559. */
  12560. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12561. /**
  12562. * Attached controls to the current camera.
  12563. * @param element Defines the element the controls should be listened from
  12564. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12565. */
  12566. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12567. /**
  12568. * Detach the current controls from the camera.
  12569. * The camera will stop reacting to inputs.
  12570. * @param element Defines the element to stop listening the inputs from
  12571. */
  12572. detachControl(element: HTMLElement): void;
  12573. private _collisionMask;
  12574. /**
  12575. * Define a collision mask to limit the list of object the camera can collide with
  12576. */
  12577. get collisionMask(): number;
  12578. set collisionMask(mask: number);
  12579. /** @hidden */
  12580. _collideWithWorld(displacement: Vector3): void;
  12581. private _onCollisionPositionChange;
  12582. /** @hidden */
  12583. _checkInputs(): void;
  12584. /** @hidden */
  12585. _decideIfNeedsToMove(): boolean;
  12586. /** @hidden */
  12587. _updatePosition(): void;
  12588. /**
  12589. * Destroy the camera and release the current resources hold by it.
  12590. */
  12591. dispose(): void;
  12592. /**
  12593. * Gets the current object class name.
  12594. * @return the class name
  12595. */
  12596. getClassName(): string;
  12597. }
  12598. }
  12599. declare module "babylonjs/Gamepads/gamepad" {
  12600. import { Observable } from "babylonjs/Misc/observable";
  12601. /**
  12602. * Represents a gamepad control stick position
  12603. */
  12604. export class StickValues {
  12605. /**
  12606. * The x component of the control stick
  12607. */
  12608. x: number;
  12609. /**
  12610. * The y component of the control stick
  12611. */
  12612. y: number;
  12613. /**
  12614. * Initializes the gamepad x and y control stick values
  12615. * @param x The x component of the gamepad control stick value
  12616. * @param y The y component of the gamepad control stick value
  12617. */
  12618. constructor(
  12619. /**
  12620. * The x component of the control stick
  12621. */
  12622. x: number,
  12623. /**
  12624. * The y component of the control stick
  12625. */
  12626. y: number);
  12627. }
  12628. /**
  12629. * An interface which manages callbacks for gamepad button changes
  12630. */
  12631. export interface GamepadButtonChanges {
  12632. /**
  12633. * Called when a gamepad has been changed
  12634. */
  12635. changed: boolean;
  12636. /**
  12637. * Called when a gamepad press event has been triggered
  12638. */
  12639. pressChanged: boolean;
  12640. /**
  12641. * Called when a touch event has been triggered
  12642. */
  12643. touchChanged: boolean;
  12644. /**
  12645. * Called when a value has changed
  12646. */
  12647. valueChanged: boolean;
  12648. }
  12649. /**
  12650. * Represents a gamepad
  12651. */
  12652. export class Gamepad {
  12653. /**
  12654. * The id of the gamepad
  12655. */
  12656. id: string;
  12657. /**
  12658. * The index of the gamepad
  12659. */
  12660. index: number;
  12661. /**
  12662. * The browser gamepad
  12663. */
  12664. browserGamepad: any;
  12665. /**
  12666. * Specifies what type of gamepad this represents
  12667. */
  12668. type: number;
  12669. private _leftStick;
  12670. private _rightStick;
  12671. /** @hidden */
  12672. _isConnected: boolean;
  12673. private _leftStickAxisX;
  12674. private _leftStickAxisY;
  12675. private _rightStickAxisX;
  12676. private _rightStickAxisY;
  12677. /**
  12678. * Triggered when the left control stick has been changed
  12679. */
  12680. private _onleftstickchanged;
  12681. /**
  12682. * Triggered when the right control stick has been changed
  12683. */
  12684. private _onrightstickchanged;
  12685. /**
  12686. * Represents a gamepad controller
  12687. */
  12688. static GAMEPAD: number;
  12689. /**
  12690. * Represents a generic controller
  12691. */
  12692. static GENERIC: number;
  12693. /**
  12694. * Represents an XBox controller
  12695. */
  12696. static XBOX: number;
  12697. /**
  12698. * Represents a pose-enabled controller
  12699. */
  12700. static POSE_ENABLED: number;
  12701. /**
  12702. * Represents an Dual Shock controller
  12703. */
  12704. static DUALSHOCK: number;
  12705. /**
  12706. * Specifies whether the left control stick should be Y-inverted
  12707. */
  12708. protected _invertLeftStickY: boolean;
  12709. /**
  12710. * Specifies if the gamepad has been connected
  12711. */
  12712. get isConnected(): boolean;
  12713. /**
  12714. * Initializes the gamepad
  12715. * @param id The id of the gamepad
  12716. * @param index The index of the gamepad
  12717. * @param browserGamepad The browser gamepad
  12718. * @param leftStickX The x component of the left joystick
  12719. * @param leftStickY The y component of the left joystick
  12720. * @param rightStickX The x component of the right joystick
  12721. * @param rightStickY The y component of the right joystick
  12722. */
  12723. constructor(
  12724. /**
  12725. * The id of the gamepad
  12726. */
  12727. id: string,
  12728. /**
  12729. * The index of the gamepad
  12730. */
  12731. index: number,
  12732. /**
  12733. * The browser gamepad
  12734. */
  12735. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12736. /**
  12737. * Callback triggered when the left joystick has changed
  12738. * @param callback
  12739. */
  12740. onleftstickchanged(callback: (values: StickValues) => void): void;
  12741. /**
  12742. * Callback triggered when the right joystick has changed
  12743. * @param callback
  12744. */
  12745. onrightstickchanged(callback: (values: StickValues) => void): void;
  12746. /**
  12747. * Gets the left joystick
  12748. */
  12749. get leftStick(): StickValues;
  12750. /**
  12751. * Sets the left joystick values
  12752. */
  12753. set leftStick(newValues: StickValues);
  12754. /**
  12755. * Gets the right joystick
  12756. */
  12757. get rightStick(): StickValues;
  12758. /**
  12759. * Sets the right joystick value
  12760. */
  12761. set rightStick(newValues: StickValues);
  12762. /**
  12763. * Updates the gamepad joystick positions
  12764. */
  12765. update(): void;
  12766. /**
  12767. * Disposes the gamepad
  12768. */
  12769. dispose(): void;
  12770. }
  12771. /**
  12772. * Represents a generic gamepad
  12773. */
  12774. export class GenericPad extends Gamepad {
  12775. private _buttons;
  12776. private _onbuttondown;
  12777. private _onbuttonup;
  12778. /**
  12779. * Observable triggered when a button has been pressed
  12780. */
  12781. onButtonDownObservable: Observable<number>;
  12782. /**
  12783. * Observable triggered when a button has been released
  12784. */
  12785. onButtonUpObservable: Observable<number>;
  12786. /**
  12787. * Callback triggered when a button has been pressed
  12788. * @param callback Called when a button has been pressed
  12789. */
  12790. onbuttondown(callback: (buttonPressed: number) => void): void;
  12791. /**
  12792. * Callback triggered when a button has been released
  12793. * @param callback Called when a button has been released
  12794. */
  12795. onbuttonup(callback: (buttonReleased: number) => void): void;
  12796. /**
  12797. * Initializes the generic gamepad
  12798. * @param id The id of the generic gamepad
  12799. * @param index The index of the generic gamepad
  12800. * @param browserGamepad The browser gamepad
  12801. */
  12802. constructor(id: string, index: number, browserGamepad: any);
  12803. private _setButtonValue;
  12804. /**
  12805. * Updates the generic gamepad
  12806. */
  12807. update(): void;
  12808. /**
  12809. * Disposes the generic gamepad
  12810. */
  12811. dispose(): void;
  12812. }
  12813. }
  12814. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12815. import { Nullable } from "babylonjs/types";
  12816. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12817. import { Scene } from "babylonjs/scene";
  12818. module "babylonjs/Engines/engine" {
  12819. interface Engine {
  12820. /**
  12821. * Creates a raw texture
  12822. * @param data defines the data to store in the texture
  12823. * @param width defines the width of the texture
  12824. * @param height defines the height of the texture
  12825. * @param format defines the format of the data
  12826. * @param generateMipMaps defines if the engine should generate the mip levels
  12827. * @param invertY defines if data must be stored with Y axis inverted
  12828. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12829. * @param compression defines the compression used (null by default)
  12830. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12831. * @returns the raw texture inside an InternalTexture
  12832. */
  12833. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12834. /**
  12835. * Update a raw texture
  12836. * @param texture defines the texture to update
  12837. * @param data defines the data to store in the texture
  12838. * @param format defines the format of the data
  12839. * @param invertY defines if data must be stored with Y axis inverted
  12840. */
  12841. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12842. /**
  12843. * Update a raw texture
  12844. * @param texture defines the texture to update
  12845. * @param data defines the data to store in the texture
  12846. * @param format defines the format of the data
  12847. * @param invertY defines if data must be stored with Y axis inverted
  12848. * @param compression defines the compression used (null by default)
  12849. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12850. */
  12851. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12852. /**
  12853. * Creates a new raw cube texture
  12854. * @param data defines the array of data to use to create each face
  12855. * @param size defines the size of the textures
  12856. * @param format defines the format of the data
  12857. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12858. * @param generateMipMaps defines if the engine should generate the mip levels
  12859. * @param invertY defines if data must be stored with Y axis inverted
  12860. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12861. * @param compression defines the compression used (null by default)
  12862. * @returns the cube texture as an InternalTexture
  12863. */
  12864. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12865. /**
  12866. * Update a raw cube texture
  12867. * @param texture defines the texture to udpdate
  12868. * @param data defines the data to store
  12869. * @param format defines the data format
  12870. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12871. * @param invertY defines if data must be stored with Y axis inverted
  12872. */
  12873. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12874. /**
  12875. * Update a raw cube texture
  12876. * @param texture defines the texture to udpdate
  12877. * @param data defines the data to store
  12878. * @param format defines the data format
  12879. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12880. * @param invertY defines if data must be stored with Y axis inverted
  12881. * @param compression defines the compression used (null by default)
  12882. */
  12883. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12884. /**
  12885. * Update a raw cube texture
  12886. * @param texture defines the texture to udpdate
  12887. * @param data defines the data to store
  12888. * @param format defines the data format
  12889. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12890. * @param invertY defines if data must be stored with Y axis inverted
  12891. * @param compression defines the compression used (null by default)
  12892. * @param level defines which level of the texture to update
  12893. */
  12894. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12895. /**
  12896. * Creates a new raw cube texture from a specified url
  12897. * @param url defines the url where the data is located
  12898. * @param scene defines the current scene
  12899. * @param size defines the size of the textures
  12900. * @param format defines the format of the data
  12901. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12902. * @param noMipmap defines if the engine should avoid generating the mip levels
  12903. * @param callback defines a callback used to extract texture data from loaded data
  12904. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12905. * @param onLoad defines a callback called when texture is loaded
  12906. * @param onError defines a callback called if there is an error
  12907. * @returns the cube texture as an InternalTexture
  12908. */
  12909. 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;
  12910. /**
  12911. * Creates a new raw cube texture from a specified url
  12912. * @param url defines the url where the data is located
  12913. * @param scene defines the current scene
  12914. * @param size defines the size of the textures
  12915. * @param format defines the format of the data
  12916. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12917. * @param noMipmap defines if the engine should avoid generating the mip levels
  12918. * @param callback defines a callback used to extract texture data from loaded data
  12919. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12920. * @param onLoad defines a callback called when texture is loaded
  12921. * @param onError defines a callback called if there is an error
  12922. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12923. * @param invertY defines if data must be stored with Y axis inverted
  12924. * @returns the cube texture as an InternalTexture
  12925. */
  12926. 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;
  12927. /**
  12928. * Creates a new raw 3D texture
  12929. * @param data defines the data used to create the texture
  12930. * @param width defines the width of the texture
  12931. * @param height defines the height of the texture
  12932. * @param depth defines the depth of the texture
  12933. * @param format defines the format of the texture
  12934. * @param generateMipMaps defines if the engine must generate mip levels
  12935. * @param invertY defines if data must be stored with Y axis inverted
  12936. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12937. * @param compression defines the compressed used (can be null)
  12938. * @param textureType defines the compressed used (can be null)
  12939. * @returns a new raw 3D texture (stored in an InternalTexture)
  12940. */
  12941. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12942. /**
  12943. * Update a raw 3D texture
  12944. * @param texture defines the texture to update
  12945. * @param data defines the data to store
  12946. * @param format defines the data format
  12947. * @param invertY defines if data must be stored with Y axis inverted
  12948. */
  12949. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12950. /**
  12951. * Update a raw 3D texture
  12952. * @param texture defines the texture to update
  12953. * @param data defines the data to store
  12954. * @param format defines the data format
  12955. * @param invertY defines if data must be stored with Y axis inverted
  12956. * @param compression defines the used compression (can be null)
  12957. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12958. */
  12959. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12960. /**
  12961. * Creates a new raw 2D array texture
  12962. * @param data defines the data used to create the texture
  12963. * @param width defines the width of the texture
  12964. * @param height defines the height of the texture
  12965. * @param depth defines the number of layers of the texture
  12966. * @param format defines the format of the texture
  12967. * @param generateMipMaps defines if the engine must generate mip levels
  12968. * @param invertY defines if data must be stored with Y axis inverted
  12969. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12970. * @param compression defines the compressed used (can be null)
  12971. * @param textureType defines the compressed used (can be null)
  12972. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12973. */
  12974. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12975. /**
  12976. * Update a raw 2D array texture
  12977. * @param texture defines the texture to update
  12978. * @param data defines the data to store
  12979. * @param format defines the data format
  12980. * @param invertY defines if data must be stored with Y axis inverted
  12981. */
  12982. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12983. /**
  12984. * Update a raw 2D array texture
  12985. * @param texture defines the texture to update
  12986. * @param data defines the data to store
  12987. * @param format defines the data format
  12988. * @param invertY defines if data must be stored with Y axis inverted
  12989. * @param compression defines the used compression (can be null)
  12990. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12991. */
  12992. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12993. }
  12994. }
  12995. }
  12996. declare module "babylonjs/Materials/Textures/rawTexture" {
  12997. import { Scene } from "babylonjs/scene";
  12998. import { Texture } from "babylonjs/Materials/Textures/texture";
  12999. import "babylonjs/Engines/Extensions/engine.rawTexture";
  13000. /**
  13001. * Raw texture can help creating a texture directly from an array of data.
  13002. * This can be super useful if you either get the data from an uncompressed source or
  13003. * if you wish to create your texture pixel by pixel.
  13004. */
  13005. export class RawTexture extends Texture {
  13006. /**
  13007. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13008. */
  13009. format: number;
  13010. private _engine;
  13011. /**
  13012. * Instantiates a new RawTexture.
  13013. * Raw texture can help creating a texture directly from an array of data.
  13014. * This can be super useful if you either get the data from an uncompressed source or
  13015. * if you wish to create your texture pixel by pixel.
  13016. * @param data define the array of data to use to create the texture
  13017. * @param width define the width of the texture
  13018. * @param height define the height of the texture
  13019. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13020. * @param scene define the scene the texture belongs to
  13021. * @param generateMipMaps define whether mip maps should be generated or not
  13022. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13023. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13024. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13025. */
  13026. constructor(data: ArrayBufferView, width: number, height: number,
  13027. /**
  13028. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13029. */
  13030. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  13031. /**
  13032. * Updates the texture underlying data.
  13033. * @param data Define the new data of the texture
  13034. */
  13035. update(data: ArrayBufferView): void;
  13036. /**
  13037. * Creates a luminance texture from some data.
  13038. * @param data Define the texture data
  13039. * @param width Define the width of the texture
  13040. * @param height Define the height of the texture
  13041. * @param scene Define the scene the texture belongs to
  13042. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13043. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13044. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13045. * @returns the luminance texture
  13046. */
  13047. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13048. /**
  13049. * Creates a luminance alpha texture from some data.
  13050. * @param data Define the texture data
  13051. * @param width Define the width of the texture
  13052. * @param height Define the height of the texture
  13053. * @param scene Define the scene the texture belongs to
  13054. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13055. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13056. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13057. * @returns the luminance alpha texture
  13058. */
  13059. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13060. /**
  13061. * Creates an alpha texture from some data.
  13062. * @param data Define the texture data
  13063. * @param width Define the width of the texture
  13064. * @param height Define the height of the texture
  13065. * @param scene Define the scene the texture belongs to
  13066. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13067. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13068. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13069. * @returns the alpha texture
  13070. */
  13071. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13072. /**
  13073. * Creates a RGB texture from some data.
  13074. * @param data Define the texture data
  13075. * @param width Define the width of the texture
  13076. * @param height Define the height of the texture
  13077. * @param scene Define the scene the texture belongs to
  13078. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13079. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13080. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13081. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13082. * @returns the RGB alpha texture
  13083. */
  13084. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13085. /**
  13086. * Creates a RGBA texture from some data.
  13087. * @param data Define the texture data
  13088. * @param width Define the width of the texture
  13089. * @param height Define the height of the texture
  13090. * @param scene Define the scene the texture belongs to
  13091. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13092. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13093. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13094. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13095. * @returns the RGBA texture
  13096. */
  13097. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13098. /**
  13099. * Creates a R texture from some data.
  13100. * @param data Define the texture data
  13101. * @param width Define the width of the texture
  13102. * @param height Define the height of the texture
  13103. * @param scene Define the scene the texture belongs to
  13104. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13105. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13106. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13107. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13108. * @returns the R texture
  13109. */
  13110. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13111. }
  13112. }
  13113. declare module "babylonjs/Maths/math.size" {
  13114. /**
  13115. * Interface for the size containing width and height
  13116. */
  13117. export interface ISize {
  13118. /**
  13119. * Width
  13120. */
  13121. width: number;
  13122. /**
  13123. * Heighht
  13124. */
  13125. height: number;
  13126. }
  13127. /**
  13128. * Size containing widht and height
  13129. */
  13130. export class Size implements ISize {
  13131. /**
  13132. * Width
  13133. */
  13134. width: number;
  13135. /**
  13136. * Height
  13137. */
  13138. height: number;
  13139. /**
  13140. * Creates a Size object from the given width and height (floats).
  13141. * @param width width of the new size
  13142. * @param height height of the new size
  13143. */
  13144. constructor(width: number, height: number);
  13145. /**
  13146. * Returns a string with the Size width and height
  13147. * @returns a string with the Size width and height
  13148. */
  13149. toString(): string;
  13150. /**
  13151. * "Size"
  13152. * @returns the string "Size"
  13153. */
  13154. getClassName(): string;
  13155. /**
  13156. * Returns the Size hash code.
  13157. * @returns a hash code for a unique width and height
  13158. */
  13159. getHashCode(): number;
  13160. /**
  13161. * Updates the current size from the given one.
  13162. * @param src the given size
  13163. */
  13164. copyFrom(src: Size): void;
  13165. /**
  13166. * Updates in place the current Size from the given floats.
  13167. * @param width width of the new size
  13168. * @param height height of the new size
  13169. * @returns the updated Size.
  13170. */
  13171. copyFromFloats(width: number, height: number): Size;
  13172. /**
  13173. * Updates in place the current Size from the given floats.
  13174. * @param width width to set
  13175. * @param height height to set
  13176. * @returns the updated Size.
  13177. */
  13178. set(width: number, height: number): Size;
  13179. /**
  13180. * Multiplies the width and height by numbers
  13181. * @param w factor to multiple the width by
  13182. * @param h factor to multiple the height by
  13183. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  13184. */
  13185. multiplyByFloats(w: number, h: number): Size;
  13186. /**
  13187. * Clones the size
  13188. * @returns a new Size copied from the given one.
  13189. */
  13190. clone(): Size;
  13191. /**
  13192. * True if the current Size and the given one width and height are strictly equal.
  13193. * @param other the other size to compare against
  13194. * @returns True if the current Size and the given one width and height are strictly equal.
  13195. */
  13196. equals(other: Size): boolean;
  13197. /**
  13198. * The surface of the Size : width * height (float).
  13199. */
  13200. get surface(): number;
  13201. /**
  13202. * Create a new size of zero
  13203. * @returns a new Size set to (0.0, 0.0)
  13204. */
  13205. static Zero(): Size;
  13206. /**
  13207. * Sums the width and height of two sizes
  13208. * @param otherSize size to add to this size
  13209. * @returns a new Size set as the addition result of the current Size and the given one.
  13210. */
  13211. add(otherSize: Size): Size;
  13212. /**
  13213. * Subtracts the width and height of two
  13214. * @param otherSize size to subtract to this size
  13215. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13216. */
  13217. subtract(otherSize: Size): Size;
  13218. /**
  13219. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13220. * @param start starting size to lerp between
  13221. * @param end end size to lerp between
  13222. * @param amount amount to lerp between the start and end values
  13223. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13224. */
  13225. static Lerp(start: Size, end: Size, amount: number): Size;
  13226. }
  13227. }
  13228. declare module "babylonjs/Animations/runtimeAnimation" {
  13229. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13230. import { Animatable } from "babylonjs/Animations/animatable";
  13231. import { Scene } from "babylonjs/scene";
  13232. /**
  13233. * Defines a runtime animation
  13234. */
  13235. export class RuntimeAnimation {
  13236. private _events;
  13237. /**
  13238. * The current frame of the runtime animation
  13239. */
  13240. private _currentFrame;
  13241. /**
  13242. * The animation used by the runtime animation
  13243. */
  13244. private _animation;
  13245. /**
  13246. * The target of the runtime animation
  13247. */
  13248. private _target;
  13249. /**
  13250. * The initiating animatable
  13251. */
  13252. private _host;
  13253. /**
  13254. * The original value of the runtime animation
  13255. */
  13256. private _originalValue;
  13257. /**
  13258. * The original blend value of the runtime animation
  13259. */
  13260. private _originalBlendValue;
  13261. /**
  13262. * The offsets cache of the runtime animation
  13263. */
  13264. private _offsetsCache;
  13265. /**
  13266. * The high limits cache of the runtime animation
  13267. */
  13268. private _highLimitsCache;
  13269. /**
  13270. * Specifies if the runtime animation has been stopped
  13271. */
  13272. private _stopped;
  13273. /**
  13274. * The blending factor of the runtime animation
  13275. */
  13276. private _blendingFactor;
  13277. /**
  13278. * The BabylonJS scene
  13279. */
  13280. private _scene;
  13281. /**
  13282. * The current value of the runtime animation
  13283. */
  13284. private _currentValue;
  13285. /** @hidden */
  13286. _animationState: _IAnimationState;
  13287. /**
  13288. * The active target of the runtime animation
  13289. */
  13290. private _activeTargets;
  13291. private _currentActiveTarget;
  13292. private _directTarget;
  13293. /**
  13294. * The target path of the runtime animation
  13295. */
  13296. private _targetPath;
  13297. /**
  13298. * The weight of the runtime animation
  13299. */
  13300. private _weight;
  13301. /**
  13302. * The ratio offset of the runtime animation
  13303. */
  13304. private _ratioOffset;
  13305. /**
  13306. * The previous delay of the runtime animation
  13307. */
  13308. private _previousDelay;
  13309. /**
  13310. * The previous ratio of the runtime animation
  13311. */
  13312. private _previousRatio;
  13313. private _enableBlending;
  13314. private _keys;
  13315. private _minFrame;
  13316. private _maxFrame;
  13317. private _minValue;
  13318. private _maxValue;
  13319. private _targetIsArray;
  13320. /**
  13321. * Gets the current frame of the runtime animation
  13322. */
  13323. get currentFrame(): number;
  13324. /**
  13325. * Gets the weight of the runtime animation
  13326. */
  13327. get weight(): number;
  13328. /**
  13329. * Gets the current value of the runtime animation
  13330. */
  13331. get currentValue(): any;
  13332. /**
  13333. * Gets the target path of the runtime animation
  13334. */
  13335. get targetPath(): string;
  13336. /**
  13337. * Gets the actual target of the runtime animation
  13338. */
  13339. get target(): any;
  13340. /** @hidden */
  13341. _onLoop: () => void;
  13342. /**
  13343. * Create a new RuntimeAnimation object
  13344. * @param target defines the target of the animation
  13345. * @param animation defines the source animation object
  13346. * @param scene defines the hosting scene
  13347. * @param host defines the initiating Animatable
  13348. */
  13349. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13350. private _preparePath;
  13351. /**
  13352. * Gets the animation from the runtime animation
  13353. */
  13354. get animation(): Animation;
  13355. /**
  13356. * Resets the runtime animation to the beginning
  13357. * @param restoreOriginal defines whether to restore the target property to the original value
  13358. */
  13359. reset(restoreOriginal?: boolean): void;
  13360. /**
  13361. * Specifies if the runtime animation is stopped
  13362. * @returns Boolean specifying if the runtime animation is stopped
  13363. */
  13364. isStopped(): boolean;
  13365. /**
  13366. * Disposes of the runtime animation
  13367. */
  13368. dispose(): void;
  13369. /**
  13370. * Apply the interpolated value to the target
  13371. * @param currentValue defines the value computed by the animation
  13372. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13373. */
  13374. setValue(currentValue: any, weight: number): void;
  13375. private _getOriginalValues;
  13376. private _setValue;
  13377. /**
  13378. * Gets the loop pmode of the runtime animation
  13379. * @returns Loop Mode
  13380. */
  13381. private _getCorrectLoopMode;
  13382. /**
  13383. * Move the current animation to a given frame
  13384. * @param frame defines the frame to move to
  13385. */
  13386. goToFrame(frame: number): void;
  13387. /**
  13388. * @hidden Internal use only
  13389. */
  13390. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13391. /**
  13392. * Execute the current animation
  13393. * @param delay defines the delay to add to the current frame
  13394. * @param from defines the lower bound of the animation range
  13395. * @param to defines the upper bound of the animation range
  13396. * @param loop defines if the current animation must loop
  13397. * @param speedRatio defines the current speed ratio
  13398. * @param weight defines the weight of the animation (default is -1 so no weight)
  13399. * @param onLoop optional callback called when animation loops
  13400. * @returns a boolean indicating if the animation is running
  13401. */
  13402. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13403. }
  13404. }
  13405. declare module "babylonjs/Animations/animatable" {
  13406. import { Animation } from "babylonjs/Animations/animation";
  13407. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13408. import { Nullable } from "babylonjs/types";
  13409. import { Observable } from "babylonjs/Misc/observable";
  13410. import { Scene } from "babylonjs/scene";
  13411. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13412. import { Node } from "babylonjs/node";
  13413. /**
  13414. * Class used to store an actual running animation
  13415. */
  13416. export class Animatable {
  13417. /** defines the target object */
  13418. target: any;
  13419. /** defines the starting frame number (default is 0) */
  13420. fromFrame: number;
  13421. /** defines the ending frame number (default is 100) */
  13422. toFrame: number;
  13423. /** defines if the animation must loop (default is false) */
  13424. loopAnimation: boolean;
  13425. /** defines a callback to call when animation ends if it is not looping */
  13426. onAnimationEnd?: (() => void) | null | undefined;
  13427. /** defines a callback to call when animation loops */
  13428. onAnimationLoop?: (() => void) | null | undefined;
  13429. private _localDelayOffset;
  13430. private _pausedDelay;
  13431. private _runtimeAnimations;
  13432. private _paused;
  13433. private _scene;
  13434. private _speedRatio;
  13435. private _weight;
  13436. private _syncRoot;
  13437. /**
  13438. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13439. * This will only apply for non looping animation (default is true)
  13440. */
  13441. disposeOnEnd: boolean;
  13442. /**
  13443. * Gets a boolean indicating if the animation has started
  13444. */
  13445. animationStarted: boolean;
  13446. /**
  13447. * Observer raised when the animation ends
  13448. */
  13449. onAnimationEndObservable: Observable<Animatable>;
  13450. /**
  13451. * Observer raised when the animation loops
  13452. */
  13453. onAnimationLoopObservable: Observable<Animatable>;
  13454. /**
  13455. * Gets the root Animatable used to synchronize and normalize animations
  13456. */
  13457. get syncRoot(): Nullable<Animatable>;
  13458. /**
  13459. * Gets the current frame of the first RuntimeAnimation
  13460. * Used to synchronize Animatables
  13461. */
  13462. get masterFrame(): number;
  13463. /**
  13464. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13465. */
  13466. get weight(): number;
  13467. set weight(value: number);
  13468. /**
  13469. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13470. */
  13471. get speedRatio(): number;
  13472. set speedRatio(value: number);
  13473. /**
  13474. * Creates a new Animatable
  13475. * @param scene defines the hosting scene
  13476. * @param target defines the target object
  13477. * @param fromFrame defines the starting frame number (default is 0)
  13478. * @param toFrame defines the ending frame number (default is 100)
  13479. * @param loopAnimation defines if the animation must loop (default is false)
  13480. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13481. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13482. * @param animations defines a group of animation to add to the new Animatable
  13483. * @param onAnimationLoop defines a callback to call when animation loops
  13484. */
  13485. constructor(scene: Scene,
  13486. /** defines the target object */
  13487. target: any,
  13488. /** defines the starting frame number (default is 0) */
  13489. fromFrame?: number,
  13490. /** defines the ending frame number (default is 100) */
  13491. toFrame?: number,
  13492. /** defines if the animation must loop (default is false) */
  13493. loopAnimation?: boolean, speedRatio?: number,
  13494. /** defines a callback to call when animation ends if it is not looping */
  13495. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13496. /** defines a callback to call when animation loops */
  13497. onAnimationLoop?: (() => void) | null | undefined);
  13498. /**
  13499. * Synchronize and normalize current Animatable with a source Animatable
  13500. * This is useful when using animation weights and when animations are not of the same length
  13501. * @param root defines the root Animatable to synchronize with
  13502. * @returns the current Animatable
  13503. */
  13504. syncWith(root: Animatable): Animatable;
  13505. /**
  13506. * Gets the list of runtime animations
  13507. * @returns an array of RuntimeAnimation
  13508. */
  13509. getAnimations(): RuntimeAnimation[];
  13510. /**
  13511. * Adds more animations to the current animatable
  13512. * @param target defines the target of the animations
  13513. * @param animations defines the new animations to add
  13514. */
  13515. appendAnimations(target: any, animations: Animation[]): void;
  13516. /**
  13517. * Gets the source animation for a specific property
  13518. * @param property defines the propertyu to look for
  13519. * @returns null or the source animation for the given property
  13520. */
  13521. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13522. /**
  13523. * Gets the runtime animation for a specific property
  13524. * @param property defines the propertyu to look for
  13525. * @returns null or the runtime animation for the given property
  13526. */
  13527. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13528. /**
  13529. * Resets the animatable to its original state
  13530. */
  13531. reset(): void;
  13532. /**
  13533. * Allows the animatable to blend with current running animations
  13534. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13535. * @param blendingSpeed defines the blending speed to use
  13536. */
  13537. enableBlending(blendingSpeed: number): void;
  13538. /**
  13539. * Disable animation blending
  13540. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13541. */
  13542. disableBlending(): void;
  13543. /**
  13544. * Jump directly to a given frame
  13545. * @param frame defines the frame to jump to
  13546. */
  13547. goToFrame(frame: number): void;
  13548. /**
  13549. * Pause the animation
  13550. */
  13551. pause(): void;
  13552. /**
  13553. * Restart the animation
  13554. */
  13555. restart(): void;
  13556. private _raiseOnAnimationEnd;
  13557. /**
  13558. * Stop and delete the current animation
  13559. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13560. * @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)
  13561. */
  13562. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13563. /**
  13564. * Wait asynchronously for the animation to end
  13565. * @returns a promise which will be fullfilled when the animation ends
  13566. */
  13567. waitAsync(): Promise<Animatable>;
  13568. /** @hidden */
  13569. _animate(delay: number): boolean;
  13570. }
  13571. module "babylonjs/scene" {
  13572. interface Scene {
  13573. /** @hidden */
  13574. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13575. /** @hidden */
  13576. _processLateAnimationBindingsForMatrices(holder: {
  13577. totalWeight: number;
  13578. animations: RuntimeAnimation[];
  13579. originalValue: Matrix;
  13580. }): any;
  13581. /** @hidden */
  13582. _processLateAnimationBindingsForQuaternions(holder: {
  13583. totalWeight: number;
  13584. animations: RuntimeAnimation[];
  13585. originalValue: Quaternion;
  13586. }, refQuaternion: Quaternion): Quaternion;
  13587. /** @hidden */
  13588. _processLateAnimationBindings(): void;
  13589. /**
  13590. * Will start the animation sequence of a given target
  13591. * @param target defines the target
  13592. * @param from defines from which frame should animation start
  13593. * @param to defines until which frame should animation run.
  13594. * @param weight defines the weight to apply to the animation (1.0 by default)
  13595. * @param loop defines if the animation loops
  13596. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13597. * @param onAnimationEnd defines the function to be executed when the animation ends
  13598. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13599. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13600. * @param onAnimationLoop defines the callback to call when an animation loops
  13601. * @returns the animatable object created for this animation
  13602. */
  13603. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13604. /**
  13605. * Will start the animation sequence of a given target
  13606. * @param target defines the target
  13607. * @param from defines from which frame should animation start
  13608. * @param to defines until which frame should animation run.
  13609. * @param loop defines if the animation loops
  13610. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13611. * @param onAnimationEnd defines the function to be executed when the animation ends
  13612. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13613. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13614. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13615. * @param onAnimationLoop defines the callback to call when an animation loops
  13616. * @returns the animatable object created for this animation
  13617. */
  13618. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13619. /**
  13620. * Will start the animation sequence of a given target and its hierarchy
  13621. * @param target defines the target
  13622. * @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.
  13623. * @param from defines from which frame should animation start
  13624. * @param to defines until which frame should animation run.
  13625. * @param loop defines if the animation loops
  13626. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13627. * @param onAnimationEnd defines the function to be executed when the animation ends
  13628. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13629. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13630. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13631. * @param onAnimationLoop defines the callback to call when an animation loops
  13632. * @returns the list of created animatables
  13633. */
  13634. 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[];
  13635. /**
  13636. * Begin a new animation on a given node
  13637. * @param target defines the target where the animation will take place
  13638. * @param animations defines the list of animations to start
  13639. * @param from defines the initial value
  13640. * @param to defines the final value
  13641. * @param loop defines if you want animation to loop (off by default)
  13642. * @param speedRatio defines the speed ratio to apply to all animations
  13643. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13644. * @param onAnimationLoop defines the callback to call when an animation loops
  13645. * @returns the list of created animatables
  13646. */
  13647. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13648. /**
  13649. * Begin a new animation on a given node and its hierarchy
  13650. * @param target defines the root node where the animation will take place
  13651. * @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.
  13652. * @param animations defines the list of animations to start
  13653. * @param from defines the initial value
  13654. * @param to defines the final value
  13655. * @param loop defines if you want animation to loop (off by default)
  13656. * @param speedRatio defines the speed ratio to apply to all animations
  13657. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13658. * @param onAnimationLoop defines the callback to call when an animation loops
  13659. * @returns the list of animatables created for all nodes
  13660. */
  13661. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13662. /**
  13663. * Gets the animatable associated with a specific target
  13664. * @param target defines the target of the animatable
  13665. * @returns the required animatable if found
  13666. */
  13667. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13668. /**
  13669. * Gets all animatables associated with a given target
  13670. * @param target defines the target to look animatables for
  13671. * @returns an array of Animatables
  13672. */
  13673. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13674. /**
  13675. * Stops and removes all animations that have been applied to the scene
  13676. */
  13677. stopAllAnimations(): void;
  13678. /**
  13679. * Gets the current delta time used by animation engine
  13680. */
  13681. deltaTime: number;
  13682. }
  13683. }
  13684. module "babylonjs/Bones/bone" {
  13685. interface Bone {
  13686. /**
  13687. * Copy an animation range from another bone
  13688. * @param source defines the source bone
  13689. * @param rangeName defines the range name to copy
  13690. * @param frameOffset defines the frame offset
  13691. * @param rescaleAsRequired defines if rescaling must be applied if required
  13692. * @param skelDimensionsRatio defines the scaling ratio
  13693. * @returns true if operation was successful
  13694. */
  13695. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13696. }
  13697. }
  13698. }
  13699. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13700. /**
  13701. * Class used to override all child animations of a given target
  13702. */
  13703. export class AnimationPropertiesOverride {
  13704. /**
  13705. * Gets or sets a value indicating if animation blending must be used
  13706. */
  13707. enableBlending: boolean;
  13708. /**
  13709. * Gets or sets the blending speed to use when enableBlending is true
  13710. */
  13711. blendingSpeed: number;
  13712. /**
  13713. * Gets or sets the default loop mode to use
  13714. */
  13715. loopMode: number;
  13716. }
  13717. }
  13718. declare module "babylonjs/Bones/skeleton" {
  13719. import { Bone } from "babylonjs/Bones/bone";
  13720. import { Observable } from "babylonjs/Misc/observable";
  13721. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13722. import { Scene } from "babylonjs/scene";
  13723. import { Nullable } from "babylonjs/types";
  13724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13725. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13726. import { Animatable } from "babylonjs/Animations/animatable";
  13727. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13728. import { Animation } from "babylonjs/Animations/animation";
  13729. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13730. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13731. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13732. /**
  13733. * Class used to handle skinning animations
  13734. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13735. */
  13736. export class Skeleton implements IAnimatable {
  13737. /** defines the skeleton name */
  13738. name: string;
  13739. /** defines the skeleton Id */
  13740. id: string;
  13741. /**
  13742. * Defines the list of child bones
  13743. */
  13744. bones: Bone[];
  13745. /**
  13746. * Defines an estimate of the dimension of the skeleton at rest
  13747. */
  13748. dimensionsAtRest: Vector3;
  13749. /**
  13750. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13751. */
  13752. needInitialSkinMatrix: boolean;
  13753. /**
  13754. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13755. */
  13756. overrideMesh: Nullable<AbstractMesh>;
  13757. /**
  13758. * Gets the list of animations attached to this skeleton
  13759. */
  13760. animations: Array<Animation>;
  13761. private _scene;
  13762. private _isDirty;
  13763. private _transformMatrices;
  13764. private _transformMatrixTexture;
  13765. private _meshesWithPoseMatrix;
  13766. private _animatables;
  13767. private _identity;
  13768. private _synchronizedWithMesh;
  13769. private _ranges;
  13770. private _lastAbsoluteTransformsUpdateId;
  13771. private _canUseTextureForBones;
  13772. private _uniqueId;
  13773. /** @hidden */
  13774. _numBonesWithLinkedTransformNode: number;
  13775. /** @hidden */
  13776. _hasWaitingData: Nullable<boolean>;
  13777. /**
  13778. * Specifies if the skeleton should be serialized
  13779. */
  13780. doNotSerialize: boolean;
  13781. private _useTextureToStoreBoneMatrices;
  13782. /**
  13783. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13784. * Please note that this option is not available if the hardware does not support it
  13785. */
  13786. get useTextureToStoreBoneMatrices(): boolean;
  13787. set useTextureToStoreBoneMatrices(value: boolean);
  13788. private _animationPropertiesOverride;
  13789. /**
  13790. * Gets or sets the animation properties override
  13791. */
  13792. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13793. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  13794. /**
  13795. * List of inspectable custom properties (used by the Inspector)
  13796. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13797. */
  13798. inspectableCustomProperties: IInspectable[];
  13799. /**
  13800. * An observable triggered before computing the skeleton's matrices
  13801. */
  13802. onBeforeComputeObservable: Observable<Skeleton>;
  13803. /**
  13804. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13805. */
  13806. get isUsingTextureForMatrices(): boolean;
  13807. /**
  13808. * Gets the unique ID of this skeleton
  13809. */
  13810. get uniqueId(): number;
  13811. /**
  13812. * Creates a new skeleton
  13813. * @param name defines the skeleton name
  13814. * @param id defines the skeleton Id
  13815. * @param scene defines the hosting scene
  13816. */
  13817. constructor(
  13818. /** defines the skeleton name */
  13819. name: string,
  13820. /** defines the skeleton Id */
  13821. id: string, scene: Scene);
  13822. /**
  13823. * Gets the current object class name.
  13824. * @return the class name
  13825. */
  13826. getClassName(): string;
  13827. /**
  13828. * Returns an array containing the root bones
  13829. * @returns an array containing the root bones
  13830. */
  13831. getChildren(): Array<Bone>;
  13832. /**
  13833. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13834. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13835. * @returns a Float32Array containing matrices data
  13836. */
  13837. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13838. /**
  13839. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13840. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13841. * @returns a raw texture containing the data
  13842. */
  13843. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13844. /**
  13845. * Gets the current hosting scene
  13846. * @returns a scene object
  13847. */
  13848. getScene(): Scene;
  13849. /**
  13850. * Gets a string representing the current skeleton data
  13851. * @param fullDetails defines a boolean indicating if we want a verbose version
  13852. * @returns a string representing the current skeleton data
  13853. */
  13854. toString(fullDetails?: boolean): string;
  13855. /**
  13856. * Get bone's index searching by name
  13857. * @param name defines bone's name to search for
  13858. * @return the indice of the bone. Returns -1 if not found
  13859. */
  13860. getBoneIndexByName(name: string): number;
  13861. /**
  13862. * Creater a new animation range
  13863. * @param name defines the name of the range
  13864. * @param from defines the start key
  13865. * @param to defines the end key
  13866. */
  13867. createAnimationRange(name: string, from: number, to: number): void;
  13868. /**
  13869. * Delete a specific animation range
  13870. * @param name defines the name of the range
  13871. * @param deleteFrames defines if frames must be removed as well
  13872. */
  13873. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13874. /**
  13875. * Gets a specific animation range
  13876. * @param name defines the name of the range to look for
  13877. * @returns the requested animation range or null if not found
  13878. */
  13879. getAnimationRange(name: string): Nullable<AnimationRange>;
  13880. /**
  13881. * Gets the list of all animation ranges defined on this skeleton
  13882. * @returns an array
  13883. */
  13884. getAnimationRanges(): Nullable<AnimationRange>[];
  13885. /**
  13886. * Copy animation range from a source skeleton.
  13887. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13888. * @param source defines the source skeleton
  13889. * @param name defines the name of the range to copy
  13890. * @param rescaleAsRequired defines if rescaling must be applied if required
  13891. * @returns true if operation was successful
  13892. */
  13893. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13894. /**
  13895. * Forces the skeleton to go to rest pose
  13896. */
  13897. returnToRest(): void;
  13898. private _getHighestAnimationFrame;
  13899. /**
  13900. * Begin a specific animation range
  13901. * @param name defines the name of the range to start
  13902. * @param loop defines if looping must be turned on (false by default)
  13903. * @param speedRatio defines the speed ratio to apply (1 by default)
  13904. * @param onAnimationEnd defines a callback which will be called when animation will end
  13905. * @returns a new animatable
  13906. */
  13907. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13908. /** @hidden */
  13909. _markAsDirty(): void;
  13910. /** @hidden */
  13911. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13912. /** @hidden */
  13913. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13914. private _computeTransformMatrices;
  13915. /**
  13916. * Build all resources required to render a skeleton
  13917. */
  13918. prepare(): void;
  13919. /**
  13920. * Gets the list of animatables currently running for this skeleton
  13921. * @returns an array of animatables
  13922. */
  13923. getAnimatables(): IAnimatable[];
  13924. /**
  13925. * Clone the current skeleton
  13926. * @param name defines the name of the new skeleton
  13927. * @param id defines the id of the new skeleton
  13928. * @returns the new skeleton
  13929. */
  13930. clone(name: string, id?: string): Skeleton;
  13931. /**
  13932. * Enable animation blending for this skeleton
  13933. * @param blendingSpeed defines the blending speed to apply
  13934. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13935. */
  13936. enableBlending(blendingSpeed?: number): void;
  13937. /**
  13938. * Releases all resources associated with the current skeleton
  13939. */
  13940. dispose(): void;
  13941. /**
  13942. * Serialize the skeleton in a JSON object
  13943. * @returns a JSON object
  13944. */
  13945. serialize(): any;
  13946. /**
  13947. * Creates a new skeleton from serialized data
  13948. * @param parsedSkeleton defines the serialized data
  13949. * @param scene defines the hosting scene
  13950. * @returns a new skeleton
  13951. */
  13952. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13953. /**
  13954. * Compute all node absolute transforms
  13955. * @param forceUpdate defines if computation must be done even if cache is up to date
  13956. */
  13957. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13958. /**
  13959. * Gets the root pose matrix
  13960. * @returns a matrix
  13961. */
  13962. getPoseMatrix(): Nullable<Matrix>;
  13963. /**
  13964. * Sorts bones per internal index
  13965. */
  13966. sortBones(): void;
  13967. private _sortBones;
  13968. }
  13969. }
  13970. declare module "babylonjs/Bones/bone" {
  13971. import { Skeleton } from "babylonjs/Bones/skeleton";
  13972. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13973. import { Nullable } from "babylonjs/types";
  13974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13975. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13976. import { Node } from "babylonjs/node";
  13977. import { Space } from "babylonjs/Maths/math.axis";
  13978. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13979. /**
  13980. * Class used to store bone information
  13981. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13982. */
  13983. export class Bone extends Node {
  13984. /**
  13985. * defines the bone name
  13986. */
  13987. name: string;
  13988. private static _tmpVecs;
  13989. private static _tmpQuat;
  13990. private static _tmpMats;
  13991. /**
  13992. * Gets the list of child bones
  13993. */
  13994. children: Bone[];
  13995. /** Gets the animations associated with this bone */
  13996. animations: import("babylonjs/Animations/animation").Animation[];
  13997. /**
  13998. * Gets or sets bone length
  13999. */
  14000. length: number;
  14001. /**
  14002. * @hidden Internal only
  14003. * Set this value to map this bone to a different index in the transform matrices
  14004. * Set this value to -1 to exclude the bone from the transform matrices
  14005. */
  14006. _index: Nullable<number>;
  14007. private _skeleton;
  14008. private _localMatrix;
  14009. private _restPose;
  14010. private _baseMatrix;
  14011. private _absoluteTransform;
  14012. private _invertedAbsoluteTransform;
  14013. private _parent;
  14014. private _scalingDeterminant;
  14015. private _worldTransform;
  14016. private _localScaling;
  14017. private _localRotation;
  14018. private _localPosition;
  14019. private _needToDecompose;
  14020. private _needToCompose;
  14021. /** @hidden */
  14022. _linkedTransformNode: Nullable<TransformNode>;
  14023. /** @hidden */
  14024. _waitingTransformNodeId: Nullable<string>;
  14025. /** @hidden */
  14026. get _matrix(): Matrix;
  14027. /** @hidden */
  14028. set _matrix(value: Matrix);
  14029. /**
  14030. * Create a new bone
  14031. * @param name defines the bone name
  14032. * @param skeleton defines the parent skeleton
  14033. * @param parentBone defines the parent (can be null if the bone is the root)
  14034. * @param localMatrix defines the local matrix
  14035. * @param restPose defines the rest pose matrix
  14036. * @param baseMatrix defines the base matrix
  14037. * @param index defines index of the bone in the hiearchy
  14038. */
  14039. constructor(
  14040. /**
  14041. * defines the bone name
  14042. */
  14043. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14044. /**
  14045. * Gets the current object class name.
  14046. * @return the class name
  14047. */
  14048. getClassName(): string;
  14049. /**
  14050. * Gets the parent skeleton
  14051. * @returns a skeleton
  14052. */
  14053. getSkeleton(): Skeleton;
  14054. /**
  14055. * Gets parent bone
  14056. * @returns a bone or null if the bone is the root of the bone hierarchy
  14057. */
  14058. getParent(): Nullable<Bone>;
  14059. /**
  14060. * Returns an array containing the root bones
  14061. * @returns an array containing the root bones
  14062. */
  14063. getChildren(): Array<Bone>;
  14064. /**
  14065. * Gets the node index in matrix array generated for rendering
  14066. * @returns the node index
  14067. */
  14068. getIndex(): number;
  14069. /**
  14070. * Sets the parent bone
  14071. * @param parent defines the parent (can be null if the bone is the root)
  14072. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14073. */
  14074. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14075. /**
  14076. * Gets the local matrix
  14077. * @returns a matrix
  14078. */
  14079. getLocalMatrix(): Matrix;
  14080. /**
  14081. * Gets the base matrix (initial matrix which remains unchanged)
  14082. * @returns a matrix
  14083. */
  14084. getBaseMatrix(): Matrix;
  14085. /**
  14086. * Gets the rest pose matrix
  14087. * @returns a matrix
  14088. */
  14089. getRestPose(): Matrix;
  14090. /**
  14091. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14092. */
  14093. getWorldMatrix(): Matrix;
  14094. /**
  14095. * Sets the local matrix to rest pose matrix
  14096. */
  14097. returnToRest(): void;
  14098. /**
  14099. * Gets the inverse of the absolute transform matrix.
  14100. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14101. * @returns a matrix
  14102. */
  14103. getInvertedAbsoluteTransform(): Matrix;
  14104. /**
  14105. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14106. * @returns a matrix
  14107. */
  14108. getAbsoluteTransform(): Matrix;
  14109. /**
  14110. * Links with the given transform node.
  14111. * The local matrix of this bone is copied from the transform node every frame.
  14112. * @param transformNode defines the transform node to link to
  14113. */
  14114. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14115. /**
  14116. * Gets the node used to drive the bone's transformation
  14117. * @returns a transform node or null
  14118. */
  14119. getTransformNode(): Nullable<TransformNode>;
  14120. /** Gets or sets current position (in local space) */
  14121. get position(): Vector3;
  14122. set position(newPosition: Vector3);
  14123. /** Gets or sets current rotation (in local space) */
  14124. get rotation(): Vector3;
  14125. set rotation(newRotation: Vector3);
  14126. /** Gets or sets current rotation quaternion (in local space) */
  14127. get rotationQuaternion(): Quaternion;
  14128. set rotationQuaternion(newRotation: Quaternion);
  14129. /** Gets or sets current scaling (in local space) */
  14130. get scaling(): Vector3;
  14131. set scaling(newScaling: Vector3);
  14132. /**
  14133. * Gets the animation properties override
  14134. */
  14135. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14136. private _decompose;
  14137. private _compose;
  14138. /**
  14139. * Update the base and local matrices
  14140. * @param matrix defines the new base or local matrix
  14141. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14142. * @param updateLocalMatrix defines if the local matrix should be updated
  14143. */
  14144. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14145. /** @hidden */
  14146. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14147. /**
  14148. * Flag the bone as dirty (Forcing it to update everything)
  14149. */
  14150. markAsDirty(): void;
  14151. /** @hidden */
  14152. _markAsDirtyAndCompose(): void;
  14153. private _markAsDirtyAndDecompose;
  14154. /**
  14155. * Translate the bone in local or world space
  14156. * @param vec The amount to translate the bone
  14157. * @param space The space that the translation is in
  14158. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14159. */
  14160. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14161. /**
  14162. * Set the postion of the bone in local or world space
  14163. * @param position The position to set the bone
  14164. * @param space The space that the position is in
  14165. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14166. */
  14167. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14168. /**
  14169. * Set the absolute position of the bone (world space)
  14170. * @param position The position to set the bone
  14171. * @param mesh The mesh that this bone is attached to
  14172. */
  14173. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14174. /**
  14175. * Scale the bone on the x, y and z axes (in local space)
  14176. * @param x The amount to scale the bone on the x axis
  14177. * @param y The amount to scale the bone on the y axis
  14178. * @param z The amount to scale the bone on the z axis
  14179. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14180. */
  14181. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14182. /**
  14183. * Set the bone scaling in local space
  14184. * @param scale defines the scaling vector
  14185. */
  14186. setScale(scale: Vector3): void;
  14187. /**
  14188. * Gets the current scaling in local space
  14189. * @returns the current scaling vector
  14190. */
  14191. getScale(): Vector3;
  14192. /**
  14193. * Gets the current scaling in local space and stores it in a target vector
  14194. * @param result defines the target vector
  14195. */
  14196. getScaleToRef(result: Vector3): void;
  14197. /**
  14198. * Set the yaw, pitch, and roll of the bone in local or world space
  14199. * @param yaw The rotation of the bone on the y axis
  14200. * @param pitch The rotation of the bone on the x axis
  14201. * @param roll The rotation of the bone on the z axis
  14202. * @param space The space that the axes of rotation are in
  14203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14204. */
  14205. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14206. /**
  14207. * Add a rotation to the bone on an axis in local or world space
  14208. * @param axis The axis to rotate the bone on
  14209. * @param amount The amount to rotate the bone
  14210. * @param space The space that the axis is in
  14211. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14212. */
  14213. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14214. /**
  14215. * Set the rotation of the bone to a particular axis angle in local or world space
  14216. * @param axis The axis to rotate the bone on
  14217. * @param angle The angle that the bone should be rotated to
  14218. * @param space The space that the axis is in
  14219. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14220. */
  14221. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14222. /**
  14223. * Set the euler rotation of the bone in local of world space
  14224. * @param rotation The euler rotation that the bone should be set to
  14225. * @param space The space that the rotation is in
  14226. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14227. */
  14228. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14229. /**
  14230. * Set the quaternion rotation of the bone in local of world space
  14231. * @param quat The quaternion rotation that the bone should be set to
  14232. * @param space The space that the rotation is in
  14233. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14234. */
  14235. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14236. /**
  14237. * Set the rotation matrix of the bone in local of world space
  14238. * @param rotMat The rotation matrix that the bone should be set to
  14239. * @param space The space that the rotation is in
  14240. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14241. */
  14242. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14243. private _rotateWithMatrix;
  14244. private _getNegativeRotationToRef;
  14245. /**
  14246. * Get the position of the bone in local or world space
  14247. * @param space The space that the returned position is in
  14248. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14249. * @returns The position of the bone
  14250. */
  14251. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14252. /**
  14253. * Copy the position of the bone to a vector3 in local or world space
  14254. * @param space The space that the returned position is in
  14255. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14256. * @param result The vector3 to copy the position to
  14257. */
  14258. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14259. /**
  14260. * Get the absolute position of the bone (world space)
  14261. * @param mesh The mesh that this bone is attached to
  14262. * @returns The absolute position of the bone
  14263. */
  14264. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14265. /**
  14266. * Copy the absolute position of the bone (world space) to the result param
  14267. * @param mesh The mesh that this bone is attached to
  14268. * @param result The vector3 to copy the absolute position to
  14269. */
  14270. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14271. /**
  14272. * Compute the absolute transforms of this bone and its children
  14273. */
  14274. computeAbsoluteTransforms(): void;
  14275. /**
  14276. * Get the world direction from an axis that is in the local space of the bone
  14277. * @param localAxis The local direction that is used to compute the world direction
  14278. * @param mesh The mesh that this bone is attached to
  14279. * @returns The world direction
  14280. */
  14281. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14282. /**
  14283. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14284. * @param localAxis The local direction that is used to compute the world direction
  14285. * @param mesh The mesh that this bone is attached to
  14286. * @param result The vector3 that the world direction will be copied to
  14287. */
  14288. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14289. /**
  14290. * Get the euler rotation of the bone in local or world space
  14291. * @param space The space that the rotation should be in
  14292. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14293. * @returns The euler rotation
  14294. */
  14295. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14296. /**
  14297. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14298. * @param space The space that the rotation should be in
  14299. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14300. * @param result The vector3 that the rotation should be copied to
  14301. */
  14302. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14303. /**
  14304. * Get the quaternion rotation of the bone in either local or world space
  14305. * @param space The space that the rotation should be in
  14306. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14307. * @returns The quaternion rotation
  14308. */
  14309. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14310. /**
  14311. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14312. * @param space The space that the rotation should be in
  14313. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14314. * @param result The quaternion that the rotation should be copied to
  14315. */
  14316. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14317. /**
  14318. * Get the rotation matrix of the bone in local or world space
  14319. * @param space The space that the rotation should be in
  14320. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14321. * @returns The rotation matrix
  14322. */
  14323. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14324. /**
  14325. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14326. * @param space The space that the rotation should be in
  14327. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14328. * @param result The quaternion that the rotation should be copied to
  14329. */
  14330. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14331. /**
  14332. * Get the world position of a point that is in the local space of the bone
  14333. * @param position The local position
  14334. * @param mesh The mesh that this bone is attached to
  14335. * @returns The world position
  14336. */
  14337. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14338. /**
  14339. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14340. * @param position The local position
  14341. * @param mesh The mesh that this bone is attached to
  14342. * @param result The vector3 that the world position should be copied to
  14343. */
  14344. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14345. /**
  14346. * Get the local position of a point that is in world space
  14347. * @param position The world position
  14348. * @param mesh The mesh that this bone is attached to
  14349. * @returns The local position
  14350. */
  14351. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14352. /**
  14353. * Get the local position of a point that is in world space and copy it to the result param
  14354. * @param position The world position
  14355. * @param mesh The mesh that this bone is attached to
  14356. * @param result The vector3 that the local position should be copied to
  14357. */
  14358. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14359. }
  14360. }
  14361. declare module "babylonjs/Meshes/transformNode" {
  14362. import { DeepImmutable } from "babylonjs/types";
  14363. import { Observable } from "babylonjs/Misc/observable";
  14364. import { Nullable } from "babylonjs/types";
  14365. import { Camera } from "babylonjs/Cameras/camera";
  14366. import { Scene } from "babylonjs/scene";
  14367. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14368. import { Node } from "babylonjs/node";
  14369. import { Bone } from "babylonjs/Bones/bone";
  14370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14371. import { Space } from "babylonjs/Maths/math.axis";
  14372. /**
  14373. * 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.
  14374. * @see https://doc.babylonjs.com/how_to/transformnode
  14375. */
  14376. export class TransformNode extends Node {
  14377. /**
  14378. * Object will not rotate to face the camera
  14379. */
  14380. static BILLBOARDMODE_NONE: number;
  14381. /**
  14382. * Object will rotate to face the camera but only on the x axis
  14383. */
  14384. static BILLBOARDMODE_X: number;
  14385. /**
  14386. * Object will rotate to face the camera but only on the y axis
  14387. */
  14388. static BILLBOARDMODE_Y: number;
  14389. /**
  14390. * Object will rotate to face the camera but only on the z axis
  14391. */
  14392. static BILLBOARDMODE_Z: number;
  14393. /**
  14394. * Object will rotate to face the camera
  14395. */
  14396. static BILLBOARDMODE_ALL: number;
  14397. /**
  14398. * Object will rotate to face the camera's position instead of orientation
  14399. */
  14400. static BILLBOARDMODE_USE_POSITION: number;
  14401. private _forward;
  14402. private _forwardInverted;
  14403. private _up;
  14404. private _right;
  14405. private _rightInverted;
  14406. private _position;
  14407. private _rotation;
  14408. private _rotationQuaternion;
  14409. protected _scaling: Vector3;
  14410. protected _isDirty: boolean;
  14411. private _transformToBoneReferal;
  14412. private _isAbsoluteSynced;
  14413. private _billboardMode;
  14414. /**
  14415. * Gets or sets the billboard mode. Default is 0.
  14416. *
  14417. * | Value | Type | Description |
  14418. * | --- | --- | --- |
  14419. * | 0 | BILLBOARDMODE_NONE | |
  14420. * | 1 | BILLBOARDMODE_X | |
  14421. * | 2 | BILLBOARDMODE_Y | |
  14422. * | 4 | BILLBOARDMODE_Z | |
  14423. * | 7 | BILLBOARDMODE_ALL | |
  14424. *
  14425. */
  14426. get billboardMode(): number;
  14427. set billboardMode(value: number);
  14428. private _preserveParentRotationForBillboard;
  14429. /**
  14430. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14431. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14432. */
  14433. get preserveParentRotationForBillboard(): boolean;
  14434. set preserveParentRotationForBillboard(value: boolean);
  14435. /**
  14436. * 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
  14437. */
  14438. scalingDeterminant: number;
  14439. private _infiniteDistance;
  14440. /**
  14441. * Gets or sets the distance of the object to max, often used by skybox
  14442. */
  14443. get infiniteDistance(): boolean;
  14444. set infiniteDistance(value: boolean);
  14445. /**
  14446. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14447. * By default the system will update normals to compensate
  14448. */
  14449. ignoreNonUniformScaling: boolean;
  14450. /**
  14451. * 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
  14452. */
  14453. reIntegrateRotationIntoRotationQuaternion: boolean;
  14454. /** @hidden */
  14455. _poseMatrix: Nullable<Matrix>;
  14456. /** @hidden */
  14457. _localMatrix: Matrix;
  14458. private _usePivotMatrix;
  14459. private _absolutePosition;
  14460. private _absoluteScaling;
  14461. private _absoluteRotationQuaternion;
  14462. private _pivotMatrix;
  14463. private _pivotMatrixInverse;
  14464. protected _postMultiplyPivotMatrix: boolean;
  14465. protected _isWorldMatrixFrozen: boolean;
  14466. /** @hidden */
  14467. _indexInSceneTransformNodesArray: number;
  14468. /**
  14469. * An event triggered after the world matrix is updated
  14470. */
  14471. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14472. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14473. /**
  14474. * Gets a string identifying the name of the class
  14475. * @returns "TransformNode" string
  14476. */
  14477. getClassName(): string;
  14478. /**
  14479. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14480. */
  14481. get position(): Vector3;
  14482. set position(newPosition: Vector3);
  14483. /**
  14484. * 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)).
  14485. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14486. */
  14487. get rotation(): Vector3;
  14488. set rotation(newRotation: Vector3);
  14489. /**
  14490. * 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)).
  14491. */
  14492. get scaling(): Vector3;
  14493. set scaling(newScaling: Vector3);
  14494. /**
  14495. * 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).
  14496. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14497. */
  14498. get rotationQuaternion(): Nullable<Quaternion>;
  14499. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14500. /**
  14501. * The forward direction of that transform in world space.
  14502. */
  14503. get forward(): Vector3;
  14504. /**
  14505. * The up direction of that transform in world space.
  14506. */
  14507. get up(): Vector3;
  14508. /**
  14509. * The right direction of that transform in world space.
  14510. */
  14511. get right(): Vector3;
  14512. /**
  14513. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14514. * @param matrix the matrix to copy the pose from
  14515. * @returns this TransformNode.
  14516. */
  14517. updatePoseMatrix(matrix: Matrix): TransformNode;
  14518. /**
  14519. * Returns the mesh Pose matrix.
  14520. * @returns the pose matrix
  14521. */
  14522. getPoseMatrix(): Matrix;
  14523. /** @hidden */
  14524. _isSynchronized(): boolean;
  14525. /** @hidden */
  14526. _initCache(): void;
  14527. /**
  14528. * Flag the transform node as dirty (Forcing it to update everything)
  14529. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14530. * @returns this transform node
  14531. */
  14532. markAsDirty(property: string): TransformNode;
  14533. /**
  14534. * Returns the current mesh absolute position.
  14535. * Returns a Vector3.
  14536. */
  14537. get absolutePosition(): Vector3;
  14538. /**
  14539. * Returns the current mesh absolute scaling.
  14540. * Returns a Vector3.
  14541. */
  14542. get absoluteScaling(): Vector3;
  14543. /**
  14544. * Returns the current mesh absolute rotation.
  14545. * Returns a Quaternion.
  14546. */
  14547. get absoluteRotationQuaternion(): Quaternion;
  14548. /**
  14549. * Sets a new matrix to apply before all other transformation
  14550. * @param matrix defines the transform matrix
  14551. * @returns the current TransformNode
  14552. */
  14553. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14554. /**
  14555. * Sets a new pivot matrix to the current node
  14556. * @param matrix defines the new pivot matrix to use
  14557. * @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
  14558. * @returns the current TransformNode
  14559. */
  14560. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14561. /**
  14562. * Returns the mesh pivot matrix.
  14563. * Default : Identity.
  14564. * @returns the matrix
  14565. */
  14566. getPivotMatrix(): Matrix;
  14567. /**
  14568. * Instantiate (when possible) or clone that node with its hierarchy
  14569. * @param newParent defines the new parent to use for the instance (or clone)
  14570. * @param options defines options to configure how copy is done
  14571. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14572. * @returns an instance (or a clone) of the current node with its hiearchy
  14573. */
  14574. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14575. doNotInstantiate: boolean;
  14576. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14577. /**
  14578. * Prevents the World matrix to be computed any longer
  14579. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14580. * @returns the TransformNode.
  14581. */
  14582. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14583. /**
  14584. * Allows back the World matrix computation.
  14585. * @returns the TransformNode.
  14586. */
  14587. unfreezeWorldMatrix(): this;
  14588. /**
  14589. * True if the World matrix has been frozen.
  14590. */
  14591. get isWorldMatrixFrozen(): boolean;
  14592. /**
  14593. * Retuns the mesh absolute position in the World.
  14594. * @returns a Vector3.
  14595. */
  14596. getAbsolutePosition(): Vector3;
  14597. /**
  14598. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14599. * @param absolutePosition the absolute position to set
  14600. * @returns the TransformNode.
  14601. */
  14602. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14603. /**
  14604. * Sets the mesh position in its local space.
  14605. * @param vector3 the position to set in localspace
  14606. * @returns the TransformNode.
  14607. */
  14608. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14609. /**
  14610. * Returns the mesh position in the local space from the current World matrix values.
  14611. * @returns a new Vector3.
  14612. */
  14613. getPositionExpressedInLocalSpace(): Vector3;
  14614. /**
  14615. * Translates the mesh along the passed Vector3 in its local space.
  14616. * @param vector3 the distance to translate in localspace
  14617. * @returns the TransformNode.
  14618. */
  14619. locallyTranslate(vector3: Vector3): TransformNode;
  14620. private static _lookAtVectorCache;
  14621. /**
  14622. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14623. * @param targetPoint the position (must be in same space as current mesh) to look at
  14624. * @param yawCor optional yaw (y-axis) correction in radians
  14625. * @param pitchCor optional pitch (x-axis) correction in radians
  14626. * @param rollCor optional roll (z-axis) correction in radians
  14627. * @param space the choosen space of the target
  14628. * @returns the TransformNode.
  14629. */
  14630. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14631. /**
  14632. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14633. * This Vector3 is expressed in the World space.
  14634. * @param localAxis axis to rotate
  14635. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14636. */
  14637. getDirection(localAxis: Vector3): Vector3;
  14638. /**
  14639. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14640. * localAxis is expressed in the mesh local space.
  14641. * result is computed in the Wordl space from the mesh World matrix.
  14642. * @param localAxis axis to rotate
  14643. * @param result the resulting transformnode
  14644. * @returns this TransformNode.
  14645. */
  14646. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14647. /**
  14648. * Sets this transform node rotation to the given local axis.
  14649. * @param localAxis the axis in local space
  14650. * @param yawCor optional yaw (y-axis) correction in radians
  14651. * @param pitchCor optional pitch (x-axis) correction in radians
  14652. * @param rollCor optional roll (z-axis) correction in radians
  14653. * @returns this TransformNode
  14654. */
  14655. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14656. /**
  14657. * Sets a new pivot point to the current node
  14658. * @param point defines the new pivot point to use
  14659. * @param space defines if the point is in world or local space (local by default)
  14660. * @returns the current TransformNode
  14661. */
  14662. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14663. /**
  14664. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14665. * @returns the pivot point
  14666. */
  14667. getPivotPoint(): Vector3;
  14668. /**
  14669. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14670. * @param result the vector3 to store the result
  14671. * @returns this TransformNode.
  14672. */
  14673. getPivotPointToRef(result: Vector3): TransformNode;
  14674. /**
  14675. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14676. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14677. */
  14678. getAbsolutePivotPoint(): Vector3;
  14679. /**
  14680. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14681. * @param result vector3 to store the result
  14682. * @returns this TransformNode.
  14683. */
  14684. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14685. /**
  14686. * Defines the passed node as the parent of the current node.
  14687. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14688. * @see https://doc.babylonjs.com/how_to/parenting
  14689. * @param node the node ot set as the parent
  14690. * @returns this TransformNode.
  14691. */
  14692. setParent(node: Nullable<Node>): TransformNode;
  14693. private _nonUniformScaling;
  14694. /**
  14695. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14696. */
  14697. get nonUniformScaling(): boolean;
  14698. /** @hidden */
  14699. _updateNonUniformScalingState(value: boolean): boolean;
  14700. /**
  14701. * Attach the current TransformNode to another TransformNode associated with a bone
  14702. * @param bone Bone affecting the TransformNode
  14703. * @param affectedTransformNode TransformNode associated with the bone
  14704. * @returns this object
  14705. */
  14706. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14707. /**
  14708. * Detach the transform node if its associated with a bone
  14709. * @returns this object
  14710. */
  14711. detachFromBone(): TransformNode;
  14712. private static _rotationAxisCache;
  14713. /**
  14714. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14715. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14716. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14717. * The passed axis is also normalized.
  14718. * @param axis the axis to rotate around
  14719. * @param amount the amount to rotate in radians
  14720. * @param space Space to rotate in (Default: local)
  14721. * @returns the TransformNode.
  14722. */
  14723. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14724. /**
  14725. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14726. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14727. * The passed axis is also normalized. .
  14728. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14729. * @param point the point to rotate around
  14730. * @param axis the axis to rotate around
  14731. * @param amount the amount to rotate in radians
  14732. * @returns the TransformNode
  14733. */
  14734. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14735. /**
  14736. * Translates the mesh along the axis vector for the passed distance in the given space.
  14737. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14738. * @param axis the axis to translate in
  14739. * @param distance the distance to translate
  14740. * @param space Space to rotate in (Default: local)
  14741. * @returns the TransformNode.
  14742. */
  14743. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14744. /**
  14745. * Adds a rotation step to the mesh current rotation.
  14746. * x, y, z are Euler angles expressed in radians.
  14747. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14748. * This means this rotation is made in the mesh local space only.
  14749. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14750. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14751. * ```javascript
  14752. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14753. * ```
  14754. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14755. * 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.
  14756. * @param x Rotation to add
  14757. * @param y Rotation to add
  14758. * @param z Rotation to add
  14759. * @returns the TransformNode.
  14760. */
  14761. addRotation(x: number, y: number, z: number): TransformNode;
  14762. /**
  14763. * @hidden
  14764. */
  14765. protected _getEffectiveParent(): Nullable<Node>;
  14766. /**
  14767. * Computes the world matrix of the node
  14768. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14769. * @returns the world matrix
  14770. */
  14771. computeWorldMatrix(force?: boolean): Matrix;
  14772. protected _afterComputeWorldMatrix(): void;
  14773. /**
  14774. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14775. * @param func callback function to add
  14776. *
  14777. * @returns the TransformNode.
  14778. */
  14779. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14780. /**
  14781. * Removes a registered callback function.
  14782. * @param func callback function to remove
  14783. * @returns the TransformNode.
  14784. */
  14785. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14786. /**
  14787. * Gets the position of the current mesh in camera space
  14788. * @param camera defines the camera to use
  14789. * @returns a position
  14790. */
  14791. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14792. /**
  14793. * Returns the distance from the mesh to the active camera
  14794. * @param camera defines the camera to use
  14795. * @returns the distance
  14796. */
  14797. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14798. /**
  14799. * Clone the current transform node
  14800. * @param name Name of the new clone
  14801. * @param newParent New parent for the clone
  14802. * @param doNotCloneChildren Do not clone children hierarchy
  14803. * @returns the new transform node
  14804. */
  14805. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14806. /**
  14807. * Serializes the objects information.
  14808. * @param currentSerializationObject defines the object to serialize in
  14809. * @returns the serialized object
  14810. */
  14811. serialize(currentSerializationObject?: any): any;
  14812. /**
  14813. * Returns a new TransformNode object parsed from the source provided.
  14814. * @param parsedTransformNode is the source.
  14815. * @param scene the scne the object belongs to
  14816. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14817. * @returns a new TransformNode object parsed from the source provided.
  14818. */
  14819. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14820. /**
  14821. * Get all child-transformNodes of this node
  14822. * @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
  14823. * @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
  14824. * @returns an array of TransformNode
  14825. */
  14826. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14827. /**
  14828. * Releases resources associated with this transform node.
  14829. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14830. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14831. */
  14832. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14833. /**
  14834. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14835. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14836. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14837. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14838. * @returns the current mesh
  14839. */
  14840. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14841. private _syncAbsoluteScalingAndRotation;
  14842. }
  14843. }
  14844. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14845. import { Observable } from "babylonjs/Misc/observable";
  14846. import { Nullable } from "babylonjs/types";
  14847. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14848. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14849. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14850. import { Ray } from "babylonjs/Culling/ray";
  14851. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14852. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14853. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14854. /**
  14855. * Defines the types of pose enabled controllers that are supported
  14856. */
  14857. export enum PoseEnabledControllerType {
  14858. /**
  14859. * HTC Vive
  14860. */
  14861. VIVE = 0,
  14862. /**
  14863. * Oculus Rift
  14864. */
  14865. OCULUS = 1,
  14866. /**
  14867. * Windows mixed reality
  14868. */
  14869. WINDOWS = 2,
  14870. /**
  14871. * Samsung gear VR
  14872. */
  14873. GEAR_VR = 3,
  14874. /**
  14875. * Google Daydream
  14876. */
  14877. DAYDREAM = 4,
  14878. /**
  14879. * Generic
  14880. */
  14881. GENERIC = 5
  14882. }
  14883. /**
  14884. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14885. */
  14886. export interface MutableGamepadButton {
  14887. /**
  14888. * Value of the button/trigger
  14889. */
  14890. value: number;
  14891. /**
  14892. * If the button/trigger is currently touched
  14893. */
  14894. touched: boolean;
  14895. /**
  14896. * If the button/trigger is currently pressed
  14897. */
  14898. pressed: boolean;
  14899. }
  14900. /**
  14901. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14902. * @hidden
  14903. */
  14904. export interface ExtendedGamepadButton extends GamepadButton {
  14905. /**
  14906. * If the button/trigger is currently pressed
  14907. */
  14908. readonly pressed: boolean;
  14909. /**
  14910. * If the button/trigger is currently touched
  14911. */
  14912. readonly touched: boolean;
  14913. /**
  14914. * Value of the button/trigger
  14915. */
  14916. readonly value: number;
  14917. }
  14918. /** @hidden */
  14919. export interface _GamePadFactory {
  14920. /**
  14921. * Returns wether or not the current gamepad can be created for this type of controller.
  14922. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14923. * @returns true if it can be created, otherwise false
  14924. */
  14925. canCreate(gamepadInfo: any): boolean;
  14926. /**
  14927. * Creates a new instance of the Gamepad.
  14928. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14929. * @returns the new gamepad instance
  14930. */
  14931. create(gamepadInfo: any): Gamepad;
  14932. }
  14933. /**
  14934. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14935. */
  14936. export class PoseEnabledControllerHelper {
  14937. /** @hidden */
  14938. static _ControllerFactories: _GamePadFactory[];
  14939. /** @hidden */
  14940. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14941. /**
  14942. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14943. * @param vrGamepad the gamepad to initialized
  14944. * @returns a vr controller of the type the gamepad identified as
  14945. */
  14946. static InitiateController(vrGamepad: any): Gamepad;
  14947. }
  14948. /**
  14949. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14950. */
  14951. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14952. /**
  14953. * If the controller is used in a webXR session
  14954. */
  14955. isXR: boolean;
  14956. private _deviceRoomPosition;
  14957. private _deviceRoomRotationQuaternion;
  14958. /**
  14959. * The device position in babylon space
  14960. */
  14961. devicePosition: Vector3;
  14962. /**
  14963. * The device rotation in babylon space
  14964. */
  14965. deviceRotationQuaternion: Quaternion;
  14966. /**
  14967. * The scale factor of the device in babylon space
  14968. */
  14969. deviceScaleFactor: number;
  14970. /**
  14971. * (Likely devicePosition should be used instead) The device position in its room space
  14972. */
  14973. position: Vector3;
  14974. /**
  14975. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14976. */
  14977. rotationQuaternion: Quaternion;
  14978. /**
  14979. * The type of controller (Eg. Windows mixed reality)
  14980. */
  14981. controllerType: PoseEnabledControllerType;
  14982. protected _calculatedPosition: Vector3;
  14983. private _calculatedRotation;
  14984. /**
  14985. * The raw pose from the device
  14986. */
  14987. rawPose: DevicePose;
  14988. private _trackPosition;
  14989. private _maxRotationDistFromHeadset;
  14990. private _draggedRoomRotation;
  14991. /**
  14992. * @hidden
  14993. */
  14994. _disableTrackPosition(fixedPosition: Vector3): void;
  14995. /**
  14996. * Internal, the mesh attached to the controller
  14997. * @hidden
  14998. */
  14999. _mesh: Nullable<AbstractMesh>;
  15000. private _poseControlledCamera;
  15001. private _leftHandSystemQuaternion;
  15002. /**
  15003. * Internal, matrix used to convert room space to babylon space
  15004. * @hidden
  15005. */
  15006. _deviceToWorld: Matrix;
  15007. /**
  15008. * Node to be used when casting a ray from the controller
  15009. * @hidden
  15010. */
  15011. _pointingPoseNode: Nullable<TransformNode>;
  15012. /**
  15013. * Name of the child mesh that can be used to cast a ray from the controller
  15014. */
  15015. static readonly POINTING_POSE: string;
  15016. /**
  15017. * Creates a new PoseEnabledController from a gamepad
  15018. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  15019. */
  15020. constructor(browserGamepad: any);
  15021. private _workingMatrix;
  15022. /**
  15023. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  15024. */
  15025. update(): void;
  15026. /**
  15027. * Updates only the pose device and mesh without doing any button event checking
  15028. */
  15029. protected _updatePoseAndMesh(): void;
  15030. /**
  15031. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  15032. * @param poseData raw pose fromthe device
  15033. */
  15034. updateFromDevice(poseData: DevicePose): void;
  15035. /**
  15036. * @hidden
  15037. */
  15038. _meshAttachedObservable: Observable<AbstractMesh>;
  15039. /**
  15040. * Attaches a mesh to the controller
  15041. * @param mesh the mesh to be attached
  15042. */
  15043. attachToMesh(mesh: AbstractMesh): void;
  15044. /**
  15045. * Attaches the controllers mesh to a camera
  15046. * @param camera the camera the mesh should be attached to
  15047. */
  15048. attachToPoseControlledCamera(camera: TargetCamera): void;
  15049. /**
  15050. * Disposes of the controller
  15051. */
  15052. dispose(): void;
  15053. /**
  15054. * The mesh that is attached to the controller
  15055. */
  15056. get mesh(): Nullable<AbstractMesh>;
  15057. /**
  15058. * Gets the ray of the controller in the direction the controller is pointing
  15059. * @param length the length the resulting ray should be
  15060. * @returns a ray in the direction the controller is pointing
  15061. */
  15062. getForwardRay(length?: number): Ray;
  15063. }
  15064. }
  15065. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  15066. import { Observable } from "babylonjs/Misc/observable";
  15067. import { Scene } from "babylonjs/scene";
  15068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15069. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  15070. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  15071. import { Nullable } from "babylonjs/types";
  15072. /**
  15073. * Defines the WebVRController object that represents controllers tracked in 3D space
  15074. */
  15075. export abstract class WebVRController extends PoseEnabledController {
  15076. /**
  15077. * Internal, the default controller model for the controller
  15078. */
  15079. protected _defaultModel: Nullable<AbstractMesh>;
  15080. /**
  15081. * Fired when the trigger state has changed
  15082. */
  15083. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  15084. /**
  15085. * Fired when the main button state has changed
  15086. */
  15087. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  15088. /**
  15089. * Fired when the secondary button state has changed
  15090. */
  15091. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  15092. /**
  15093. * Fired when the pad state has changed
  15094. */
  15095. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  15096. /**
  15097. * Fired when controllers stick values have changed
  15098. */
  15099. onPadValuesChangedObservable: Observable<StickValues>;
  15100. /**
  15101. * Array of button availible on the controller
  15102. */
  15103. protected _buttons: Array<MutableGamepadButton>;
  15104. private _onButtonStateChange;
  15105. /**
  15106. * Fired when a controller button's state has changed
  15107. * @param callback the callback containing the button that was modified
  15108. */
  15109. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  15110. /**
  15111. * X and Y axis corresponding to the controllers joystick
  15112. */
  15113. pad: StickValues;
  15114. /**
  15115. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  15116. */
  15117. hand: string;
  15118. /**
  15119. * The default controller model for the controller
  15120. */
  15121. get defaultModel(): Nullable<AbstractMesh>;
  15122. /**
  15123. * Creates a new WebVRController from a gamepad
  15124. * @param vrGamepad the gamepad that the WebVRController should be created from
  15125. */
  15126. constructor(vrGamepad: any);
  15127. /**
  15128. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  15129. */
  15130. update(): void;
  15131. /**
  15132. * Function to be called when a button is modified
  15133. */
  15134. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  15135. /**
  15136. * Loads a mesh and attaches it to the controller
  15137. * @param scene the scene the mesh should be added to
  15138. * @param meshLoaded callback for when the mesh has been loaded
  15139. */
  15140. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  15141. private _setButtonValue;
  15142. private _changes;
  15143. private _checkChanges;
  15144. /**
  15145. * Disposes of th webVRCOntroller
  15146. */
  15147. dispose(): void;
  15148. }
  15149. }
  15150. declare module "babylonjs/Lights/hemisphericLight" {
  15151. import { Nullable } from "babylonjs/types";
  15152. import { Scene } from "babylonjs/scene";
  15153. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15154. import { Color3 } from "babylonjs/Maths/math.color";
  15155. import { Effect } from "babylonjs/Materials/effect";
  15156. import { Light } from "babylonjs/Lights/light";
  15157. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  15158. /**
  15159. * The HemisphericLight simulates the ambient environment light,
  15160. * so the passed direction is the light reflection direction, not the incoming direction.
  15161. */
  15162. export class HemisphericLight extends Light {
  15163. /**
  15164. * The groundColor is the light in the opposite direction to the one specified during creation.
  15165. * 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.
  15166. */
  15167. groundColor: Color3;
  15168. /**
  15169. * The light reflection direction, not the incoming direction.
  15170. */
  15171. direction: Vector3;
  15172. /**
  15173. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15174. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15175. * The HemisphericLight can't cast shadows.
  15176. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15177. * @param name The friendly name of the light
  15178. * @param direction The direction of the light reflection
  15179. * @param scene The scene the light belongs to
  15180. */
  15181. constructor(name: string, direction: Vector3, scene: Scene);
  15182. protected _buildUniformLayout(): void;
  15183. /**
  15184. * Returns the string "HemisphericLight".
  15185. * @return The class name
  15186. */
  15187. getClassName(): string;
  15188. /**
  15189. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15190. * Returns the updated direction.
  15191. * @param target The target the direction should point to
  15192. * @return The computed direction
  15193. */
  15194. setDirectionToTarget(target: Vector3): Vector3;
  15195. /**
  15196. * Returns the shadow generator associated to the light.
  15197. * @returns Always null for hemispheric lights because it does not support shadows.
  15198. */
  15199. getShadowGenerator(): Nullable<IShadowGenerator>;
  15200. /**
  15201. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15202. * @param effect The effect to update
  15203. * @param lightIndex The index of the light in the effect to update
  15204. * @returns The hemispheric light
  15205. */
  15206. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15207. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  15208. /**
  15209. * Computes the world matrix of the node
  15210. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15211. * @param useWasUpdatedFlag defines a reserved property
  15212. * @returns the world matrix
  15213. */
  15214. computeWorldMatrix(): Matrix;
  15215. /**
  15216. * Returns the integer 3.
  15217. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15218. */
  15219. getTypeID(): number;
  15220. /**
  15221. * Prepares the list of defines specific to the light type.
  15222. * @param defines the list of defines
  15223. * @param lightIndex defines the index of the light for the effect
  15224. */
  15225. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15226. }
  15227. }
  15228. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  15229. /** @hidden */
  15230. export var vrMultiviewToSingleviewPixelShader: {
  15231. name: string;
  15232. shader: string;
  15233. };
  15234. }
  15235. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15236. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15237. import { Scene } from "babylonjs/scene";
  15238. /**
  15239. * Renders to multiple views with a single draw call
  15240. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15241. */
  15242. export class MultiviewRenderTarget extends RenderTargetTexture {
  15243. /**
  15244. * Creates a multiview render target
  15245. * @param scene scene used with the render target
  15246. * @param size the size of the render target (used for each view)
  15247. */
  15248. constructor(scene: Scene, size?: number | {
  15249. width: number;
  15250. height: number;
  15251. } | {
  15252. ratio: number;
  15253. });
  15254. /**
  15255. * @hidden
  15256. * @param faceIndex the face index, if its a cube texture
  15257. */
  15258. _bindFrameBuffer(faceIndex?: number): void;
  15259. /**
  15260. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15261. * @returns the view count
  15262. */
  15263. getViewCount(): number;
  15264. }
  15265. }
  15266. declare module "babylonjs/Maths/math.frustum" {
  15267. import { Matrix } from "babylonjs/Maths/math.vector";
  15268. import { DeepImmutable } from "babylonjs/types";
  15269. import { Plane } from "babylonjs/Maths/math.plane";
  15270. /**
  15271. * Represents a camera frustum
  15272. */
  15273. export class Frustum {
  15274. /**
  15275. * Gets the planes representing the frustum
  15276. * @param transform matrix to be applied to the returned planes
  15277. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15278. */
  15279. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15280. /**
  15281. * Gets the near frustum plane transformed by the transform matrix
  15282. * @param transform transformation matrix to be applied to the resulting frustum plane
  15283. * @param frustumPlane the resuling frustum plane
  15284. */
  15285. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15286. /**
  15287. * Gets the far frustum plane transformed by the transform matrix
  15288. * @param transform transformation matrix to be applied to the resulting frustum plane
  15289. * @param frustumPlane the resuling frustum plane
  15290. */
  15291. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15292. /**
  15293. * Gets the left frustum plane transformed by the transform matrix
  15294. * @param transform transformation matrix to be applied to the resulting frustum plane
  15295. * @param frustumPlane the resuling frustum plane
  15296. */
  15297. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15298. /**
  15299. * Gets the right frustum plane transformed by the transform matrix
  15300. * @param transform transformation matrix to be applied to the resulting frustum plane
  15301. * @param frustumPlane the resuling frustum plane
  15302. */
  15303. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15304. /**
  15305. * Gets the top frustum plane transformed by the transform matrix
  15306. * @param transform transformation matrix to be applied to the resulting frustum plane
  15307. * @param frustumPlane the resuling frustum plane
  15308. */
  15309. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15310. /**
  15311. * Gets the bottom frustum plane transformed by the transform matrix
  15312. * @param transform transformation matrix to be applied to the resulting frustum plane
  15313. * @param frustumPlane the resuling frustum plane
  15314. */
  15315. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15316. /**
  15317. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15318. * @param transform transformation matrix to be applied to the resulting frustum planes
  15319. * @param frustumPlanes the resuling frustum planes
  15320. */
  15321. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15322. }
  15323. }
  15324. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15325. import { Camera } from "babylonjs/Cameras/camera";
  15326. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15327. import { Nullable } from "babylonjs/types";
  15328. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15329. import { Matrix } from "babylonjs/Maths/math.vector";
  15330. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15331. module "babylonjs/Engines/engine" {
  15332. interface Engine {
  15333. /**
  15334. * Creates a new multiview render target
  15335. * @param width defines the width of the texture
  15336. * @param height defines the height of the texture
  15337. * @returns the created multiview texture
  15338. */
  15339. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15340. /**
  15341. * Binds a multiview framebuffer to be drawn to
  15342. * @param multiviewTexture texture to bind
  15343. */
  15344. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15345. }
  15346. }
  15347. module "babylonjs/Cameras/camera" {
  15348. interface Camera {
  15349. /**
  15350. * @hidden
  15351. * 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)
  15352. */
  15353. _useMultiviewToSingleView: boolean;
  15354. /**
  15355. * @hidden
  15356. * 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)
  15357. */
  15358. _multiviewTexture: Nullable<RenderTargetTexture>;
  15359. /**
  15360. * @hidden
  15361. * ensures the multiview texture of the camera exists and has the specified width/height
  15362. * @param width height to set on the multiview texture
  15363. * @param height width to set on the multiview texture
  15364. */
  15365. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15366. }
  15367. }
  15368. module "babylonjs/scene" {
  15369. interface Scene {
  15370. /** @hidden */
  15371. _transformMatrixR: Matrix;
  15372. /** @hidden */
  15373. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15374. /** @hidden */
  15375. _createMultiviewUbo(): void;
  15376. /** @hidden */
  15377. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15378. /** @hidden */
  15379. _renderMultiviewToSingleView(camera: Camera): void;
  15380. }
  15381. }
  15382. }
  15383. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15384. import { Camera } from "babylonjs/Cameras/camera";
  15385. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15386. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15387. import "babylonjs/Engines/Extensions/engine.multiview";
  15388. /**
  15389. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15390. * This will not be used for webXR as it supports displaying texture arrays directly
  15391. */
  15392. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15393. /**
  15394. * Initializes a VRMultiviewToSingleview
  15395. * @param name name of the post process
  15396. * @param camera camera to be applied to
  15397. * @param scaleFactor scaling factor to the size of the output texture
  15398. */
  15399. constructor(name: string, camera: Camera, scaleFactor: number);
  15400. }
  15401. }
  15402. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15403. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15404. import { Nullable } from "babylonjs/types";
  15405. import { Size } from "babylonjs/Maths/math.size";
  15406. import { Observable } from "babylonjs/Misc/observable";
  15407. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  15408. /**
  15409. * Interface used to define additional presentation attributes
  15410. */
  15411. export interface IVRPresentationAttributes {
  15412. /**
  15413. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15414. */
  15415. highRefreshRate: boolean;
  15416. /**
  15417. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15418. */
  15419. foveationLevel: number;
  15420. }
  15421. module "babylonjs/Engines/engine" {
  15422. interface Engine {
  15423. /** @hidden */
  15424. _vrDisplay: any;
  15425. /** @hidden */
  15426. _vrSupported: boolean;
  15427. /** @hidden */
  15428. _oldSize: Size;
  15429. /** @hidden */
  15430. _oldHardwareScaleFactor: number;
  15431. /** @hidden */
  15432. _vrExclusivePointerMode: boolean;
  15433. /** @hidden */
  15434. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15435. /** @hidden */
  15436. _onVRDisplayPointerRestricted: () => void;
  15437. /** @hidden */
  15438. _onVRDisplayPointerUnrestricted: () => void;
  15439. /** @hidden */
  15440. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15441. /** @hidden */
  15442. _onVrDisplayDisconnect: Nullable<() => void>;
  15443. /** @hidden */
  15444. _onVrDisplayPresentChange: Nullable<() => void>;
  15445. /**
  15446. * Observable signaled when VR display mode changes
  15447. */
  15448. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15449. /**
  15450. * Observable signaled when VR request present is complete
  15451. */
  15452. onVRRequestPresentComplete: Observable<boolean>;
  15453. /**
  15454. * Observable signaled when VR request present starts
  15455. */
  15456. onVRRequestPresentStart: Observable<Engine>;
  15457. /**
  15458. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15459. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15460. */
  15461. isInVRExclusivePointerMode: boolean;
  15462. /**
  15463. * Gets a boolean indicating if a webVR device was detected
  15464. * @returns true if a webVR device was detected
  15465. */
  15466. isVRDevicePresent(): boolean;
  15467. /**
  15468. * Gets the current webVR device
  15469. * @returns the current webVR device (or null)
  15470. */
  15471. getVRDevice(): any;
  15472. /**
  15473. * Initializes a webVR display and starts listening to display change events
  15474. * The onVRDisplayChangedObservable will be notified upon these changes
  15475. * @returns A promise containing a VRDisplay and if vr is supported
  15476. */
  15477. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15478. /** @hidden */
  15479. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15480. /**
  15481. * Gets or sets the presentation attributes used to configure VR rendering
  15482. */
  15483. vrPresentationAttributes?: IVRPresentationAttributes;
  15484. /**
  15485. * Call this function to switch to webVR mode
  15486. * Will do nothing if webVR is not supported or if there is no webVR device
  15487. * @param options the webvr options provided to the camera. mainly used for multiview
  15488. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15489. */
  15490. enableVR(options: WebVROptions): void;
  15491. /** @hidden */
  15492. _onVRFullScreenTriggered(): void;
  15493. }
  15494. }
  15495. }
  15496. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15497. import { Nullable } from "babylonjs/types";
  15498. import { Observable } from "babylonjs/Misc/observable";
  15499. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15500. import { Scene } from "babylonjs/scene";
  15501. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15502. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15503. import { Node } from "babylonjs/node";
  15504. import { Ray } from "babylonjs/Culling/ray";
  15505. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15506. import "babylonjs/Engines/Extensions/engine.webVR";
  15507. /**
  15508. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15509. * IMPORTANT!! The data is right-hand data.
  15510. * @export
  15511. * @interface DevicePose
  15512. */
  15513. export interface DevicePose {
  15514. /**
  15515. * The position of the device, values in array are [x,y,z].
  15516. */
  15517. readonly position: Nullable<Float32Array>;
  15518. /**
  15519. * The linearVelocity of the device, values in array are [x,y,z].
  15520. */
  15521. readonly linearVelocity: Nullable<Float32Array>;
  15522. /**
  15523. * The linearAcceleration of the device, values in array are [x,y,z].
  15524. */
  15525. readonly linearAcceleration: Nullable<Float32Array>;
  15526. /**
  15527. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15528. */
  15529. readonly orientation: Nullable<Float32Array>;
  15530. /**
  15531. * The angularVelocity of the device, values in array are [x,y,z].
  15532. */
  15533. readonly angularVelocity: Nullable<Float32Array>;
  15534. /**
  15535. * The angularAcceleration of the device, values in array are [x,y,z].
  15536. */
  15537. readonly angularAcceleration: Nullable<Float32Array>;
  15538. }
  15539. /**
  15540. * Interface representing a pose controlled object in Babylon.
  15541. * A pose controlled object has both regular pose values as well as pose values
  15542. * from an external device such as a VR head mounted display
  15543. */
  15544. export interface PoseControlled {
  15545. /**
  15546. * The position of the object in babylon space.
  15547. */
  15548. position: Vector3;
  15549. /**
  15550. * The rotation quaternion of the object in babylon space.
  15551. */
  15552. rotationQuaternion: Quaternion;
  15553. /**
  15554. * The position of the device in babylon space.
  15555. */
  15556. devicePosition?: Vector3;
  15557. /**
  15558. * The rotation quaternion of the device in babylon space.
  15559. */
  15560. deviceRotationQuaternion: Quaternion;
  15561. /**
  15562. * The raw pose coming from the device.
  15563. */
  15564. rawPose: Nullable<DevicePose>;
  15565. /**
  15566. * The scale of the device to be used when translating from device space to babylon space.
  15567. */
  15568. deviceScaleFactor: number;
  15569. /**
  15570. * Updates the poseControlled values based on the input device pose.
  15571. * @param poseData the pose data to update the object with
  15572. */
  15573. updateFromDevice(poseData: DevicePose): void;
  15574. }
  15575. /**
  15576. * Set of options to customize the webVRCamera
  15577. */
  15578. export interface WebVROptions {
  15579. /**
  15580. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15581. */
  15582. trackPosition?: boolean;
  15583. /**
  15584. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15585. */
  15586. positionScale?: number;
  15587. /**
  15588. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15589. */
  15590. displayName?: string;
  15591. /**
  15592. * Should the native controller meshes be initialized. (default: true)
  15593. */
  15594. controllerMeshes?: boolean;
  15595. /**
  15596. * Creating a default HemiLight only on controllers. (default: true)
  15597. */
  15598. defaultLightingOnControllers?: boolean;
  15599. /**
  15600. * If you don't want to use the default VR button of the helper. (default: false)
  15601. */
  15602. useCustomVRButton?: boolean;
  15603. /**
  15604. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15605. */
  15606. customVRButton?: HTMLButtonElement;
  15607. /**
  15608. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15609. */
  15610. rayLength?: number;
  15611. /**
  15612. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15613. */
  15614. defaultHeight?: number;
  15615. /**
  15616. * If multiview should be used if availible (default: false)
  15617. */
  15618. useMultiview?: boolean;
  15619. }
  15620. /**
  15621. * This represents a WebVR camera.
  15622. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15623. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15624. */
  15625. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15626. private webVROptions;
  15627. /**
  15628. * @hidden
  15629. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15630. */
  15631. _vrDevice: any;
  15632. /**
  15633. * The rawPose of the vrDevice.
  15634. */
  15635. rawPose: Nullable<DevicePose>;
  15636. private _onVREnabled;
  15637. private _specsVersion;
  15638. private _attached;
  15639. private _frameData;
  15640. protected _descendants: Array<Node>;
  15641. private _deviceRoomPosition;
  15642. /** @hidden */
  15643. _deviceRoomRotationQuaternion: Quaternion;
  15644. private _standingMatrix;
  15645. /**
  15646. * Represents device position in babylon space.
  15647. */
  15648. devicePosition: Vector3;
  15649. /**
  15650. * Represents device rotation in babylon space.
  15651. */
  15652. deviceRotationQuaternion: Quaternion;
  15653. /**
  15654. * The scale of the device to be used when translating from device space to babylon space.
  15655. */
  15656. deviceScaleFactor: number;
  15657. private _deviceToWorld;
  15658. private _worldToDevice;
  15659. /**
  15660. * References to the webVR controllers for the vrDevice.
  15661. */
  15662. controllers: Array<WebVRController>;
  15663. /**
  15664. * Emits an event when a controller is attached.
  15665. */
  15666. onControllersAttachedObservable: Observable<WebVRController[]>;
  15667. /**
  15668. * Emits an event when a controller's mesh has been loaded;
  15669. */
  15670. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15671. /**
  15672. * Emits an event when the HMD's pose has been updated.
  15673. */
  15674. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15675. private _poseSet;
  15676. /**
  15677. * If the rig cameras be used as parent instead of this camera.
  15678. */
  15679. rigParenting: boolean;
  15680. private _lightOnControllers;
  15681. private _defaultHeight?;
  15682. /**
  15683. * Instantiates a WebVRFreeCamera.
  15684. * @param name The name of the WebVRFreeCamera
  15685. * @param position The starting anchor position for the camera
  15686. * @param scene The scene the camera belongs to
  15687. * @param webVROptions a set of customizable options for the webVRCamera
  15688. */
  15689. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15690. /**
  15691. * Gets the device distance from the ground in meters.
  15692. * @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.
  15693. */
  15694. deviceDistanceToRoomGround(): number;
  15695. /**
  15696. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15697. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15698. */
  15699. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15700. /**
  15701. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15702. * @returns A promise with a boolean set to if the standing matrix is supported.
  15703. */
  15704. useStandingMatrixAsync(): Promise<boolean>;
  15705. /**
  15706. * Disposes the camera
  15707. */
  15708. dispose(): void;
  15709. /**
  15710. * Gets a vrController by name.
  15711. * @param name The name of the controller to retreive
  15712. * @returns the controller matching the name specified or null if not found
  15713. */
  15714. getControllerByName(name: string): Nullable<WebVRController>;
  15715. private _leftController;
  15716. /**
  15717. * The controller corresponding to the users left hand.
  15718. */
  15719. get leftController(): Nullable<WebVRController>;
  15720. private _rightController;
  15721. /**
  15722. * The controller corresponding to the users right hand.
  15723. */
  15724. get rightController(): Nullable<WebVRController>;
  15725. /**
  15726. * Casts a ray forward from the vrCamera's gaze.
  15727. * @param length Length of the ray (default: 100)
  15728. * @returns the ray corresponding to the gaze
  15729. */
  15730. getForwardRay(length?: number): Ray;
  15731. /**
  15732. * @hidden
  15733. * Updates the camera based on device's frame data
  15734. */
  15735. _checkInputs(): void;
  15736. /**
  15737. * Updates the poseControlled values based on the input device pose.
  15738. * @param poseData Pose coming from the device
  15739. */
  15740. updateFromDevice(poseData: DevicePose): void;
  15741. private _htmlElementAttached;
  15742. private _detachIfAttached;
  15743. /**
  15744. * WebVR's attach control will start broadcasting frames to the device.
  15745. * Note that in certain browsers (chrome for example) this function must be called
  15746. * within a user-interaction callback. Example:
  15747. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15748. *
  15749. * @param element html element to attach the vrDevice to
  15750. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15751. */
  15752. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15753. /**
  15754. * Detaches the camera from the html element and disables VR
  15755. *
  15756. * @param element html element to detach from
  15757. */
  15758. detachControl(element: HTMLElement): void;
  15759. /**
  15760. * @returns the name of this class
  15761. */
  15762. getClassName(): string;
  15763. /**
  15764. * Calls resetPose on the vrDisplay
  15765. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15766. */
  15767. resetToCurrentRotation(): void;
  15768. /**
  15769. * @hidden
  15770. * Updates the rig cameras (left and right eye)
  15771. */
  15772. _updateRigCameras(): void;
  15773. private _workingVector;
  15774. private _oneVector;
  15775. private _workingMatrix;
  15776. private updateCacheCalled;
  15777. private _correctPositionIfNotTrackPosition;
  15778. /**
  15779. * @hidden
  15780. * Updates the cached values of the camera
  15781. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15782. */
  15783. _updateCache(ignoreParentClass?: boolean): void;
  15784. /**
  15785. * @hidden
  15786. * Get current device position in babylon world
  15787. */
  15788. _computeDevicePosition(): void;
  15789. /**
  15790. * Updates the current device position and rotation in the babylon world
  15791. */
  15792. update(): void;
  15793. /**
  15794. * @hidden
  15795. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15796. * @returns an identity matrix
  15797. */
  15798. _getViewMatrix(): Matrix;
  15799. private _tmpMatrix;
  15800. /**
  15801. * This function is called by the two RIG cameras.
  15802. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15803. * @hidden
  15804. */
  15805. _getWebVRViewMatrix(): Matrix;
  15806. /** @hidden */
  15807. _getWebVRProjectionMatrix(): Matrix;
  15808. private _onGamepadConnectedObserver;
  15809. private _onGamepadDisconnectedObserver;
  15810. private _updateCacheWhenTrackingDisabledObserver;
  15811. /**
  15812. * Initializes the controllers and their meshes
  15813. */
  15814. initControllers(): void;
  15815. }
  15816. }
  15817. declare module "babylonjs/PostProcesses/postProcess" {
  15818. import { Nullable } from "babylonjs/types";
  15819. import { SmartArray } from "babylonjs/Misc/smartArray";
  15820. import { Observable } from "babylonjs/Misc/observable";
  15821. import { Vector2 } from "babylonjs/Maths/math.vector";
  15822. import { Camera } from "babylonjs/Cameras/camera";
  15823. import { Effect } from "babylonjs/Materials/effect";
  15824. import "babylonjs/Shaders/postprocess.vertex";
  15825. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15826. import { Engine } from "babylonjs/Engines/engine";
  15827. import { Color4 } from "babylonjs/Maths/math.color";
  15828. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15829. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15830. /**
  15831. * Size options for a post process
  15832. */
  15833. export type PostProcessOptions = {
  15834. width: number;
  15835. height: number;
  15836. };
  15837. /**
  15838. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15839. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15840. */
  15841. export class PostProcess {
  15842. /** Name of the PostProcess. */
  15843. name: string;
  15844. /**
  15845. * Gets or sets the unique id of the post process
  15846. */
  15847. uniqueId: number;
  15848. /**
  15849. * Width of the texture to apply the post process on
  15850. */
  15851. width: number;
  15852. /**
  15853. * Height of the texture to apply the post process on
  15854. */
  15855. height: number;
  15856. /**
  15857. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15858. * @hidden
  15859. */
  15860. _outputTexture: Nullable<InternalTexture>;
  15861. /**
  15862. * Sampling mode used by the shader
  15863. * See https://doc.babylonjs.com/classes/3.1/texture
  15864. */
  15865. renderTargetSamplingMode: number;
  15866. /**
  15867. * Clear color to use when screen clearing
  15868. */
  15869. clearColor: Color4;
  15870. /**
  15871. * If the buffer needs to be cleared before applying the post process. (default: true)
  15872. * Should be set to false if shader will overwrite all previous pixels.
  15873. */
  15874. autoClear: boolean;
  15875. /**
  15876. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15877. */
  15878. alphaMode: number;
  15879. /**
  15880. * Sets the setAlphaBlendConstants of the babylon engine
  15881. */
  15882. alphaConstants: Color4;
  15883. /**
  15884. * Animations to be used for the post processing
  15885. */
  15886. animations: import("babylonjs/Animations/animation").Animation[];
  15887. /**
  15888. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15889. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15890. */
  15891. enablePixelPerfectMode: boolean;
  15892. /**
  15893. * Force the postprocess to be applied without taking in account viewport
  15894. */
  15895. forceFullscreenViewport: boolean;
  15896. /**
  15897. * List of inspectable custom properties (used by the Inspector)
  15898. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15899. */
  15900. inspectableCustomProperties: IInspectable[];
  15901. /**
  15902. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15903. *
  15904. * | Value | Type | Description |
  15905. * | ----- | ----------------------------------- | ----------- |
  15906. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15907. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15908. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15909. *
  15910. */
  15911. scaleMode: number;
  15912. /**
  15913. * Force textures to be a power of two (default: false)
  15914. */
  15915. alwaysForcePOT: boolean;
  15916. private _samples;
  15917. /**
  15918. * Number of sample textures (default: 1)
  15919. */
  15920. get samples(): number;
  15921. set samples(n: number);
  15922. /**
  15923. * Modify the scale of the post process to be the same as the viewport (default: false)
  15924. */
  15925. adaptScaleToCurrentViewport: boolean;
  15926. private _camera;
  15927. private _scene;
  15928. private _engine;
  15929. private _options;
  15930. private _reusable;
  15931. private _textureType;
  15932. /**
  15933. * Smart array of input and output textures for the post process.
  15934. * @hidden
  15935. */
  15936. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15937. /**
  15938. * The index in _textures that corresponds to the output texture.
  15939. * @hidden
  15940. */
  15941. _currentRenderTextureInd: number;
  15942. private _effect;
  15943. private _samplers;
  15944. private _fragmentUrl;
  15945. private _vertexUrl;
  15946. private _parameters;
  15947. private _scaleRatio;
  15948. protected _indexParameters: any;
  15949. private _shareOutputWithPostProcess;
  15950. private _texelSize;
  15951. private _forcedOutputTexture;
  15952. /**
  15953. * Returns the fragment url or shader name used in the post process.
  15954. * @returns the fragment url or name in the shader store.
  15955. */
  15956. getEffectName(): string;
  15957. /**
  15958. * An event triggered when the postprocess is activated.
  15959. */
  15960. onActivateObservable: Observable<Camera>;
  15961. private _onActivateObserver;
  15962. /**
  15963. * A function that is added to the onActivateObservable
  15964. */
  15965. set onActivate(callback: Nullable<(camera: Camera) => void>);
  15966. /**
  15967. * An event triggered when the postprocess changes its size.
  15968. */
  15969. onSizeChangedObservable: Observable<PostProcess>;
  15970. private _onSizeChangedObserver;
  15971. /**
  15972. * A function that is added to the onSizeChangedObservable
  15973. */
  15974. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  15975. /**
  15976. * An event triggered when the postprocess applies its effect.
  15977. */
  15978. onApplyObservable: Observable<Effect>;
  15979. private _onApplyObserver;
  15980. /**
  15981. * A function that is added to the onApplyObservable
  15982. */
  15983. set onApply(callback: (effect: Effect) => void);
  15984. /**
  15985. * An event triggered before rendering the postprocess
  15986. */
  15987. onBeforeRenderObservable: Observable<Effect>;
  15988. private _onBeforeRenderObserver;
  15989. /**
  15990. * A function that is added to the onBeforeRenderObservable
  15991. */
  15992. set onBeforeRender(callback: (effect: Effect) => void);
  15993. /**
  15994. * An event triggered after rendering the postprocess
  15995. */
  15996. onAfterRenderObservable: Observable<Effect>;
  15997. private _onAfterRenderObserver;
  15998. /**
  15999. * A function that is added to the onAfterRenderObservable
  16000. */
  16001. set onAfterRender(callback: (efect: Effect) => void);
  16002. /**
  16003. * 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
  16004. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  16005. */
  16006. get inputTexture(): InternalTexture;
  16007. set inputTexture(value: InternalTexture);
  16008. /**
  16009. * Gets the camera which post process is applied to.
  16010. * @returns The camera the post process is applied to.
  16011. */
  16012. getCamera(): Camera;
  16013. /**
  16014. * Gets the texel size of the postprocess.
  16015. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  16016. */
  16017. get texelSize(): Vector2;
  16018. /**
  16019. * Creates a new instance PostProcess
  16020. * @param name The name of the PostProcess.
  16021. * @param fragmentUrl The url of the fragment shader to be used.
  16022. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  16023. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  16024. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16025. * @param camera The camera to apply the render pass to.
  16026. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16027. * @param engine The engine which the post process will be applied. (default: current engine)
  16028. * @param reusable If the post process can be reused on the same frame. (default: false)
  16029. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  16030. * @param textureType Type of textures used when performing the post process. (default: 0)
  16031. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  16032. * @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
  16033. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  16034. */
  16035. constructor(
  16036. /** Name of the PostProcess. */
  16037. 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);
  16038. /**
  16039. * Gets a string idenfifying the name of the class
  16040. * @returns "PostProcess" string
  16041. */
  16042. getClassName(): string;
  16043. /**
  16044. * Gets the engine which this post process belongs to.
  16045. * @returns The engine the post process was enabled with.
  16046. */
  16047. getEngine(): Engine;
  16048. /**
  16049. * The effect that is created when initializing the post process.
  16050. * @returns The created effect corresponding the the postprocess.
  16051. */
  16052. getEffect(): Effect;
  16053. /**
  16054. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  16055. * @param postProcess The post process to share the output with.
  16056. * @returns This post process.
  16057. */
  16058. shareOutputWith(postProcess: PostProcess): PostProcess;
  16059. /**
  16060. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  16061. * This should be called if the post process that shares output with this post process is disabled/disposed.
  16062. */
  16063. useOwnOutput(): void;
  16064. /**
  16065. * Updates the effect with the current post process compile time values and recompiles the shader.
  16066. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16067. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16068. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16069. * @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
  16070. * @param onCompiled Called when the shader has been compiled.
  16071. * @param onError Called if there is an error when compiling a shader.
  16072. */
  16073. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16074. /**
  16075. * The post process is reusable if it can be used multiple times within one frame.
  16076. * @returns If the post process is reusable
  16077. */
  16078. isReusable(): boolean;
  16079. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  16080. markTextureDirty(): void;
  16081. /**
  16082. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  16083. * 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.
  16084. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  16085. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  16086. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  16087. * @returns The target texture that was bound to be written to.
  16088. */
  16089. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  16090. /**
  16091. * If the post process is supported.
  16092. */
  16093. get isSupported(): boolean;
  16094. /**
  16095. * The aspect ratio of the output texture.
  16096. */
  16097. get aspectRatio(): number;
  16098. /**
  16099. * Get a value indicating if the post-process is ready to be used
  16100. * @returns true if the post-process is ready (shader is compiled)
  16101. */
  16102. isReady(): boolean;
  16103. /**
  16104. * Binds all textures and uniforms to the shader, this will be run on every pass.
  16105. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  16106. */
  16107. apply(): Nullable<Effect>;
  16108. private _disposeTextures;
  16109. /**
  16110. * Disposes the post process.
  16111. * @param camera The camera to dispose the post process on.
  16112. */
  16113. dispose(camera?: Camera): void;
  16114. }
  16115. }
  16116. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  16117. /** @hidden */
  16118. export var kernelBlurVaryingDeclaration: {
  16119. name: string;
  16120. shader: string;
  16121. };
  16122. }
  16123. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  16124. /** @hidden */
  16125. export var kernelBlurFragment: {
  16126. name: string;
  16127. shader: string;
  16128. };
  16129. }
  16130. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  16131. /** @hidden */
  16132. export var kernelBlurFragment2: {
  16133. name: string;
  16134. shader: string;
  16135. };
  16136. }
  16137. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  16138. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16139. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  16140. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  16141. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  16142. /** @hidden */
  16143. export var kernelBlurPixelShader: {
  16144. name: string;
  16145. shader: string;
  16146. };
  16147. }
  16148. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  16149. /** @hidden */
  16150. export var kernelBlurVertex: {
  16151. name: string;
  16152. shader: string;
  16153. };
  16154. }
  16155. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  16156. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16157. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  16158. /** @hidden */
  16159. export var kernelBlurVertexShader: {
  16160. name: string;
  16161. shader: string;
  16162. };
  16163. }
  16164. declare module "babylonjs/PostProcesses/blurPostProcess" {
  16165. import { Vector2 } from "babylonjs/Maths/math.vector";
  16166. import { Nullable } from "babylonjs/types";
  16167. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  16168. import { Camera } from "babylonjs/Cameras/camera";
  16169. import { Effect } from "babylonjs/Materials/effect";
  16170. import { Engine } from "babylonjs/Engines/engine";
  16171. import "babylonjs/Shaders/kernelBlur.fragment";
  16172. import "babylonjs/Shaders/kernelBlur.vertex";
  16173. /**
  16174. * The Blur Post Process which blurs an image based on a kernel and direction.
  16175. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  16176. */
  16177. export class BlurPostProcess extends PostProcess {
  16178. /** The direction in which to blur the image. */
  16179. direction: Vector2;
  16180. private blockCompilation;
  16181. protected _kernel: number;
  16182. protected _idealKernel: number;
  16183. protected _packedFloat: boolean;
  16184. private _staticDefines;
  16185. /**
  16186. * Sets the length in pixels of the blur sample region
  16187. */
  16188. set kernel(v: number);
  16189. /**
  16190. * Gets the length in pixels of the blur sample region
  16191. */
  16192. get kernel(): number;
  16193. /**
  16194. * Sets wether or not the blur needs to unpack/repack floats
  16195. */
  16196. set packedFloat(v: boolean);
  16197. /**
  16198. * Gets wether or not the blur is unpacking/repacking floats
  16199. */
  16200. get packedFloat(): boolean;
  16201. /**
  16202. * Creates a new instance BlurPostProcess
  16203. * @param name The name of the effect.
  16204. * @param direction The direction in which to blur the image.
  16205. * @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.
  16206. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16207. * @param camera The camera to apply the render pass to.
  16208. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16209. * @param engine The engine which the post process will be applied. (default: current engine)
  16210. * @param reusable If the post process can be reused on the same frame. (default: false)
  16211. * @param textureType Type of textures used when performing the post process. (default: 0)
  16212. * @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)
  16213. */
  16214. constructor(name: string,
  16215. /** The direction in which to blur the image. */
  16216. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  16217. /**
  16218. * Updates the effect with the current post process compile time values and recompiles the shader.
  16219. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16220. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16221. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16222. * @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
  16223. * @param onCompiled Called when the shader has been compiled.
  16224. * @param onError Called if there is an error when compiling a shader.
  16225. */
  16226. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16227. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16228. /**
  16229. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  16230. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  16231. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  16232. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  16233. * The gaps between physical kernels are compensated for in the weighting of the samples
  16234. * @param idealKernel Ideal blur kernel.
  16235. * @return Nearest best kernel.
  16236. */
  16237. protected _nearestBestKernel(idealKernel: number): number;
  16238. /**
  16239. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  16240. * @param x The point on the Gaussian distribution to sample.
  16241. * @return the value of the Gaussian function at x.
  16242. */
  16243. protected _gaussianWeight(x: number): number;
  16244. /**
  16245. * Generates a string that can be used as a floating point number in GLSL.
  16246. * @param x Value to print.
  16247. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  16248. * @return GLSL float string.
  16249. */
  16250. protected _glslFloat(x: number, decimalFigures?: number): string;
  16251. }
  16252. }
  16253. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16254. import { Scene } from "babylonjs/scene";
  16255. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16256. import { Plane } from "babylonjs/Maths/math.plane";
  16257. /**
  16258. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16259. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16260. * You can then easily use it as a reflectionTexture on a flat surface.
  16261. * In case the surface is not a plane, please consider relying on reflection probes.
  16262. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16263. */
  16264. export class MirrorTexture extends RenderTargetTexture {
  16265. private scene;
  16266. /**
  16267. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16268. * 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.
  16269. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16270. */
  16271. mirrorPlane: Plane;
  16272. /**
  16273. * Define the blur ratio used to blur the reflection if needed.
  16274. */
  16275. set blurRatio(value: number);
  16276. get blurRatio(): number;
  16277. /**
  16278. * Define the adaptive blur kernel used to blur the reflection if needed.
  16279. * This will autocompute the closest best match for the `blurKernel`
  16280. */
  16281. set adaptiveBlurKernel(value: number);
  16282. /**
  16283. * Define the blur kernel used to blur the reflection if needed.
  16284. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16285. */
  16286. set blurKernel(value: number);
  16287. /**
  16288. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16289. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16290. */
  16291. set blurKernelX(value: number);
  16292. get blurKernelX(): number;
  16293. /**
  16294. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16295. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16296. */
  16297. set blurKernelY(value: number);
  16298. get blurKernelY(): number;
  16299. private _autoComputeBlurKernel;
  16300. protected _onRatioRescale(): void;
  16301. private _updateGammaSpace;
  16302. private _imageProcessingConfigChangeObserver;
  16303. private _transformMatrix;
  16304. private _mirrorMatrix;
  16305. private _savedViewMatrix;
  16306. private _blurX;
  16307. private _blurY;
  16308. private _adaptiveBlurKernel;
  16309. private _blurKernelX;
  16310. private _blurKernelY;
  16311. private _blurRatio;
  16312. /**
  16313. * Instantiates a Mirror Texture.
  16314. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16315. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16316. * You can then easily use it as a reflectionTexture on a flat surface.
  16317. * In case the surface is not a plane, please consider relying on reflection probes.
  16318. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16319. * @param name
  16320. * @param size
  16321. * @param scene
  16322. * @param generateMipMaps
  16323. * @param type
  16324. * @param samplingMode
  16325. * @param generateDepthBuffer
  16326. */
  16327. constructor(name: string, size: number | {
  16328. width: number;
  16329. height: number;
  16330. } | {
  16331. ratio: number;
  16332. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16333. private _preparePostProcesses;
  16334. /**
  16335. * Clone the mirror texture.
  16336. * @returns the cloned texture
  16337. */
  16338. clone(): MirrorTexture;
  16339. /**
  16340. * Serialize the texture to a JSON representation you could use in Parse later on
  16341. * @returns the serialized JSON representation
  16342. */
  16343. serialize(): any;
  16344. /**
  16345. * Dispose the texture and release its associated resources.
  16346. */
  16347. dispose(): void;
  16348. }
  16349. }
  16350. declare module "babylonjs/Materials/Textures/texture" {
  16351. import { Observable } from "babylonjs/Misc/observable";
  16352. import { Nullable } from "babylonjs/types";
  16353. import { Matrix } from "babylonjs/Maths/math.vector";
  16354. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16355. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16356. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16357. import { Scene } from "babylonjs/scene";
  16358. /**
  16359. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16360. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16361. */
  16362. export class Texture extends BaseTexture {
  16363. /**
  16364. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16365. */
  16366. static SerializeBuffers: boolean;
  16367. /** @hidden */
  16368. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16369. /** @hidden */
  16370. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16371. /** @hidden */
  16372. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16373. /** nearest is mag = nearest and min = nearest and mip = linear */
  16374. static readonly NEAREST_SAMPLINGMODE: number;
  16375. /** nearest is mag = nearest and min = nearest and mip = linear */
  16376. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16377. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16378. static readonly BILINEAR_SAMPLINGMODE: number;
  16379. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16380. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16381. /** Trilinear is mag = linear and min = linear and mip = linear */
  16382. static readonly TRILINEAR_SAMPLINGMODE: number;
  16383. /** Trilinear is mag = linear and min = linear and mip = linear */
  16384. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16385. /** mag = nearest and min = nearest and mip = nearest */
  16386. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16387. /** mag = nearest and min = linear and mip = nearest */
  16388. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16389. /** mag = nearest and min = linear and mip = linear */
  16390. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16391. /** mag = nearest and min = linear and mip = none */
  16392. static readonly NEAREST_LINEAR: number;
  16393. /** mag = nearest and min = nearest and mip = none */
  16394. static readonly NEAREST_NEAREST: number;
  16395. /** mag = linear and min = nearest and mip = nearest */
  16396. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16397. /** mag = linear and min = nearest and mip = linear */
  16398. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16399. /** mag = linear and min = linear and mip = none */
  16400. static readonly LINEAR_LINEAR: number;
  16401. /** mag = linear and min = nearest and mip = none */
  16402. static readonly LINEAR_NEAREST: number;
  16403. /** Explicit coordinates mode */
  16404. static readonly EXPLICIT_MODE: number;
  16405. /** Spherical coordinates mode */
  16406. static readonly SPHERICAL_MODE: number;
  16407. /** Planar coordinates mode */
  16408. static readonly PLANAR_MODE: number;
  16409. /** Cubic coordinates mode */
  16410. static readonly CUBIC_MODE: number;
  16411. /** Projection coordinates mode */
  16412. static readonly PROJECTION_MODE: number;
  16413. /** Inverse Cubic coordinates mode */
  16414. static readonly SKYBOX_MODE: number;
  16415. /** Inverse Cubic coordinates mode */
  16416. static readonly INVCUBIC_MODE: number;
  16417. /** Equirectangular coordinates mode */
  16418. static readonly EQUIRECTANGULAR_MODE: number;
  16419. /** Equirectangular Fixed coordinates mode */
  16420. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16421. /** Equirectangular Fixed Mirrored coordinates mode */
  16422. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16423. /** Texture is not repeating outside of 0..1 UVs */
  16424. static readonly CLAMP_ADDRESSMODE: number;
  16425. /** Texture is repeating outside of 0..1 UVs */
  16426. static readonly WRAP_ADDRESSMODE: number;
  16427. /** Texture is repeating and mirrored */
  16428. static readonly MIRROR_ADDRESSMODE: number;
  16429. /**
  16430. * 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
  16431. */
  16432. static UseSerializedUrlIfAny: boolean;
  16433. /**
  16434. * Define the url of the texture.
  16435. */
  16436. url: Nullable<string>;
  16437. /**
  16438. * Define an offset on the texture to offset the u coordinates of the UVs
  16439. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16440. */
  16441. uOffset: number;
  16442. /**
  16443. * Define an offset on the texture to offset the v coordinates of the UVs
  16444. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16445. */
  16446. vOffset: number;
  16447. /**
  16448. * Define an offset on the texture to scale the u coordinates of the UVs
  16449. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16450. */
  16451. uScale: number;
  16452. /**
  16453. * Define an offset on the texture to scale the v coordinates of the UVs
  16454. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16455. */
  16456. vScale: number;
  16457. /**
  16458. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16459. * @see http://doc.babylonjs.com/how_to/more_materials
  16460. */
  16461. uAng: number;
  16462. /**
  16463. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16464. * @see http://doc.babylonjs.com/how_to/more_materials
  16465. */
  16466. vAng: number;
  16467. /**
  16468. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16469. * @see http://doc.babylonjs.com/how_to/more_materials
  16470. */
  16471. wAng: number;
  16472. /**
  16473. * Defines the center of rotation (U)
  16474. */
  16475. uRotationCenter: number;
  16476. /**
  16477. * Defines the center of rotation (V)
  16478. */
  16479. vRotationCenter: number;
  16480. /**
  16481. * Defines the center of rotation (W)
  16482. */
  16483. wRotationCenter: number;
  16484. /**
  16485. * Are mip maps generated for this texture or not.
  16486. */
  16487. get noMipmap(): boolean;
  16488. /**
  16489. * List of inspectable custom properties (used by the Inspector)
  16490. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16491. */
  16492. inspectableCustomProperties: Nullable<IInspectable[]>;
  16493. private _noMipmap;
  16494. /** @hidden */
  16495. _invertY: boolean;
  16496. private _rowGenerationMatrix;
  16497. private _cachedTextureMatrix;
  16498. private _projectionModeMatrix;
  16499. private _t0;
  16500. private _t1;
  16501. private _t2;
  16502. private _cachedUOffset;
  16503. private _cachedVOffset;
  16504. private _cachedUScale;
  16505. private _cachedVScale;
  16506. private _cachedUAng;
  16507. private _cachedVAng;
  16508. private _cachedWAng;
  16509. private _cachedProjectionMatrixId;
  16510. private _cachedCoordinatesMode;
  16511. /** @hidden */
  16512. protected _initialSamplingMode: number;
  16513. /** @hidden */
  16514. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16515. private _deleteBuffer;
  16516. protected _format: Nullable<number>;
  16517. private _delayedOnLoad;
  16518. private _delayedOnError;
  16519. private _mimeType?;
  16520. /**
  16521. * Observable triggered once the texture has been loaded.
  16522. */
  16523. onLoadObservable: Observable<Texture>;
  16524. protected _isBlocking: boolean;
  16525. /**
  16526. * Is the texture preventing material to render while loading.
  16527. * If false, a default texture will be used instead of the loading one during the preparation step.
  16528. */
  16529. set isBlocking(value: boolean);
  16530. get isBlocking(): boolean;
  16531. /**
  16532. * Get the current sampling mode associated with the texture.
  16533. */
  16534. get samplingMode(): number;
  16535. /**
  16536. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16537. */
  16538. get invertY(): boolean;
  16539. /**
  16540. * Instantiates a new texture.
  16541. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16542. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16543. * @param url defines the url of the picture to load as a texture
  16544. * @param scene defines the scene or engine the texture will belong to
  16545. * @param noMipmap defines if the texture will require mip maps or not
  16546. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16547. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16548. * @param onLoad defines a callback triggered when the texture has been loaded
  16549. * @param onError defines a callback triggered when an error occurred during the loading session
  16550. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16551. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16552. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16553. * @param mimeType defines an optional mime type information
  16554. */
  16555. 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);
  16556. /**
  16557. * Update the url (and optional buffer) of this texture if url was null during construction.
  16558. * @param url the url of the texture
  16559. * @param buffer the buffer of the texture (defaults to null)
  16560. * @param onLoad callback called when the texture is loaded (defaults to null)
  16561. */
  16562. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16563. /**
  16564. * Finish the loading sequence of a texture flagged as delayed load.
  16565. * @hidden
  16566. */
  16567. delayLoad(): void;
  16568. private _prepareRowForTextureGeneration;
  16569. /**
  16570. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16571. * @returns the transform matrix of the texture.
  16572. */
  16573. getTextureMatrix(uBase?: number): Matrix;
  16574. /**
  16575. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16576. * @returns The reflection texture transform
  16577. */
  16578. getReflectionTextureMatrix(): Matrix;
  16579. /**
  16580. * Clones the texture.
  16581. * @returns the cloned texture
  16582. */
  16583. clone(): Texture;
  16584. /**
  16585. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16586. * @returns The JSON representation of the texture
  16587. */
  16588. serialize(): any;
  16589. /**
  16590. * Get the current class name of the texture useful for serialization or dynamic coding.
  16591. * @returns "Texture"
  16592. */
  16593. getClassName(): string;
  16594. /**
  16595. * Dispose the texture and release its associated resources.
  16596. */
  16597. dispose(): void;
  16598. /**
  16599. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16600. * @param parsedTexture Define the JSON representation of the texture
  16601. * @param scene Define the scene the parsed texture should be instantiated in
  16602. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16603. * @returns The parsed texture if successful
  16604. */
  16605. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16606. /**
  16607. * Creates a texture from its base 64 representation.
  16608. * @param data Define the base64 payload without the data: prefix
  16609. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16610. * @param scene Define the scene the texture should belong to
  16611. * @param noMipmap Forces the texture to not create mip map information if true
  16612. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16613. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16614. * @param onLoad define a callback triggered when the texture has been loaded
  16615. * @param onError define a callback triggered when an error occurred during the loading session
  16616. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16617. * @returns the created texture
  16618. */
  16619. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16620. /**
  16621. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16622. * @param data Define the base64 payload without the data: prefix
  16623. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16624. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16625. * @param scene Define the scene the texture should belong to
  16626. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16627. * @param noMipmap Forces the texture to not create mip map information if true
  16628. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16629. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16630. * @param onLoad define a callback triggered when the texture has been loaded
  16631. * @param onError define a callback triggered when an error occurred during the loading session
  16632. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16633. * @returns the created texture
  16634. */
  16635. 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;
  16636. }
  16637. }
  16638. declare module "babylonjs/PostProcesses/postProcessManager" {
  16639. import { Nullable } from "babylonjs/types";
  16640. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16641. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16642. import { Scene } from "babylonjs/scene";
  16643. /**
  16644. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16645. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16646. */
  16647. export class PostProcessManager {
  16648. private _scene;
  16649. private _indexBuffer;
  16650. private _vertexBuffers;
  16651. /**
  16652. * Creates a new instance PostProcess
  16653. * @param scene The scene that the post process is associated with.
  16654. */
  16655. constructor(scene: Scene);
  16656. private _prepareBuffers;
  16657. private _buildIndexBuffer;
  16658. /**
  16659. * Rebuilds the vertex buffers of the manager.
  16660. * @hidden
  16661. */
  16662. _rebuild(): void;
  16663. /**
  16664. * Prepares a frame to be run through a post process.
  16665. * @param sourceTexture The input texture to the post procesess. (default: null)
  16666. * @param postProcesses An array of post processes to be run. (default: null)
  16667. * @returns True if the post processes were able to be run.
  16668. * @hidden
  16669. */
  16670. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16671. /**
  16672. * Manually render a set of post processes to a texture.
  16673. * @param postProcesses An array of post processes to be run.
  16674. * @param targetTexture The target texture to render to.
  16675. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16676. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16677. * @param lodLevel defines which lod of the texture to render to
  16678. */
  16679. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16680. /**
  16681. * Finalize the result of the output of the postprocesses.
  16682. * @param doNotPresent If true the result will not be displayed to the screen.
  16683. * @param targetTexture The target texture to render to.
  16684. * @param faceIndex The index of the face to bind the target texture to.
  16685. * @param postProcesses The array of post processes to render.
  16686. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16687. * @hidden
  16688. */
  16689. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16690. /**
  16691. * Disposes of the post process manager.
  16692. */
  16693. dispose(): void;
  16694. }
  16695. }
  16696. declare module "babylonjs/Misc/gradients" {
  16697. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16698. /** Interface used by value gradients (color, factor, ...) */
  16699. export interface IValueGradient {
  16700. /**
  16701. * Gets or sets the gradient value (between 0 and 1)
  16702. */
  16703. gradient: number;
  16704. }
  16705. /** Class used to store color4 gradient */
  16706. export class ColorGradient implements IValueGradient {
  16707. /**
  16708. * Gets or sets the gradient value (between 0 and 1)
  16709. */
  16710. gradient: number;
  16711. /**
  16712. * Gets or sets first associated color
  16713. */
  16714. color1: Color4;
  16715. /**
  16716. * Gets or sets second associated color
  16717. */
  16718. color2?: Color4;
  16719. /**
  16720. * Will get a color picked randomly between color1 and color2.
  16721. * If color2 is undefined then color1 will be used
  16722. * @param result defines the target Color4 to store the result in
  16723. */
  16724. getColorToRef(result: Color4): void;
  16725. }
  16726. /** Class used to store color 3 gradient */
  16727. export class Color3Gradient implements IValueGradient {
  16728. /**
  16729. * Gets or sets the gradient value (between 0 and 1)
  16730. */
  16731. gradient: number;
  16732. /**
  16733. * Gets or sets the associated color
  16734. */
  16735. color: Color3;
  16736. }
  16737. /** Class used to store factor gradient */
  16738. export class FactorGradient implements IValueGradient {
  16739. /**
  16740. * Gets or sets the gradient value (between 0 and 1)
  16741. */
  16742. gradient: number;
  16743. /**
  16744. * Gets or sets first associated factor
  16745. */
  16746. factor1: number;
  16747. /**
  16748. * Gets or sets second associated factor
  16749. */
  16750. factor2?: number;
  16751. /**
  16752. * Will get a number picked randomly between factor1 and factor2.
  16753. * If factor2 is undefined then factor1 will be used
  16754. * @returns the picked number
  16755. */
  16756. getFactor(): number;
  16757. }
  16758. /**
  16759. * Helper used to simplify some generic gradient tasks
  16760. */
  16761. export class GradientHelper {
  16762. /**
  16763. * Gets the current gradient from an array of IValueGradient
  16764. * @param ratio defines the current ratio to get
  16765. * @param gradients defines the array of IValueGradient
  16766. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16767. */
  16768. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16769. }
  16770. }
  16771. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16772. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16773. import { Nullable } from "babylonjs/types";
  16774. module "babylonjs/Engines/thinEngine" {
  16775. interface ThinEngine {
  16776. /**
  16777. * Creates a dynamic texture
  16778. * @param width defines the width of the texture
  16779. * @param height defines the height of the texture
  16780. * @param generateMipMaps defines if the engine should generate the mip levels
  16781. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16782. * @returns the dynamic texture inside an InternalTexture
  16783. */
  16784. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16785. /**
  16786. * Update the content of a dynamic texture
  16787. * @param texture defines the texture to update
  16788. * @param canvas defines the canvas containing the source
  16789. * @param invertY defines if data must be stored with Y axis inverted
  16790. * @param premulAlpha defines if alpha is stored as premultiplied
  16791. * @param format defines the format of the data
  16792. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16793. */
  16794. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16795. }
  16796. }
  16797. }
  16798. declare module "babylonjs/Misc/canvasGenerator" {
  16799. /**
  16800. * Helper class used to generate a canvas to manipulate images
  16801. */
  16802. export class CanvasGenerator {
  16803. /**
  16804. * Create a new canvas (or offscreen canvas depending on the context)
  16805. * @param width defines the expected width
  16806. * @param height defines the expected height
  16807. * @return a new canvas or offscreen canvas
  16808. */
  16809. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16810. }
  16811. }
  16812. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16813. import { Scene } from "babylonjs/scene";
  16814. import { Texture } from "babylonjs/Materials/Textures/texture";
  16815. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16816. /**
  16817. * A class extending Texture allowing drawing on a texture
  16818. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16819. */
  16820. export class DynamicTexture extends Texture {
  16821. private _generateMipMaps;
  16822. private _canvas;
  16823. private _context;
  16824. private _engine;
  16825. /**
  16826. * Creates a DynamicTexture
  16827. * @param name defines the name of the texture
  16828. * @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
  16829. * @param scene defines the scene where you want the texture
  16830. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16831. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16832. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16833. */
  16834. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16835. /**
  16836. * Get the current class name of the texture useful for serialization or dynamic coding.
  16837. * @returns "DynamicTexture"
  16838. */
  16839. getClassName(): string;
  16840. /**
  16841. * Gets the current state of canRescale
  16842. */
  16843. get canRescale(): boolean;
  16844. private _recreate;
  16845. /**
  16846. * Scales the texture
  16847. * @param ratio the scale factor to apply to both width and height
  16848. */
  16849. scale(ratio: number): void;
  16850. /**
  16851. * Resizes the texture
  16852. * @param width the new width
  16853. * @param height the new height
  16854. */
  16855. scaleTo(width: number, height: number): void;
  16856. /**
  16857. * Gets the context of the canvas used by the texture
  16858. * @returns the canvas context of the dynamic texture
  16859. */
  16860. getContext(): CanvasRenderingContext2D;
  16861. /**
  16862. * Clears the texture
  16863. */
  16864. clear(): void;
  16865. /**
  16866. * Updates the texture
  16867. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16868. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16869. */
  16870. update(invertY?: boolean, premulAlpha?: boolean): void;
  16871. /**
  16872. * Draws text onto the texture
  16873. * @param text defines the text to be drawn
  16874. * @param x defines the placement of the text from the left
  16875. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16876. * @param font defines the font to be used with font-style, font-size, font-name
  16877. * @param color defines the color used for the text
  16878. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16879. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16880. * @param update defines whether texture is immediately update (default is true)
  16881. */
  16882. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16883. /**
  16884. * Clones the texture
  16885. * @returns the clone of the texture.
  16886. */
  16887. clone(): DynamicTexture;
  16888. /**
  16889. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16890. * @returns a serialized dynamic texture object
  16891. */
  16892. serialize(): any;
  16893. /** @hidden */
  16894. _rebuild(): void;
  16895. }
  16896. }
  16897. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16898. import { Scene } from "babylonjs/scene";
  16899. import { ISceneComponent } from "babylonjs/sceneComponent";
  16900. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16901. module "babylonjs/abstractScene" {
  16902. interface AbstractScene {
  16903. /**
  16904. * The list of procedural textures added to the scene
  16905. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16906. */
  16907. proceduralTextures: Array<ProceduralTexture>;
  16908. }
  16909. }
  16910. /**
  16911. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16912. * in a given scene.
  16913. */
  16914. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16915. /**
  16916. * The component name helpfull to identify the component in the list of scene components.
  16917. */
  16918. readonly name: string;
  16919. /**
  16920. * The scene the component belongs to.
  16921. */
  16922. scene: Scene;
  16923. /**
  16924. * Creates a new instance of the component for the given scene
  16925. * @param scene Defines the scene to register the component in
  16926. */
  16927. constructor(scene: Scene);
  16928. /**
  16929. * Registers the component in a given scene
  16930. */
  16931. register(): void;
  16932. /**
  16933. * Rebuilds the elements related to this component in case of
  16934. * context lost for instance.
  16935. */
  16936. rebuild(): void;
  16937. /**
  16938. * Disposes the component and the associated ressources.
  16939. */
  16940. dispose(): void;
  16941. private _beforeClear;
  16942. }
  16943. }
  16944. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16945. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16946. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16947. module "babylonjs/Engines/thinEngine" {
  16948. interface ThinEngine {
  16949. /**
  16950. * Creates a new render target cube texture
  16951. * @param size defines the size of the texture
  16952. * @param options defines the options used to create the texture
  16953. * @returns a new render target cube texture stored in an InternalTexture
  16954. */
  16955. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16956. }
  16957. }
  16958. }
  16959. declare module "babylonjs/Shaders/procedural.vertex" {
  16960. /** @hidden */
  16961. export var proceduralVertexShader: {
  16962. name: string;
  16963. shader: string;
  16964. };
  16965. }
  16966. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16967. import { Observable } from "babylonjs/Misc/observable";
  16968. import { Nullable } from "babylonjs/types";
  16969. import { Scene } from "babylonjs/scene";
  16970. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16971. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16972. import { Effect } from "babylonjs/Materials/effect";
  16973. import { Texture } from "babylonjs/Materials/Textures/texture";
  16974. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16975. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16976. import "babylonjs/Shaders/procedural.vertex";
  16977. /**
  16978. * 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.
  16979. * This is the base class of any Procedural texture and contains most of the shareable code.
  16980. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16981. */
  16982. export class ProceduralTexture extends Texture {
  16983. isCube: boolean;
  16984. /**
  16985. * Define if the texture is enabled or not (disabled texture will not render)
  16986. */
  16987. isEnabled: boolean;
  16988. /**
  16989. * Define if the texture must be cleared before rendering (default is true)
  16990. */
  16991. autoClear: boolean;
  16992. /**
  16993. * Callback called when the texture is generated
  16994. */
  16995. onGenerated: () => void;
  16996. /**
  16997. * Event raised when the texture is generated
  16998. */
  16999. onGeneratedObservable: Observable<ProceduralTexture>;
  17000. /** @hidden */
  17001. _generateMipMaps: boolean;
  17002. /** @hidden **/
  17003. _effect: Effect;
  17004. /** @hidden */
  17005. _textures: {
  17006. [key: string]: Texture;
  17007. };
  17008. private _size;
  17009. private _currentRefreshId;
  17010. private _frameId;
  17011. private _refreshRate;
  17012. private _vertexBuffers;
  17013. private _indexBuffer;
  17014. private _uniforms;
  17015. private _samplers;
  17016. private _fragment;
  17017. private _floats;
  17018. private _ints;
  17019. private _floatsArrays;
  17020. private _colors3;
  17021. private _colors4;
  17022. private _vectors2;
  17023. private _vectors3;
  17024. private _matrices;
  17025. private _fallbackTexture;
  17026. private _fallbackTextureUsed;
  17027. private _engine;
  17028. private _cachedDefines;
  17029. private _contentUpdateId;
  17030. private _contentData;
  17031. /**
  17032. * Instantiates a new procedural texture.
  17033. * 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.
  17034. * This is the base class of any Procedural texture and contains most of the shareable code.
  17035. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  17036. * @param name Define the name of the texture
  17037. * @param size Define the size of the texture to create
  17038. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  17039. * @param scene Define the scene the texture belongs to
  17040. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  17041. * @param generateMipMaps Define if the texture should creates mip maps or not
  17042. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  17043. */
  17044. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  17045. /**
  17046. * The effect that is created when initializing the post process.
  17047. * @returns The created effect corresponding the the postprocess.
  17048. */
  17049. getEffect(): Effect;
  17050. /**
  17051. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  17052. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  17053. */
  17054. getContent(): Nullable<ArrayBufferView>;
  17055. private _createIndexBuffer;
  17056. /** @hidden */
  17057. _rebuild(): void;
  17058. /**
  17059. * Resets the texture in order to recreate its associated resources.
  17060. * This can be called in case of context loss
  17061. */
  17062. reset(): void;
  17063. protected _getDefines(): string;
  17064. /**
  17065. * Is the texture ready to be used ? (rendered at least once)
  17066. * @returns true if ready, otherwise, false.
  17067. */
  17068. isReady(): boolean;
  17069. /**
  17070. * Resets the refresh counter of the texture and start bak from scratch.
  17071. * Could be useful to regenerate the texture if it is setup to render only once.
  17072. */
  17073. resetRefreshCounter(): void;
  17074. /**
  17075. * Set the fragment shader to use in order to render the texture.
  17076. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  17077. */
  17078. setFragment(fragment: any): void;
  17079. /**
  17080. * Define the refresh rate of the texture or the rendering frequency.
  17081. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17082. */
  17083. get refreshRate(): number;
  17084. set refreshRate(value: number);
  17085. /** @hidden */
  17086. _shouldRender(): boolean;
  17087. /**
  17088. * Get the size the texture is rendering at.
  17089. * @returns the size (texture is always squared)
  17090. */
  17091. getRenderSize(): number;
  17092. /**
  17093. * Resize the texture to new value.
  17094. * @param size Define the new size the texture should have
  17095. * @param generateMipMaps Define whether the new texture should create mip maps
  17096. */
  17097. resize(size: number, generateMipMaps: boolean): void;
  17098. private _checkUniform;
  17099. /**
  17100. * Set a texture in the shader program used to render.
  17101. * @param name Define the name of the uniform samplers as defined in the shader
  17102. * @param texture Define the texture to bind to this sampler
  17103. * @return the texture itself allowing "fluent" like uniform updates
  17104. */
  17105. setTexture(name: string, texture: Texture): ProceduralTexture;
  17106. /**
  17107. * Set a float in the shader.
  17108. * @param name Define the name of the uniform as defined in the shader
  17109. * @param value Define the value to give to the uniform
  17110. * @return the texture itself allowing "fluent" like uniform updates
  17111. */
  17112. setFloat(name: string, value: number): ProceduralTexture;
  17113. /**
  17114. * Set a int in the shader.
  17115. * @param name Define the name of the uniform as defined in the shader
  17116. * @param value Define the value to give to the uniform
  17117. * @return the texture itself allowing "fluent" like uniform updates
  17118. */
  17119. setInt(name: string, value: number): ProceduralTexture;
  17120. /**
  17121. * Set an array of floats in the shader.
  17122. * @param name Define the name of the uniform as defined in the shader
  17123. * @param value Define the value to give to the uniform
  17124. * @return the texture itself allowing "fluent" like uniform updates
  17125. */
  17126. setFloats(name: string, value: number[]): ProceduralTexture;
  17127. /**
  17128. * Set a vec3 in the shader from a Color3.
  17129. * @param name Define the name of the uniform as defined in the shader
  17130. * @param value Define the value to give to the uniform
  17131. * @return the texture itself allowing "fluent" like uniform updates
  17132. */
  17133. setColor3(name: string, value: Color3): ProceduralTexture;
  17134. /**
  17135. * Set a vec4 in the shader from a Color4.
  17136. * @param name Define the name of the uniform as defined in the shader
  17137. * @param value Define the value to give to the uniform
  17138. * @return the texture itself allowing "fluent" like uniform updates
  17139. */
  17140. setColor4(name: string, value: Color4): ProceduralTexture;
  17141. /**
  17142. * Set a vec2 in the shader from a Vector2.
  17143. * @param name Define the name of the uniform as defined in the shader
  17144. * @param value Define the value to give to the uniform
  17145. * @return the texture itself allowing "fluent" like uniform updates
  17146. */
  17147. setVector2(name: string, value: Vector2): ProceduralTexture;
  17148. /**
  17149. * Set a vec3 in the shader from a Vector3.
  17150. * @param name Define the name of the uniform as defined in the shader
  17151. * @param value Define the value to give to the uniform
  17152. * @return the texture itself allowing "fluent" like uniform updates
  17153. */
  17154. setVector3(name: string, value: Vector3): ProceduralTexture;
  17155. /**
  17156. * Set a mat4 in the shader from a MAtrix.
  17157. * @param name Define the name of the uniform as defined in the shader
  17158. * @param value Define the value to give to the uniform
  17159. * @return the texture itself allowing "fluent" like uniform updates
  17160. */
  17161. setMatrix(name: string, value: Matrix): ProceduralTexture;
  17162. /**
  17163. * Render the texture to its associated render target.
  17164. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  17165. */
  17166. render(useCameraPostProcess?: boolean): void;
  17167. /**
  17168. * Clone the texture.
  17169. * @returns the cloned texture
  17170. */
  17171. clone(): ProceduralTexture;
  17172. /**
  17173. * Dispose the texture and release its asoociated resources.
  17174. */
  17175. dispose(): void;
  17176. }
  17177. }
  17178. declare module "babylonjs/Particles/baseParticleSystem" {
  17179. import { Nullable } from "babylonjs/types";
  17180. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  17181. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17182. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17183. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17184. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  17185. import { Scene } from "babylonjs/scene";
  17186. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  17187. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17188. import { Texture } from "babylonjs/Materials/Textures/texture";
  17189. import { Color4 } from "babylonjs/Maths/math.color";
  17190. import { Animation } from "babylonjs/Animations/animation";
  17191. /**
  17192. * This represents the base class for particle system in Babylon.
  17193. * 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.
  17194. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17195. * @example https://doc.babylonjs.com/babylon101/particles
  17196. */
  17197. export class BaseParticleSystem {
  17198. /**
  17199. * Source color is added to the destination color without alpha affecting the result
  17200. */
  17201. static BLENDMODE_ONEONE: number;
  17202. /**
  17203. * Blend current color and particle color using particle’s alpha
  17204. */
  17205. static BLENDMODE_STANDARD: number;
  17206. /**
  17207. * Add current color and particle color multiplied by particle’s alpha
  17208. */
  17209. static BLENDMODE_ADD: number;
  17210. /**
  17211. * Multiply current color with particle color
  17212. */
  17213. static BLENDMODE_MULTIPLY: number;
  17214. /**
  17215. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  17216. */
  17217. static BLENDMODE_MULTIPLYADD: number;
  17218. /**
  17219. * List of animations used by the particle system.
  17220. */
  17221. animations: Animation[];
  17222. /**
  17223. * The id of the Particle system.
  17224. */
  17225. id: string;
  17226. /**
  17227. * The friendly name of the Particle system.
  17228. */
  17229. name: string;
  17230. /**
  17231. * The rendering group used by the Particle system to chose when to render.
  17232. */
  17233. renderingGroupId: number;
  17234. /**
  17235. * The emitter represents the Mesh or position we are attaching the particle system to.
  17236. */
  17237. emitter: Nullable<AbstractMesh | Vector3>;
  17238. /**
  17239. * The maximum number of particles to emit per frame
  17240. */
  17241. emitRate: number;
  17242. /**
  17243. * If you want to launch only a few particles at once, that can be done, as well.
  17244. */
  17245. manualEmitCount: number;
  17246. /**
  17247. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17248. */
  17249. updateSpeed: number;
  17250. /**
  17251. * The amount of time the particle system is running (depends of the overall update speed).
  17252. */
  17253. targetStopDuration: number;
  17254. /**
  17255. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17256. */
  17257. disposeOnStop: boolean;
  17258. /**
  17259. * Minimum power of emitting particles.
  17260. */
  17261. minEmitPower: number;
  17262. /**
  17263. * Maximum power of emitting particles.
  17264. */
  17265. maxEmitPower: number;
  17266. /**
  17267. * Minimum life time of emitting particles.
  17268. */
  17269. minLifeTime: number;
  17270. /**
  17271. * Maximum life time of emitting particles.
  17272. */
  17273. maxLifeTime: number;
  17274. /**
  17275. * Minimum Size of emitting particles.
  17276. */
  17277. minSize: number;
  17278. /**
  17279. * Maximum Size of emitting particles.
  17280. */
  17281. maxSize: number;
  17282. /**
  17283. * Minimum scale of emitting particles on X axis.
  17284. */
  17285. minScaleX: number;
  17286. /**
  17287. * Maximum scale of emitting particles on X axis.
  17288. */
  17289. maxScaleX: number;
  17290. /**
  17291. * Minimum scale of emitting particles on Y axis.
  17292. */
  17293. minScaleY: number;
  17294. /**
  17295. * Maximum scale of emitting particles on Y axis.
  17296. */
  17297. maxScaleY: number;
  17298. /**
  17299. * Gets or sets the minimal initial rotation in radians.
  17300. */
  17301. minInitialRotation: number;
  17302. /**
  17303. * Gets or sets the maximal initial rotation in radians.
  17304. */
  17305. maxInitialRotation: number;
  17306. /**
  17307. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17308. */
  17309. minAngularSpeed: number;
  17310. /**
  17311. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17312. */
  17313. maxAngularSpeed: number;
  17314. /**
  17315. * The texture used to render each particle. (this can be a spritesheet)
  17316. */
  17317. particleTexture: Nullable<Texture>;
  17318. /**
  17319. * The layer mask we are rendering the particles through.
  17320. */
  17321. layerMask: number;
  17322. /**
  17323. * This can help using your own shader to render the particle system.
  17324. * The according effect will be created
  17325. */
  17326. customShader: any;
  17327. /**
  17328. * By default particle system starts as soon as they are created. This prevents the
  17329. * automatic start to happen and let you decide when to start emitting particles.
  17330. */
  17331. preventAutoStart: boolean;
  17332. private _noiseTexture;
  17333. /**
  17334. * Gets or sets a texture used to add random noise to particle positions
  17335. */
  17336. get noiseTexture(): Nullable<ProceduralTexture>;
  17337. set noiseTexture(value: Nullable<ProceduralTexture>);
  17338. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17339. noiseStrength: Vector3;
  17340. /**
  17341. * Callback triggered when the particle animation is ending.
  17342. */
  17343. onAnimationEnd: Nullable<() => void>;
  17344. /**
  17345. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17346. */
  17347. blendMode: number;
  17348. /**
  17349. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17350. * to override the particles.
  17351. */
  17352. forceDepthWrite: boolean;
  17353. /** 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 */
  17354. preWarmCycles: number;
  17355. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17356. preWarmStepOffset: number;
  17357. /**
  17358. * 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)
  17359. */
  17360. spriteCellChangeSpeed: number;
  17361. /**
  17362. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17363. */
  17364. startSpriteCellID: number;
  17365. /**
  17366. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17367. */
  17368. endSpriteCellID: number;
  17369. /**
  17370. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17371. */
  17372. spriteCellWidth: number;
  17373. /**
  17374. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17375. */
  17376. spriteCellHeight: number;
  17377. /**
  17378. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17379. */
  17380. spriteRandomStartCell: boolean;
  17381. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17382. translationPivot: Vector2;
  17383. /** @hidden */
  17384. protected _isAnimationSheetEnabled: boolean;
  17385. /**
  17386. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17387. */
  17388. beginAnimationOnStart: boolean;
  17389. /**
  17390. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17391. */
  17392. beginAnimationFrom: number;
  17393. /**
  17394. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17395. */
  17396. beginAnimationTo: number;
  17397. /**
  17398. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17399. */
  17400. beginAnimationLoop: boolean;
  17401. /**
  17402. * Gets or sets a world offset applied to all particles
  17403. */
  17404. worldOffset: Vector3;
  17405. /**
  17406. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17407. */
  17408. get isAnimationSheetEnabled(): boolean;
  17409. set isAnimationSheetEnabled(value: boolean);
  17410. /**
  17411. * Get hosting scene
  17412. * @returns the scene
  17413. */
  17414. getScene(): Scene;
  17415. /**
  17416. * You can use gravity if you want to give an orientation to your particles.
  17417. */
  17418. gravity: Vector3;
  17419. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17420. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17421. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17422. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17423. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17424. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17425. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17426. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17427. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17428. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17429. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17430. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17431. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17432. /**
  17433. * Defines the delay in milliseconds before starting the system (0 by default)
  17434. */
  17435. startDelay: number;
  17436. /**
  17437. * Gets the current list of drag gradients.
  17438. * You must use addDragGradient and removeDragGradient to udpate this list
  17439. * @returns the list of drag gradients
  17440. */
  17441. getDragGradients(): Nullable<Array<FactorGradient>>;
  17442. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17443. limitVelocityDamping: number;
  17444. /**
  17445. * Gets the current list of limit velocity gradients.
  17446. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17447. * @returns the list of limit velocity gradients
  17448. */
  17449. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17450. /**
  17451. * Gets the current list of color gradients.
  17452. * You must use addColorGradient and removeColorGradient to udpate this list
  17453. * @returns the list of color gradients
  17454. */
  17455. getColorGradients(): Nullable<Array<ColorGradient>>;
  17456. /**
  17457. * Gets the current list of size gradients.
  17458. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17459. * @returns the list of size gradients
  17460. */
  17461. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17462. /**
  17463. * Gets the current list of color remap gradients.
  17464. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17465. * @returns the list of color remap gradients
  17466. */
  17467. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17468. /**
  17469. * Gets the current list of alpha remap gradients.
  17470. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17471. * @returns the list of alpha remap gradients
  17472. */
  17473. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17474. /**
  17475. * Gets the current list of life time gradients.
  17476. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17477. * @returns the list of life time gradients
  17478. */
  17479. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17480. /**
  17481. * Gets the current list of angular speed gradients.
  17482. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17483. * @returns the list of angular speed gradients
  17484. */
  17485. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17486. /**
  17487. * Gets the current list of velocity gradients.
  17488. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17489. * @returns the list of velocity gradients
  17490. */
  17491. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17492. /**
  17493. * Gets the current list of start size gradients.
  17494. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17495. * @returns the list of start size gradients
  17496. */
  17497. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17498. /**
  17499. * Gets the current list of emit rate gradients.
  17500. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17501. * @returns the list of emit rate gradients
  17502. */
  17503. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17504. /**
  17505. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17506. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17507. */
  17508. get direction1(): Vector3;
  17509. set direction1(value: Vector3);
  17510. /**
  17511. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17512. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17513. */
  17514. get direction2(): Vector3;
  17515. set direction2(value: Vector3);
  17516. /**
  17517. * 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.
  17518. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17519. */
  17520. get minEmitBox(): Vector3;
  17521. set minEmitBox(value: Vector3);
  17522. /**
  17523. * 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.
  17524. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17525. */
  17526. get maxEmitBox(): Vector3;
  17527. set maxEmitBox(value: Vector3);
  17528. /**
  17529. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17530. */
  17531. color1: Color4;
  17532. /**
  17533. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17534. */
  17535. color2: Color4;
  17536. /**
  17537. * Color the particle will have at the end of its lifetime
  17538. */
  17539. colorDead: Color4;
  17540. /**
  17541. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17542. */
  17543. textureMask: Color4;
  17544. /**
  17545. * The particle emitter type defines the emitter used by the particle system.
  17546. * It can be for example box, sphere, or cone...
  17547. */
  17548. particleEmitterType: IParticleEmitterType;
  17549. /** @hidden */
  17550. _isSubEmitter: boolean;
  17551. /**
  17552. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17553. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17554. */
  17555. billboardMode: number;
  17556. protected _isBillboardBased: boolean;
  17557. /**
  17558. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17559. */
  17560. get isBillboardBased(): boolean;
  17561. set isBillboardBased(value: boolean);
  17562. /**
  17563. * The scene the particle system belongs to.
  17564. */
  17565. protected _scene: Scene;
  17566. /**
  17567. * Local cache of defines for image processing.
  17568. */
  17569. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17570. /**
  17571. * Default configuration related to image processing available in the standard Material.
  17572. */
  17573. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17574. /**
  17575. * Gets the image processing configuration used either in this material.
  17576. */
  17577. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17578. /**
  17579. * Sets the Default image processing configuration used either in the this material.
  17580. *
  17581. * If sets to null, the scene one is in use.
  17582. */
  17583. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17584. /**
  17585. * Attaches a new image processing configuration to the Standard Material.
  17586. * @param configuration
  17587. */
  17588. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17589. /** @hidden */
  17590. protected _reset(): void;
  17591. /** @hidden */
  17592. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17593. /**
  17594. * Instantiates a particle system.
  17595. * 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.
  17596. * @param name The name of the particle system
  17597. */
  17598. constructor(name: string);
  17599. /**
  17600. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17601. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17602. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17603. * @returns the emitter
  17604. */
  17605. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17606. /**
  17607. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17608. * @param radius The radius of the hemisphere to emit from
  17609. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17610. * @returns the emitter
  17611. */
  17612. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17613. /**
  17614. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17615. * @param radius The radius of the sphere to emit from
  17616. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17617. * @returns the emitter
  17618. */
  17619. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17620. /**
  17621. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17622. * @param radius The radius of the sphere to emit from
  17623. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17624. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17625. * @returns the emitter
  17626. */
  17627. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17628. /**
  17629. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17630. * @param radius The radius of the emission cylinder
  17631. * @param height The height of the emission cylinder
  17632. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17633. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17634. * @returns the emitter
  17635. */
  17636. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17637. /**
  17638. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17639. * @param radius The radius of the cylinder to emit from
  17640. * @param height The height of the emission cylinder
  17641. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17642. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17643. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17644. * @returns the emitter
  17645. */
  17646. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17647. /**
  17648. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17649. * @param radius The radius of the cone to emit from
  17650. * @param angle The base angle of the cone
  17651. * @returns the emitter
  17652. */
  17653. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17654. /**
  17655. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17656. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17657. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17658. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17659. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17660. * @returns the emitter
  17661. */
  17662. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17663. }
  17664. }
  17665. declare module "babylonjs/Particles/subEmitter" {
  17666. import { Scene } from "babylonjs/scene";
  17667. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17668. /**
  17669. * Type of sub emitter
  17670. */
  17671. export enum SubEmitterType {
  17672. /**
  17673. * Attached to the particle over it's lifetime
  17674. */
  17675. ATTACHED = 0,
  17676. /**
  17677. * Created when the particle dies
  17678. */
  17679. END = 1
  17680. }
  17681. /**
  17682. * Sub emitter class used to emit particles from an existing particle
  17683. */
  17684. export class SubEmitter {
  17685. /**
  17686. * the particle system to be used by the sub emitter
  17687. */
  17688. particleSystem: ParticleSystem;
  17689. /**
  17690. * Type of the submitter (Default: END)
  17691. */
  17692. type: SubEmitterType;
  17693. /**
  17694. * 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)
  17695. * Note: This only is supported when using an emitter of type Mesh
  17696. */
  17697. inheritDirection: boolean;
  17698. /**
  17699. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17700. */
  17701. inheritedVelocityAmount: number;
  17702. /**
  17703. * Creates a sub emitter
  17704. * @param particleSystem the particle system to be used by the sub emitter
  17705. */
  17706. constructor(
  17707. /**
  17708. * the particle system to be used by the sub emitter
  17709. */
  17710. particleSystem: ParticleSystem);
  17711. /**
  17712. * Clones the sub emitter
  17713. * @returns the cloned sub emitter
  17714. */
  17715. clone(): SubEmitter;
  17716. /**
  17717. * Serialize current object to a JSON object
  17718. * @returns the serialized object
  17719. */
  17720. serialize(): any;
  17721. /** @hidden */
  17722. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17723. /**
  17724. * Creates a new SubEmitter from a serialized JSON version
  17725. * @param serializationObject defines the JSON object to read from
  17726. * @param scene defines the hosting scene
  17727. * @param rootUrl defines the rootUrl for data loading
  17728. * @returns a new SubEmitter
  17729. */
  17730. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17731. /** Release associated resources */
  17732. dispose(): void;
  17733. }
  17734. }
  17735. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17736. /** @hidden */
  17737. export var clipPlaneFragmentDeclaration: {
  17738. name: string;
  17739. shader: string;
  17740. };
  17741. }
  17742. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17743. /** @hidden */
  17744. export var imageProcessingDeclaration: {
  17745. name: string;
  17746. shader: string;
  17747. };
  17748. }
  17749. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17750. /** @hidden */
  17751. export var imageProcessingFunctions: {
  17752. name: string;
  17753. shader: string;
  17754. };
  17755. }
  17756. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17757. /** @hidden */
  17758. export var clipPlaneFragment: {
  17759. name: string;
  17760. shader: string;
  17761. };
  17762. }
  17763. declare module "babylonjs/Shaders/particles.fragment" {
  17764. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17765. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17766. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17767. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17768. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17769. /** @hidden */
  17770. export var particlesPixelShader: {
  17771. name: string;
  17772. shader: string;
  17773. };
  17774. }
  17775. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17776. /** @hidden */
  17777. export var clipPlaneVertexDeclaration: {
  17778. name: string;
  17779. shader: string;
  17780. };
  17781. }
  17782. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17783. /** @hidden */
  17784. export var clipPlaneVertex: {
  17785. name: string;
  17786. shader: string;
  17787. };
  17788. }
  17789. declare module "babylonjs/Shaders/particles.vertex" {
  17790. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17791. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17792. /** @hidden */
  17793. export var particlesVertexShader: {
  17794. name: string;
  17795. shader: string;
  17796. };
  17797. }
  17798. declare module "babylonjs/Particles/particleSystem" {
  17799. import { Nullable } from "babylonjs/types";
  17800. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17801. import { Observable } from "babylonjs/Misc/observable";
  17802. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17803. import { Effect } from "babylonjs/Materials/effect";
  17804. import { Scene, IDisposable } from "babylonjs/scene";
  17805. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17806. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17807. import { Particle } from "babylonjs/Particles/particle";
  17808. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17809. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17810. import "babylonjs/Shaders/particles.fragment";
  17811. import "babylonjs/Shaders/particles.vertex";
  17812. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17813. /**
  17814. * This represents a particle system in Babylon.
  17815. * 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.
  17816. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17817. * @example https://doc.babylonjs.com/babylon101/particles
  17818. */
  17819. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17820. /**
  17821. * Billboard mode will only apply to Y axis
  17822. */
  17823. static readonly BILLBOARDMODE_Y: number;
  17824. /**
  17825. * Billboard mode will apply to all axes
  17826. */
  17827. static readonly BILLBOARDMODE_ALL: number;
  17828. /**
  17829. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17830. */
  17831. static readonly BILLBOARDMODE_STRETCHED: number;
  17832. /**
  17833. * This function can be defined to provide custom update for active particles.
  17834. * This function will be called instead of regular update (age, position, color, etc.).
  17835. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17836. */
  17837. updateFunction: (particles: Particle[]) => void;
  17838. private _emitterWorldMatrix;
  17839. /**
  17840. * This function can be defined to specify initial direction for every new particle.
  17841. * It by default use the emitterType defined function
  17842. */
  17843. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17844. /**
  17845. * This function can be defined to specify initial position for every new particle.
  17846. * It by default use the emitterType defined function
  17847. */
  17848. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17849. /**
  17850. * @hidden
  17851. */
  17852. _inheritedVelocityOffset: Vector3;
  17853. /**
  17854. * An event triggered when the system is disposed
  17855. */
  17856. onDisposeObservable: Observable<ParticleSystem>;
  17857. private _onDisposeObserver;
  17858. /**
  17859. * Sets a callback that will be triggered when the system is disposed
  17860. */
  17861. set onDispose(callback: () => void);
  17862. private _particles;
  17863. private _epsilon;
  17864. private _capacity;
  17865. private _stockParticles;
  17866. private _newPartsExcess;
  17867. private _vertexData;
  17868. private _vertexBuffer;
  17869. private _vertexBuffers;
  17870. private _spriteBuffer;
  17871. private _indexBuffer;
  17872. private _effect;
  17873. private _customEffect;
  17874. private _cachedDefines;
  17875. private _scaledColorStep;
  17876. private _colorDiff;
  17877. private _scaledDirection;
  17878. private _scaledGravity;
  17879. private _currentRenderId;
  17880. private _alive;
  17881. private _useInstancing;
  17882. private _started;
  17883. private _stopped;
  17884. private _actualFrame;
  17885. private _scaledUpdateSpeed;
  17886. private _vertexBufferSize;
  17887. /** @hidden */
  17888. _currentEmitRateGradient: Nullable<FactorGradient>;
  17889. /** @hidden */
  17890. _currentEmitRate1: number;
  17891. /** @hidden */
  17892. _currentEmitRate2: number;
  17893. /** @hidden */
  17894. _currentStartSizeGradient: Nullable<FactorGradient>;
  17895. /** @hidden */
  17896. _currentStartSize1: number;
  17897. /** @hidden */
  17898. _currentStartSize2: number;
  17899. private readonly _rawTextureWidth;
  17900. private _rampGradientsTexture;
  17901. private _useRampGradients;
  17902. /** Gets or sets a boolean indicating that ramp gradients must be used
  17903. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17904. */
  17905. get useRampGradients(): boolean;
  17906. set useRampGradients(value: boolean);
  17907. /**
  17908. * 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.
  17909. * 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: [])
  17910. */
  17911. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17912. private _subEmitters;
  17913. /**
  17914. * @hidden
  17915. * If the particle systems emitter should be disposed when the particle system is disposed
  17916. */
  17917. _disposeEmitterOnDispose: boolean;
  17918. /**
  17919. * The current active Sub-systems, this property is used by the root particle system only.
  17920. */
  17921. activeSubSystems: Array<ParticleSystem>;
  17922. private _rootParticleSystem;
  17923. /**
  17924. * Gets the current list of active particles
  17925. */
  17926. get particles(): Particle[];
  17927. /**
  17928. * Returns the string "ParticleSystem"
  17929. * @returns a string containing the class name
  17930. */
  17931. getClassName(): string;
  17932. /**
  17933. * Instantiates a particle system.
  17934. * 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.
  17935. * @param name The name of the particle system
  17936. * @param capacity The max number of particles alive at the same time
  17937. * @param scene The scene the particle system belongs to
  17938. * @param customEffect a custom effect used to change the way particles are rendered by default
  17939. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17940. * @param epsilon Offset used to render the particles
  17941. */
  17942. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17943. private _addFactorGradient;
  17944. private _removeFactorGradient;
  17945. /**
  17946. * Adds a new life time gradient
  17947. * @param gradient defines the gradient to use (between 0 and 1)
  17948. * @param factor defines the life time factor to affect to the specified gradient
  17949. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17950. * @returns the current particle system
  17951. */
  17952. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17953. /**
  17954. * Remove a specific life time gradient
  17955. * @param gradient defines the gradient to remove
  17956. * @returns the current particle system
  17957. */
  17958. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17959. /**
  17960. * Adds a new size gradient
  17961. * @param gradient defines the gradient to use (between 0 and 1)
  17962. * @param factor defines the size factor to affect to the specified gradient
  17963. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17964. * @returns the current particle system
  17965. */
  17966. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17967. /**
  17968. * Remove a specific size gradient
  17969. * @param gradient defines the gradient to remove
  17970. * @returns the current particle system
  17971. */
  17972. removeSizeGradient(gradient: number): IParticleSystem;
  17973. /**
  17974. * Adds a new color remap gradient
  17975. * @param gradient defines the gradient to use (between 0 and 1)
  17976. * @param min defines the color remap minimal range
  17977. * @param max defines the color remap maximal range
  17978. * @returns the current particle system
  17979. */
  17980. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17981. /**
  17982. * Remove a specific color remap gradient
  17983. * @param gradient defines the gradient to remove
  17984. * @returns the current particle system
  17985. */
  17986. removeColorRemapGradient(gradient: number): IParticleSystem;
  17987. /**
  17988. * Adds a new alpha remap gradient
  17989. * @param gradient defines the gradient to use (between 0 and 1)
  17990. * @param min defines the alpha remap minimal range
  17991. * @param max defines the alpha remap maximal range
  17992. * @returns the current particle system
  17993. */
  17994. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17995. /**
  17996. * Remove a specific alpha remap gradient
  17997. * @param gradient defines the gradient to remove
  17998. * @returns the current particle system
  17999. */
  18000. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  18001. /**
  18002. * Adds a new angular speed gradient
  18003. * @param gradient defines the gradient to use (between 0 and 1)
  18004. * @param factor defines the angular speed to affect to the specified gradient
  18005. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18006. * @returns the current particle system
  18007. */
  18008. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18009. /**
  18010. * Remove a specific angular speed gradient
  18011. * @param gradient defines the gradient to remove
  18012. * @returns the current particle system
  18013. */
  18014. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18015. /**
  18016. * Adds a new velocity gradient
  18017. * @param gradient defines the gradient to use (between 0 and 1)
  18018. * @param factor defines the velocity to affect to the specified gradient
  18019. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18020. * @returns the current particle system
  18021. */
  18022. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18023. /**
  18024. * Remove a specific velocity gradient
  18025. * @param gradient defines the gradient to remove
  18026. * @returns the current particle system
  18027. */
  18028. removeVelocityGradient(gradient: number): IParticleSystem;
  18029. /**
  18030. * Adds a new limit velocity gradient
  18031. * @param gradient defines the gradient to use (between 0 and 1)
  18032. * @param factor defines the limit velocity value to affect to the specified gradient
  18033. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18034. * @returns the current particle system
  18035. */
  18036. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18037. /**
  18038. * Remove a specific limit velocity gradient
  18039. * @param gradient defines the gradient to remove
  18040. * @returns the current particle system
  18041. */
  18042. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18043. /**
  18044. * Adds a new drag gradient
  18045. * @param gradient defines the gradient to use (between 0 and 1)
  18046. * @param factor defines the drag value to affect to the specified gradient
  18047. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18048. * @returns the current particle system
  18049. */
  18050. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18051. /**
  18052. * Remove a specific drag gradient
  18053. * @param gradient defines the gradient to remove
  18054. * @returns the current particle system
  18055. */
  18056. removeDragGradient(gradient: number): IParticleSystem;
  18057. /**
  18058. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18059. * @param gradient defines the gradient to use (between 0 and 1)
  18060. * @param factor defines the emit rate value to affect to the specified gradient
  18061. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18062. * @returns the current particle system
  18063. */
  18064. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18065. /**
  18066. * Remove a specific emit rate gradient
  18067. * @param gradient defines the gradient to remove
  18068. * @returns the current particle system
  18069. */
  18070. removeEmitRateGradient(gradient: number): IParticleSystem;
  18071. /**
  18072. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18073. * @param gradient defines the gradient to use (between 0 and 1)
  18074. * @param factor defines the start size value to affect to the specified gradient
  18075. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18076. * @returns the current particle system
  18077. */
  18078. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18079. /**
  18080. * Remove a specific start size gradient
  18081. * @param gradient defines the gradient to remove
  18082. * @returns the current particle system
  18083. */
  18084. removeStartSizeGradient(gradient: number): IParticleSystem;
  18085. private _createRampGradientTexture;
  18086. /**
  18087. * Gets the current list of ramp gradients.
  18088. * You must use addRampGradient and removeRampGradient to udpate this list
  18089. * @returns the list of ramp gradients
  18090. */
  18091. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18092. /**
  18093. * Adds a new ramp gradient used to remap particle colors
  18094. * @param gradient defines the gradient to use (between 0 and 1)
  18095. * @param color defines the color to affect to the specified gradient
  18096. * @returns the current particle system
  18097. */
  18098. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  18099. /**
  18100. * Remove a specific ramp gradient
  18101. * @param gradient defines the gradient to remove
  18102. * @returns the current particle system
  18103. */
  18104. removeRampGradient(gradient: number): ParticleSystem;
  18105. /**
  18106. * Adds a new color gradient
  18107. * @param gradient defines the gradient to use (between 0 and 1)
  18108. * @param color1 defines the color to affect to the specified gradient
  18109. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18110. * @returns this particle system
  18111. */
  18112. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18113. /**
  18114. * Remove a specific color gradient
  18115. * @param gradient defines the gradient to remove
  18116. * @returns this particle system
  18117. */
  18118. removeColorGradient(gradient: number): IParticleSystem;
  18119. private _fetchR;
  18120. protected _reset(): void;
  18121. private _resetEffect;
  18122. private _createVertexBuffers;
  18123. private _createIndexBuffer;
  18124. /**
  18125. * Gets the maximum number of particles active at the same time.
  18126. * @returns The max number of active particles.
  18127. */
  18128. getCapacity(): number;
  18129. /**
  18130. * Gets whether there are still active particles in the system.
  18131. * @returns True if it is alive, otherwise false.
  18132. */
  18133. isAlive(): boolean;
  18134. /**
  18135. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18136. * @returns True if it has been started, otherwise false.
  18137. */
  18138. isStarted(): boolean;
  18139. private _prepareSubEmitterInternalArray;
  18140. /**
  18141. * Starts the particle system and begins to emit
  18142. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  18143. */
  18144. start(delay?: number): void;
  18145. /**
  18146. * Stops the particle system.
  18147. * @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.
  18148. */
  18149. stop(stopSubEmitters?: boolean): void;
  18150. /**
  18151. * Remove all active particles
  18152. */
  18153. reset(): void;
  18154. /**
  18155. * @hidden (for internal use only)
  18156. */
  18157. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18158. /**
  18159. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  18160. * Its lifetime will start back at 0.
  18161. */
  18162. recycleParticle: (particle: Particle) => void;
  18163. private _stopSubEmitters;
  18164. private _createParticle;
  18165. private _removeFromRoot;
  18166. private _emitFromParticle;
  18167. private _update;
  18168. /** @hidden */
  18169. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  18170. /** @hidden */
  18171. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  18172. /** @hidden */
  18173. private _getEffect;
  18174. /**
  18175. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18176. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  18177. */
  18178. animate(preWarmOnly?: boolean): void;
  18179. private _appendParticleVertices;
  18180. /**
  18181. * Rebuilds the particle system.
  18182. */
  18183. rebuild(): void;
  18184. /**
  18185. * Is this system ready to be used/rendered
  18186. * @return true if the system is ready
  18187. */
  18188. isReady(): boolean;
  18189. private _render;
  18190. /**
  18191. * Renders the particle system in its current state.
  18192. * @returns the current number of particles
  18193. */
  18194. render(): number;
  18195. /**
  18196. * Disposes the particle system and free the associated resources
  18197. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18198. */
  18199. dispose(disposeTexture?: boolean): void;
  18200. /**
  18201. * Clones the particle system.
  18202. * @param name The name of the cloned object
  18203. * @param newEmitter The new emitter to use
  18204. * @returns the cloned particle system
  18205. */
  18206. clone(name: string, newEmitter: any): ParticleSystem;
  18207. /**
  18208. * Serializes the particle system to a JSON object.
  18209. * @returns the JSON object
  18210. */
  18211. serialize(): any;
  18212. /** @hidden */
  18213. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  18214. /** @hidden */
  18215. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  18216. /**
  18217. * Parses a JSON object to create a particle system.
  18218. * @param parsedParticleSystem The JSON object to parse
  18219. * @param scene The scene to create the particle system in
  18220. * @param rootUrl The root url to use to load external dependencies like texture
  18221. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  18222. * @returns the Parsed particle system
  18223. */
  18224. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  18225. }
  18226. }
  18227. declare module "babylonjs/Particles/particle" {
  18228. import { Nullable } from "babylonjs/types";
  18229. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  18230. import { Color4 } from "babylonjs/Maths/math.color";
  18231. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  18232. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  18233. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  18234. /**
  18235. * A particle represents one of the element emitted by a particle system.
  18236. * This is mainly define by its coordinates, direction, velocity and age.
  18237. */
  18238. export class Particle {
  18239. /**
  18240. * The particle system the particle belongs to.
  18241. */
  18242. particleSystem: ParticleSystem;
  18243. private static _Count;
  18244. /**
  18245. * Unique ID of the particle
  18246. */
  18247. id: number;
  18248. /**
  18249. * The world position of the particle in the scene.
  18250. */
  18251. position: Vector3;
  18252. /**
  18253. * The world direction of the particle in the scene.
  18254. */
  18255. direction: Vector3;
  18256. /**
  18257. * The color of the particle.
  18258. */
  18259. color: Color4;
  18260. /**
  18261. * The color change of the particle per step.
  18262. */
  18263. colorStep: Color4;
  18264. /**
  18265. * Defines how long will the life of the particle be.
  18266. */
  18267. lifeTime: number;
  18268. /**
  18269. * The current age of the particle.
  18270. */
  18271. age: number;
  18272. /**
  18273. * The current size of the particle.
  18274. */
  18275. size: number;
  18276. /**
  18277. * The current scale of the particle.
  18278. */
  18279. scale: Vector2;
  18280. /**
  18281. * The current angle of the particle.
  18282. */
  18283. angle: number;
  18284. /**
  18285. * Defines how fast is the angle changing.
  18286. */
  18287. angularSpeed: number;
  18288. /**
  18289. * Defines the cell index used by the particle to be rendered from a sprite.
  18290. */
  18291. cellIndex: number;
  18292. /**
  18293. * The information required to support color remapping
  18294. */
  18295. remapData: Vector4;
  18296. /** @hidden */
  18297. _randomCellOffset?: number;
  18298. /** @hidden */
  18299. _initialDirection: Nullable<Vector3>;
  18300. /** @hidden */
  18301. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18302. /** @hidden */
  18303. _initialStartSpriteCellID: number;
  18304. /** @hidden */
  18305. _initialEndSpriteCellID: number;
  18306. /** @hidden */
  18307. _currentColorGradient: Nullable<ColorGradient>;
  18308. /** @hidden */
  18309. _currentColor1: Color4;
  18310. /** @hidden */
  18311. _currentColor2: Color4;
  18312. /** @hidden */
  18313. _currentSizeGradient: Nullable<FactorGradient>;
  18314. /** @hidden */
  18315. _currentSize1: number;
  18316. /** @hidden */
  18317. _currentSize2: number;
  18318. /** @hidden */
  18319. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18320. /** @hidden */
  18321. _currentAngularSpeed1: number;
  18322. /** @hidden */
  18323. _currentAngularSpeed2: number;
  18324. /** @hidden */
  18325. _currentVelocityGradient: Nullable<FactorGradient>;
  18326. /** @hidden */
  18327. _currentVelocity1: number;
  18328. /** @hidden */
  18329. _currentVelocity2: number;
  18330. /** @hidden */
  18331. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18332. /** @hidden */
  18333. _currentLimitVelocity1: number;
  18334. /** @hidden */
  18335. _currentLimitVelocity2: number;
  18336. /** @hidden */
  18337. _currentDragGradient: Nullable<FactorGradient>;
  18338. /** @hidden */
  18339. _currentDrag1: number;
  18340. /** @hidden */
  18341. _currentDrag2: number;
  18342. /** @hidden */
  18343. _randomNoiseCoordinates1: Vector3;
  18344. /** @hidden */
  18345. _randomNoiseCoordinates2: Vector3;
  18346. /**
  18347. * Creates a new instance Particle
  18348. * @param particleSystem the particle system the particle belongs to
  18349. */
  18350. constructor(
  18351. /**
  18352. * The particle system the particle belongs to.
  18353. */
  18354. particleSystem: ParticleSystem);
  18355. private updateCellInfoFromSystem;
  18356. /**
  18357. * Defines how the sprite cell index is updated for the particle
  18358. */
  18359. updateCellIndex(): void;
  18360. /** @hidden */
  18361. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18362. /** @hidden */
  18363. _inheritParticleInfoToSubEmitters(): void;
  18364. /** @hidden */
  18365. _reset(): void;
  18366. /**
  18367. * Copy the properties of particle to another one.
  18368. * @param other the particle to copy the information to.
  18369. */
  18370. copyTo(other: Particle): void;
  18371. }
  18372. }
  18373. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18374. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18375. import { Effect } from "babylonjs/Materials/effect";
  18376. import { Particle } from "babylonjs/Particles/particle";
  18377. /**
  18378. * Particle emitter represents a volume emitting particles.
  18379. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18380. */
  18381. export interface IParticleEmitterType {
  18382. /**
  18383. * Called by the particle System when the direction is computed for the created particle.
  18384. * @param worldMatrix is the world matrix of the particle system
  18385. * @param directionToUpdate is the direction vector to update with the result
  18386. * @param particle is the particle we are computed the direction for
  18387. */
  18388. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18389. /**
  18390. * Called by the particle System when the position is computed for the created particle.
  18391. * @param worldMatrix is the world matrix of the particle system
  18392. * @param positionToUpdate is the position vector to update with the result
  18393. * @param particle is the particle we are computed the position for
  18394. */
  18395. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18396. /**
  18397. * Clones the current emitter and returns a copy of it
  18398. * @returns the new emitter
  18399. */
  18400. clone(): IParticleEmitterType;
  18401. /**
  18402. * Called by the GPUParticleSystem to setup the update shader
  18403. * @param effect defines the update shader
  18404. */
  18405. applyToShader(effect: Effect): void;
  18406. /**
  18407. * Returns a string to use to update the GPU particles update shader
  18408. * @returns the effect defines string
  18409. */
  18410. getEffectDefines(): string;
  18411. /**
  18412. * Returns a string representing the class name
  18413. * @returns a string containing the class name
  18414. */
  18415. getClassName(): string;
  18416. /**
  18417. * Serializes the particle system to a JSON object.
  18418. * @returns the JSON object
  18419. */
  18420. serialize(): any;
  18421. /**
  18422. * Parse properties from a JSON object
  18423. * @param serializationObject defines the JSON object
  18424. */
  18425. parse(serializationObject: any): void;
  18426. }
  18427. }
  18428. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18429. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18430. import { Effect } from "babylonjs/Materials/effect";
  18431. import { Particle } from "babylonjs/Particles/particle";
  18432. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18433. /**
  18434. * Particle emitter emitting particles from the inside of a box.
  18435. * It emits the particles randomly between 2 given directions.
  18436. */
  18437. export class BoxParticleEmitter implements IParticleEmitterType {
  18438. /**
  18439. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18440. */
  18441. direction1: Vector3;
  18442. /**
  18443. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18444. */
  18445. direction2: Vector3;
  18446. /**
  18447. * 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.
  18448. */
  18449. minEmitBox: Vector3;
  18450. /**
  18451. * 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.
  18452. */
  18453. maxEmitBox: Vector3;
  18454. /**
  18455. * Creates a new instance BoxParticleEmitter
  18456. */
  18457. constructor();
  18458. /**
  18459. * Called by the particle System when the direction is computed for the created particle.
  18460. * @param worldMatrix is the world matrix of the particle system
  18461. * @param directionToUpdate is the direction vector to update with the result
  18462. * @param particle is the particle we are computed the direction for
  18463. */
  18464. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18465. /**
  18466. * Called by the particle System when the position is computed for the created particle.
  18467. * @param worldMatrix is the world matrix of the particle system
  18468. * @param positionToUpdate is the position vector to update with the result
  18469. * @param particle is the particle we are computed the position for
  18470. */
  18471. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18472. /**
  18473. * Clones the current emitter and returns a copy of it
  18474. * @returns the new emitter
  18475. */
  18476. clone(): BoxParticleEmitter;
  18477. /**
  18478. * Called by the GPUParticleSystem to setup the update shader
  18479. * @param effect defines the update shader
  18480. */
  18481. applyToShader(effect: Effect): void;
  18482. /**
  18483. * Returns a string to use to update the GPU particles update shader
  18484. * @returns a string containng the defines string
  18485. */
  18486. getEffectDefines(): string;
  18487. /**
  18488. * Returns the string "BoxParticleEmitter"
  18489. * @returns a string containing the class name
  18490. */
  18491. getClassName(): string;
  18492. /**
  18493. * Serializes the particle system to a JSON object.
  18494. * @returns the JSON object
  18495. */
  18496. serialize(): any;
  18497. /**
  18498. * Parse properties from a JSON object
  18499. * @param serializationObject defines the JSON object
  18500. */
  18501. parse(serializationObject: any): void;
  18502. }
  18503. }
  18504. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18505. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18506. import { Effect } from "babylonjs/Materials/effect";
  18507. import { Particle } from "babylonjs/Particles/particle";
  18508. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18509. /**
  18510. * Particle emitter emitting particles from the inside of a cone.
  18511. * It emits the particles alongside the cone volume from the base to the particle.
  18512. * The emission direction might be randomized.
  18513. */
  18514. export class ConeParticleEmitter implements IParticleEmitterType {
  18515. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18516. directionRandomizer: number;
  18517. private _radius;
  18518. private _angle;
  18519. private _height;
  18520. /**
  18521. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18522. */
  18523. radiusRange: number;
  18524. /**
  18525. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18526. */
  18527. heightRange: number;
  18528. /**
  18529. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18530. */
  18531. emitFromSpawnPointOnly: boolean;
  18532. /**
  18533. * Gets or sets the radius of the emission cone
  18534. */
  18535. get radius(): number;
  18536. set radius(value: number);
  18537. /**
  18538. * Gets or sets the angle of the emission cone
  18539. */
  18540. get angle(): number;
  18541. set angle(value: number);
  18542. private _buildHeight;
  18543. /**
  18544. * Creates a new instance ConeParticleEmitter
  18545. * @param radius the radius of the emission cone (1 by default)
  18546. * @param angle the cone base angle (PI by default)
  18547. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18548. */
  18549. constructor(radius?: number, angle?: number,
  18550. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18551. directionRandomizer?: number);
  18552. /**
  18553. * Called by the particle System when the direction is computed for the created particle.
  18554. * @param worldMatrix is the world matrix of the particle system
  18555. * @param directionToUpdate is the direction vector to update with the result
  18556. * @param particle is the particle we are computed the direction for
  18557. */
  18558. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18559. /**
  18560. * Called by the particle System when the position is computed for the created particle.
  18561. * @param worldMatrix is the world matrix of the particle system
  18562. * @param positionToUpdate is the position vector to update with the result
  18563. * @param particle is the particle we are computed the position for
  18564. */
  18565. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18566. /**
  18567. * Clones the current emitter and returns a copy of it
  18568. * @returns the new emitter
  18569. */
  18570. clone(): ConeParticleEmitter;
  18571. /**
  18572. * Called by the GPUParticleSystem to setup the update shader
  18573. * @param effect defines the update shader
  18574. */
  18575. applyToShader(effect: Effect): void;
  18576. /**
  18577. * Returns a string to use to update the GPU particles update shader
  18578. * @returns a string containng the defines string
  18579. */
  18580. getEffectDefines(): string;
  18581. /**
  18582. * Returns the string "ConeParticleEmitter"
  18583. * @returns a string containing the class name
  18584. */
  18585. getClassName(): string;
  18586. /**
  18587. * Serializes the particle system to a JSON object.
  18588. * @returns the JSON object
  18589. */
  18590. serialize(): any;
  18591. /**
  18592. * Parse properties from a JSON object
  18593. * @param serializationObject defines the JSON object
  18594. */
  18595. parse(serializationObject: any): void;
  18596. }
  18597. }
  18598. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18599. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18600. import { Effect } from "babylonjs/Materials/effect";
  18601. import { Particle } from "babylonjs/Particles/particle";
  18602. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18603. /**
  18604. * Particle emitter emitting particles from the inside of a cylinder.
  18605. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18606. */
  18607. export class CylinderParticleEmitter implements IParticleEmitterType {
  18608. /**
  18609. * The radius of the emission cylinder.
  18610. */
  18611. radius: number;
  18612. /**
  18613. * The height of the emission cylinder.
  18614. */
  18615. height: number;
  18616. /**
  18617. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18618. */
  18619. radiusRange: number;
  18620. /**
  18621. * How much to randomize the particle direction [0-1].
  18622. */
  18623. directionRandomizer: number;
  18624. /**
  18625. * Creates a new instance CylinderParticleEmitter
  18626. * @param radius the radius of the emission cylinder (1 by default)
  18627. * @param height the height of the emission cylinder (1 by default)
  18628. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18629. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18630. */
  18631. constructor(
  18632. /**
  18633. * The radius of the emission cylinder.
  18634. */
  18635. radius?: number,
  18636. /**
  18637. * The height of the emission cylinder.
  18638. */
  18639. height?: number,
  18640. /**
  18641. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18642. */
  18643. radiusRange?: number,
  18644. /**
  18645. * How much to randomize the particle direction [0-1].
  18646. */
  18647. directionRandomizer?: number);
  18648. /**
  18649. * Called by the particle System when the direction is computed for the created particle.
  18650. * @param worldMatrix is the world matrix of the particle system
  18651. * @param directionToUpdate is the direction vector to update with the result
  18652. * @param particle is the particle we are computed the direction for
  18653. */
  18654. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18655. /**
  18656. * Called by the particle System when the position is computed for the created particle.
  18657. * @param worldMatrix is the world matrix of the particle system
  18658. * @param positionToUpdate is the position vector to update with the result
  18659. * @param particle is the particle we are computed the position for
  18660. */
  18661. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18662. /**
  18663. * Clones the current emitter and returns a copy of it
  18664. * @returns the new emitter
  18665. */
  18666. clone(): CylinderParticleEmitter;
  18667. /**
  18668. * Called by the GPUParticleSystem to setup the update shader
  18669. * @param effect defines the update shader
  18670. */
  18671. applyToShader(effect: Effect): void;
  18672. /**
  18673. * Returns a string to use to update the GPU particles update shader
  18674. * @returns a string containng the defines string
  18675. */
  18676. getEffectDefines(): string;
  18677. /**
  18678. * Returns the string "CylinderParticleEmitter"
  18679. * @returns a string containing the class name
  18680. */
  18681. getClassName(): string;
  18682. /**
  18683. * Serializes the particle system to a JSON object.
  18684. * @returns the JSON object
  18685. */
  18686. serialize(): any;
  18687. /**
  18688. * Parse properties from a JSON object
  18689. * @param serializationObject defines the JSON object
  18690. */
  18691. parse(serializationObject: any): void;
  18692. }
  18693. /**
  18694. * Particle emitter emitting particles from the inside of a cylinder.
  18695. * It emits the particles randomly between two vectors.
  18696. */
  18697. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18698. /**
  18699. * The min limit of the emission direction.
  18700. */
  18701. direction1: Vector3;
  18702. /**
  18703. * The max limit of the emission direction.
  18704. */
  18705. direction2: Vector3;
  18706. /**
  18707. * Creates a new instance CylinderDirectedParticleEmitter
  18708. * @param radius the radius of the emission cylinder (1 by default)
  18709. * @param height the height of the emission cylinder (1 by default)
  18710. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18711. * @param direction1 the min limit of the emission direction (up vector by default)
  18712. * @param direction2 the max limit of the emission direction (up vector by default)
  18713. */
  18714. constructor(radius?: number, height?: number, radiusRange?: number,
  18715. /**
  18716. * The min limit of the emission direction.
  18717. */
  18718. direction1?: Vector3,
  18719. /**
  18720. * The max limit of the emission direction.
  18721. */
  18722. direction2?: Vector3);
  18723. /**
  18724. * Called by the particle System when the direction is computed for the created particle.
  18725. * @param worldMatrix is the world matrix of the particle system
  18726. * @param directionToUpdate is the direction vector to update with the result
  18727. * @param particle is the particle we are computed the direction for
  18728. */
  18729. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18730. /**
  18731. * Clones the current emitter and returns a copy of it
  18732. * @returns the new emitter
  18733. */
  18734. clone(): CylinderDirectedParticleEmitter;
  18735. /**
  18736. * Called by the GPUParticleSystem to setup the update shader
  18737. * @param effect defines the update shader
  18738. */
  18739. applyToShader(effect: Effect): void;
  18740. /**
  18741. * Returns a string to use to update the GPU particles update shader
  18742. * @returns a string containng the defines string
  18743. */
  18744. getEffectDefines(): string;
  18745. /**
  18746. * Returns the string "CylinderDirectedParticleEmitter"
  18747. * @returns a string containing the class name
  18748. */
  18749. getClassName(): string;
  18750. /**
  18751. * Serializes the particle system to a JSON object.
  18752. * @returns the JSON object
  18753. */
  18754. serialize(): any;
  18755. /**
  18756. * Parse properties from a JSON object
  18757. * @param serializationObject defines the JSON object
  18758. */
  18759. parse(serializationObject: any): void;
  18760. }
  18761. }
  18762. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18763. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18764. import { Effect } from "babylonjs/Materials/effect";
  18765. import { Particle } from "babylonjs/Particles/particle";
  18766. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18767. /**
  18768. * Particle emitter emitting particles from the inside of a hemisphere.
  18769. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18770. */
  18771. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18772. /**
  18773. * The radius of the emission hemisphere.
  18774. */
  18775. radius: number;
  18776. /**
  18777. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18778. */
  18779. radiusRange: number;
  18780. /**
  18781. * How much to randomize the particle direction [0-1].
  18782. */
  18783. directionRandomizer: number;
  18784. /**
  18785. * Creates a new instance HemisphericParticleEmitter
  18786. * @param radius the radius of the emission hemisphere (1 by default)
  18787. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18788. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18789. */
  18790. constructor(
  18791. /**
  18792. * The radius of the emission hemisphere.
  18793. */
  18794. radius?: number,
  18795. /**
  18796. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18797. */
  18798. radiusRange?: number,
  18799. /**
  18800. * How much to randomize the particle direction [0-1].
  18801. */
  18802. directionRandomizer?: number);
  18803. /**
  18804. * Called by the particle System when the direction is computed for the created particle.
  18805. * @param worldMatrix is the world matrix of the particle system
  18806. * @param directionToUpdate is the direction vector to update with the result
  18807. * @param particle is the particle we are computed the direction for
  18808. */
  18809. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18810. /**
  18811. * Called by the particle System when the position is computed for the created particle.
  18812. * @param worldMatrix is the world matrix of the particle system
  18813. * @param positionToUpdate is the position vector to update with the result
  18814. * @param particle is the particle we are computed the position for
  18815. */
  18816. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18817. /**
  18818. * Clones the current emitter and returns a copy of it
  18819. * @returns the new emitter
  18820. */
  18821. clone(): HemisphericParticleEmitter;
  18822. /**
  18823. * Called by the GPUParticleSystem to setup the update shader
  18824. * @param effect defines the update shader
  18825. */
  18826. applyToShader(effect: Effect): void;
  18827. /**
  18828. * Returns a string to use to update the GPU particles update shader
  18829. * @returns a string containng the defines string
  18830. */
  18831. getEffectDefines(): string;
  18832. /**
  18833. * Returns the string "HemisphericParticleEmitter"
  18834. * @returns a string containing the class name
  18835. */
  18836. getClassName(): string;
  18837. /**
  18838. * Serializes the particle system to a JSON object.
  18839. * @returns the JSON object
  18840. */
  18841. serialize(): any;
  18842. /**
  18843. * Parse properties from a JSON object
  18844. * @param serializationObject defines the JSON object
  18845. */
  18846. parse(serializationObject: any): void;
  18847. }
  18848. }
  18849. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18850. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18851. import { Effect } from "babylonjs/Materials/effect";
  18852. import { Particle } from "babylonjs/Particles/particle";
  18853. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18854. /**
  18855. * Particle emitter emitting particles from a point.
  18856. * It emits the particles randomly between 2 given directions.
  18857. */
  18858. export class PointParticleEmitter implements IParticleEmitterType {
  18859. /**
  18860. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18861. */
  18862. direction1: Vector3;
  18863. /**
  18864. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18865. */
  18866. direction2: Vector3;
  18867. /**
  18868. * Creates a new instance PointParticleEmitter
  18869. */
  18870. constructor();
  18871. /**
  18872. * Called by the particle System when the direction is computed for the created particle.
  18873. * @param worldMatrix is the world matrix of the particle system
  18874. * @param directionToUpdate is the direction vector to update with the result
  18875. * @param particle is the particle we are computed the direction for
  18876. */
  18877. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18878. /**
  18879. * Called by the particle System when the position is computed for the created particle.
  18880. * @param worldMatrix is the world matrix of the particle system
  18881. * @param positionToUpdate is the position vector to update with the result
  18882. * @param particle is the particle we are computed the position for
  18883. */
  18884. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18885. /**
  18886. * Clones the current emitter and returns a copy of it
  18887. * @returns the new emitter
  18888. */
  18889. clone(): PointParticleEmitter;
  18890. /**
  18891. * Called by the GPUParticleSystem to setup the update shader
  18892. * @param effect defines the update shader
  18893. */
  18894. applyToShader(effect: Effect): void;
  18895. /**
  18896. * Returns a string to use to update the GPU particles update shader
  18897. * @returns a string containng the defines string
  18898. */
  18899. getEffectDefines(): string;
  18900. /**
  18901. * Returns the string "PointParticleEmitter"
  18902. * @returns a string containing the class name
  18903. */
  18904. getClassName(): string;
  18905. /**
  18906. * Serializes the particle system to a JSON object.
  18907. * @returns the JSON object
  18908. */
  18909. serialize(): any;
  18910. /**
  18911. * Parse properties from a JSON object
  18912. * @param serializationObject defines the JSON object
  18913. */
  18914. parse(serializationObject: any): void;
  18915. }
  18916. }
  18917. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18918. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18919. import { Effect } from "babylonjs/Materials/effect";
  18920. import { Particle } from "babylonjs/Particles/particle";
  18921. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18922. /**
  18923. * Particle emitter emitting particles from the inside of a sphere.
  18924. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18925. */
  18926. export class SphereParticleEmitter implements IParticleEmitterType {
  18927. /**
  18928. * The radius of the emission sphere.
  18929. */
  18930. radius: number;
  18931. /**
  18932. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18933. */
  18934. radiusRange: number;
  18935. /**
  18936. * How much to randomize the particle direction [0-1].
  18937. */
  18938. directionRandomizer: number;
  18939. /**
  18940. * Creates a new instance SphereParticleEmitter
  18941. * @param radius the radius of the emission sphere (1 by default)
  18942. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18943. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18944. */
  18945. constructor(
  18946. /**
  18947. * The radius of the emission sphere.
  18948. */
  18949. radius?: number,
  18950. /**
  18951. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18952. */
  18953. radiusRange?: number,
  18954. /**
  18955. * How much to randomize the particle direction [0-1].
  18956. */
  18957. directionRandomizer?: number);
  18958. /**
  18959. * Called by the particle System when the direction is computed for the created particle.
  18960. * @param worldMatrix is the world matrix of the particle system
  18961. * @param directionToUpdate is the direction vector to update with the result
  18962. * @param particle is the particle we are computed the direction for
  18963. */
  18964. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18965. /**
  18966. * Called by the particle System when the position is computed for the created particle.
  18967. * @param worldMatrix is the world matrix of the particle system
  18968. * @param positionToUpdate is the position vector to update with the result
  18969. * @param particle is the particle we are computed the position for
  18970. */
  18971. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18972. /**
  18973. * Clones the current emitter and returns a copy of it
  18974. * @returns the new emitter
  18975. */
  18976. clone(): SphereParticleEmitter;
  18977. /**
  18978. * Called by the GPUParticleSystem to setup the update shader
  18979. * @param effect defines the update shader
  18980. */
  18981. applyToShader(effect: Effect): void;
  18982. /**
  18983. * Returns a string to use to update the GPU particles update shader
  18984. * @returns a string containng the defines string
  18985. */
  18986. getEffectDefines(): string;
  18987. /**
  18988. * Returns the string "SphereParticleEmitter"
  18989. * @returns a string containing the class name
  18990. */
  18991. getClassName(): string;
  18992. /**
  18993. * Serializes the particle system to a JSON object.
  18994. * @returns the JSON object
  18995. */
  18996. serialize(): any;
  18997. /**
  18998. * Parse properties from a JSON object
  18999. * @param serializationObject defines the JSON object
  19000. */
  19001. parse(serializationObject: any): void;
  19002. }
  19003. /**
  19004. * Particle emitter emitting particles from the inside of a sphere.
  19005. * It emits the particles randomly between two vectors.
  19006. */
  19007. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  19008. /**
  19009. * The min limit of the emission direction.
  19010. */
  19011. direction1: Vector3;
  19012. /**
  19013. * The max limit of the emission direction.
  19014. */
  19015. direction2: Vector3;
  19016. /**
  19017. * Creates a new instance SphereDirectedParticleEmitter
  19018. * @param radius the radius of the emission sphere (1 by default)
  19019. * @param direction1 the min limit of the emission direction (up vector by default)
  19020. * @param direction2 the max limit of the emission direction (up vector by default)
  19021. */
  19022. constructor(radius?: number,
  19023. /**
  19024. * The min limit of the emission direction.
  19025. */
  19026. direction1?: Vector3,
  19027. /**
  19028. * The max limit of the emission direction.
  19029. */
  19030. direction2?: Vector3);
  19031. /**
  19032. * Called by the particle System when the direction is computed for the created particle.
  19033. * @param worldMatrix is the world matrix of the particle system
  19034. * @param directionToUpdate is the direction vector to update with the result
  19035. * @param particle is the particle we are computed the direction for
  19036. */
  19037. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  19038. /**
  19039. * Clones the current emitter and returns a copy of it
  19040. * @returns the new emitter
  19041. */
  19042. clone(): SphereDirectedParticleEmitter;
  19043. /**
  19044. * Called by the GPUParticleSystem to setup the update shader
  19045. * @param effect defines the update shader
  19046. */
  19047. applyToShader(effect: Effect): void;
  19048. /**
  19049. * Returns a string to use to update the GPU particles update shader
  19050. * @returns a string containng the defines string
  19051. */
  19052. getEffectDefines(): string;
  19053. /**
  19054. * Returns the string "SphereDirectedParticleEmitter"
  19055. * @returns a string containing the class name
  19056. */
  19057. getClassName(): string;
  19058. /**
  19059. * Serializes the particle system to a JSON object.
  19060. * @returns the JSON object
  19061. */
  19062. serialize(): any;
  19063. /**
  19064. * Parse properties from a JSON object
  19065. * @param serializationObject defines the JSON object
  19066. */
  19067. parse(serializationObject: any): void;
  19068. }
  19069. }
  19070. declare module "babylonjs/Particles/EmitterTypes/index" {
  19071. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  19072. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  19073. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  19074. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  19075. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  19076. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  19077. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  19078. }
  19079. declare module "babylonjs/Particles/IParticleSystem" {
  19080. import { Nullable } from "babylonjs/types";
  19081. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  19082. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19083. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19084. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19085. import { Texture } from "babylonjs/Materials/Textures/texture";
  19086. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  19087. import { Scene } from "babylonjs/scene";
  19088. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  19089. import { Animation } from "babylonjs/Animations/animation";
  19090. /**
  19091. * Interface representing a particle system in Babylon.js.
  19092. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  19093. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  19094. */
  19095. export interface IParticleSystem {
  19096. /**
  19097. * List of animations used by the particle system.
  19098. */
  19099. animations: Animation[];
  19100. /**
  19101. * The id of the Particle system.
  19102. */
  19103. id: string;
  19104. /**
  19105. * The name of the Particle system.
  19106. */
  19107. name: string;
  19108. /**
  19109. * The emitter represents the Mesh or position we are attaching the particle system to.
  19110. */
  19111. emitter: Nullable<AbstractMesh | Vector3>;
  19112. /**
  19113. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19114. */
  19115. isBillboardBased: boolean;
  19116. /**
  19117. * The rendering group used by the Particle system to chose when to render.
  19118. */
  19119. renderingGroupId: number;
  19120. /**
  19121. * The layer mask we are rendering the particles through.
  19122. */
  19123. layerMask: number;
  19124. /**
  19125. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19126. */
  19127. updateSpeed: number;
  19128. /**
  19129. * The amount of time the particle system is running (depends of the overall update speed).
  19130. */
  19131. targetStopDuration: number;
  19132. /**
  19133. * The texture used to render each particle. (this can be a spritesheet)
  19134. */
  19135. particleTexture: Nullable<Texture>;
  19136. /**
  19137. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  19138. */
  19139. blendMode: number;
  19140. /**
  19141. * Minimum life time of emitting particles.
  19142. */
  19143. minLifeTime: number;
  19144. /**
  19145. * Maximum life time of emitting particles.
  19146. */
  19147. maxLifeTime: number;
  19148. /**
  19149. * Minimum Size of emitting particles.
  19150. */
  19151. minSize: number;
  19152. /**
  19153. * Maximum Size of emitting particles.
  19154. */
  19155. maxSize: number;
  19156. /**
  19157. * Minimum scale of emitting particles on X axis.
  19158. */
  19159. minScaleX: number;
  19160. /**
  19161. * Maximum scale of emitting particles on X axis.
  19162. */
  19163. maxScaleX: number;
  19164. /**
  19165. * Minimum scale of emitting particles on Y axis.
  19166. */
  19167. minScaleY: number;
  19168. /**
  19169. * Maximum scale of emitting particles on Y axis.
  19170. */
  19171. maxScaleY: number;
  19172. /**
  19173. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19174. */
  19175. color1: Color4;
  19176. /**
  19177. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19178. */
  19179. color2: Color4;
  19180. /**
  19181. * Color the particle will have at the end of its lifetime.
  19182. */
  19183. colorDead: Color4;
  19184. /**
  19185. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19186. */
  19187. emitRate: number;
  19188. /**
  19189. * You can use gravity if you want to give an orientation to your particles.
  19190. */
  19191. gravity: Vector3;
  19192. /**
  19193. * Minimum power of emitting particles.
  19194. */
  19195. minEmitPower: number;
  19196. /**
  19197. * Maximum power of emitting particles.
  19198. */
  19199. maxEmitPower: number;
  19200. /**
  19201. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19202. */
  19203. minAngularSpeed: number;
  19204. /**
  19205. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19206. */
  19207. maxAngularSpeed: number;
  19208. /**
  19209. * Gets or sets the minimal initial rotation in radians.
  19210. */
  19211. minInitialRotation: number;
  19212. /**
  19213. * Gets or sets the maximal initial rotation in radians.
  19214. */
  19215. maxInitialRotation: number;
  19216. /**
  19217. * The particle emitter type defines the emitter used by the particle system.
  19218. * It can be for example box, sphere, or cone...
  19219. */
  19220. particleEmitterType: Nullable<IParticleEmitterType>;
  19221. /**
  19222. * Defines the delay in milliseconds before starting the system (0 by default)
  19223. */
  19224. startDelay: number;
  19225. /**
  19226. * 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
  19227. */
  19228. preWarmCycles: number;
  19229. /**
  19230. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  19231. */
  19232. preWarmStepOffset: number;
  19233. /**
  19234. * 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)
  19235. */
  19236. spriteCellChangeSpeed: number;
  19237. /**
  19238. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19239. */
  19240. startSpriteCellID: number;
  19241. /**
  19242. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19243. */
  19244. endSpriteCellID: number;
  19245. /**
  19246. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19247. */
  19248. spriteCellWidth: number;
  19249. /**
  19250. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19251. */
  19252. spriteCellHeight: number;
  19253. /**
  19254. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19255. */
  19256. spriteRandomStartCell: boolean;
  19257. /**
  19258. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  19259. */
  19260. isAnimationSheetEnabled: boolean;
  19261. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19262. translationPivot: Vector2;
  19263. /**
  19264. * Gets or sets a texture used to add random noise to particle positions
  19265. */
  19266. noiseTexture: Nullable<BaseTexture>;
  19267. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19268. noiseStrength: Vector3;
  19269. /**
  19270. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19271. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19272. */
  19273. billboardMode: number;
  19274. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19275. limitVelocityDamping: number;
  19276. /**
  19277. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19278. */
  19279. beginAnimationOnStart: boolean;
  19280. /**
  19281. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19282. */
  19283. beginAnimationFrom: number;
  19284. /**
  19285. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19286. */
  19287. beginAnimationTo: number;
  19288. /**
  19289. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19290. */
  19291. beginAnimationLoop: boolean;
  19292. /**
  19293. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19294. */
  19295. disposeOnStop: boolean;
  19296. /**
  19297. * Gets the maximum number of particles active at the same time.
  19298. * @returns The max number of active particles.
  19299. */
  19300. getCapacity(): number;
  19301. /**
  19302. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19303. * @returns True if it has been started, otherwise false.
  19304. */
  19305. isStarted(): boolean;
  19306. /**
  19307. * Animates the particle system for this frame.
  19308. */
  19309. animate(): void;
  19310. /**
  19311. * Renders the particle system in its current state.
  19312. * @returns the current number of particles
  19313. */
  19314. render(): number;
  19315. /**
  19316. * Dispose the particle system and frees its associated resources.
  19317. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19318. */
  19319. dispose(disposeTexture?: boolean): void;
  19320. /**
  19321. * Clones the particle system.
  19322. * @param name The name of the cloned object
  19323. * @param newEmitter The new emitter to use
  19324. * @returns the cloned particle system
  19325. */
  19326. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19327. /**
  19328. * Serializes the particle system to a JSON object.
  19329. * @returns the JSON object
  19330. */
  19331. serialize(): any;
  19332. /**
  19333. * Rebuild the particle system
  19334. */
  19335. rebuild(): void;
  19336. /**
  19337. * Starts the particle system and begins to emit
  19338. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19339. */
  19340. start(delay?: number): void;
  19341. /**
  19342. * Stops the particle system.
  19343. */
  19344. stop(): void;
  19345. /**
  19346. * Remove all active particles
  19347. */
  19348. reset(): void;
  19349. /**
  19350. * Is this system ready to be used/rendered
  19351. * @return true if the system is ready
  19352. */
  19353. isReady(): boolean;
  19354. /**
  19355. * Adds a new color gradient
  19356. * @param gradient defines the gradient to use (between 0 and 1)
  19357. * @param color1 defines the color to affect to the specified gradient
  19358. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19359. * @returns the current particle system
  19360. */
  19361. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19362. /**
  19363. * Remove a specific color gradient
  19364. * @param gradient defines the gradient to remove
  19365. * @returns the current particle system
  19366. */
  19367. removeColorGradient(gradient: number): IParticleSystem;
  19368. /**
  19369. * Adds a new size gradient
  19370. * @param gradient defines the gradient to use (between 0 and 1)
  19371. * @param factor defines the size factor to affect to the specified gradient
  19372. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19373. * @returns the current particle system
  19374. */
  19375. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19376. /**
  19377. * Remove a specific size gradient
  19378. * @param gradient defines the gradient to remove
  19379. * @returns the current particle system
  19380. */
  19381. removeSizeGradient(gradient: number): IParticleSystem;
  19382. /**
  19383. * Gets the current list of color gradients.
  19384. * You must use addColorGradient and removeColorGradient to udpate this list
  19385. * @returns the list of color gradients
  19386. */
  19387. getColorGradients(): Nullable<Array<ColorGradient>>;
  19388. /**
  19389. * Gets the current list of size gradients.
  19390. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19391. * @returns the list of size gradients
  19392. */
  19393. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19394. /**
  19395. * Gets the current list of angular speed gradients.
  19396. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19397. * @returns the list of angular speed gradients
  19398. */
  19399. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19400. /**
  19401. * Adds a new angular speed gradient
  19402. * @param gradient defines the gradient to use (between 0 and 1)
  19403. * @param factor defines the angular speed to affect to the specified gradient
  19404. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19405. * @returns the current particle system
  19406. */
  19407. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19408. /**
  19409. * Remove a specific angular speed gradient
  19410. * @param gradient defines the gradient to remove
  19411. * @returns the current particle system
  19412. */
  19413. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19414. /**
  19415. * Gets the current list of velocity gradients.
  19416. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19417. * @returns the list of velocity gradients
  19418. */
  19419. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19420. /**
  19421. * Adds a new velocity gradient
  19422. * @param gradient defines the gradient to use (between 0 and 1)
  19423. * @param factor defines the velocity to affect to the specified gradient
  19424. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19425. * @returns the current particle system
  19426. */
  19427. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19428. /**
  19429. * Remove a specific velocity gradient
  19430. * @param gradient defines the gradient to remove
  19431. * @returns the current particle system
  19432. */
  19433. removeVelocityGradient(gradient: number): IParticleSystem;
  19434. /**
  19435. * Gets the current list of limit velocity gradients.
  19436. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19437. * @returns the list of limit velocity gradients
  19438. */
  19439. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19440. /**
  19441. * Adds a new limit velocity gradient
  19442. * @param gradient defines the gradient to use (between 0 and 1)
  19443. * @param factor defines the limit velocity to affect to the specified gradient
  19444. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19445. * @returns the current particle system
  19446. */
  19447. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19448. /**
  19449. * Remove a specific limit velocity gradient
  19450. * @param gradient defines the gradient to remove
  19451. * @returns the current particle system
  19452. */
  19453. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19454. /**
  19455. * Adds a new drag gradient
  19456. * @param gradient defines the gradient to use (between 0 and 1)
  19457. * @param factor defines the drag to affect to the specified gradient
  19458. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19459. * @returns the current particle system
  19460. */
  19461. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19462. /**
  19463. * Remove a specific drag gradient
  19464. * @param gradient defines the gradient to remove
  19465. * @returns the current particle system
  19466. */
  19467. removeDragGradient(gradient: number): IParticleSystem;
  19468. /**
  19469. * Gets the current list of drag gradients.
  19470. * You must use addDragGradient and removeDragGradient to udpate this list
  19471. * @returns the list of drag gradients
  19472. */
  19473. getDragGradients(): Nullable<Array<FactorGradient>>;
  19474. /**
  19475. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19476. * @param gradient defines the gradient to use (between 0 and 1)
  19477. * @param factor defines the emit rate to affect to the specified gradient
  19478. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19479. * @returns the current particle system
  19480. */
  19481. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19482. /**
  19483. * Remove a specific emit rate gradient
  19484. * @param gradient defines the gradient to remove
  19485. * @returns the current particle system
  19486. */
  19487. removeEmitRateGradient(gradient: number): IParticleSystem;
  19488. /**
  19489. * Gets the current list of emit rate gradients.
  19490. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19491. * @returns the list of emit rate gradients
  19492. */
  19493. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19494. /**
  19495. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19496. * @param gradient defines the gradient to use (between 0 and 1)
  19497. * @param factor defines the start size to affect to the specified gradient
  19498. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19499. * @returns the current particle system
  19500. */
  19501. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19502. /**
  19503. * Remove a specific start size gradient
  19504. * @param gradient defines the gradient to remove
  19505. * @returns the current particle system
  19506. */
  19507. removeStartSizeGradient(gradient: number): IParticleSystem;
  19508. /**
  19509. * Gets the current list of start size gradients.
  19510. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19511. * @returns the list of start size gradients
  19512. */
  19513. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19514. /**
  19515. * Adds a new life time gradient
  19516. * @param gradient defines the gradient to use (between 0 and 1)
  19517. * @param factor defines the life time factor to affect to the specified gradient
  19518. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19519. * @returns the current particle system
  19520. */
  19521. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19522. /**
  19523. * Remove a specific life time gradient
  19524. * @param gradient defines the gradient to remove
  19525. * @returns the current particle system
  19526. */
  19527. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19528. /**
  19529. * Gets the current list of life time gradients.
  19530. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19531. * @returns the list of life time gradients
  19532. */
  19533. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19534. /**
  19535. * Gets the current list of color gradients.
  19536. * You must use addColorGradient and removeColorGradient to udpate this list
  19537. * @returns the list of color gradients
  19538. */
  19539. getColorGradients(): Nullable<Array<ColorGradient>>;
  19540. /**
  19541. * Adds a new ramp gradient used to remap particle colors
  19542. * @param gradient defines the gradient to use (between 0 and 1)
  19543. * @param color defines the color to affect to the specified gradient
  19544. * @returns the current particle system
  19545. */
  19546. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19547. /**
  19548. * Gets the current list of ramp gradients.
  19549. * You must use addRampGradient and removeRampGradient to udpate this list
  19550. * @returns the list of ramp gradients
  19551. */
  19552. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19553. /** Gets or sets a boolean indicating that ramp gradients must be used
  19554. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19555. */
  19556. useRampGradients: boolean;
  19557. /**
  19558. * Adds a new color remap gradient
  19559. * @param gradient defines the gradient to use (between 0 and 1)
  19560. * @param min defines the color remap minimal range
  19561. * @param max defines the color remap maximal range
  19562. * @returns the current particle system
  19563. */
  19564. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19565. /**
  19566. * Gets the current list of color remap gradients.
  19567. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19568. * @returns the list of color remap gradients
  19569. */
  19570. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19571. /**
  19572. * Adds a new alpha remap gradient
  19573. * @param gradient defines the gradient to use (between 0 and 1)
  19574. * @param min defines the alpha remap minimal range
  19575. * @param max defines the alpha remap maximal range
  19576. * @returns the current particle system
  19577. */
  19578. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19579. /**
  19580. * Gets the current list of alpha remap gradients.
  19581. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19582. * @returns the list of alpha remap gradients
  19583. */
  19584. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19585. /**
  19586. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19587. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19588. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19589. * @returns the emitter
  19590. */
  19591. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19592. /**
  19593. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19594. * @param radius The radius of the hemisphere to emit from
  19595. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19596. * @returns the emitter
  19597. */
  19598. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19599. /**
  19600. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19601. * @param radius The radius of the sphere to emit from
  19602. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19603. * @returns the emitter
  19604. */
  19605. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19606. /**
  19607. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19608. * @param radius The radius of the sphere to emit from
  19609. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19610. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19611. * @returns the emitter
  19612. */
  19613. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19614. /**
  19615. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19616. * @param radius The radius of the emission cylinder
  19617. * @param height The height of the emission cylinder
  19618. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19619. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19620. * @returns the emitter
  19621. */
  19622. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19623. /**
  19624. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19625. * @param radius The radius of the cylinder to emit from
  19626. * @param height The height of the emission cylinder
  19627. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19628. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19629. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19630. * @returns the emitter
  19631. */
  19632. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19633. /**
  19634. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19635. * @param radius The radius of the cone to emit from
  19636. * @param angle The base angle of the cone
  19637. * @returns the emitter
  19638. */
  19639. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19640. /**
  19641. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19642. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19643. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19644. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19645. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19646. * @returns the emitter
  19647. */
  19648. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19649. /**
  19650. * Get hosting scene
  19651. * @returns the scene
  19652. */
  19653. getScene(): Scene;
  19654. }
  19655. }
  19656. declare module "babylonjs/Meshes/instancedMesh" {
  19657. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19658. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19659. import { Camera } from "babylonjs/Cameras/camera";
  19660. import { Node } from "babylonjs/node";
  19661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19662. import { Mesh } from "babylonjs/Meshes/mesh";
  19663. import { Material } from "babylonjs/Materials/material";
  19664. import { Skeleton } from "babylonjs/Bones/skeleton";
  19665. import { Light } from "babylonjs/Lights/light";
  19666. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19667. /**
  19668. * Creates an instance based on a source mesh.
  19669. */
  19670. export class InstancedMesh extends AbstractMesh {
  19671. private _sourceMesh;
  19672. private _currentLOD;
  19673. /** @hidden */
  19674. _indexInSourceMeshInstanceArray: number;
  19675. constructor(name: string, source: Mesh);
  19676. /**
  19677. * Returns the string "InstancedMesh".
  19678. */
  19679. getClassName(): string;
  19680. /** Gets the list of lights affecting that mesh */
  19681. get lightSources(): Light[];
  19682. _resyncLightSources(): void;
  19683. _resyncLightSource(light: Light): void;
  19684. _removeLightSource(light: Light, dispose: boolean): void;
  19685. /**
  19686. * If the source mesh receives shadows
  19687. */
  19688. get receiveShadows(): boolean;
  19689. /**
  19690. * The material of the source mesh
  19691. */
  19692. get material(): Nullable<Material>;
  19693. /**
  19694. * Visibility of the source mesh
  19695. */
  19696. get visibility(): number;
  19697. /**
  19698. * Skeleton of the source mesh
  19699. */
  19700. get skeleton(): Nullable<Skeleton>;
  19701. /**
  19702. * Rendering ground id of the source mesh
  19703. */
  19704. get renderingGroupId(): number;
  19705. set renderingGroupId(value: number);
  19706. /**
  19707. * Returns the total number of vertices (integer).
  19708. */
  19709. getTotalVertices(): number;
  19710. /**
  19711. * Returns a positive integer : the total number of indices in this mesh geometry.
  19712. * @returns the numner of indices or zero if the mesh has no geometry.
  19713. */
  19714. getTotalIndices(): number;
  19715. /**
  19716. * The source mesh of the instance
  19717. */
  19718. get sourceMesh(): Mesh;
  19719. /**
  19720. * Is this node ready to be used/rendered
  19721. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19722. * @return {boolean} is it ready
  19723. */
  19724. isReady(completeCheck?: boolean): boolean;
  19725. /**
  19726. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19727. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19728. * @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.
  19729. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19730. */
  19731. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19732. /**
  19733. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19734. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19735. * The `data` are either a numeric array either a Float32Array.
  19736. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19737. * 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).
  19738. * Note that a new underlying VertexBuffer object is created each call.
  19739. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19740. *
  19741. * Possible `kind` values :
  19742. * - VertexBuffer.PositionKind
  19743. * - VertexBuffer.UVKind
  19744. * - VertexBuffer.UV2Kind
  19745. * - VertexBuffer.UV3Kind
  19746. * - VertexBuffer.UV4Kind
  19747. * - VertexBuffer.UV5Kind
  19748. * - VertexBuffer.UV6Kind
  19749. * - VertexBuffer.ColorKind
  19750. * - VertexBuffer.MatricesIndicesKind
  19751. * - VertexBuffer.MatricesIndicesExtraKind
  19752. * - VertexBuffer.MatricesWeightsKind
  19753. * - VertexBuffer.MatricesWeightsExtraKind
  19754. *
  19755. * Returns the Mesh.
  19756. */
  19757. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19758. /**
  19759. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19760. * If the mesh has no geometry, it is simply returned as it is.
  19761. * The `data` are either a numeric array either a Float32Array.
  19762. * No new underlying VertexBuffer object is created.
  19763. * 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.
  19764. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19765. *
  19766. * Possible `kind` values :
  19767. * - VertexBuffer.PositionKind
  19768. * - VertexBuffer.UVKind
  19769. * - VertexBuffer.UV2Kind
  19770. * - VertexBuffer.UV3Kind
  19771. * - VertexBuffer.UV4Kind
  19772. * - VertexBuffer.UV5Kind
  19773. * - VertexBuffer.UV6Kind
  19774. * - VertexBuffer.ColorKind
  19775. * - VertexBuffer.MatricesIndicesKind
  19776. * - VertexBuffer.MatricesIndicesExtraKind
  19777. * - VertexBuffer.MatricesWeightsKind
  19778. * - VertexBuffer.MatricesWeightsExtraKind
  19779. *
  19780. * Returns the Mesh.
  19781. */
  19782. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19783. /**
  19784. * Sets the mesh indices.
  19785. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19786. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19787. * This method creates a new index buffer each call.
  19788. * Returns the Mesh.
  19789. */
  19790. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19791. /**
  19792. * Boolean : True if the mesh owns the requested kind of data.
  19793. */
  19794. isVerticesDataPresent(kind: string): boolean;
  19795. /**
  19796. * Returns an array of indices (IndicesArray).
  19797. */
  19798. getIndices(): Nullable<IndicesArray>;
  19799. get _positions(): Nullable<Vector3[]>;
  19800. /**
  19801. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19802. * This means the mesh underlying bounding box and sphere are recomputed.
  19803. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19804. * @returns the current mesh
  19805. */
  19806. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19807. /** @hidden */
  19808. _preActivate(): InstancedMesh;
  19809. /** @hidden */
  19810. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19811. /** @hidden */
  19812. _postActivate(): void;
  19813. getWorldMatrix(): Matrix;
  19814. get isAnInstance(): boolean;
  19815. /**
  19816. * Returns the current associated LOD AbstractMesh.
  19817. */
  19818. getLOD(camera: Camera): AbstractMesh;
  19819. /** @hidden */
  19820. _syncSubMeshes(): InstancedMesh;
  19821. /** @hidden */
  19822. _generatePointsArray(): boolean;
  19823. /**
  19824. * Creates a new InstancedMesh from the current mesh.
  19825. * - name (string) : the cloned mesh name
  19826. * - newParent (optional Node) : the optional Node to parent the clone to.
  19827. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19828. *
  19829. * Returns the clone.
  19830. */
  19831. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19832. /**
  19833. * Disposes the InstancedMesh.
  19834. * Returns nothing.
  19835. */
  19836. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19837. }
  19838. module "babylonjs/Meshes/mesh" {
  19839. interface Mesh {
  19840. /**
  19841. * Register a custom buffer that will be instanced
  19842. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19843. * @param kind defines the buffer kind
  19844. * @param stride defines the stride in floats
  19845. */
  19846. registerInstancedBuffer(kind: string, stride: number): void;
  19847. /** @hidden */
  19848. _userInstancedBuffersStorage: {
  19849. data: {
  19850. [key: string]: Float32Array;
  19851. };
  19852. sizes: {
  19853. [key: string]: number;
  19854. };
  19855. vertexBuffers: {
  19856. [key: string]: Nullable<VertexBuffer>;
  19857. };
  19858. strides: {
  19859. [key: string]: number;
  19860. };
  19861. };
  19862. }
  19863. }
  19864. module "babylonjs/Meshes/abstractMesh" {
  19865. interface AbstractMesh {
  19866. /**
  19867. * Object used to store instanced buffers defined by user
  19868. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19869. */
  19870. instancedBuffers: {
  19871. [key: string]: any;
  19872. };
  19873. }
  19874. }
  19875. }
  19876. declare module "babylonjs/Materials/shaderMaterial" {
  19877. import { Scene } from "babylonjs/scene";
  19878. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19880. import { Mesh } from "babylonjs/Meshes/mesh";
  19881. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19882. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19883. import { Texture } from "babylonjs/Materials/Textures/texture";
  19884. import { Material } from "babylonjs/Materials/material";
  19885. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19886. /**
  19887. * Defines the options associated with the creation of a shader material.
  19888. */
  19889. export interface IShaderMaterialOptions {
  19890. /**
  19891. * Does the material work in alpha blend mode
  19892. */
  19893. needAlphaBlending: boolean;
  19894. /**
  19895. * Does the material work in alpha test mode
  19896. */
  19897. needAlphaTesting: boolean;
  19898. /**
  19899. * The list of attribute names used in the shader
  19900. */
  19901. attributes: string[];
  19902. /**
  19903. * The list of unifrom names used in the shader
  19904. */
  19905. uniforms: string[];
  19906. /**
  19907. * The list of UBO names used in the shader
  19908. */
  19909. uniformBuffers: string[];
  19910. /**
  19911. * The list of sampler names used in the shader
  19912. */
  19913. samplers: string[];
  19914. /**
  19915. * The list of defines used in the shader
  19916. */
  19917. defines: string[];
  19918. }
  19919. /**
  19920. * 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.
  19921. *
  19922. * This returned material effects how the mesh will look based on the code in the shaders.
  19923. *
  19924. * @see http://doc.babylonjs.com/how_to/shader_material
  19925. */
  19926. export class ShaderMaterial extends Material {
  19927. private _shaderPath;
  19928. private _options;
  19929. private _textures;
  19930. private _textureArrays;
  19931. private _floats;
  19932. private _ints;
  19933. private _floatsArrays;
  19934. private _colors3;
  19935. private _colors3Arrays;
  19936. private _colors4;
  19937. private _colors4Arrays;
  19938. private _vectors2;
  19939. private _vectors3;
  19940. private _vectors4;
  19941. private _matrices;
  19942. private _matrixArrays;
  19943. private _matrices3x3;
  19944. private _matrices2x2;
  19945. private _vectors2Arrays;
  19946. private _vectors3Arrays;
  19947. private _vectors4Arrays;
  19948. private _cachedWorldViewMatrix;
  19949. private _cachedWorldViewProjectionMatrix;
  19950. private _renderId;
  19951. private _multiview;
  19952. /**
  19953. * Instantiate a new shader material.
  19954. * 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.
  19955. * This returned material effects how the mesh will look based on the code in the shaders.
  19956. * @see http://doc.babylonjs.com/how_to/shader_material
  19957. * @param name Define the name of the material in the scene
  19958. * @param scene Define the scene the material belongs to
  19959. * @param shaderPath Defines the route to the shader code in one of three ways:
  19960. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19961. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19962. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19963. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19964. * @param options Define the options used to create the shader
  19965. */
  19966. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19967. /**
  19968. * Gets the shader path used to define the shader code
  19969. * It can be modified to trigger a new compilation
  19970. */
  19971. get shaderPath(): any;
  19972. /**
  19973. * Sets the shader path used to define the shader code
  19974. * It can be modified to trigger a new compilation
  19975. */
  19976. set shaderPath(shaderPath: any);
  19977. /**
  19978. * Gets the options used to compile the shader.
  19979. * They can be modified to trigger a new compilation
  19980. */
  19981. get options(): IShaderMaterialOptions;
  19982. /**
  19983. * Gets the current class name of the material e.g. "ShaderMaterial"
  19984. * Mainly use in serialization.
  19985. * @returns the class name
  19986. */
  19987. getClassName(): string;
  19988. /**
  19989. * Specifies if the material will require alpha blending
  19990. * @returns a boolean specifying if alpha blending is needed
  19991. */
  19992. needAlphaBlending(): boolean;
  19993. /**
  19994. * Specifies if this material should be rendered in alpha test mode
  19995. * @returns a boolean specifying if an alpha test is needed.
  19996. */
  19997. needAlphaTesting(): boolean;
  19998. private _checkUniform;
  19999. /**
  20000. * Set a texture in the shader.
  20001. * @param name Define the name of the uniform samplers as defined in the shader
  20002. * @param texture Define the texture to bind to this sampler
  20003. * @return the material itself allowing "fluent" like uniform updates
  20004. */
  20005. setTexture(name: string, texture: Texture): ShaderMaterial;
  20006. /**
  20007. * Set a texture array in the shader.
  20008. * @param name Define the name of the uniform sampler array as defined in the shader
  20009. * @param textures Define the list of textures to bind to this sampler
  20010. * @return the material itself allowing "fluent" like uniform updates
  20011. */
  20012. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  20013. /**
  20014. * Set a float in the shader.
  20015. * @param name Define the name of the uniform as defined in the shader
  20016. * @param value Define the value to give to the uniform
  20017. * @return the material itself allowing "fluent" like uniform updates
  20018. */
  20019. setFloat(name: string, value: number): ShaderMaterial;
  20020. /**
  20021. * Set a int in the shader.
  20022. * @param name Define the name of the uniform as defined in the shader
  20023. * @param value Define the value to give to the uniform
  20024. * @return the material itself allowing "fluent" like uniform updates
  20025. */
  20026. setInt(name: string, value: number): ShaderMaterial;
  20027. /**
  20028. * Set an array of floats in the shader.
  20029. * @param name Define the name of the uniform as defined in the shader
  20030. * @param value Define the value to give to the uniform
  20031. * @return the material itself allowing "fluent" like uniform updates
  20032. */
  20033. setFloats(name: string, value: number[]): ShaderMaterial;
  20034. /**
  20035. * Set a vec3 in the shader from a Color3.
  20036. * @param name Define the name of the uniform as defined in the shader
  20037. * @param value Define the value to give to the uniform
  20038. * @return the material itself allowing "fluent" like uniform updates
  20039. */
  20040. setColor3(name: string, value: Color3): ShaderMaterial;
  20041. /**
  20042. * Set a vec3 array in the shader from a Color3 array.
  20043. * @param name Define the name of the uniform as defined in the shader
  20044. * @param value Define the value to give to the uniform
  20045. * @return the material itself allowing "fluent" like uniform updates
  20046. */
  20047. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  20048. /**
  20049. * Set a vec4 in the shader from a Color4.
  20050. * @param name Define the name of the uniform as defined in the shader
  20051. * @param value Define the value to give to the uniform
  20052. * @return the material itself allowing "fluent" like uniform updates
  20053. */
  20054. setColor4(name: string, value: Color4): ShaderMaterial;
  20055. /**
  20056. * Set a vec4 array in the shader from a Color4 array.
  20057. * @param name Define the name of the uniform as defined in the shader
  20058. * @param value Define the value to give to the uniform
  20059. * @return the material itself allowing "fluent" like uniform updates
  20060. */
  20061. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  20062. /**
  20063. * Set a vec2 in the shader from a Vector2.
  20064. * @param name Define the name of the uniform as defined in the shader
  20065. * @param value Define the value to give to the uniform
  20066. * @return the material itself allowing "fluent" like uniform updates
  20067. */
  20068. setVector2(name: string, value: Vector2): ShaderMaterial;
  20069. /**
  20070. * Set a vec3 in the shader from a Vector3.
  20071. * @param name Define the name of the uniform as defined in the shader
  20072. * @param value Define the value to give to the uniform
  20073. * @return the material itself allowing "fluent" like uniform updates
  20074. */
  20075. setVector3(name: string, value: Vector3): ShaderMaterial;
  20076. /**
  20077. * Set a vec4 in the shader from a Vector4.
  20078. * @param name Define the name of the uniform as defined in the shader
  20079. * @param value Define the value to give to the uniform
  20080. * @return the material itself allowing "fluent" like uniform updates
  20081. */
  20082. setVector4(name: string, value: Vector4): ShaderMaterial;
  20083. /**
  20084. * Set a mat4 in the shader from a Matrix.
  20085. * @param name Define the name of the uniform as defined in the shader
  20086. * @param value Define the value to give to the uniform
  20087. * @return the material itself allowing "fluent" like uniform updates
  20088. */
  20089. setMatrix(name: string, value: Matrix): ShaderMaterial;
  20090. /**
  20091. * Set a float32Array in the shader from a matrix array.
  20092. * @param name Define the name of the uniform as defined in the shader
  20093. * @param value Define the value to give to the uniform
  20094. * @return the material itself allowing "fluent" like uniform updates
  20095. */
  20096. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  20097. /**
  20098. * Set a mat3 in the shader from a Float32Array.
  20099. * @param name Define the name of the uniform as defined in the shader
  20100. * @param value Define the value to give to the uniform
  20101. * @return the material itself allowing "fluent" like uniform updates
  20102. */
  20103. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  20104. /**
  20105. * Set a mat2 in the shader from a Float32Array.
  20106. * @param name Define the name of the uniform as defined in the shader
  20107. * @param value Define the value to give to the uniform
  20108. * @return the material itself allowing "fluent" like uniform updates
  20109. */
  20110. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  20111. /**
  20112. * Set a vec2 array in the shader from a number array.
  20113. * @param name Define the name of the uniform as defined in the shader
  20114. * @param value Define the value to give to the uniform
  20115. * @return the material itself allowing "fluent" like uniform updates
  20116. */
  20117. setArray2(name: string, value: number[]): ShaderMaterial;
  20118. /**
  20119. * Set a vec3 array in the shader from a number array.
  20120. * @param name Define the name of the uniform as defined in the shader
  20121. * @param value Define the value to give to the uniform
  20122. * @return the material itself allowing "fluent" like uniform updates
  20123. */
  20124. setArray3(name: string, value: number[]): ShaderMaterial;
  20125. /**
  20126. * Set a vec4 array in the shader from a number array.
  20127. * @param name Define the name of the uniform as defined in the shader
  20128. * @param value Define the value to give to the uniform
  20129. * @return the material itself allowing "fluent" like uniform updates
  20130. */
  20131. setArray4(name: string, value: number[]): ShaderMaterial;
  20132. private _checkCache;
  20133. /**
  20134. * Specifies that the submesh is ready to be used
  20135. * @param mesh defines the mesh to check
  20136. * @param subMesh defines which submesh to check
  20137. * @param useInstances specifies that instances should be used
  20138. * @returns a boolean indicating that the submesh is ready or not
  20139. */
  20140. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20141. /**
  20142. * Checks if the material is ready to render the requested mesh
  20143. * @param mesh Define the mesh to render
  20144. * @param useInstances Define whether or not the material is used with instances
  20145. * @returns true if ready, otherwise false
  20146. */
  20147. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20148. /**
  20149. * Binds the world matrix to the material
  20150. * @param world defines the world transformation matrix
  20151. */
  20152. bindOnlyWorldMatrix(world: Matrix): void;
  20153. /**
  20154. * Binds the material to the mesh
  20155. * @param world defines the world transformation matrix
  20156. * @param mesh defines the mesh to bind the material to
  20157. */
  20158. bind(world: Matrix, mesh?: Mesh): void;
  20159. /**
  20160. * Gets the active textures from the material
  20161. * @returns an array of textures
  20162. */
  20163. getActiveTextures(): BaseTexture[];
  20164. /**
  20165. * Specifies if the material uses a texture
  20166. * @param texture defines the texture to check against the material
  20167. * @returns a boolean specifying if the material uses the texture
  20168. */
  20169. hasTexture(texture: BaseTexture): boolean;
  20170. /**
  20171. * Makes a duplicate of the material, and gives it a new name
  20172. * @param name defines the new name for the duplicated material
  20173. * @returns the cloned material
  20174. */
  20175. clone(name: string): ShaderMaterial;
  20176. /**
  20177. * Disposes the material
  20178. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20179. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20180. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20181. */
  20182. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20183. /**
  20184. * Serializes this material in a JSON representation
  20185. * @returns the serialized material object
  20186. */
  20187. serialize(): any;
  20188. /**
  20189. * Creates a shader material from parsed shader material data
  20190. * @param source defines the JSON represnetation of the material
  20191. * @param scene defines the hosting scene
  20192. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20193. * @returns a new material
  20194. */
  20195. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  20196. }
  20197. }
  20198. declare module "babylonjs/Shaders/color.fragment" {
  20199. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20200. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20201. /** @hidden */
  20202. export var colorPixelShader: {
  20203. name: string;
  20204. shader: string;
  20205. };
  20206. }
  20207. declare module "babylonjs/Shaders/color.vertex" {
  20208. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  20209. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20210. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  20211. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  20212. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  20213. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20214. /** @hidden */
  20215. export var colorVertexShader: {
  20216. name: string;
  20217. shader: string;
  20218. };
  20219. }
  20220. declare module "babylonjs/Meshes/linesMesh" {
  20221. import { Nullable } from "babylonjs/types";
  20222. import { Scene } from "babylonjs/scene";
  20223. import { Color3 } from "babylonjs/Maths/math.color";
  20224. import { Node } from "babylonjs/node";
  20225. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20226. import { Mesh } from "babylonjs/Meshes/mesh";
  20227. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20228. import { Effect } from "babylonjs/Materials/effect";
  20229. import { Material } from "babylonjs/Materials/material";
  20230. import "babylonjs/Shaders/color.fragment";
  20231. import "babylonjs/Shaders/color.vertex";
  20232. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20233. /**
  20234. * Line mesh
  20235. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  20236. */
  20237. export class LinesMesh extends Mesh {
  20238. /**
  20239. * If vertex color should be applied to the mesh
  20240. */
  20241. readonly useVertexColor?: boolean | undefined;
  20242. /**
  20243. * If vertex alpha should be applied to the mesh
  20244. */
  20245. readonly useVertexAlpha?: boolean | undefined;
  20246. /**
  20247. * Color of the line (Default: White)
  20248. */
  20249. color: Color3;
  20250. /**
  20251. * Alpha of the line (Default: 1)
  20252. */
  20253. alpha: number;
  20254. /**
  20255. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20256. * This margin is expressed in world space coordinates, so its value may vary.
  20257. * Default value is 0.1
  20258. */
  20259. intersectionThreshold: number;
  20260. private _colorShader;
  20261. private color4;
  20262. /**
  20263. * Creates a new LinesMesh
  20264. * @param name defines the name
  20265. * @param scene defines the hosting scene
  20266. * @param parent defines the parent mesh if any
  20267. * @param source defines the optional source LinesMesh used to clone data from
  20268. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20269. * When false, achieved by calling a clone(), also passing False.
  20270. * This will make creation of children, recursive.
  20271. * @param useVertexColor defines if this LinesMesh supports vertex color
  20272. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  20273. */
  20274. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  20275. /**
  20276. * If vertex color should be applied to the mesh
  20277. */
  20278. useVertexColor?: boolean | undefined,
  20279. /**
  20280. * If vertex alpha should be applied to the mesh
  20281. */
  20282. useVertexAlpha?: boolean | undefined);
  20283. private _addClipPlaneDefine;
  20284. private _removeClipPlaneDefine;
  20285. isReady(): boolean;
  20286. /**
  20287. * Returns the string "LineMesh"
  20288. */
  20289. getClassName(): string;
  20290. /**
  20291. * @hidden
  20292. */
  20293. get material(): Material;
  20294. /**
  20295. * @hidden
  20296. */
  20297. set material(value: Material);
  20298. /**
  20299. * @hidden
  20300. */
  20301. get checkCollisions(): boolean;
  20302. /** @hidden */
  20303. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20304. /** @hidden */
  20305. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20306. /**
  20307. * Disposes of the line mesh
  20308. * @param doNotRecurse If children should be disposed
  20309. */
  20310. dispose(doNotRecurse?: boolean): void;
  20311. /**
  20312. * Returns a new LineMesh object cloned from the current one.
  20313. */
  20314. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20315. /**
  20316. * Creates a new InstancedLinesMesh object from the mesh model.
  20317. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20318. * @param name defines the name of the new instance
  20319. * @returns a new InstancedLinesMesh
  20320. */
  20321. createInstance(name: string): InstancedLinesMesh;
  20322. }
  20323. /**
  20324. * Creates an instance based on a source LinesMesh
  20325. */
  20326. export class InstancedLinesMesh extends InstancedMesh {
  20327. /**
  20328. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20329. * This margin is expressed in world space coordinates, so its value may vary.
  20330. * Initilized with the intersectionThreshold value of the source LinesMesh
  20331. */
  20332. intersectionThreshold: number;
  20333. constructor(name: string, source: LinesMesh);
  20334. /**
  20335. * Returns the string "InstancedLinesMesh".
  20336. */
  20337. getClassName(): string;
  20338. }
  20339. }
  20340. declare module "babylonjs/Shaders/line.fragment" {
  20341. /** @hidden */
  20342. export var linePixelShader: {
  20343. name: string;
  20344. shader: string;
  20345. };
  20346. }
  20347. declare module "babylonjs/Shaders/line.vertex" {
  20348. /** @hidden */
  20349. export var lineVertexShader: {
  20350. name: string;
  20351. shader: string;
  20352. };
  20353. }
  20354. declare module "babylonjs/Rendering/edgesRenderer" {
  20355. import { Nullable } from "babylonjs/types";
  20356. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20357. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20358. import { Vector3 } from "babylonjs/Maths/math.vector";
  20359. import { IDisposable } from "babylonjs/scene";
  20360. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20361. import "babylonjs/Shaders/line.fragment";
  20362. import "babylonjs/Shaders/line.vertex";
  20363. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20364. module "babylonjs/Meshes/abstractMesh" {
  20365. interface AbstractMesh {
  20366. /**
  20367. * Gets the edgesRenderer associated with the mesh
  20368. */
  20369. edgesRenderer: Nullable<EdgesRenderer>;
  20370. }
  20371. }
  20372. module "babylonjs/Meshes/linesMesh" {
  20373. interface LinesMesh {
  20374. /**
  20375. * Enables the edge rendering mode on the mesh.
  20376. * This mode makes the mesh edges visible
  20377. * @param epsilon defines the maximal distance between two angles to detect a face
  20378. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20379. * @returns the currentAbstractMesh
  20380. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20381. */
  20382. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20383. }
  20384. }
  20385. module "babylonjs/Meshes/linesMesh" {
  20386. interface InstancedLinesMesh {
  20387. /**
  20388. * Enables the edge rendering mode on the mesh.
  20389. * This mode makes the mesh edges visible
  20390. * @param epsilon defines the maximal distance between two angles to detect a face
  20391. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20392. * @returns the current InstancedLinesMesh
  20393. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20394. */
  20395. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20396. }
  20397. }
  20398. /**
  20399. * Defines the minimum contract an Edges renderer should follow.
  20400. */
  20401. export interface IEdgesRenderer extends IDisposable {
  20402. /**
  20403. * Gets or sets a boolean indicating if the edgesRenderer is active
  20404. */
  20405. isEnabled: boolean;
  20406. /**
  20407. * Renders the edges of the attached mesh,
  20408. */
  20409. render(): void;
  20410. /**
  20411. * Checks wether or not the edges renderer is ready to render.
  20412. * @return true if ready, otherwise false.
  20413. */
  20414. isReady(): boolean;
  20415. }
  20416. /**
  20417. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20418. */
  20419. export class EdgesRenderer implements IEdgesRenderer {
  20420. /**
  20421. * Define the size of the edges with an orthographic camera
  20422. */
  20423. edgesWidthScalerForOrthographic: number;
  20424. /**
  20425. * Define the size of the edges with a perspective camera
  20426. */
  20427. edgesWidthScalerForPerspective: number;
  20428. protected _source: AbstractMesh;
  20429. protected _linesPositions: number[];
  20430. protected _linesNormals: number[];
  20431. protected _linesIndices: number[];
  20432. protected _epsilon: number;
  20433. protected _indicesCount: number;
  20434. protected _lineShader: ShaderMaterial;
  20435. protected _ib: DataBuffer;
  20436. protected _buffers: {
  20437. [key: string]: Nullable<VertexBuffer>;
  20438. };
  20439. protected _checkVerticesInsteadOfIndices: boolean;
  20440. private _meshRebuildObserver;
  20441. private _meshDisposeObserver;
  20442. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20443. isEnabled: boolean;
  20444. /**
  20445. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20446. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20447. * @param source Mesh used to create edges
  20448. * @param epsilon sum of angles in adjacency to check for edge
  20449. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20450. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20451. */
  20452. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20453. protected _prepareRessources(): void;
  20454. /** @hidden */
  20455. _rebuild(): void;
  20456. /**
  20457. * Releases the required resources for the edges renderer
  20458. */
  20459. dispose(): void;
  20460. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20461. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20462. /**
  20463. * Checks if the pair of p0 and p1 is en edge
  20464. * @param faceIndex
  20465. * @param edge
  20466. * @param faceNormals
  20467. * @param p0
  20468. * @param p1
  20469. * @private
  20470. */
  20471. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20472. /**
  20473. * push line into the position, normal and index buffer
  20474. * @protected
  20475. */
  20476. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20477. /**
  20478. * Generates lines edges from adjacencjes
  20479. * @private
  20480. */
  20481. _generateEdgesLines(): void;
  20482. /**
  20483. * Checks wether or not the edges renderer is ready to render.
  20484. * @return true if ready, otherwise false.
  20485. */
  20486. isReady(): boolean;
  20487. /**
  20488. * Renders the edges of the attached mesh,
  20489. */
  20490. render(): void;
  20491. }
  20492. /**
  20493. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20494. */
  20495. export class LineEdgesRenderer extends EdgesRenderer {
  20496. /**
  20497. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20498. * @param source LineMesh used to generate edges
  20499. * @param epsilon not important (specified angle for edge detection)
  20500. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20501. */
  20502. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20503. /**
  20504. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20505. */
  20506. _generateEdgesLines(): void;
  20507. }
  20508. }
  20509. declare module "babylonjs/Rendering/renderingGroup" {
  20510. import { SmartArray } from "babylonjs/Misc/smartArray";
  20511. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20512. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20513. import { Nullable } from "babylonjs/types";
  20514. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20515. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20516. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20517. import { Material } from "babylonjs/Materials/material";
  20518. import { Scene } from "babylonjs/scene";
  20519. /**
  20520. * This represents the object necessary to create a rendering group.
  20521. * This is exclusively used and created by the rendering manager.
  20522. * To modify the behavior, you use the available helpers in your scene or meshes.
  20523. * @hidden
  20524. */
  20525. export class RenderingGroup {
  20526. index: number;
  20527. private static _zeroVector;
  20528. private _scene;
  20529. private _opaqueSubMeshes;
  20530. private _transparentSubMeshes;
  20531. private _alphaTestSubMeshes;
  20532. private _depthOnlySubMeshes;
  20533. private _particleSystems;
  20534. private _spriteManagers;
  20535. private _opaqueSortCompareFn;
  20536. private _alphaTestSortCompareFn;
  20537. private _transparentSortCompareFn;
  20538. private _renderOpaque;
  20539. private _renderAlphaTest;
  20540. private _renderTransparent;
  20541. /** @hidden */
  20542. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20543. onBeforeTransparentRendering: () => void;
  20544. /**
  20545. * Set the opaque sort comparison function.
  20546. * If null the sub meshes will be render in the order they were created
  20547. */
  20548. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20549. /**
  20550. * Set the alpha test sort comparison function.
  20551. * If null the sub meshes will be render in the order they were created
  20552. */
  20553. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20554. /**
  20555. * Set the transparent sort comparison function.
  20556. * If null the sub meshes will be render in the order they were created
  20557. */
  20558. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20559. /**
  20560. * Creates a new rendering group.
  20561. * @param index The rendering group index
  20562. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20563. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20564. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20565. */
  20566. 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>);
  20567. /**
  20568. * Render all the sub meshes contained in the group.
  20569. * @param customRenderFunction Used to override the default render behaviour of the group.
  20570. * @returns true if rendered some submeshes.
  20571. */
  20572. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20573. /**
  20574. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20575. * @param subMeshes The submeshes to render
  20576. */
  20577. private renderOpaqueSorted;
  20578. /**
  20579. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20580. * @param subMeshes The submeshes to render
  20581. */
  20582. private renderAlphaTestSorted;
  20583. /**
  20584. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20585. * @param subMeshes The submeshes to render
  20586. */
  20587. private renderTransparentSorted;
  20588. /**
  20589. * Renders the submeshes in a specified order.
  20590. * @param subMeshes The submeshes to sort before render
  20591. * @param sortCompareFn The comparison function use to sort
  20592. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20593. * @param transparent Specifies to activate blending if true
  20594. */
  20595. private static renderSorted;
  20596. /**
  20597. * Renders the submeshes in the order they were dispatched (no sort applied).
  20598. * @param subMeshes The submeshes to render
  20599. */
  20600. private static renderUnsorted;
  20601. /**
  20602. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20603. * are rendered back to front if in the same alpha index.
  20604. *
  20605. * @param a The first submesh
  20606. * @param b The second submesh
  20607. * @returns The result of the comparison
  20608. */
  20609. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20610. /**
  20611. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20612. * are rendered back to front.
  20613. *
  20614. * @param a The first submesh
  20615. * @param b The second submesh
  20616. * @returns The result of the comparison
  20617. */
  20618. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20619. /**
  20620. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20621. * are rendered front to back (prevent overdraw).
  20622. *
  20623. * @param a The first submesh
  20624. * @param b The second submesh
  20625. * @returns The result of the comparison
  20626. */
  20627. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20628. /**
  20629. * Resets the different lists of submeshes to prepare a new frame.
  20630. */
  20631. prepare(): void;
  20632. dispose(): void;
  20633. /**
  20634. * Inserts the submesh in its correct queue depending on its material.
  20635. * @param subMesh The submesh to dispatch
  20636. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20637. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20638. */
  20639. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20640. dispatchSprites(spriteManager: ISpriteManager): void;
  20641. dispatchParticles(particleSystem: IParticleSystem): void;
  20642. private _renderParticles;
  20643. private _renderSprites;
  20644. }
  20645. }
  20646. declare module "babylonjs/Rendering/renderingManager" {
  20647. import { Nullable } from "babylonjs/types";
  20648. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20649. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20650. import { SmartArray } from "babylonjs/Misc/smartArray";
  20651. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20652. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20653. import { Material } from "babylonjs/Materials/material";
  20654. import { Scene } from "babylonjs/scene";
  20655. import { Camera } from "babylonjs/Cameras/camera";
  20656. /**
  20657. * Interface describing the different options available in the rendering manager
  20658. * regarding Auto Clear between groups.
  20659. */
  20660. export interface IRenderingManagerAutoClearSetup {
  20661. /**
  20662. * Defines whether or not autoclear is enable.
  20663. */
  20664. autoClear: boolean;
  20665. /**
  20666. * Defines whether or not to autoclear the depth buffer.
  20667. */
  20668. depth: boolean;
  20669. /**
  20670. * Defines whether or not to autoclear the stencil buffer.
  20671. */
  20672. stencil: boolean;
  20673. }
  20674. /**
  20675. * This class is used by the onRenderingGroupObservable
  20676. */
  20677. export class RenderingGroupInfo {
  20678. /**
  20679. * The Scene that being rendered
  20680. */
  20681. scene: Scene;
  20682. /**
  20683. * The camera currently used for the rendering pass
  20684. */
  20685. camera: Nullable<Camera>;
  20686. /**
  20687. * The ID of the renderingGroup being processed
  20688. */
  20689. renderingGroupId: number;
  20690. }
  20691. /**
  20692. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20693. * It is enable to manage the different groups as well as the different necessary sort functions.
  20694. * This should not be used directly aside of the few static configurations
  20695. */
  20696. export class RenderingManager {
  20697. /**
  20698. * The max id used for rendering groups (not included)
  20699. */
  20700. static MAX_RENDERINGGROUPS: number;
  20701. /**
  20702. * The min id used for rendering groups (included)
  20703. */
  20704. static MIN_RENDERINGGROUPS: number;
  20705. /**
  20706. * Used to globally prevent autoclearing scenes.
  20707. */
  20708. static AUTOCLEAR: boolean;
  20709. /**
  20710. * @hidden
  20711. */
  20712. _useSceneAutoClearSetup: boolean;
  20713. private _scene;
  20714. private _renderingGroups;
  20715. private _depthStencilBufferAlreadyCleaned;
  20716. private _autoClearDepthStencil;
  20717. private _customOpaqueSortCompareFn;
  20718. private _customAlphaTestSortCompareFn;
  20719. private _customTransparentSortCompareFn;
  20720. private _renderingGroupInfo;
  20721. /**
  20722. * Instantiates a new rendering group for a particular scene
  20723. * @param scene Defines the scene the groups belongs to
  20724. */
  20725. constructor(scene: Scene);
  20726. private _clearDepthStencilBuffer;
  20727. /**
  20728. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20729. * @hidden
  20730. */
  20731. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20732. /**
  20733. * Resets the different information of the group to prepare a new frame
  20734. * @hidden
  20735. */
  20736. reset(): void;
  20737. /**
  20738. * Dispose and release the group and its associated resources.
  20739. * @hidden
  20740. */
  20741. dispose(): void;
  20742. /**
  20743. * Clear the info related to rendering groups preventing retention points during dispose.
  20744. */
  20745. freeRenderingGroups(): void;
  20746. private _prepareRenderingGroup;
  20747. /**
  20748. * Add a sprite manager to the rendering manager in order to render it this frame.
  20749. * @param spriteManager Define the sprite manager to render
  20750. */
  20751. dispatchSprites(spriteManager: ISpriteManager): void;
  20752. /**
  20753. * Add a particle system to the rendering manager in order to render it this frame.
  20754. * @param particleSystem Define the particle system to render
  20755. */
  20756. dispatchParticles(particleSystem: IParticleSystem): void;
  20757. /**
  20758. * Add a submesh to the manager in order to render it this frame
  20759. * @param subMesh The submesh to dispatch
  20760. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20761. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20762. */
  20763. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20764. /**
  20765. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20766. * This allowed control for front to back rendering or reversly depending of the special needs.
  20767. *
  20768. * @param renderingGroupId The rendering group id corresponding to its index
  20769. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20770. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20771. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20772. */
  20773. 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;
  20774. /**
  20775. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20776. *
  20777. * @param renderingGroupId The rendering group id corresponding to its index
  20778. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20779. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20780. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20781. */
  20782. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20783. /**
  20784. * Gets the current auto clear configuration for one rendering group of the rendering
  20785. * manager.
  20786. * @param index the rendering group index to get the information for
  20787. * @returns The auto clear setup for the requested rendering group
  20788. */
  20789. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20790. }
  20791. }
  20792. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20793. import { Observable } from "babylonjs/Misc/observable";
  20794. import { SmartArray } from "babylonjs/Misc/smartArray";
  20795. import { Nullable } from "babylonjs/types";
  20796. import { Camera } from "babylonjs/Cameras/camera";
  20797. import { Scene } from "babylonjs/scene";
  20798. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20799. import { Color4 } from "babylonjs/Maths/math.color";
  20800. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20801. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20802. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20803. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20804. import { Texture } from "babylonjs/Materials/Textures/texture";
  20805. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20806. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20807. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20808. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20809. import { Engine } from "babylonjs/Engines/engine";
  20810. /**
  20811. * This Helps creating a texture that will be created from a camera in your scene.
  20812. * It is basically a dynamic texture that could be used to create special effects for instance.
  20813. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20814. */
  20815. export class RenderTargetTexture extends Texture {
  20816. isCube: boolean;
  20817. /**
  20818. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20819. */
  20820. static readonly REFRESHRATE_RENDER_ONCE: number;
  20821. /**
  20822. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20823. */
  20824. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20825. /**
  20826. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20827. * the central point of your effect and can save a lot of performances.
  20828. */
  20829. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20830. /**
  20831. * Use this predicate to dynamically define the list of mesh you want to render.
  20832. * If set, the renderList property will be overwritten.
  20833. */
  20834. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20835. private _renderList;
  20836. /**
  20837. * Use this list to define the list of mesh you want to render.
  20838. */
  20839. get renderList(): Nullable<Array<AbstractMesh>>;
  20840. set renderList(value: Nullable<Array<AbstractMesh>>);
  20841. private _hookArray;
  20842. /**
  20843. * Define if particles should be rendered in your texture.
  20844. */
  20845. renderParticles: boolean;
  20846. /**
  20847. * Define if sprites should be rendered in your texture.
  20848. */
  20849. renderSprites: boolean;
  20850. /**
  20851. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20852. */
  20853. coordinatesMode: number;
  20854. /**
  20855. * Define the camera used to render the texture.
  20856. */
  20857. activeCamera: Nullable<Camera>;
  20858. /**
  20859. * Override the render function of the texture with your own one.
  20860. */
  20861. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20862. /**
  20863. * Define if camera post processes should be use while rendering the texture.
  20864. */
  20865. useCameraPostProcesses: boolean;
  20866. /**
  20867. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20868. */
  20869. ignoreCameraViewport: boolean;
  20870. private _postProcessManager;
  20871. private _postProcesses;
  20872. private _resizeObserver;
  20873. /**
  20874. * An event triggered when the texture is unbind.
  20875. */
  20876. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20877. /**
  20878. * An event triggered when the texture is unbind.
  20879. */
  20880. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20881. private _onAfterUnbindObserver;
  20882. /**
  20883. * Set a after unbind callback in the texture.
  20884. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20885. */
  20886. set onAfterUnbind(callback: () => void);
  20887. /**
  20888. * An event triggered before rendering the texture
  20889. */
  20890. onBeforeRenderObservable: Observable<number>;
  20891. private _onBeforeRenderObserver;
  20892. /**
  20893. * Set a before render callback in the texture.
  20894. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20895. */
  20896. set onBeforeRender(callback: (faceIndex: number) => void);
  20897. /**
  20898. * An event triggered after rendering the texture
  20899. */
  20900. onAfterRenderObservable: Observable<number>;
  20901. private _onAfterRenderObserver;
  20902. /**
  20903. * Set a after render callback in the texture.
  20904. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20905. */
  20906. set onAfterRender(callback: (faceIndex: number) => void);
  20907. /**
  20908. * An event triggered after the texture clear
  20909. */
  20910. onClearObservable: Observable<Engine>;
  20911. private _onClearObserver;
  20912. /**
  20913. * Set a clear callback in the texture.
  20914. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20915. */
  20916. set onClear(callback: (Engine: Engine) => void);
  20917. /**
  20918. * An event triggered when the texture is resized.
  20919. */
  20920. onResizeObservable: Observable<RenderTargetTexture>;
  20921. /**
  20922. * Define the clear color of the Render Target if it should be different from the scene.
  20923. */
  20924. clearColor: Color4;
  20925. protected _size: number | {
  20926. width: number;
  20927. height: number;
  20928. };
  20929. protected _initialSizeParameter: number | {
  20930. width: number;
  20931. height: number;
  20932. } | {
  20933. ratio: number;
  20934. };
  20935. protected _sizeRatio: Nullable<number>;
  20936. /** @hidden */
  20937. _generateMipMaps: boolean;
  20938. protected _renderingManager: RenderingManager;
  20939. /** @hidden */
  20940. _waitingRenderList: string[];
  20941. protected _doNotChangeAspectRatio: boolean;
  20942. protected _currentRefreshId: number;
  20943. protected _refreshRate: number;
  20944. protected _textureMatrix: Matrix;
  20945. protected _samples: number;
  20946. protected _renderTargetOptions: RenderTargetCreationOptions;
  20947. /**
  20948. * Gets render target creation options that were used.
  20949. */
  20950. get renderTargetOptions(): RenderTargetCreationOptions;
  20951. protected _engine: Engine;
  20952. protected _onRatioRescale(): void;
  20953. /**
  20954. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20955. * It must define where the camera used to render the texture is set
  20956. */
  20957. boundingBoxPosition: Vector3;
  20958. private _boundingBoxSize;
  20959. /**
  20960. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20961. * When defined, the cubemap will switch to local mode
  20962. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20963. * @example https://www.babylonjs-playground.com/#RNASML
  20964. */
  20965. set boundingBoxSize(value: Vector3);
  20966. get boundingBoxSize(): Vector3;
  20967. /**
  20968. * In case the RTT has been created with a depth texture, get the associated
  20969. * depth texture.
  20970. * Otherwise, return null.
  20971. */
  20972. depthStencilTexture: Nullable<InternalTexture>;
  20973. /**
  20974. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20975. * or used a shadow, depth texture...
  20976. * @param name The friendly name of the texture
  20977. * @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)
  20978. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20979. * @param generateMipMaps True if mip maps need to be generated after render.
  20980. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20981. * @param type The type of the buffer in the RTT (int, half float, float...)
  20982. * @param isCube True if a cube texture needs to be created
  20983. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20984. * @param generateDepthBuffer True to generate a depth buffer
  20985. * @param generateStencilBuffer True to generate a stencil buffer
  20986. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20987. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20988. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20989. */
  20990. constructor(name: string, size: number | {
  20991. width: number;
  20992. height: number;
  20993. } | {
  20994. ratio: number;
  20995. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20996. /**
  20997. * Creates a depth stencil texture.
  20998. * This is only available in WebGL 2 or with the depth texture extension available.
  20999. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21000. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21001. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21002. */
  21003. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21004. private _processSizeParameter;
  21005. /**
  21006. * Define the number of samples to use in case of MSAA.
  21007. * It defaults to one meaning no MSAA has been enabled.
  21008. */
  21009. get samples(): number;
  21010. set samples(value: number);
  21011. /**
  21012. * Resets the refresh counter of the texture and start bak from scratch.
  21013. * Could be useful to regenerate the texture if it is setup to render only once.
  21014. */
  21015. resetRefreshCounter(): void;
  21016. /**
  21017. * Define the refresh rate of the texture or the rendering frequency.
  21018. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21019. */
  21020. get refreshRate(): number;
  21021. set refreshRate(value: number);
  21022. /**
  21023. * Adds a post process to the render target rendering passes.
  21024. * @param postProcess define the post process to add
  21025. */
  21026. addPostProcess(postProcess: PostProcess): void;
  21027. /**
  21028. * Clear all the post processes attached to the render target
  21029. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21030. */
  21031. clearPostProcesses(dispose?: boolean): void;
  21032. /**
  21033. * Remove one of the post process from the list of attached post processes to the texture
  21034. * @param postProcess define the post process to remove from the list
  21035. */
  21036. removePostProcess(postProcess: PostProcess): void;
  21037. /** @hidden */
  21038. _shouldRender(): boolean;
  21039. /**
  21040. * Gets the actual render size of the texture.
  21041. * @returns the width of the render size
  21042. */
  21043. getRenderSize(): number;
  21044. /**
  21045. * Gets the actual render width of the texture.
  21046. * @returns the width of the render size
  21047. */
  21048. getRenderWidth(): number;
  21049. /**
  21050. * Gets the actual render height of the texture.
  21051. * @returns the height of the render size
  21052. */
  21053. getRenderHeight(): number;
  21054. /**
  21055. * Get if the texture can be rescaled or not.
  21056. */
  21057. get canRescale(): boolean;
  21058. /**
  21059. * Resize the texture using a ratio.
  21060. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21061. */
  21062. scale(ratio: number): void;
  21063. /**
  21064. * Get the texture reflection matrix used to rotate/transform the reflection.
  21065. * @returns the reflection matrix
  21066. */
  21067. getReflectionTextureMatrix(): Matrix;
  21068. /**
  21069. * Resize the texture to a new desired size.
  21070. * Be carrefull as it will recreate all the data in the new texture.
  21071. * @param size Define the new size. It can be:
  21072. * - a number for squared texture,
  21073. * - an object containing { width: number, height: number }
  21074. * - or an object containing a ratio { ratio: number }
  21075. */
  21076. resize(size: number | {
  21077. width: number;
  21078. height: number;
  21079. } | {
  21080. ratio: number;
  21081. }): void;
  21082. /**
  21083. * Renders all the objects from the render list into the texture.
  21084. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21085. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21086. */
  21087. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21088. private _bestReflectionRenderTargetDimension;
  21089. /**
  21090. * @hidden
  21091. * @param faceIndex face index to bind to if this is a cubetexture
  21092. */
  21093. _bindFrameBuffer(faceIndex?: number): void;
  21094. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21095. private renderToTarget;
  21096. /**
  21097. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21098. * This allowed control for front to back rendering or reversly depending of the special needs.
  21099. *
  21100. * @param renderingGroupId The rendering group id corresponding to its index
  21101. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21102. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21103. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21104. */
  21105. 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;
  21106. /**
  21107. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21108. *
  21109. * @param renderingGroupId The rendering group id corresponding to its index
  21110. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21111. */
  21112. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21113. /**
  21114. * Clones the texture.
  21115. * @returns the cloned texture
  21116. */
  21117. clone(): RenderTargetTexture;
  21118. /**
  21119. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21120. * @returns The JSON representation of the texture
  21121. */
  21122. serialize(): any;
  21123. /**
  21124. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21125. */
  21126. disposeFramebufferObjects(): void;
  21127. /**
  21128. * Dispose the texture and release its associated resources.
  21129. */
  21130. dispose(): void;
  21131. /** @hidden */
  21132. _rebuild(): void;
  21133. /**
  21134. * Clear the info related to rendering groups preventing retention point in material dispose.
  21135. */
  21136. freeRenderingGroups(): void;
  21137. /**
  21138. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21139. * @returns the view count
  21140. */
  21141. getViewCount(): number;
  21142. }
  21143. }
  21144. declare module "babylonjs/Materials/material" {
  21145. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21146. import { SmartArray } from "babylonjs/Misc/smartArray";
  21147. import { Observable } from "babylonjs/Misc/observable";
  21148. import { Nullable } from "babylonjs/types";
  21149. import { Scene } from "babylonjs/scene";
  21150. import { Matrix } from "babylonjs/Maths/math.vector";
  21151. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21153. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21154. import { Effect } from "babylonjs/Materials/effect";
  21155. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21156. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21157. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21158. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21159. import { Mesh } from "babylonjs/Meshes/mesh";
  21160. import { Animation } from "babylonjs/Animations/animation";
  21161. /**
  21162. * Options for compiling materials.
  21163. */
  21164. export interface IMaterialCompilationOptions {
  21165. /**
  21166. * Defines whether clip planes are enabled.
  21167. */
  21168. clipPlane: boolean;
  21169. /**
  21170. * Defines whether instances are enabled.
  21171. */
  21172. useInstances: boolean;
  21173. }
  21174. /**
  21175. * Base class for the main features of a material in Babylon.js
  21176. */
  21177. export class Material implements IAnimatable {
  21178. /**
  21179. * Returns the triangle fill mode
  21180. */
  21181. static readonly TriangleFillMode: number;
  21182. /**
  21183. * Returns the wireframe mode
  21184. */
  21185. static readonly WireFrameFillMode: number;
  21186. /**
  21187. * Returns the point fill mode
  21188. */
  21189. static readonly PointFillMode: number;
  21190. /**
  21191. * Returns the point list draw mode
  21192. */
  21193. static readonly PointListDrawMode: number;
  21194. /**
  21195. * Returns the line list draw mode
  21196. */
  21197. static readonly LineListDrawMode: number;
  21198. /**
  21199. * Returns the line loop draw mode
  21200. */
  21201. static readonly LineLoopDrawMode: number;
  21202. /**
  21203. * Returns the line strip draw mode
  21204. */
  21205. static readonly LineStripDrawMode: number;
  21206. /**
  21207. * Returns the triangle strip draw mode
  21208. */
  21209. static readonly TriangleStripDrawMode: number;
  21210. /**
  21211. * Returns the triangle fan draw mode
  21212. */
  21213. static readonly TriangleFanDrawMode: number;
  21214. /**
  21215. * Stores the clock-wise side orientation
  21216. */
  21217. static readonly ClockWiseSideOrientation: number;
  21218. /**
  21219. * Stores the counter clock-wise side orientation
  21220. */
  21221. static readonly CounterClockWiseSideOrientation: number;
  21222. /**
  21223. * The dirty texture flag value
  21224. */
  21225. static readonly TextureDirtyFlag: number;
  21226. /**
  21227. * The dirty light flag value
  21228. */
  21229. static readonly LightDirtyFlag: number;
  21230. /**
  21231. * The dirty fresnel flag value
  21232. */
  21233. static readonly FresnelDirtyFlag: number;
  21234. /**
  21235. * The dirty attribute flag value
  21236. */
  21237. static readonly AttributesDirtyFlag: number;
  21238. /**
  21239. * The dirty misc flag value
  21240. */
  21241. static readonly MiscDirtyFlag: number;
  21242. /**
  21243. * The all dirty flag value
  21244. */
  21245. static readonly AllDirtyFlag: number;
  21246. /**
  21247. * The ID of the material
  21248. */
  21249. id: string;
  21250. /**
  21251. * Gets or sets the unique id of the material
  21252. */
  21253. uniqueId: number;
  21254. /**
  21255. * The name of the material
  21256. */
  21257. name: string;
  21258. /**
  21259. * Gets or sets user defined metadata
  21260. */
  21261. metadata: any;
  21262. /**
  21263. * For internal use only. Please do not use.
  21264. */
  21265. reservedDataStore: any;
  21266. /**
  21267. * Specifies if the ready state should be checked on each call
  21268. */
  21269. checkReadyOnEveryCall: boolean;
  21270. /**
  21271. * Specifies if the ready state should be checked once
  21272. */
  21273. checkReadyOnlyOnce: boolean;
  21274. /**
  21275. * The state of the material
  21276. */
  21277. state: string;
  21278. /**
  21279. * The alpha value of the material
  21280. */
  21281. protected _alpha: number;
  21282. /**
  21283. * List of inspectable custom properties (used by the Inspector)
  21284. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21285. */
  21286. inspectableCustomProperties: IInspectable[];
  21287. /**
  21288. * Sets the alpha value of the material
  21289. */
  21290. set alpha(value: number);
  21291. /**
  21292. * Gets the alpha value of the material
  21293. */
  21294. get alpha(): number;
  21295. /**
  21296. * Specifies if back face culling is enabled
  21297. */
  21298. protected _backFaceCulling: boolean;
  21299. /**
  21300. * Sets the back-face culling state
  21301. */
  21302. set backFaceCulling(value: boolean);
  21303. /**
  21304. * Gets the back-face culling state
  21305. */
  21306. get backFaceCulling(): boolean;
  21307. /**
  21308. * Stores the value for side orientation
  21309. */
  21310. sideOrientation: number;
  21311. /**
  21312. * Callback triggered when the material is compiled
  21313. */
  21314. onCompiled: Nullable<(effect: Effect) => void>;
  21315. /**
  21316. * Callback triggered when an error occurs
  21317. */
  21318. onError: Nullable<(effect: Effect, errors: string) => void>;
  21319. /**
  21320. * Callback triggered to get the render target textures
  21321. */
  21322. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21323. /**
  21324. * Gets a boolean indicating that current material needs to register RTT
  21325. */
  21326. get hasRenderTargetTextures(): boolean;
  21327. /**
  21328. * Specifies if the material should be serialized
  21329. */
  21330. doNotSerialize: boolean;
  21331. /**
  21332. * @hidden
  21333. */
  21334. _storeEffectOnSubMeshes: boolean;
  21335. /**
  21336. * Stores the animations for the material
  21337. */
  21338. animations: Nullable<Array<Animation>>;
  21339. /**
  21340. * An event triggered when the material is disposed
  21341. */
  21342. onDisposeObservable: Observable<Material>;
  21343. /**
  21344. * An observer which watches for dispose events
  21345. */
  21346. private _onDisposeObserver;
  21347. private _onUnBindObservable;
  21348. /**
  21349. * Called during a dispose event
  21350. */
  21351. set onDispose(callback: () => void);
  21352. private _onBindObservable;
  21353. /**
  21354. * An event triggered when the material is bound
  21355. */
  21356. get onBindObservable(): Observable<AbstractMesh>;
  21357. /**
  21358. * An observer which watches for bind events
  21359. */
  21360. private _onBindObserver;
  21361. /**
  21362. * Called during a bind event
  21363. */
  21364. set onBind(callback: (Mesh: AbstractMesh) => void);
  21365. /**
  21366. * An event triggered when the material is unbound
  21367. */
  21368. get onUnBindObservable(): Observable<Material>;
  21369. /**
  21370. * Stores the value of the alpha mode
  21371. */
  21372. private _alphaMode;
  21373. /**
  21374. * Sets the value of the alpha mode.
  21375. *
  21376. * | Value | Type | Description |
  21377. * | --- | --- | --- |
  21378. * | 0 | ALPHA_DISABLE | |
  21379. * | 1 | ALPHA_ADD | |
  21380. * | 2 | ALPHA_COMBINE | |
  21381. * | 3 | ALPHA_SUBTRACT | |
  21382. * | 4 | ALPHA_MULTIPLY | |
  21383. * | 5 | ALPHA_MAXIMIZED | |
  21384. * | 6 | ALPHA_ONEONE | |
  21385. * | 7 | ALPHA_PREMULTIPLIED | |
  21386. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21387. * | 9 | ALPHA_INTERPOLATE | |
  21388. * | 10 | ALPHA_SCREENMODE | |
  21389. *
  21390. */
  21391. set alphaMode(value: number);
  21392. /**
  21393. * Gets the value of the alpha mode
  21394. */
  21395. get alphaMode(): number;
  21396. /**
  21397. * Stores the state of the need depth pre-pass value
  21398. */
  21399. private _needDepthPrePass;
  21400. /**
  21401. * Sets the need depth pre-pass value
  21402. */
  21403. set needDepthPrePass(value: boolean);
  21404. /**
  21405. * Gets the depth pre-pass value
  21406. */
  21407. get needDepthPrePass(): boolean;
  21408. /**
  21409. * Specifies if depth writing should be disabled
  21410. */
  21411. disableDepthWrite: boolean;
  21412. /**
  21413. * Specifies if depth writing should be forced
  21414. */
  21415. forceDepthWrite: boolean;
  21416. /**
  21417. * Specifies the depth function that should be used. 0 means the default engine function
  21418. */
  21419. depthFunction: number;
  21420. /**
  21421. * Specifies if there should be a separate pass for culling
  21422. */
  21423. separateCullingPass: boolean;
  21424. /**
  21425. * Stores the state specifing if fog should be enabled
  21426. */
  21427. private _fogEnabled;
  21428. /**
  21429. * Sets the state for enabling fog
  21430. */
  21431. set fogEnabled(value: boolean);
  21432. /**
  21433. * Gets the value of the fog enabled state
  21434. */
  21435. get fogEnabled(): boolean;
  21436. /**
  21437. * Stores the size of points
  21438. */
  21439. pointSize: number;
  21440. /**
  21441. * Stores the z offset value
  21442. */
  21443. zOffset: number;
  21444. /**
  21445. * Gets a value specifying if wireframe mode is enabled
  21446. */
  21447. get wireframe(): boolean;
  21448. /**
  21449. * Sets the state of wireframe mode
  21450. */
  21451. set wireframe(value: boolean);
  21452. /**
  21453. * Gets the value specifying if point clouds are enabled
  21454. */
  21455. get pointsCloud(): boolean;
  21456. /**
  21457. * Sets the state of point cloud mode
  21458. */
  21459. set pointsCloud(value: boolean);
  21460. /**
  21461. * Gets the material fill mode
  21462. */
  21463. get fillMode(): number;
  21464. /**
  21465. * Sets the material fill mode
  21466. */
  21467. set fillMode(value: number);
  21468. /**
  21469. * @hidden
  21470. * Stores the effects for the material
  21471. */
  21472. _effect: Nullable<Effect>;
  21473. /**
  21474. * @hidden
  21475. * Specifies if the material was previously ready
  21476. */
  21477. _wasPreviouslyReady: boolean;
  21478. /**
  21479. * Specifies if uniform buffers should be used
  21480. */
  21481. private _useUBO;
  21482. /**
  21483. * Stores a reference to the scene
  21484. */
  21485. private _scene;
  21486. /**
  21487. * Stores the fill mode state
  21488. */
  21489. private _fillMode;
  21490. /**
  21491. * Specifies if the depth write state should be cached
  21492. */
  21493. private _cachedDepthWriteState;
  21494. /**
  21495. * Specifies if the depth function state should be cached
  21496. */
  21497. private _cachedDepthFunctionState;
  21498. /**
  21499. * Stores the uniform buffer
  21500. */
  21501. protected _uniformBuffer: UniformBuffer;
  21502. /** @hidden */
  21503. _indexInSceneMaterialArray: number;
  21504. /** @hidden */
  21505. meshMap: Nullable<{
  21506. [id: string]: AbstractMesh | undefined;
  21507. }>;
  21508. /**
  21509. * Creates a material instance
  21510. * @param name defines the name of the material
  21511. * @param scene defines the scene to reference
  21512. * @param doNotAdd specifies if the material should be added to the scene
  21513. */
  21514. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21515. /**
  21516. * Returns a string representation of the current material
  21517. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21518. * @returns a string with material information
  21519. */
  21520. toString(fullDetails?: boolean): string;
  21521. /**
  21522. * Gets the class name of the material
  21523. * @returns a string with the class name of the material
  21524. */
  21525. getClassName(): string;
  21526. /**
  21527. * Specifies if updates for the material been locked
  21528. */
  21529. get isFrozen(): boolean;
  21530. /**
  21531. * Locks updates for the material
  21532. */
  21533. freeze(): void;
  21534. /**
  21535. * Unlocks updates for the material
  21536. */
  21537. unfreeze(): void;
  21538. /**
  21539. * Specifies if the material is ready to be used
  21540. * @param mesh defines the mesh to check
  21541. * @param useInstances specifies if instances should be used
  21542. * @returns a boolean indicating if the material is ready to be used
  21543. */
  21544. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21545. /**
  21546. * Specifies that the submesh is ready to be used
  21547. * @param mesh defines the mesh to check
  21548. * @param subMesh defines which submesh to check
  21549. * @param useInstances specifies that instances should be used
  21550. * @returns a boolean indicating that the submesh is ready or not
  21551. */
  21552. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21553. /**
  21554. * Returns the material effect
  21555. * @returns the effect associated with the material
  21556. */
  21557. getEffect(): Nullable<Effect>;
  21558. /**
  21559. * Returns the current scene
  21560. * @returns a Scene
  21561. */
  21562. getScene(): Scene;
  21563. /**
  21564. * Specifies if the material will require alpha blending
  21565. * @returns a boolean specifying if alpha blending is needed
  21566. */
  21567. needAlphaBlending(): boolean;
  21568. /**
  21569. * Specifies if the mesh will require alpha blending
  21570. * @param mesh defines the mesh to check
  21571. * @returns a boolean specifying if alpha blending is needed for the mesh
  21572. */
  21573. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21574. /**
  21575. * Specifies if this material should be rendered in alpha test mode
  21576. * @returns a boolean specifying if an alpha test is needed.
  21577. */
  21578. needAlphaTesting(): boolean;
  21579. /**
  21580. * Gets the texture used for the alpha test
  21581. * @returns the texture to use for alpha testing
  21582. */
  21583. getAlphaTestTexture(): Nullable<BaseTexture>;
  21584. /**
  21585. * Marks the material to indicate that it needs to be re-calculated
  21586. */
  21587. markDirty(): void;
  21588. /** @hidden */
  21589. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21590. /**
  21591. * Binds the material to the mesh
  21592. * @param world defines the world transformation matrix
  21593. * @param mesh defines the mesh to bind the material to
  21594. */
  21595. bind(world: Matrix, mesh?: Mesh): void;
  21596. /**
  21597. * Binds the submesh to the material
  21598. * @param world defines the world transformation matrix
  21599. * @param mesh defines the mesh containing the submesh
  21600. * @param subMesh defines the submesh to bind the material to
  21601. */
  21602. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21603. /**
  21604. * Binds the world matrix to the material
  21605. * @param world defines the world transformation matrix
  21606. */
  21607. bindOnlyWorldMatrix(world: Matrix): void;
  21608. /**
  21609. * Binds the scene's uniform buffer to the effect.
  21610. * @param effect defines the effect to bind to the scene uniform buffer
  21611. * @param sceneUbo defines the uniform buffer storing scene data
  21612. */
  21613. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21614. /**
  21615. * Binds the view matrix to the effect
  21616. * @param effect defines the effect to bind the view matrix to
  21617. */
  21618. bindView(effect: Effect): void;
  21619. /**
  21620. * Binds the view projection matrix to the effect
  21621. * @param effect defines the effect to bind the view projection matrix to
  21622. */
  21623. bindViewProjection(effect: Effect): void;
  21624. /**
  21625. * Specifies if material alpha testing should be turned on for the mesh
  21626. * @param mesh defines the mesh to check
  21627. */
  21628. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21629. /**
  21630. * Processes to execute after binding the material to a mesh
  21631. * @param mesh defines the rendered mesh
  21632. */
  21633. protected _afterBind(mesh?: Mesh): void;
  21634. /**
  21635. * Unbinds the material from the mesh
  21636. */
  21637. unbind(): void;
  21638. /**
  21639. * Gets the active textures from the material
  21640. * @returns an array of textures
  21641. */
  21642. getActiveTextures(): BaseTexture[];
  21643. /**
  21644. * Specifies if the material uses a texture
  21645. * @param texture defines the texture to check against the material
  21646. * @returns a boolean specifying if the material uses the texture
  21647. */
  21648. hasTexture(texture: BaseTexture): boolean;
  21649. /**
  21650. * Makes a duplicate of the material, and gives it a new name
  21651. * @param name defines the new name for the duplicated material
  21652. * @returns the cloned material
  21653. */
  21654. clone(name: string): Nullable<Material>;
  21655. /**
  21656. * Gets the meshes bound to the material
  21657. * @returns an array of meshes bound to the material
  21658. */
  21659. getBindedMeshes(): AbstractMesh[];
  21660. /**
  21661. * Force shader compilation
  21662. * @param mesh defines the mesh associated with this material
  21663. * @param onCompiled defines a function to execute once the material is compiled
  21664. * @param options defines the options to configure the compilation
  21665. * @param onError defines a function to execute if the material fails compiling
  21666. */
  21667. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21668. /**
  21669. * Force shader compilation
  21670. * @param mesh defines the mesh that will use this material
  21671. * @param options defines additional options for compiling the shaders
  21672. * @returns a promise that resolves when the compilation completes
  21673. */
  21674. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21675. private static readonly _AllDirtyCallBack;
  21676. private static readonly _ImageProcessingDirtyCallBack;
  21677. private static readonly _TextureDirtyCallBack;
  21678. private static readonly _FresnelDirtyCallBack;
  21679. private static readonly _MiscDirtyCallBack;
  21680. private static readonly _LightsDirtyCallBack;
  21681. private static readonly _AttributeDirtyCallBack;
  21682. private static _FresnelAndMiscDirtyCallBack;
  21683. private static _TextureAndMiscDirtyCallBack;
  21684. private static readonly _DirtyCallbackArray;
  21685. private static readonly _RunDirtyCallBacks;
  21686. /**
  21687. * Marks a define in the material to indicate that it needs to be re-computed
  21688. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21689. */
  21690. markAsDirty(flag: number): void;
  21691. /**
  21692. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21693. * @param func defines a function which checks material defines against the submeshes
  21694. */
  21695. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21696. /**
  21697. * Indicates that we need to re-calculated for all submeshes
  21698. */
  21699. protected _markAllSubMeshesAsAllDirty(): void;
  21700. /**
  21701. * Indicates that image processing needs to be re-calculated for all submeshes
  21702. */
  21703. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21704. /**
  21705. * Indicates that textures need to be re-calculated for all submeshes
  21706. */
  21707. protected _markAllSubMeshesAsTexturesDirty(): void;
  21708. /**
  21709. * Indicates that fresnel needs to be re-calculated for all submeshes
  21710. */
  21711. protected _markAllSubMeshesAsFresnelDirty(): void;
  21712. /**
  21713. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21714. */
  21715. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21716. /**
  21717. * Indicates that lights need to be re-calculated for all submeshes
  21718. */
  21719. protected _markAllSubMeshesAsLightsDirty(): void;
  21720. /**
  21721. * Indicates that attributes need to be re-calculated for all submeshes
  21722. */
  21723. protected _markAllSubMeshesAsAttributesDirty(): void;
  21724. /**
  21725. * Indicates that misc needs to be re-calculated for all submeshes
  21726. */
  21727. protected _markAllSubMeshesAsMiscDirty(): void;
  21728. /**
  21729. * Indicates that textures and misc need to be re-calculated for all submeshes
  21730. */
  21731. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21732. /**
  21733. * Disposes the material
  21734. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21735. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21736. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21737. */
  21738. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21739. /** @hidden */
  21740. private releaseVertexArrayObject;
  21741. /**
  21742. * Serializes this material
  21743. * @returns the serialized material object
  21744. */
  21745. serialize(): any;
  21746. /**
  21747. * Creates a material from parsed material data
  21748. * @param parsedMaterial defines parsed material data
  21749. * @param scene defines the hosting scene
  21750. * @param rootUrl defines the root URL to use to load textures
  21751. * @returns a new material
  21752. */
  21753. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21754. }
  21755. }
  21756. declare module "babylonjs/Materials/multiMaterial" {
  21757. import { Nullable } from "babylonjs/types";
  21758. import { Scene } from "babylonjs/scene";
  21759. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21760. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21761. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21762. import { Material } from "babylonjs/Materials/material";
  21763. /**
  21764. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21765. * separate meshes. This can be use to improve performances.
  21766. * @see http://doc.babylonjs.com/how_to/multi_materials
  21767. */
  21768. export class MultiMaterial extends Material {
  21769. private _subMaterials;
  21770. /**
  21771. * Gets or Sets the list of Materials used within the multi material.
  21772. * They need to be ordered according to the submeshes order in the associated mesh
  21773. */
  21774. get subMaterials(): Nullable<Material>[];
  21775. set subMaterials(value: Nullable<Material>[]);
  21776. /**
  21777. * Function used to align with Node.getChildren()
  21778. * @returns the list of Materials used within the multi material
  21779. */
  21780. getChildren(): Nullable<Material>[];
  21781. /**
  21782. * Instantiates a new Multi Material
  21783. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21784. * separate meshes. This can be use to improve performances.
  21785. * @see http://doc.babylonjs.com/how_to/multi_materials
  21786. * @param name Define the name in the scene
  21787. * @param scene Define the scene the material belongs to
  21788. */
  21789. constructor(name: string, scene: Scene);
  21790. private _hookArray;
  21791. /**
  21792. * Get one of the submaterial by its index in the submaterials array
  21793. * @param index The index to look the sub material at
  21794. * @returns The Material if the index has been defined
  21795. */
  21796. getSubMaterial(index: number): Nullable<Material>;
  21797. /**
  21798. * Get the list of active textures for the whole sub materials list.
  21799. * @returns All the textures that will be used during the rendering
  21800. */
  21801. getActiveTextures(): BaseTexture[];
  21802. /**
  21803. * Gets the current class name of the material e.g. "MultiMaterial"
  21804. * Mainly use in serialization.
  21805. * @returns the class name
  21806. */
  21807. getClassName(): string;
  21808. /**
  21809. * Checks if the material is ready to render the requested sub mesh
  21810. * @param mesh Define the mesh the submesh belongs to
  21811. * @param subMesh Define the sub mesh to look readyness for
  21812. * @param useInstances Define whether or not the material is used with instances
  21813. * @returns true if ready, otherwise false
  21814. */
  21815. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21816. /**
  21817. * Clones the current material and its related sub materials
  21818. * @param name Define the name of the newly cloned material
  21819. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21820. * @returns the cloned material
  21821. */
  21822. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21823. /**
  21824. * Serializes the materials into a JSON representation.
  21825. * @returns the JSON representation
  21826. */
  21827. serialize(): any;
  21828. /**
  21829. * Dispose the material and release its associated resources
  21830. * @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)
  21831. * @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)
  21832. * @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)
  21833. */
  21834. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21835. /**
  21836. * Creates a MultiMaterial from parsed MultiMaterial data.
  21837. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21838. * @param scene defines the hosting scene
  21839. * @returns a new MultiMaterial
  21840. */
  21841. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21842. }
  21843. }
  21844. declare module "babylonjs/Meshes/subMesh" {
  21845. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21846. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21847. import { Engine } from "babylonjs/Engines/engine";
  21848. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21849. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21850. import { Effect } from "babylonjs/Materials/effect";
  21851. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21852. import { Plane } from "babylonjs/Maths/math.plane";
  21853. import { Collider } from "babylonjs/Collisions/collider";
  21854. import { Material } from "babylonjs/Materials/material";
  21855. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21856. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21857. import { Mesh } from "babylonjs/Meshes/mesh";
  21858. import { Ray } from "babylonjs/Culling/ray";
  21859. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21860. /**
  21861. * Base class for submeshes
  21862. */
  21863. export class BaseSubMesh {
  21864. /** @hidden */
  21865. _materialDefines: Nullable<MaterialDefines>;
  21866. /** @hidden */
  21867. _materialEffect: Nullable<Effect>;
  21868. /**
  21869. * Gets material defines used by the effect associated to the sub mesh
  21870. */
  21871. get materialDefines(): Nullable<MaterialDefines>;
  21872. /**
  21873. * Sets material defines used by the effect associated to the sub mesh
  21874. */
  21875. set materialDefines(defines: Nullable<MaterialDefines>);
  21876. /**
  21877. * Gets associated effect
  21878. */
  21879. get effect(): Nullable<Effect>;
  21880. /**
  21881. * Sets associated effect (effect used to render this submesh)
  21882. * @param effect defines the effect to associate with
  21883. * @param defines defines the set of defines used to compile this effect
  21884. */
  21885. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21886. }
  21887. /**
  21888. * Defines a subdivision inside a mesh
  21889. */
  21890. export class SubMesh extends BaseSubMesh implements ICullable {
  21891. /** the material index to use */
  21892. materialIndex: number;
  21893. /** vertex index start */
  21894. verticesStart: number;
  21895. /** vertices count */
  21896. verticesCount: number;
  21897. /** index start */
  21898. indexStart: number;
  21899. /** indices count */
  21900. indexCount: number;
  21901. /** @hidden */
  21902. _linesIndexCount: number;
  21903. private _mesh;
  21904. private _renderingMesh;
  21905. private _boundingInfo;
  21906. private _linesIndexBuffer;
  21907. /** @hidden */
  21908. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21909. /** @hidden */
  21910. _trianglePlanes: Plane[];
  21911. /** @hidden */
  21912. _lastColliderTransformMatrix: Nullable<Matrix>;
  21913. /** @hidden */
  21914. _renderId: number;
  21915. /** @hidden */
  21916. _alphaIndex: number;
  21917. /** @hidden */
  21918. _distanceToCamera: number;
  21919. /** @hidden */
  21920. _id: number;
  21921. private _currentMaterial;
  21922. /**
  21923. * Add a new submesh to a mesh
  21924. * @param materialIndex defines the material index to use
  21925. * @param verticesStart defines vertex index start
  21926. * @param verticesCount defines vertices count
  21927. * @param indexStart defines index start
  21928. * @param indexCount defines indices count
  21929. * @param mesh defines the parent mesh
  21930. * @param renderingMesh defines an optional rendering mesh
  21931. * @param createBoundingBox defines if bounding box should be created for this submesh
  21932. * @returns the new submesh
  21933. */
  21934. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21935. /**
  21936. * Creates a new submesh
  21937. * @param materialIndex defines the material index to use
  21938. * @param verticesStart defines vertex index start
  21939. * @param verticesCount defines vertices count
  21940. * @param indexStart defines index start
  21941. * @param indexCount defines indices count
  21942. * @param mesh defines the parent mesh
  21943. * @param renderingMesh defines an optional rendering mesh
  21944. * @param createBoundingBox defines if bounding box should be created for this submesh
  21945. */
  21946. constructor(
  21947. /** the material index to use */
  21948. materialIndex: number,
  21949. /** vertex index start */
  21950. verticesStart: number,
  21951. /** vertices count */
  21952. verticesCount: number,
  21953. /** index start */
  21954. indexStart: number,
  21955. /** indices count */
  21956. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21957. /**
  21958. * Returns true if this submesh covers the entire parent mesh
  21959. * @ignorenaming
  21960. */
  21961. get IsGlobal(): boolean;
  21962. /**
  21963. * Returns the submesh BoudingInfo object
  21964. * @returns current bounding info (or mesh's one if the submesh is global)
  21965. */
  21966. getBoundingInfo(): BoundingInfo;
  21967. /**
  21968. * Sets the submesh BoundingInfo
  21969. * @param boundingInfo defines the new bounding info to use
  21970. * @returns the SubMesh
  21971. */
  21972. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21973. /**
  21974. * Returns the mesh of the current submesh
  21975. * @return the parent mesh
  21976. */
  21977. getMesh(): AbstractMesh;
  21978. /**
  21979. * Returns the rendering mesh of the submesh
  21980. * @returns the rendering mesh (could be different from parent mesh)
  21981. */
  21982. getRenderingMesh(): Mesh;
  21983. /**
  21984. * Returns the submesh material
  21985. * @returns null or the current material
  21986. */
  21987. getMaterial(): Nullable<Material>;
  21988. /**
  21989. * Sets a new updated BoundingInfo object to the submesh
  21990. * @param data defines an optional position array to use to determine the bounding info
  21991. * @returns the SubMesh
  21992. */
  21993. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21994. /** @hidden */
  21995. _checkCollision(collider: Collider): boolean;
  21996. /**
  21997. * Updates the submesh BoundingInfo
  21998. * @param world defines the world matrix to use to update the bounding info
  21999. * @returns the submesh
  22000. */
  22001. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22002. /**
  22003. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22004. * @param frustumPlanes defines the frustum planes
  22005. * @returns true if the submesh is intersecting with the frustum
  22006. */
  22007. isInFrustum(frustumPlanes: Plane[]): boolean;
  22008. /**
  22009. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22010. * @param frustumPlanes defines the frustum planes
  22011. * @returns true if the submesh is inside the frustum
  22012. */
  22013. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22014. /**
  22015. * Renders the submesh
  22016. * @param enableAlphaMode defines if alpha needs to be used
  22017. * @returns the submesh
  22018. */
  22019. render(enableAlphaMode: boolean): SubMesh;
  22020. /**
  22021. * @hidden
  22022. */
  22023. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22024. /**
  22025. * Checks if the submesh intersects with a ray
  22026. * @param ray defines the ray to test
  22027. * @returns true is the passed ray intersects the submesh bounding box
  22028. */
  22029. canIntersects(ray: Ray): boolean;
  22030. /**
  22031. * Intersects current submesh with a ray
  22032. * @param ray defines the ray to test
  22033. * @param positions defines mesh's positions array
  22034. * @param indices defines mesh's indices array
  22035. * @param fastCheck defines if only bounding info should be used
  22036. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22037. * @returns intersection info or null if no intersection
  22038. */
  22039. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22040. /** @hidden */
  22041. private _intersectLines;
  22042. /** @hidden */
  22043. private _intersectUnIndexedLines;
  22044. /** @hidden */
  22045. private _intersectTriangles;
  22046. /** @hidden */
  22047. private _intersectUnIndexedTriangles;
  22048. /** @hidden */
  22049. _rebuild(): void;
  22050. /**
  22051. * Creates a new submesh from the passed mesh
  22052. * @param newMesh defines the new hosting mesh
  22053. * @param newRenderingMesh defines an optional rendering mesh
  22054. * @returns the new submesh
  22055. */
  22056. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22057. /**
  22058. * Release associated resources
  22059. */
  22060. dispose(): void;
  22061. /**
  22062. * Gets the class name
  22063. * @returns the string "SubMesh".
  22064. */
  22065. getClassName(): string;
  22066. /**
  22067. * Creates a new submesh from indices data
  22068. * @param materialIndex the index of the main mesh material
  22069. * @param startIndex the index where to start the copy in the mesh indices array
  22070. * @param indexCount the number of indices to copy then from the startIndex
  22071. * @param mesh the main mesh to create the submesh from
  22072. * @param renderingMesh the optional rendering mesh
  22073. * @returns a new submesh
  22074. */
  22075. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22076. }
  22077. }
  22078. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22079. /**
  22080. * Class used to represent data loading progression
  22081. */
  22082. export class SceneLoaderFlags {
  22083. private static _ForceFullSceneLoadingForIncremental;
  22084. private static _ShowLoadingScreen;
  22085. private static _CleanBoneMatrixWeights;
  22086. private static _loggingLevel;
  22087. /**
  22088. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22089. */
  22090. static get ForceFullSceneLoadingForIncremental(): boolean;
  22091. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22092. /**
  22093. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22094. */
  22095. static get ShowLoadingScreen(): boolean;
  22096. static set ShowLoadingScreen(value: boolean);
  22097. /**
  22098. * Defines the current logging level (while loading the scene)
  22099. * @ignorenaming
  22100. */
  22101. static get loggingLevel(): number;
  22102. static set loggingLevel(value: number);
  22103. /**
  22104. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22105. */
  22106. static get CleanBoneMatrixWeights(): boolean;
  22107. static set CleanBoneMatrixWeights(value: boolean);
  22108. }
  22109. }
  22110. declare module "babylonjs/Meshes/geometry" {
  22111. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22112. import { Scene } from "babylonjs/scene";
  22113. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22114. import { Engine } from "babylonjs/Engines/engine";
  22115. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22116. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22117. import { Effect } from "babylonjs/Materials/effect";
  22118. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22119. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22120. import { Mesh } from "babylonjs/Meshes/mesh";
  22121. /**
  22122. * Class used to store geometry data (vertex buffers + index buffer)
  22123. */
  22124. export class Geometry implements IGetSetVerticesData {
  22125. /**
  22126. * Gets or sets the ID of the geometry
  22127. */
  22128. id: string;
  22129. /**
  22130. * Gets or sets the unique ID of the geometry
  22131. */
  22132. uniqueId: number;
  22133. /**
  22134. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22135. */
  22136. delayLoadState: number;
  22137. /**
  22138. * Gets the file containing the data to load when running in delay load state
  22139. */
  22140. delayLoadingFile: Nullable<string>;
  22141. /**
  22142. * Callback called when the geometry is updated
  22143. */
  22144. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22145. private _scene;
  22146. private _engine;
  22147. private _meshes;
  22148. private _totalVertices;
  22149. /** @hidden */
  22150. _indices: IndicesArray;
  22151. /** @hidden */
  22152. _vertexBuffers: {
  22153. [key: string]: VertexBuffer;
  22154. };
  22155. private _isDisposed;
  22156. private _extend;
  22157. private _boundingBias;
  22158. /** @hidden */
  22159. _delayInfo: Array<string>;
  22160. private _indexBuffer;
  22161. private _indexBufferIsUpdatable;
  22162. /** @hidden */
  22163. _boundingInfo: Nullable<BoundingInfo>;
  22164. /** @hidden */
  22165. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22166. /** @hidden */
  22167. _softwareSkinningFrameId: number;
  22168. private _vertexArrayObjects;
  22169. private _updatable;
  22170. /** @hidden */
  22171. _positions: Nullable<Vector3[]>;
  22172. /**
  22173. * 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
  22174. */
  22175. get boundingBias(): Vector2;
  22176. /**
  22177. * 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
  22178. */
  22179. set boundingBias(value: Vector2);
  22180. /**
  22181. * Static function used to attach a new empty geometry to a mesh
  22182. * @param mesh defines the mesh to attach the geometry to
  22183. * @returns the new Geometry
  22184. */
  22185. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22186. /**
  22187. * Creates a new geometry
  22188. * @param id defines the unique ID
  22189. * @param scene defines the hosting scene
  22190. * @param vertexData defines the VertexData used to get geometry data
  22191. * @param updatable defines if geometry must be updatable (false by default)
  22192. * @param mesh defines the mesh that will be associated with the geometry
  22193. */
  22194. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22195. /**
  22196. * Gets the current extend of the geometry
  22197. */
  22198. get extend(): {
  22199. minimum: Vector3;
  22200. maximum: Vector3;
  22201. };
  22202. /**
  22203. * Gets the hosting scene
  22204. * @returns the hosting Scene
  22205. */
  22206. getScene(): Scene;
  22207. /**
  22208. * Gets the hosting engine
  22209. * @returns the hosting Engine
  22210. */
  22211. getEngine(): Engine;
  22212. /**
  22213. * Defines if the geometry is ready to use
  22214. * @returns true if the geometry is ready to be used
  22215. */
  22216. isReady(): boolean;
  22217. /**
  22218. * Gets a value indicating that the geometry should not be serialized
  22219. */
  22220. get doNotSerialize(): boolean;
  22221. /** @hidden */
  22222. _rebuild(): void;
  22223. /**
  22224. * Affects all geometry data in one call
  22225. * @param vertexData defines the geometry data
  22226. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22227. */
  22228. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22229. /**
  22230. * Set specific vertex data
  22231. * @param kind defines the data kind (Position, normal, etc...)
  22232. * @param data defines the vertex data to use
  22233. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22234. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22235. */
  22236. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22237. /**
  22238. * Removes a specific vertex data
  22239. * @param kind defines the data kind (Position, normal, etc...)
  22240. */
  22241. removeVerticesData(kind: string): void;
  22242. /**
  22243. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22244. * @param buffer defines the vertex buffer to use
  22245. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22246. */
  22247. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22248. /**
  22249. * Update a specific vertex buffer
  22250. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22251. * It will do nothing if the buffer is not updatable
  22252. * @param kind defines the data kind (Position, normal, etc...)
  22253. * @param data defines the data to use
  22254. * @param offset defines the offset in the target buffer where to store the data
  22255. * @param useBytes set to true if the offset is in bytes
  22256. */
  22257. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22258. /**
  22259. * Update a specific vertex buffer
  22260. * This function will create a new buffer if the current one is not updatable
  22261. * @param kind defines the data kind (Position, normal, etc...)
  22262. * @param data defines the data to use
  22263. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22264. */
  22265. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22266. private _updateBoundingInfo;
  22267. /** @hidden */
  22268. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22269. /**
  22270. * Gets total number of vertices
  22271. * @returns the total number of vertices
  22272. */
  22273. getTotalVertices(): number;
  22274. /**
  22275. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22276. * @param kind defines the data kind (Position, normal, etc...)
  22277. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22278. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22279. * @returns a float array containing vertex data
  22280. */
  22281. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22282. /**
  22283. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22284. * @param kind defines the data kind (Position, normal, etc...)
  22285. * @returns true if the vertex buffer with the specified kind is updatable
  22286. */
  22287. isVertexBufferUpdatable(kind: string): boolean;
  22288. /**
  22289. * Gets a specific vertex buffer
  22290. * @param kind defines the data kind (Position, normal, etc...)
  22291. * @returns a VertexBuffer
  22292. */
  22293. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22294. /**
  22295. * Returns all vertex buffers
  22296. * @return an object holding all vertex buffers indexed by kind
  22297. */
  22298. getVertexBuffers(): Nullable<{
  22299. [key: string]: VertexBuffer;
  22300. }>;
  22301. /**
  22302. * Gets a boolean indicating if specific vertex buffer is present
  22303. * @param kind defines the data kind (Position, normal, etc...)
  22304. * @returns true if data is present
  22305. */
  22306. isVerticesDataPresent(kind: string): boolean;
  22307. /**
  22308. * Gets a list of all attached data kinds (Position, normal, etc...)
  22309. * @returns a list of string containing all kinds
  22310. */
  22311. getVerticesDataKinds(): string[];
  22312. /**
  22313. * Update index buffer
  22314. * @param indices defines the indices to store in the index buffer
  22315. * @param offset defines the offset in the target buffer where to store the data
  22316. * @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)
  22317. */
  22318. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22319. /**
  22320. * Creates a new index buffer
  22321. * @param indices defines the indices to store in the index buffer
  22322. * @param totalVertices defines the total number of vertices (could be null)
  22323. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22324. */
  22325. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22326. /**
  22327. * Return the total number of indices
  22328. * @returns the total number of indices
  22329. */
  22330. getTotalIndices(): number;
  22331. /**
  22332. * Gets the index buffer array
  22333. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22334. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22335. * @returns the index buffer array
  22336. */
  22337. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22338. /**
  22339. * Gets the index buffer
  22340. * @return the index buffer
  22341. */
  22342. getIndexBuffer(): Nullable<DataBuffer>;
  22343. /** @hidden */
  22344. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22345. /**
  22346. * Release the associated resources for a specific mesh
  22347. * @param mesh defines the source mesh
  22348. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22349. */
  22350. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22351. /**
  22352. * Apply current geometry to a given mesh
  22353. * @param mesh defines the mesh to apply geometry to
  22354. */
  22355. applyToMesh(mesh: Mesh): void;
  22356. private _updateExtend;
  22357. private _applyToMesh;
  22358. private notifyUpdate;
  22359. /**
  22360. * Load the geometry if it was flagged as delay loaded
  22361. * @param scene defines the hosting scene
  22362. * @param onLoaded defines a callback called when the geometry is loaded
  22363. */
  22364. load(scene: Scene, onLoaded?: () => void): void;
  22365. private _queueLoad;
  22366. /**
  22367. * Invert the geometry to move from a right handed system to a left handed one.
  22368. */
  22369. toLeftHanded(): void;
  22370. /** @hidden */
  22371. _resetPointsArrayCache(): void;
  22372. /** @hidden */
  22373. _generatePointsArray(): boolean;
  22374. /**
  22375. * Gets a value indicating if the geometry is disposed
  22376. * @returns true if the geometry was disposed
  22377. */
  22378. isDisposed(): boolean;
  22379. private _disposeVertexArrayObjects;
  22380. /**
  22381. * Free all associated resources
  22382. */
  22383. dispose(): void;
  22384. /**
  22385. * Clone the current geometry into a new geometry
  22386. * @param id defines the unique ID of the new geometry
  22387. * @returns a new geometry object
  22388. */
  22389. copy(id: string): Geometry;
  22390. /**
  22391. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22392. * @return a JSON representation of the current geometry data (without the vertices data)
  22393. */
  22394. serialize(): any;
  22395. private toNumberArray;
  22396. /**
  22397. * Serialize all vertices data into a JSON oject
  22398. * @returns a JSON representation of the current geometry data
  22399. */
  22400. serializeVerticeData(): any;
  22401. /**
  22402. * Extracts a clone of a mesh geometry
  22403. * @param mesh defines the source mesh
  22404. * @param id defines the unique ID of the new geometry object
  22405. * @returns the new geometry object
  22406. */
  22407. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22408. /**
  22409. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22410. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22411. * Be aware Math.random() could cause collisions, but:
  22412. * "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"
  22413. * @returns a string containing a new GUID
  22414. */
  22415. static RandomId(): string;
  22416. /** @hidden */
  22417. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22418. private static _CleanMatricesWeights;
  22419. /**
  22420. * Create a new geometry from persisted data (Using .babylon file format)
  22421. * @param parsedVertexData defines the persisted data
  22422. * @param scene defines the hosting scene
  22423. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22424. * @returns the new geometry object
  22425. */
  22426. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22427. }
  22428. }
  22429. declare module "babylonjs/Meshes/mesh.vertexData" {
  22430. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22431. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22432. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22433. import { Geometry } from "babylonjs/Meshes/geometry";
  22434. import { Mesh } from "babylonjs/Meshes/mesh";
  22435. /**
  22436. * Define an interface for all classes that will get and set the data on vertices
  22437. */
  22438. export interface IGetSetVerticesData {
  22439. /**
  22440. * Gets a boolean indicating if specific vertex data is present
  22441. * @param kind defines the vertex data kind to use
  22442. * @returns true is data kind is present
  22443. */
  22444. isVerticesDataPresent(kind: string): boolean;
  22445. /**
  22446. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22447. * @param kind defines the data kind (Position, normal, etc...)
  22448. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22449. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22450. * @returns a float array containing vertex data
  22451. */
  22452. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22453. /**
  22454. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22455. * @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.
  22456. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22457. * @returns the indices array or an empty array if the mesh has no geometry
  22458. */
  22459. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22460. /**
  22461. * Set specific vertex data
  22462. * @param kind defines the data kind (Position, normal, etc...)
  22463. * @param data defines the vertex data to use
  22464. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22465. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22466. */
  22467. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22468. /**
  22469. * Update a specific associated vertex buffer
  22470. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22471. * - VertexBuffer.PositionKind
  22472. * - VertexBuffer.UVKind
  22473. * - VertexBuffer.UV2Kind
  22474. * - VertexBuffer.UV3Kind
  22475. * - VertexBuffer.UV4Kind
  22476. * - VertexBuffer.UV5Kind
  22477. * - VertexBuffer.UV6Kind
  22478. * - VertexBuffer.ColorKind
  22479. * - VertexBuffer.MatricesIndicesKind
  22480. * - VertexBuffer.MatricesIndicesExtraKind
  22481. * - VertexBuffer.MatricesWeightsKind
  22482. * - VertexBuffer.MatricesWeightsExtraKind
  22483. * @param data defines the data source
  22484. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22485. * @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)
  22486. */
  22487. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22488. /**
  22489. * Creates a new index buffer
  22490. * @param indices defines the indices to store in the index buffer
  22491. * @param totalVertices defines the total number of vertices (could be null)
  22492. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22493. */
  22494. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22495. }
  22496. /**
  22497. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22498. */
  22499. export class VertexData {
  22500. /**
  22501. * Mesh side orientation : usually the external or front surface
  22502. */
  22503. static readonly FRONTSIDE: number;
  22504. /**
  22505. * Mesh side orientation : usually the internal or back surface
  22506. */
  22507. static readonly BACKSIDE: number;
  22508. /**
  22509. * Mesh side orientation : both internal and external or front and back surfaces
  22510. */
  22511. static readonly DOUBLESIDE: number;
  22512. /**
  22513. * Mesh side orientation : by default, `FRONTSIDE`
  22514. */
  22515. static readonly DEFAULTSIDE: number;
  22516. /**
  22517. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22518. */
  22519. positions: Nullable<FloatArray>;
  22520. /**
  22521. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22522. */
  22523. normals: Nullable<FloatArray>;
  22524. /**
  22525. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22526. */
  22527. tangents: Nullable<FloatArray>;
  22528. /**
  22529. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22530. */
  22531. uvs: Nullable<FloatArray>;
  22532. /**
  22533. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22534. */
  22535. uvs2: Nullable<FloatArray>;
  22536. /**
  22537. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22538. */
  22539. uvs3: Nullable<FloatArray>;
  22540. /**
  22541. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22542. */
  22543. uvs4: Nullable<FloatArray>;
  22544. /**
  22545. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22546. */
  22547. uvs5: Nullable<FloatArray>;
  22548. /**
  22549. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22550. */
  22551. uvs6: Nullable<FloatArray>;
  22552. /**
  22553. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22554. */
  22555. colors: Nullable<FloatArray>;
  22556. /**
  22557. * 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).
  22558. */
  22559. matricesIndices: Nullable<FloatArray>;
  22560. /**
  22561. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22562. */
  22563. matricesWeights: Nullable<FloatArray>;
  22564. /**
  22565. * An array extending the number of possible indices
  22566. */
  22567. matricesIndicesExtra: Nullable<FloatArray>;
  22568. /**
  22569. * An array extending the number of possible weights when the number of indices is extended
  22570. */
  22571. matricesWeightsExtra: Nullable<FloatArray>;
  22572. /**
  22573. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22574. */
  22575. indices: Nullable<IndicesArray>;
  22576. /**
  22577. * Uses the passed data array to set the set the values for the specified kind of data
  22578. * @param data a linear array of floating numbers
  22579. * @param kind the type of data that is being set, eg positions, colors etc
  22580. */
  22581. set(data: FloatArray, kind: string): void;
  22582. /**
  22583. * Associates the vertexData to the passed Mesh.
  22584. * Sets it as updatable or not (default `false`)
  22585. * @param mesh the mesh the vertexData is applied to
  22586. * @param updatable when used and having the value true allows new data to update the vertexData
  22587. * @returns the VertexData
  22588. */
  22589. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22590. /**
  22591. * Associates the vertexData to the passed Geometry.
  22592. * Sets it as updatable or not (default `false`)
  22593. * @param geometry the geometry the vertexData is applied to
  22594. * @param updatable when used and having the value true allows new data to update the vertexData
  22595. * @returns VertexData
  22596. */
  22597. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22598. /**
  22599. * Updates the associated mesh
  22600. * @param mesh the mesh to be updated
  22601. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22602. * @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
  22603. * @returns VertexData
  22604. */
  22605. updateMesh(mesh: Mesh): VertexData;
  22606. /**
  22607. * Updates the associated geometry
  22608. * @param geometry the geometry to be updated
  22609. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22610. * @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
  22611. * @returns VertexData.
  22612. */
  22613. updateGeometry(geometry: Geometry): VertexData;
  22614. private _applyTo;
  22615. private _update;
  22616. /**
  22617. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22618. * @param matrix the transforming matrix
  22619. * @returns the VertexData
  22620. */
  22621. transform(matrix: Matrix): VertexData;
  22622. /**
  22623. * Merges the passed VertexData into the current one
  22624. * @param other the VertexData to be merged into the current one
  22625. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22626. * @returns the modified VertexData
  22627. */
  22628. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22629. private _mergeElement;
  22630. private _validate;
  22631. /**
  22632. * Serializes the VertexData
  22633. * @returns a serialized object
  22634. */
  22635. serialize(): any;
  22636. /**
  22637. * Extracts the vertexData from a mesh
  22638. * @param mesh the mesh from which to extract the VertexData
  22639. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22640. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22641. * @returns the object VertexData associated to the passed mesh
  22642. */
  22643. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22644. /**
  22645. * Extracts the vertexData from the geometry
  22646. * @param geometry the geometry from which to extract the VertexData
  22647. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22648. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22649. * @returns the object VertexData associated to the passed mesh
  22650. */
  22651. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22652. private static _ExtractFrom;
  22653. /**
  22654. * Creates the VertexData for a Ribbon
  22655. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22656. * * pathArray array of paths, each of which an array of successive Vector3
  22657. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22658. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22659. * * 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
  22660. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22661. * * 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)
  22662. * * 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)
  22663. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22664. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22665. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22666. * @returns the VertexData of the ribbon
  22667. */
  22668. static CreateRibbon(options: {
  22669. pathArray: Vector3[][];
  22670. closeArray?: boolean;
  22671. closePath?: boolean;
  22672. offset?: number;
  22673. sideOrientation?: number;
  22674. frontUVs?: Vector4;
  22675. backUVs?: Vector4;
  22676. invertUV?: boolean;
  22677. uvs?: Vector2[];
  22678. colors?: Color4[];
  22679. }): VertexData;
  22680. /**
  22681. * Creates the VertexData for a box
  22682. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22683. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22684. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22685. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22686. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22687. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22688. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22689. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22690. * * 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)
  22691. * * 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)
  22692. * @returns the VertexData of the box
  22693. */
  22694. static CreateBox(options: {
  22695. size?: number;
  22696. width?: number;
  22697. height?: number;
  22698. depth?: number;
  22699. faceUV?: Vector4[];
  22700. faceColors?: Color4[];
  22701. sideOrientation?: number;
  22702. frontUVs?: Vector4;
  22703. backUVs?: Vector4;
  22704. }): VertexData;
  22705. /**
  22706. * Creates the VertexData for a tiled box
  22707. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22708. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22709. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22710. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22711. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22712. * @returns the VertexData of the box
  22713. */
  22714. static CreateTiledBox(options: {
  22715. pattern?: number;
  22716. width?: number;
  22717. height?: number;
  22718. depth?: number;
  22719. tileSize?: number;
  22720. tileWidth?: number;
  22721. tileHeight?: number;
  22722. alignHorizontal?: number;
  22723. alignVertical?: number;
  22724. faceUV?: Vector4[];
  22725. faceColors?: Color4[];
  22726. sideOrientation?: number;
  22727. }): VertexData;
  22728. /**
  22729. * Creates the VertexData for a tiled plane
  22730. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22731. * * pattern a limited pattern arrangement depending on the number
  22732. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22733. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22734. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22735. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22736. * * 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)
  22737. * * 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)
  22738. * @returns the VertexData of the tiled plane
  22739. */
  22740. static CreateTiledPlane(options: {
  22741. pattern?: number;
  22742. tileSize?: number;
  22743. tileWidth?: number;
  22744. tileHeight?: number;
  22745. size?: number;
  22746. width?: number;
  22747. height?: number;
  22748. alignHorizontal?: number;
  22749. alignVertical?: number;
  22750. sideOrientation?: number;
  22751. frontUVs?: Vector4;
  22752. backUVs?: Vector4;
  22753. }): VertexData;
  22754. /**
  22755. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22756. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22757. * * segments sets the number of horizontal strips optional, default 32
  22758. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22759. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22760. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22761. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22762. * * 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
  22763. * * 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
  22764. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22765. * * 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)
  22766. * * 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)
  22767. * @returns the VertexData of the ellipsoid
  22768. */
  22769. static CreateSphere(options: {
  22770. segments?: number;
  22771. diameter?: number;
  22772. diameterX?: number;
  22773. diameterY?: number;
  22774. diameterZ?: number;
  22775. arc?: number;
  22776. slice?: number;
  22777. sideOrientation?: number;
  22778. frontUVs?: Vector4;
  22779. backUVs?: Vector4;
  22780. }): VertexData;
  22781. /**
  22782. * Creates the VertexData for a cylinder, cone or prism
  22783. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22784. * * height sets the height (y direction) of the cylinder, optional, default 2
  22785. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22786. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22787. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22788. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22789. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22790. * * 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
  22791. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22792. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22793. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22794. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22795. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22796. * * 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)
  22797. * * 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)
  22798. * @returns the VertexData of the cylinder, cone or prism
  22799. */
  22800. static CreateCylinder(options: {
  22801. height?: number;
  22802. diameterTop?: number;
  22803. diameterBottom?: number;
  22804. diameter?: number;
  22805. tessellation?: number;
  22806. subdivisions?: number;
  22807. arc?: number;
  22808. faceColors?: Color4[];
  22809. faceUV?: Vector4[];
  22810. hasRings?: boolean;
  22811. enclose?: boolean;
  22812. sideOrientation?: number;
  22813. frontUVs?: Vector4;
  22814. backUVs?: Vector4;
  22815. }): VertexData;
  22816. /**
  22817. * Creates the VertexData for a torus
  22818. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22819. * * diameter the diameter of the torus, optional default 1
  22820. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22821. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22822. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22823. * * 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)
  22824. * * 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)
  22825. * @returns the VertexData of the torus
  22826. */
  22827. static CreateTorus(options: {
  22828. diameter?: number;
  22829. thickness?: number;
  22830. tessellation?: number;
  22831. sideOrientation?: number;
  22832. frontUVs?: Vector4;
  22833. backUVs?: Vector4;
  22834. }): VertexData;
  22835. /**
  22836. * Creates the VertexData of the LineSystem
  22837. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22838. * - lines an array of lines, each line being an array of successive Vector3
  22839. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22840. * @returns the VertexData of the LineSystem
  22841. */
  22842. static CreateLineSystem(options: {
  22843. lines: Vector3[][];
  22844. colors?: Nullable<Color4[][]>;
  22845. }): VertexData;
  22846. /**
  22847. * Create the VertexData for a DashedLines
  22848. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22849. * - points an array successive Vector3
  22850. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22851. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22852. * - dashNb the intended total number of dashes, optional, default 200
  22853. * @returns the VertexData for the DashedLines
  22854. */
  22855. static CreateDashedLines(options: {
  22856. points: Vector3[];
  22857. dashSize?: number;
  22858. gapSize?: number;
  22859. dashNb?: number;
  22860. }): VertexData;
  22861. /**
  22862. * Creates the VertexData for a Ground
  22863. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22864. * - width the width (x direction) of the ground, optional, default 1
  22865. * - height the height (z direction) of the ground, optional, default 1
  22866. * - subdivisions the number of subdivisions per side, optional, default 1
  22867. * @returns the VertexData of the Ground
  22868. */
  22869. static CreateGround(options: {
  22870. width?: number;
  22871. height?: number;
  22872. subdivisions?: number;
  22873. subdivisionsX?: number;
  22874. subdivisionsY?: number;
  22875. }): VertexData;
  22876. /**
  22877. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22878. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22879. * * xmin the ground minimum X coordinate, optional, default -1
  22880. * * zmin the ground minimum Z coordinate, optional, default -1
  22881. * * xmax the ground maximum X coordinate, optional, default 1
  22882. * * zmax the ground maximum Z coordinate, optional, default 1
  22883. * * 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}
  22884. * * 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}
  22885. * @returns the VertexData of the TiledGround
  22886. */
  22887. static CreateTiledGround(options: {
  22888. xmin: number;
  22889. zmin: number;
  22890. xmax: number;
  22891. zmax: number;
  22892. subdivisions?: {
  22893. w: number;
  22894. h: number;
  22895. };
  22896. precision?: {
  22897. w: number;
  22898. h: number;
  22899. };
  22900. }): VertexData;
  22901. /**
  22902. * Creates the VertexData of the Ground designed from a heightmap
  22903. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22904. * * width the width (x direction) of the ground
  22905. * * height the height (z direction) of the ground
  22906. * * subdivisions the number of subdivisions per side
  22907. * * minHeight the minimum altitude on the ground, optional, default 0
  22908. * * maxHeight the maximum altitude on the ground, optional default 1
  22909. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22910. * * buffer the array holding the image color data
  22911. * * bufferWidth the width of image
  22912. * * bufferHeight the height of image
  22913. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22914. * @returns the VertexData of the Ground designed from a heightmap
  22915. */
  22916. static CreateGroundFromHeightMap(options: {
  22917. width: number;
  22918. height: number;
  22919. subdivisions: number;
  22920. minHeight: number;
  22921. maxHeight: number;
  22922. colorFilter: Color3;
  22923. buffer: Uint8Array;
  22924. bufferWidth: number;
  22925. bufferHeight: number;
  22926. alphaFilter: number;
  22927. }): VertexData;
  22928. /**
  22929. * Creates the VertexData for a Plane
  22930. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22931. * * size sets the width and height of the plane to the value of size, optional default 1
  22932. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22933. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22934. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22935. * * 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)
  22936. * * 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)
  22937. * @returns the VertexData of the box
  22938. */
  22939. static CreatePlane(options: {
  22940. size?: number;
  22941. width?: number;
  22942. height?: number;
  22943. sideOrientation?: number;
  22944. frontUVs?: Vector4;
  22945. backUVs?: Vector4;
  22946. }): VertexData;
  22947. /**
  22948. * Creates the VertexData of the Disc or regular Polygon
  22949. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22950. * * radius the radius of the disc, optional default 0.5
  22951. * * tessellation the number of polygon sides, optional, default 64
  22952. * * 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
  22953. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22954. * * 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)
  22955. * * 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)
  22956. * @returns the VertexData of the box
  22957. */
  22958. static CreateDisc(options: {
  22959. radius?: number;
  22960. tessellation?: number;
  22961. arc?: number;
  22962. sideOrientation?: number;
  22963. frontUVs?: Vector4;
  22964. backUVs?: Vector4;
  22965. }): VertexData;
  22966. /**
  22967. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22968. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22969. * @param polygon a mesh built from polygonTriangulation.build()
  22970. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22971. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22972. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22973. * @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)
  22974. * @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)
  22975. * @returns the VertexData of the Polygon
  22976. */
  22977. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22978. /**
  22979. * Creates the VertexData of the IcoSphere
  22980. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22981. * * radius the radius of the IcoSphere, optional default 1
  22982. * * radiusX allows stretching in the x direction, optional, default radius
  22983. * * radiusY allows stretching in the y direction, optional, default radius
  22984. * * radiusZ allows stretching in the z direction, optional, default radius
  22985. * * flat when true creates a flat shaded mesh, optional, default true
  22986. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22987. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22988. * * 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)
  22989. * * 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)
  22990. * @returns the VertexData of the IcoSphere
  22991. */
  22992. static CreateIcoSphere(options: {
  22993. radius?: number;
  22994. radiusX?: number;
  22995. radiusY?: number;
  22996. radiusZ?: number;
  22997. flat?: boolean;
  22998. subdivisions?: number;
  22999. sideOrientation?: number;
  23000. frontUVs?: Vector4;
  23001. backUVs?: Vector4;
  23002. }): VertexData;
  23003. /**
  23004. * Creates the VertexData for a Polyhedron
  23005. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23006. * * type provided types are:
  23007. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23008. * * 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)
  23009. * * size the size of the IcoSphere, optional default 1
  23010. * * sizeX allows stretching in the x direction, optional, default size
  23011. * * sizeY allows stretching in the y direction, optional, default size
  23012. * * sizeZ allows stretching in the z direction, optional, default size
  23013. * * 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
  23014. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23015. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23016. * * flat when true creates a flat shaded mesh, optional, default true
  23017. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23018. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23019. * * 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)
  23020. * * 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)
  23021. * @returns the VertexData of the Polyhedron
  23022. */
  23023. static CreatePolyhedron(options: {
  23024. type?: number;
  23025. size?: number;
  23026. sizeX?: number;
  23027. sizeY?: number;
  23028. sizeZ?: number;
  23029. custom?: any;
  23030. faceUV?: Vector4[];
  23031. faceColors?: Color4[];
  23032. flat?: boolean;
  23033. sideOrientation?: number;
  23034. frontUVs?: Vector4;
  23035. backUVs?: Vector4;
  23036. }): VertexData;
  23037. /**
  23038. * Creates the VertexData for a TorusKnot
  23039. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23040. * * radius the radius of the torus knot, optional, default 2
  23041. * * tube the thickness of the tube, optional, default 0.5
  23042. * * radialSegments the number of sides on each tube segments, optional, default 32
  23043. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23044. * * p the number of windings around the z axis, optional, default 2
  23045. * * q the number of windings around the x axis, optional, default 3
  23046. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23047. * * 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)
  23048. * * 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)
  23049. * @returns the VertexData of the Torus Knot
  23050. */
  23051. static CreateTorusKnot(options: {
  23052. radius?: number;
  23053. tube?: number;
  23054. radialSegments?: number;
  23055. tubularSegments?: number;
  23056. p?: number;
  23057. q?: number;
  23058. sideOrientation?: number;
  23059. frontUVs?: Vector4;
  23060. backUVs?: Vector4;
  23061. }): VertexData;
  23062. /**
  23063. * Compute normals for given positions and indices
  23064. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23065. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23066. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23067. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23068. * * facetNormals : optional array of facet normals (vector3)
  23069. * * facetPositions : optional array of facet positions (vector3)
  23070. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23071. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23072. * * bInfo : optional bounding info, required for facetPartitioning computation
  23073. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23074. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23075. * * useRightHandedSystem: optional boolean to for right handed system computation
  23076. * * depthSort : optional boolean to enable the facet depth sort computation
  23077. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23078. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23079. */
  23080. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23081. facetNormals?: any;
  23082. facetPositions?: any;
  23083. facetPartitioning?: any;
  23084. ratio?: number;
  23085. bInfo?: any;
  23086. bbSize?: Vector3;
  23087. subDiv?: any;
  23088. useRightHandedSystem?: boolean;
  23089. depthSort?: boolean;
  23090. distanceTo?: Vector3;
  23091. depthSortedFacets?: any;
  23092. }): void;
  23093. /** @hidden */
  23094. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23095. /**
  23096. * Applies VertexData created from the imported parameters to the geometry
  23097. * @param parsedVertexData the parsed data from an imported file
  23098. * @param geometry the geometry to apply the VertexData to
  23099. */
  23100. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23101. }
  23102. }
  23103. declare module "babylonjs/Morph/morphTarget" {
  23104. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23105. import { Observable } from "babylonjs/Misc/observable";
  23106. import { Nullable, FloatArray } from "babylonjs/types";
  23107. import { Scene } from "babylonjs/scene";
  23108. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23109. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23110. /**
  23111. * Defines a target to use with MorphTargetManager
  23112. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23113. */
  23114. export class MorphTarget implements IAnimatable {
  23115. /** defines the name of the target */
  23116. name: string;
  23117. /**
  23118. * Gets or sets the list of animations
  23119. */
  23120. animations: import("babylonjs/Animations/animation").Animation[];
  23121. private _scene;
  23122. private _positions;
  23123. private _normals;
  23124. private _tangents;
  23125. private _uvs;
  23126. private _influence;
  23127. private _uniqueId;
  23128. /**
  23129. * Observable raised when the influence changes
  23130. */
  23131. onInfluenceChanged: Observable<boolean>;
  23132. /** @hidden */
  23133. _onDataLayoutChanged: Observable<void>;
  23134. /**
  23135. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23136. */
  23137. get influence(): number;
  23138. set influence(influence: number);
  23139. /**
  23140. * Gets or sets the id of the morph Target
  23141. */
  23142. id: string;
  23143. private _animationPropertiesOverride;
  23144. /**
  23145. * Gets or sets the animation properties override
  23146. */
  23147. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23148. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23149. /**
  23150. * Creates a new MorphTarget
  23151. * @param name defines the name of the target
  23152. * @param influence defines the influence to use
  23153. * @param scene defines the scene the morphtarget belongs to
  23154. */
  23155. constructor(
  23156. /** defines the name of the target */
  23157. name: string, influence?: number, scene?: Nullable<Scene>);
  23158. /**
  23159. * Gets the unique ID of this manager
  23160. */
  23161. get uniqueId(): number;
  23162. /**
  23163. * Gets a boolean defining if the target contains position data
  23164. */
  23165. get hasPositions(): boolean;
  23166. /**
  23167. * Gets a boolean defining if the target contains normal data
  23168. */
  23169. get hasNormals(): boolean;
  23170. /**
  23171. * Gets a boolean defining if the target contains tangent data
  23172. */
  23173. get hasTangents(): boolean;
  23174. /**
  23175. * Gets a boolean defining if the target contains texture coordinates data
  23176. */
  23177. get hasUVs(): boolean;
  23178. /**
  23179. * Affects position data to this target
  23180. * @param data defines the position data to use
  23181. */
  23182. setPositions(data: Nullable<FloatArray>): void;
  23183. /**
  23184. * Gets the position data stored in this target
  23185. * @returns a FloatArray containing the position data (or null if not present)
  23186. */
  23187. getPositions(): Nullable<FloatArray>;
  23188. /**
  23189. * Affects normal data to this target
  23190. * @param data defines the normal data to use
  23191. */
  23192. setNormals(data: Nullable<FloatArray>): void;
  23193. /**
  23194. * Gets the normal data stored in this target
  23195. * @returns a FloatArray containing the normal data (or null if not present)
  23196. */
  23197. getNormals(): Nullable<FloatArray>;
  23198. /**
  23199. * Affects tangent data to this target
  23200. * @param data defines the tangent data to use
  23201. */
  23202. setTangents(data: Nullable<FloatArray>): void;
  23203. /**
  23204. * Gets the tangent data stored in this target
  23205. * @returns a FloatArray containing the tangent data (or null if not present)
  23206. */
  23207. getTangents(): Nullable<FloatArray>;
  23208. /**
  23209. * Affects texture coordinates data to this target
  23210. * @param data defines the texture coordinates data to use
  23211. */
  23212. setUVs(data: Nullable<FloatArray>): void;
  23213. /**
  23214. * Gets the texture coordinates data stored in this target
  23215. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23216. */
  23217. getUVs(): Nullable<FloatArray>;
  23218. /**
  23219. * Clone the current target
  23220. * @returns a new MorphTarget
  23221. */
  23222. clone(): MorphTarget;
  23223. /**
  23224. * Serializes the current target into a Serialization object
  23225. * @returns the serialized object
  23226. */
  23227. serialize(): any;
  23228. /**
  23229. * Returns the string "MorphTarget"
  23230. * @returns "MorphTarget"
  23231. */
  23232. getClassName(): string;
  23233. /**
  23234. * Creates a new target from serialized data
  23235. * @param serializationObject defines the serialized data to use
  23236. * @returns a new MorphTarget
  23237. */
  23238. static Parse(serializationObject: any): MorphTarget;
  23239. /**
  23240. * Creates a MorphTarget from mesh data
  23241. * @param mesh defines the source mesh
  23242. * @param name defines the name to use for the new target
  23243. * @param influence defines the influence to attach to the target
  23244. * @returns a new MorphTarget
  23245. */
  23246. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23247. }
  23248. }
  23249. declare module "babylonjs/Morph/morphTargetManager" {
  23250. import { Nullable } from "babylonjs/types";
  23251. import { Scene } from "babylonjs/scene";
  23252. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23253. /**
  23254. * This class is used to deform meshes using morphing between different targets
  23255. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23256. */
  23257. export class MorphTargetManager {
  23258. private _targets;
  23259. private _targetInfluenceChangedObservers;
  23260. private _targetDataLayoutChangedObservers;
  23261. private _activeTargets;
  23262. private _scene;
  23263. private _influences;
  23264. private _supportsNormals;
  23265. private _supportsTangents;
  23266. private _supportsUVs;
  23267. private _vertexCount;
  23268. private _uniqueId;
  23269. private _tempInfluences;
  23270. /**
  23271. * Gets or sets a boolean indicating if normals must be morphed
  23272. */
  23273. enableNormalMorphing: boolean;
  23274. /**
  23275. * Gets or sets a boolean indicating if tangents must be morphed
  23276. */
  23277. enableTangentMorphing: boolean;
  23278. /**
  23279. * Gets or sets a boolean indicating if UV must be morphed
  23280. */
  23281. enableUVMorphing: boolean;
  23282. /**
  23283. * Creates a new MorphTargetManager
  23284. * @param scene defines the current scene
  23285. */
  23286. constructor(scene?: Nullable<Scene>);
  23287. /**
  23288. * Gets the unique ID of this manager
  23289. */
  23290. get uniqueId(): number;
  23291. /**
  23292. * Gets the number of vertices handled by this manager
  23293. */
  23294. get vertexCount(): number;
  23295. /**
  23296. * Gets a boolean indicating if this manager supports morphing of normals
  23297. */
  23298. get supportsNormals(): boolean;
  23299. /**
  23300. * Gets a boolean indicating if this manager supports morphing of tangents
  23301. */
  23302. get supportsTangents(): boolean;
  23303. /**
  23304. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23305. */
  23306. get supportsUVs(): boolean;
  23307. /**
  23308. * Gets the number of targets stored in this manager
  23309. */
  23310. get numTargets(): number;
  23311. /**
  23312. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23313. */
  23314. get numInfluencers(): number;
  23315. /**
  23316. * Gets the list of influences (one per target)
  23317. */
  23318. get influences(): Float32Array;
  23319. /**
  23320. * Gets the active target at specified index. An active target is a target with an influence > 0
  23321. * @param index defines the index to check
  23322. * @returns the requested target
  23323. */
  23324. getActiveTarget(index: number): MorphTarget;
  23325. /**
  23326. * Gets the target at specified index
  23327. * @param index defines the index to check
  23328. * @returns the requested target
  23329. */
  23330. getTarget(index: number): MorphTarget;
  23331. /**
  23332. * Add a new target to this manager
  23333. * @param target defines the target to add
  23334. */
  23335. addTarget(target: MorphTarget): void;
  23336. /**
  23337. * Removes a target from the manager
  23338. * @param target defines the target to remove
  23339. */
  23340. removeTarget(target: MorphTarget): void;
  23341. /**
  23342. * Clone the current manager
  23343. * @returns a new MorphTargetManager
  23344. */
  23345. clone(): MorphTargetManager;
  23346. /**
  23347. * Serializes the current manager into a Serialization object
  23348. * @returns the serialized object
  23349. */
  23350. serialize(): any;
  23351. private _syncActiveTargets;
  23352. /**
  23353. * Syncrhonize the targets with all the meshes using this morph target manager
  23354. */
  23355. synchronize(): void;
  23356. /**
  23357. * Creates a new MorphTargetManager from serialized data
  23358. * @param serializationObject defines the serialized data
  23359. * @param scene defines the hosting scene
  23360. * @returns the new MorphTargetManager
  23361. */
  23362. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23363. }
  23364. }
  23365. declare module "babylonjs/Meshes/meshLODLevel" {
  23366. import { Mesh } from "babylonjs/Meshes/mesh";
  23367. import { Nullable } from "babylonjs/types";
  23368. /**
  23369. * Class used to represent a specific level of detail of a mesh
  23370. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23371. */
  23372. export class MeshLODLevel {
  23373. /** Defines the distance where this level should start being displayed */
  23374. distance: number;
  23375. /** Defines the mesh to use to render this level */
  23376. mesh: Nullable<Mesh>;
  23377. /**
  23378. * Creates a new LOD level
  23379. * @param distance defines the distance where this level should star being displayed
  23380. * @param mesh defines the mesh to use to render this level
  23381. */
  23382. constructor(
  23383. /** Defines the distance where this level should start being displayed */
  23384. distance: number,
  23385. /** Defines the mesh to use to render this level */
  23386. mesh: Nullable<Mesh>);
  23387. }
  23388. }
  23389. declare module "babylonjs/Meshes/groundMesh" {
  23390. import { Scene } from "babylonjs/scene";
  23391. import { Vector3 } from "babylonjs/Maths/math.vector";
  23392. import { Mesh } from "babylonjs/Meshes/mesh";
  23393. /**
  23394. * Mesh representing the gorund
  23395. */
  23396. export class GroundMesh extends Mesh {
  23397. /** If octree should be generated */
  23398. generateOctree: boolean;
  23399. private _heightQuads;
  23400. /** @hidden */
  23401. _subdivisionsX: number;
  23402. /** @hidden */
  23403. _subdivisionsY: number;
  23404. /** @hidden */
  23405. _width: number;
  23406. /** @hidden */
  23407. _height: number;
  23408. /** @hidden */
  23409. _minX: number;
  23410. /** @hidden */
  23411. _maxX: number;
  23412. /** @hidden */
  23413. _minZ: number;
  23414. /** @hidden */
  23415. _maxZ: number;
  23416. constructor(name: string, scene: Scene);
  23417. /**
  23418. * "GroundMesh"
  23419. * @returns "GroundMesh"
  23420. */
  23421. getClassName(): string;
  23422. /**
  23423. * The minimum of x and y subdivisions
  23424. */
  23425. get subdivisions(): number;
  23426. /**
  23427. * X subdivisions
  23428. */
  23429. get subdivisionsX(): number;
  23430. /**
  23431. * Y subdivisions
  23432. */
  23433. get subdivisionsY(): number;
  23434. /**
  23435. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23436. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23437. * @param chunksCount the number of subdivisions for x and y
  23438. * @param octreeBlocksSize (Default: 32)
  23439. */
  23440. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23441. /**
  23442. * Returns a height (y) value in the Worl system :
  23443. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23444. * @param x x coordinate
  23445. * @param z z coordinate
  23446. * @returns the ground y position if (x, z) are outside the ground surface.
  23447. */
  23448. getHeightAtCoordinates(x: number, z: number): number;
  23449. /**
  23450. * Returns a normalized vector (Vector3) orthogonal to the ground
  23451. * at the ground coordinates (x, z) expressed in the World system.
  23452. * @param x x coordinate
  23453. * @param z z coordinate
  23454. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23455. */
  23456. getNormalAtCoordinates(x: number, z: number): Vector3;
  23457. /**
  23458. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23459. * at the ground coordinates (x, z) expressed in the World system.
  23460. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23461. * @param x x coordinate
  23462. * @param z z coordinate
  23463. * @param ref vector to store the result
  23464. * @returns the GroundMesh.
  23465. */
  23466. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23467. /**
  23468. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23469. * if the ground has been updated.
  23470. * This can be used in the render loop.
  23471. * @returns the GroundMesh.
  23472. */
  23473. updateCoordinateHeights(): GroundMesh;
  23474. private _getFacetAt;
  23475. private _initHeightQuads;
  23476. private _computeHeightQuads;
  23477. /**
  23478. * Serializes this ground mesh
  23479. * @param serializationObject object to write serialization to
  23480. */
  23481. serialize(serializationObject: any): void;
  23482. /**
  23483. * Parses a serialized ground mesh
  23484. * @param parsedMesh the serialized mesh
  23485. * @param scene the scene to create the ground mesh in
  23486. * @returns the created ground mesh
  23487. */
  23488. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23489. }
  23490. }
  23491. declare module "babylonjs/Physics/physicsJoint" {
  23492. import { Vector3 } from "babylonjs/Maths/math.vector";
  23493. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23494. /**
  23495. * Interface for Physics-Joint data
  23496. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23497. */
  23498. export interface PhysicsJointData {
  23499. /**
  23500. * The main pivot of the joint
  23501. */
  23502. mainPivot?: Vector3;
  23503. /**
  23504. * The connected pivot of the joint
  23505. */
  23506. connectedPivot?: Vector3;
  23507. /**
  23508. * The main axis of the joint
  23509. */
  23510. mainAxis?: Vector3;
  23511. /**
  23512. * The connected axis of the joint
  23513. */
  23514. connectedAxis?: Vector3;
  23515. /**
  23516. * The collision of the joint
  23517. */
  23518. collision?: boolean;
  23519. /**
  23520. * Native Oimo/Cannon/Energy data
  23521. */
  23522. nativeParams?: any;
  23523. }
  23524. /**
  23525. * This is a holder class for the physics joint created by the physics plugin
  23526. * It holds a set of functions to control the underlying joint
  23527. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23528. */
  23529. export class PhysicsJoint {
  23530. /**
  23531. * The type of the physics joint
  23532. */
  23533. type: number;
  23534. /**
  23535. * The data for the physics joint
  23536. */
  23537. jointData: PhysicsJointData;
  23538. private _physicsJoint;
  23539. protected _physicsPlugin: IPhysicsEnginePlugin;
  23540. /**
  23541. * Initializes the physics joint
  23542. * @param type The type of the physics joint
  23543. * @param jointData The data for the physics joint
  23544. */
  23545. constructor(
  23546. /**
  23547. * The type of the physics joint
  23548. */
  23549. type: number,
  23550. /**
  23551. * The data for the physics joint
  23552. */
  23553. jointData: PhysicsJointData);
  23554. /**
  23555. * Gets the physics joint
  23556. */
  23557. get physicsJoint(): any;
  23558. /**
  23559. * Sets the physics joint
  23560. */
  23561. set physicsJoint(newJoint: any);
  23562. /**
  23563. * Sets the physics plugin
  23564. */
  23565. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23566. /**
  23567. * Execute a function that is physics-plugin specific.
  23568. * @param {Function} func the function that will be executed.
  23569. * It accepts two parameters: the physics world and the physics joint
  23570. */
  23571. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23572. /**
  23573. * Distance-Joint type
  23574. */
  23575. static DistanceJoint: number;
  23576. /**
  23577. * Hinge-Joint type
  23578. */
  23579. static HingeJoint: number;
  23580. /**
  23581. * Ball-and-Socket joint type
  23582. */
  23583. static BallAndSocketJoint: number;
  23584. /**
  23585. * Wheel-Joint type
  23586. */
  23587. static WheelJoint: number;
  23588. /**
  23589. * Slider-Joint type
  23590. */
  23591. static SliderJoint: number;
  23592. /**
  23593. * Prismatic-Joint type
  23594. */
  23595. static PrismaticJoint: number;
  23596. /**
  23597. * Universal-Joint type
  23598. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23599. */
  23600. static UniversalJoint: number;
  23601. /**
  23602. * Hinge-Joint 2 type
  23603. */
  23604. static Hinge2Joint: number;
  23605. /**
  23606. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23607. */
  23608. static PointToPointJoint: number;
  23609. /**
  23610. * Spring-Joint type
  23611. */
  23612. static SpringJoint: number;
  23613. /**
  23614. * Lock-Joint type
  23615. */
  23616. static LockJoint: number;
  23617. }
  23618. /**
  23619. * A class representing a physics distance joint
  23620. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23621. */
  23622. export class DistanceJoint extends PhysicsJoint {
  23623. /**
  23624. *
  23625. * @param jointData The data for the Distance-Joint
  23626. */
  23627. constructor(jointData: DistanceJointData);
  23628. /**
  23629. * Update the predefined distance.
  23630. * @param maxDistance The maximum preferred distance
  23631. * @param minDistance The minimum preferred distance
  23632. */
  23633. updateDistance(maxDistance: number, minDistance?: number): void;
  23634. }
  23635. /**
  23636. * Represents a Motor-Enabled Joint
  23637. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23638. */
  23639. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23640. /**
  23641. * Initializes the Motor-Enabled Joint
  23642. * @param type The type of the joint
  23643. * @param jointData The physica joint data for the joint
  23644. */
  23645. constructor(type: number, jointData: PhysicsJointData);
  23646. /**
  23647. * Set the motor values.
  23648. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23649. * @param force the force to apply
  23650. * @param maxForce max force for this motor.
  23651. */
  23652. setMotor(force?: number, maxForce?: number): void;
  23653. /**
  23654. * Set the motor's limits.
  23655. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23656. * @param upperLimit The upper limit of the motor
  23657. * @param lowerLimit The lower limit of the motor
  23658. */
  23659. setLimit(upperLimit: number, lowerLimit?: number): void;
  23660. }
  23661. /**
  23662. * This class represents a single physics Hinge-Joint
  23663. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23664. */
  23665. export class HingeJoint extends MotorEnabledJoint {
  23666. /**
  23667. * Initializes the Hinge-Joint
  23668. * @param jointData The joint data for the Hinge-Joint
  23669. */
  23670. constructor(jointData: PhysicsJointData);
  23671. /**
  23672. * Set the motor values.
  23673. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23674. * @param {number} force the force to apply
  23675. * @param {number} maxForce max force for this motor.
  23676. */
  23677. setMotor(force?: number, maxForce?: number): void;
  23678. /**
  23679. * Set the motor's limits.
  23680. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23681. * @param upperLimit The upper limit of the motor
  23682. * @param lowerLimit The lower limit of the motor
  23683. */
  23684. setLimit(upperLimit: number, lowerLimit?: number): void;
  23685. }
  23686. /**
  23687. * This class represents a dual hinge physics joint (same as wheel joint)
  23688. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23689. */
  23690. export class Hinge2Joint extends MotorEnabledJoint {
  23691. /**
  23692. * Initializes the Hinge2-Joint
  23693. * @param jointData The joint data for the Hinge2-Joint
  23694. */
  23695. constructor(jointData: PhysicsJointData);
  23696. /**
  23697. * Set the motor values.
  23698. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23699. * @param {number} targetSpeed the speed the motor is to reach
  23700. * @param {number} maxForce max force for this motor.
  23701. * @param {motorIndex} the motor's index, 0 or 1.
  23702. */
  23703. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23704. /**
  23705. * Set the motor limits.
  23706. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23707. * @param {number} upperLimit the upper limit
  23708. * @param {number} lowerLimit lower limit
  23709. * @param {motorIndex} the motor's index, 0 or 1.
  23710. */
  23711. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23712. }
  23713. /**
  23714. * Interface for a motor enabled joint
  23715. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23716. */
  23717. export interface IMotorEnabledJoint {
  23718. /**
  23719. * Physics joint
  23720. */
  23721. physicsJoint: any;
  23722. /**
  23723. * Sets the motor of the motor-enabled joint
  23724. * @param force The force of the motor
  23725. * @param maxForce The maximum force of the motor
  23726. * @param motorIndex The index of the motor
  23727. */
  23728. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23729. /**
  23730. * Sets the limit of the motor
  23731. * @param upperLimit The upper limit of the motor
  23732. * @param lowerLimit The lower limit of the motor
  23733. * @param motorIndex The index of the motor
  23734. */
  23735. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23736. }
  23737. /**
  23738. * Joint data for a Distance-Joint
  23739. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23740. */
  23741. export interface DistanceJointData extends PhysicsJointData {
  23742. /**
  23743. * Max distance the 2 joint objects can be apart
  23744. */
  23745. maxDistance: number;
  23746. }
  23747. /**
  23748. * Joint data from a spring joint
  23749. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23750. */
  23751. export interface SpringJointData extends PhysicsJointData {
  23752. /**
  23753. * Length of the spring
  23754. */
  23755. length: number;
  23756. /**
  23757. * Stiffness of the spring
  23758. */
  23759. stiffness: number;
  23760. /**
  23761. * Damping of the spring
  23762. */
  23763. damping: number;
  23764. /** this callback will be called when applying the force to the impostors. */
  23765. forceApplicationCallback: () => void;
  23766. }
  23767. }
  23768. declare module "babylonjs/Physics/physicsRaycastResult" {
  23769. import { Vector3 } from "babylonjs/Maths/math.vector";
  23770. /**
  23771. * Holds the data for the raycast result
  23772. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23773. */
  23774. export class PhysicsRaycastResult {
  23775. private _hasHit;
  23776. private _hitDistance;
  23777. private _hitNormalWorld;
  23778. private _hitPointWorld;
  23779. private _rayFromWorld;
  23780. private _rayToWorld;
  23781. /**
  23782. * Gets if there was a hit
  23783. */
  23784. get hasHit(): boolean;
  23785. /**
  23786. * Gets the distance from the hit
  23787. */
  23788. get hitDistance(): number;
  23789. /**
  23790. * Gets the hit normal/direction in the world
  23791. */
  23792. get hitNormalWorld(): Vector3;
  23793. /**
  23794. * Gets the hit point in the world
  23795. */
  23796. get hitPointWorld(): Vector3;
  23797. /**
  23798. * Gets the ray "start point" of the ray in the world
  23799. */
  23800. get rayFromWorld(): Vector3;
  23801. /**
  23802. * Gets the ray "end point" of the ray in the world
  23803. */
  23804. get rayToWorld(): Vector3;
  23805. /**
  23806. * Sets the hit data (normal & point in world space)
  23807. * @param hitNormalWorld defines the normal in world space
  23808. * @param hitPointWorld defines the point in world space
  23809. */
  23810. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23811. /**
  23812. * Sets the distance from the start point to the hit point
  23813. * @param distance
  23814. */
  23815. setHitDistance(distance: number): void;
  23816. /**
  23817. * Calculates the distance manually
  23818. */
  23819. calculateHitDistance(): void;
  23820. /**
  23821. * Resets all the values to default
  23822. * @param from The from point on world space
  23823. * @param to The to point on world space
  23824. */
  23825. reset(from?: Vector3, to?: Vector3): void;
  23826. }
  23827. /**
  23828. * Interface for the size containing width and height
  23829. */
  23830. interface IXYZ {
  23831. /**
  23832. * X
  23833. */
  23834. x: number;
  23835. /**
  23836. * Y
  23837. */
  23838. y: number;
  23839. /**
  23840. * Z
  23841. */
  23842. z: number;
  23843. }
  23844. }
  23845. declare module "babylonjs/Physics/IPhysicsEngine" {
  23846. import { Nullable } from "babylonjs/types";
  23847. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23848. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23849. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23850. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23851. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23852. /**
  23853. * Interface used to describe a physics joint
  23854. */
  23855. export interface PhysicsImpostorJoint {
  23856. /** Defines the main impostor to which the joint is linked */
  23857. mainImpostor: PhysicsImpostor;
  23858. /** Defines the impostor that is connected to the main impostor using this joint */
  23859. connectedImpostor: PhysicsImpostor;
  23860. /** Defines the joint itself */
  23861. joint: PhysicsJoint;
  23862. }
  23863. /** @hidden */
  23864. export interface IPhysicsEnginePlugin {
  23865. world: any;
  23866. name: string;
  23867. setGravity(gravity: Vector3): void;
  23868. setTimeStep(timeStep: number): void;
  23869. getTimeStep(): number;
  23870. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23871. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23872. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23873. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23874. removePhysicsBody(impostor: PhysicsImpostor): void;
  23875. generateJoint(joint: PhysicsImpostorJoint): void;
  23876. removeJoint(joint: PhysicsImpostorJoint): void;
  23877. isSupported(): boolean;
  23878. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23879. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23880. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23881. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23882. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23883. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23884. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23885. getBodyMass(impostor: PhysicsImpostor): number;
  23886. getBodyFriction(impostor: PhysicsImpostor): number;
  23887. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23888. getBodyRestitution(impostor: PhysicsImpostor): number;
  23889. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23890. getBodyPressure?(impostor: PhysicsImpostor): number;
  23891. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23892. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23893. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23894. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23895. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23896. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23897. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23898. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23899. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23900. sleepBody(impostor: PhysicsImpostor): void;
  23901. wakeUpBody(impostor: PhysicsImpostor): void;
  23902. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23903. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23904. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23905. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23906. getRadius(impostor: PhysicsImpostor): number;
  23907. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23908. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23909. dispose(): void;
  23910. }
  23911. /**
  23912. * Interface used to define a physics engine
  23913. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23914. */
  23915. export interface IPhysicsEngine {
  23916. /**
  23917. * Gets the gravity vector used by the simulation
  23918. */
  23919. gravity: Vector3;
  23920. /**
  23921. * Sets the gravity vector used by the simulation
  23922. * @param gravity defines the gravity vector to use
  23923. */
  23924. setGravity(gravity: Vector3): void;
  23925. /**
  23926. * Set the time step of the physics engine.
  23927. * Default is 1/60.
  23928. * To slow it down, enter 1/600 for example.
  23929. * To speed it up, 1/30
  23930. * @param newTimeStep the new timestep to apply to this world.
  23931. */
  23932. setTimeStep(newTimeStep: number): void;
  23933. /**
  23934. * Get the time step of the physics engine.
  23935. * @returns the current time step
  23936. */
  23937. getTimeStep(): number;
  23938. /**
  23939. * Set the sub time step of the physics engine.
  23940. * Default is 0 meaning there is no sub steps
  23941. * To increase physics resolution precision, set a small value (like 1 ms)
  23942. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23943. */
  23944. setSubTimeStep(subTimeStep: number): void;
  23945. /**
  23946. * Get the sub time step of the physics engine.
  23947. * @returns the current sub time step
  23948. */
  23949. getSubTimeStep(): number;
  23950. /**
  23951. * Release all resources
  23952. */
  23953. dispose(): void;
  23954. /**
  23955. * Gets the name of the current physics plugin
  23956. * @returns the name of the plugin
  23957. */
  23958. getPhysicsPluginName(): string;
  23959. /**
  23960. * Adding a new impostor for the impostor tracking.
  23961. * This will be done by the impostor itself.
  23962. * @param impostor the impostor to add
  23963. */
  23964. addImpostor(impostor: PhysicsImpostor): void;
  23965. /**
  23966. * Remove an impostor from the engine.
  23967. * This impostor and its mesh will not longer be updated by the physics engine.
  23968. * @param impostor the impostor to remove
  23969. */
  23970. removeImpostor(impostor: PhysicsImpostor): void;
  23971. /**
  23972. * Add a joint to the physics engine
  23973. * @param mainImpostor defines the main impostor to which the joint is added.
  23974. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23975. * @param joint defines the joint that will connect both impostors.
  23976. */
  23977. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23978. /**
  23979. * Removes a joint from the simulation
  23980. * @param mainImpostor defines the impostor used with the joint
  23981. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23982. * @param joint defines the joint to remove
  23983. */
  23984. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23985. /**
  23986. * Gets the current plugin used to run the simulation
  23987. * @returns current plugin
  23988. */
  23989. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23990. /**
  23991. * Gets the list of physic impostors
  23992. * @returns an array of PhysicsImpostor
  23993. */
  23994. getImpostors(): Array<PhysicsImpostor>;
  23995. /**
  23996. * Gets the impostor for a physics enabled object
  23997. * @param object defines the object impersonated by the impostor
  23998. * @returns the PhysicsImpostor or null if not found
  23999. */
  24000. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24001. /**
  24002. * Gets the impostor for a physics body object
  24003. * @param body defines physics body used by the impostor
  24004. * @returns the PhysicsImpostor or null if not found
  24005. */
  24006. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24007. /**
  24008. * Does a raycast in the physics world
  24009. * @param from when should the ray start?
  24010. * @param to when should the ray end?
  24011. * @returns PhysicsRaycastResult
  24012. */
  24013. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24014. /**
  24015. * Called by the scene. No need to call it.
  24016. * @param delta defines the timespam between frames
  24017. */
  24018. _step(delta: number): void;
  24019. }
  24020. }
  24021. declare module "babylonjs/Physics/physicsImpostor" {
  24022. import { Nullable, IndicesArray } from "babylonjs/types";
  24023. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24024. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24025. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24026. import { Scene } from "babylonjs/scene";
  24027. import { Bone } from "babylonjs/Bones/bone";
  24028. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24029. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24030. import { Space } from "babylonjs/Maths/math.axis";
  24031. /**
  24032. * The interface for the physics imposter parameters
  24033. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24034. */
  24035. export interface PhysicsImpostorParameters {
  24036. /**
  24037. * The mass of the physics imposter
  24038. */
  24039. mass: number;
  24040. /**
  24041. * The friction of the physics imposter
  24042. */
  24043. friction?: number;
  24044. /**
  24045. * The coefficient of restitution of the physics imposter
  24046. */
  24047. restitution?: number;
  24048. /**
  24049. * The native options of the physics imposter
  24050. */
  24051. nativeOptions?: any;
  24052. /**
  24053. * Specifies if the parent should be ignored
  24054. */
  24055. ignoreParent?: boolean;
  24056. /**
  24057. * Specifies if bi-directional transformations should be disabled
  24058. */
  24059. disableBidirectionalTransformation?: boolean;
  24060. /**
  24061. * The pressure inside the physics imposter, soft object only
  24062. */
  24063. pressure?: number;
  24064. /**
  24065. * The stiffness the physics imposter, soft object only
  24066. */
  24067. stiffness?: number;
  24068. /**
  24069. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24070. */
  24071. velocityIterations?: number;
  24072. /**
  24073. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24074. */
  24075. positionIterations?: number;
  24076. /**
  24077. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24078. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24079. * Add to fix multiple points
  24080. */
  24081. fixedPoints?: number;
  24082. /**
  24083. * The collision margin around a soft object
  24084. */
  24085. margin?: number;
  24086. /**
  24087. * The collision margin around a soft object
  24088. */
  24089. damping?: number;
  24090. /**
  24091. * The path for a rope based on an extrusion
  24092. */
  24093. path?: any;
  24094. /**
  24095. * The shape of an extrusion used for a rope based on an extrusion
  24096. */
  24097. shape?: any;
  24098. }
  24099. /**
  24100. * Interface for a physics-enabled object
  24101. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24102. */
  24103. export interface IPhysicsEnabledObject {
  24104. /**
  24105. * The position of the physics-enabled object
  24106. */
  24107. position: Vector3;
  24108. /**
  24109. * The rotation of the physics-enabled object
  24110. */
  24111. rotationQuaternion: Nullable<Quaternion>;
  24112. /**
  24113. * The scale of the physics-enabled object
  24114. */
  24115. scaling: Vector3;
  24116. /**
  24117. * The rotation of the physics-enabled object
  24118. */
  24119. rotation?: Vector3;
  24120. /**
  24121. * The parent of the physics-enabled object
  24122. */
  24123. parent?: any;
  24124. /**
  24125. * The bounding info of the physics-enabled object
  24126. * @returns The bounding info of the physics-enabled object
  24127. */
  24128. getBoundingInfo(): BoundingInfo;
  24129. /**
  24130. * Computes the world matrix
  24131. * @param force Specifies if the world matrix should be computed by force
  24132. * @returns A world matrix
  24133. */
  24134. computeWorldMatrix(force: boolean): Matrix;
  24135. /**
  24136. * Gets the world matrix
  24137. * @returns A world matrix
  24138. */
  24139. getWorldMatrix?(): Matrix;
  24140. /**
  24141. * Gets the child meshes
  24142. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24143. * @returns An array of abstract meshes
  24144. */
  24145. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24146. /**
  24147. * Gets the vertex data
  24148. * @param kind The type of vertex data
  24149. * @returns A nullable array of numbers, or a float32 array
  24150. */
  24151. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24152. /**
  24153. * Gets the indices from the mesh
  24154. * @returns A nullable array of index arrays
  24155. */
  24156. getIndices?(): Nullable<IndicesArray>;
  24157. /**
  24158. * Gets the scene from the mesh
  24159. * @returns the indices array or null
  24160. */
  24161. getScene?(): Scene;
  24162. /**
  24163. * Gets the absolute position from the mesh
  24164. * @returns the absolute position
  24165. */
  24166. getAbsolutePosition(): Vector3;
  24167. /**
  24168. * Gets the absolute pivot point from the mesh
  24169. * @returns the absolute pivot point
  24170. */
  24171. getAbsolutePivotPoint(): Vector3;
  24172. /**
  24173. * Rotates the mesh
  24174. * @param axis The axis of rotation
  24175. * @param amount The amount of rotation
  24176. * @param space The space of the rotation
  24177. * @returns The rotation transform node
  24178. */
  24179. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24180. /**
  24181. * Translates the mesh
  24182. * @param axis The axis of translation
  24183. * @param distance The distance of translation
  24184. * @param space The space of the translation
  24185. * @returns The transform node
  24186. */
  24187. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24188. /**
  24189. * Sets the absolute position of the mesh
  24190. * @param absolutePosition The absolute position of the mesh
  24191. * @returns The transform node
  24192. */
  24193. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24194. /**
  24195. * Gets the class name of the mesh
  24196. * @returns The class name
  24197. */
  24198. getClassName(): string;
  24199. }
  24200. /**
  24201. * Represents a physics imposter
  24202. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24203. */
  24204. export class PhysicsImpostor {
  24205. /**
  24206. * The physics-enabled object used as the physics imposter
  24207. */
  24208. object: IPhysicsEnabledObject;
  24209. /**
  24210. * The type of the physics imposter
  24211. */
  24212. type: number;
  24213. private _options;
  24214. private _scene?;
  24215. /**
  24216. * The default object size of the imposter
  24217. */
  24218. static DEFAULT_OBJECT_SIZE: Vector3;
  24219. /**
  24220. * The identity quaternion of the imposter
  24221. */
  24222. static IDENTITY_QUATERNION: Quaternion;
  24223. /** @hidden */
  24224. _pluginData: any;
  24225. private _physicsEngine;
  24226. private _physicsBody;
  24227. private _bodyUpdateRequired;
  24228. private _onBeforePhysicsStepCallbacks;
  24229. private _onAfterPhysicsStepCallbacks;
  24230. /** @hidden */
  24231. _onPhysicsCollideCallbacks: Array<{
  24232. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24233. otherImpostors: Array<PhysicsImpostor>;
  24234. }>;
  24235. private _deltaPosition;
  24236. private _deltaRotation;
  24237. private _deltaRotationConjugated;
  24238. /** @hidden */
  24239. _isFromLine: boolean;
  24240. private _parent;
  24241. private _isDisposed;
  24242. private static _tmpVecs;
  24243. private static _tmpQuat;
  24244. /**
  24245. * Specifies if the physics imposter is disposed
  24246. */
  24247. get isDisposed(): boolean;
  24248. /**
  24249. * Gets the mass of the physics imposter
  24250. */
  24251. get mass(): number;
  24252. set mass(value: number);
  24253. /**
  24254. * Gets the coefficient of friction
  24255. */
  24256. get friction(): number;
  24257. /**
  24258. * Sets the coefficient of friction
  24259. */
  24260. set friction(value: number);
  24261. /**
  24262. * Gets the coefficient of restitution
  24263. */
  24264. get restitution(): number;
  24265. /**
  24266. * Sets the coefficient of restitution
  24267. */
  24268. set restitution(value: number);
  24269. /**
  24270. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24271. */
  24272. get pressure(): number;
  24273. /**
  24274. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24275. */
  24276. set pressure(value: number);
  24277. /**
  24278. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24279. */
  24280. get stiffness(): number;
  24281. /**
  24282. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24283. */
  24284. set stiffness(value: number);
  24285. /**
  24286. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24287. */
  24288. get velocityIterations(): number;
  24289. /**
  24290. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24291. */
  24292. set velocityIterations(value: number);
  24293. /**
  24294. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24295. */
  24296. get positionIterations(): number;
  24297. /**
  24298. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24299. */
  24300. set positionIterations(value: number);
  24301. /**
  24302. * The unique id of the physics imposter
  24303. * set by the physics engine when adding this impostor to the array
  24304. */
  24305. uniqueId: number;
  24306. /**
  24307. * @hidden
  24308. */
  24309. soft: boolean;
  24310. /**
  24311. * @hidden
  24312. */
  24313. segments: number;
  24314. private _joints;
  24315. /**
  24316. * Initializes the physics imposter
  24317. * @param object The physics-enabled object used as the physics imposter
  24318. * @param type The type of the physics imposter
  24319. * @param _options The options for the physics imposter
  24320. * @param _scene The Babylon scene
  24321. */
  24322. constructor(
  24323. /**
  24324. * The physics-enabled object used as the physics imposter
  24325. */
  24326. object: IPhysicsEnabledObject,
  24327. /**
  24328. * The type of the physics imposter
  24329. */
  24330. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24331. /**
  24332. * This function will completly initialize this impostor.
  24333. * It will create a new body - but only if this mesh has no parent.
  24334. * If it has, this impostor will not be used other than to define the impostor
  24335. * of the child mesh.
  24336. * @hidden
  24337. */
  24338. _init(): void;
  24339. private _getPhysicsParent;
  24340. /**
  24341. * Should a new body be generated.
  24342. * @returns boolean specifying if body initialization is required
  24343. */
  24344. isBodyInitRequired(): boolean;
  24345. /**
  24346. * Sets the updated scaling
  24347. * @param updated Specifies if the scaling is updated
  24348. */
  24349. setScalingUpdated(): void;
  24350. /**
  24351. * Force a regeneration of this or the parent's impostor's body.
  24352. * Use under cautious - This will remove all joints already implemented.
  24353. */
  24354. forceUpdate(): void;
  24355. /**
  24356. * Gets the body that holds this impostor. Either its own, or its parent.
  24357. */
  24358. get physicsBody(): any;
  24359. /**
  24360. * Get the parent of the physics imposter
  24361. * @returns Physics imposter or null
  24362. */
  24363. get parent(): Nullable<PhysicsImpostor>;
  24364. /**
  24365. * Sets the parent of the physics imposter
  24366. */
  24367. set parent(value: Nullable<PhysicsImpostor>);
  24368. /**
  24369. * Set the physics body. Used mainly by the physics engine/plugin
  24370. */
  24371. set physicsBody(physicsBody: any);
  24372. /**
  24373. * Resets the update flags
  24374. */
  24375. resetUpdateFlags(): void;
  24376. /**
  24377. * Gets the object extend size
  24378. * @returns the object extend size
  24379. */
  24380. getObjectExtendSize(): Vector3;
  24381. /**
  24382. * Gets the object center
  24383. * @returns The object center
  24384. */
  24385. getObjectCenter(): Vector3;
  24386. /**
  24387. * Get a specific parametes from the options parameter
  24388. * @param paramName The object parameter name
  24389. * @returns The object parameter
  24390. */
  24391. getParam(paramName: string): any;
  24392. /**
  24393. * Sets a specific parameter in the options given to the physics plugin
  24394. * @param paramName The parameter name
  24395. * @param value The value of the parameter
  24396. */
  24397. setParam(paramName: string, value: number): void;
  24398. /**
  24399. * Specifically change the body's mass option. Won't recreate the physics body object
  24400. * @param mass The mass of the physics imposter
  24401. */
  24402. setMass(mass: number): void;
  24403. /**
  24404. * Gets the linear velocity
  24405. * @returns linear velocity or null
  24406. */
  24407. getLinearVelocity(): Nullable<Vector3>;
  24408. /**
  24409. * Sets the linear velocity
  24410. * @param velocity linear velocity or null
  24411. */
  24412. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24413. /**
  24414. * Gets the angular velocity
  24415. * @returns angular velocity or null
  24416. */
  24417. getAngularVelocity(): Nullable<Vector3>;
  24418. /**
  24419. * Sets the angular velocity
  24420. * @param velocity The velocity or null
  24421. */
  24422. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24423. /**
  24424. * Execute a function with the physics plugin native code
  24425. * Provide a function the will have two variables - the world object and the physics body object
  24426. * @param func The function to execute with the physics plugin native code
  24427. */
  24428. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24429. /**
  24430. * Register a function that will be executed before the physics world is stepping forward
  24431. * @param func The function to execute before the physics world is stepped forward
  24432. */
  24433. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24434. /**
  24435. * Unregister a function that will be executed before the physics world is stepping forward
  24436. * @param func The function to execute before the physics world is stepped forward
  24437. */
  24438. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24439. /**
  24440. * Register a function that will be executed after the physics step
  24441. * @param func The function to execute after physics step
  24442. */
  24443. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24444. /**
  24445. * Unregisters a function that will be executed after the physics step
  24446. * @param func The function to execute after physics step
  24447. */
  24448. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24449. /**
  24450. * register a function that will be executed when this impostor collides against a different body
  24451. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24452. * @param func Callback that is executed on collision
  24453. */
  24454. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24455. /**
  24456. * Unregisters the physics imposter on contact
  24457. * @param collideAgainst The physics object to collide against
  24458. * @param func Callback to execute on collision
  24459. */
  24460. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24461. private _tmpQuat;
  24462. private _tmpQuat2;
  24463. /**
  24464. * Get the parent rotation
  24465. * @returns The parent rotation
  24466. */
  24467. getParentsRotation(): Quaternion;
  24468. /**
  24469. * this function is executed by the physics engine.
  24470. */
  24471. beforeStep: () => void;
  24472. /**
  24473. * this function is executed by the physics engine
  24474. */
  24475. afterStep: () => void;
  24476. /**
  24477. * Legacy collision detection event support
  24478. */
  24479. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24480. /**
  24481. * event and body object due to cannon's event-based architecture.
  24482. */
  24483. onCollide: (e: {
  24484. body: any;
  24485. }) => void;
  24486. /**
  24487. * Apply a force
  24488. * @param force The force to apply
  24489. * @param contactPoint The contact point for the force
  24490. * @returns The physics imposter
  24491. */
  24492. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24493. /**
  24494. * Apply an impulse
  24495. * @param force The impulse force
  24496. * @param contactPoint The contact point for the impulse force
  24497. * @returns The physics imposter
  24498. */
  24499. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24500. /**
  24501. * A help function to create a joint
  24502. * @param otherImpostor A physics imposter used to create a joint
  24503. * @param jointType The type of joint
  24504. * @param jointData The data for the joint
  24505. * @returns The physics imposter
  24506. */
  24507. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24508. /**
  24509. * Add a joint to this impostor with a different impostor
  24510. * @param otherImpostor A physics imposter used to add a joint
  24511. * @param joint The joint to add
  24512. * @returns The physics imposter
  24513. */
  24514. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24515. /**
  24516. * Add an anchor to a cloth impostor
  24517. * @param otherImpostor rigid impostor to anchor to
  24518. * @param width ratio across width from 0 to 1
  24519. * @param height ratio up height from 0 to 1
  24520. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24521. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24522. * @returns impostor the soft imposter
  24523. */
  24524. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24525. /**
  24526. * Add a hook to a rope impostor
  24527. * @param otherImpostor rigid impostor to anchor to
  24528. * @param length ratio across rope from 0 to 1
  24529. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24530. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24531. * @returns impostor the rope imposter
  24532. */
  24533. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24534. /**
  24535. * Will keep this body still, in a sleep mode.
  24536. * @returns the physics imposter
  24537. */
  24538. sleep(): PhysicsImpostor;
  24539. /**
  24540. * Wake the body up.
  24541. * @returns The physics imposter
  24542. */
  24543. wakeUp(): PhysicsImpostor;
  24544. /**
  24545. * Clones the physics imposter
  24546. * @param newObject The physics imposter clones to this physics-enabled object
  24547. * @returns A nullable physics imposter
  24548. */
  24549. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24550. /**
  24551. * Disposes the physics imposter
  24552. */
  24553. dispose(): void;
  24554. /**
  24555. * Sets the delta position
  24556. * @param position The delta position amount
  24557. */
  24558. setDeltaPosition(position: Vector3): void;
  24559. /**
  24560. * Sets the delta rotation
  24561. * @param rotation The delta rotation amount
  24562. */
  24563. setDeltaRotation(rotation: Quaternion): void;
  24564. /**
  24565. * Gets the box size of the physics imposter and stores the result in the input parameter
  24566. * @param result Stores the box size
  24567. * @returns The physics imposter
  24568. */
  24569. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24570. /**
  24571. * Gets the radius of the physics imposter
  24572. * @returns Radius of the physics imposter
  24573. */
  24574. getRadius(): number;
  24575. /**
  24576. * Sync a bone with this impostor
  24577. * @param bone The bone to sync to the impostor.
  24578. * @param boneMesh The mesh that the bone is influencing.
  24579. * @param jointPivot The pivot of the joint / bone in local space.
  24580. * @param distToJoint Optional distance from the impostor to the joint.
  24581. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24582. */
  24583. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24584. /**
  24585. * Sync impostor to a bone
  24586. * @param bone The bone that the impostor will be synced to.
  24587. * @param boneMesh The mesh that the bone is influencing.
  24588. * @param jointPivot The pivot of the joint / bone in local space.
  24589. * @param distToJoint Optional distance from the impostor to the joint.
  24590. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24591. * @param boneAxis Optional vector3 axis the bone is aligned with
  24592. */
  24593. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24594. /**
  24595. * No-Imposter type
  24596. */
  24597. static NoImpostor: number;
  24598. /**
  24599. * Sphere-Imposter type
  24600. */
  24601. static SphereImpostor: number;
  24602. /**
  24603. * Box-Imposter type
  24604. */
  24605. static BoxImpostor: number;
  24606. /**
  24607. * Plane-Imposter type
  24608. */
  24609. static PlaneImpostor: number;
  24610. /**
  24611. * Mesh-imposter type
  24612. */
  24613. static MeshImpostor: number;
  24614. /**
  24615. * Capsule-Impostor type (Ammo.js plugin only)
  24616. */
  24617. static CapsuleImpostor: number;
  24618. /**
  24619. * Cylinder-Imposter type
  24620. */
  24621. static CylinderImpostor: number;
  24622. /**
  24623. * Particle-Imposter type
  24624. */
  24625. static ParticleImpostor: number;
  24626. /**
  24627. * Heightmap-Imposter type
  24628. */
  24629. static HeightmapImpostor: number;
  24630. /**
  24631. * ConvexHull-Impostor type (Ammo.js plugin only)
  24632. */
  24633. static ConvexHullImpostor: number;
  24634. /**
  24635. * Custom-Imposter type (Ammo.js plugin only)
  24636. */
  24637. static CustomImpostor: number;
  24638. /**
  24639. * Rope-Imposter type
  24640. */
  24641. static RopeImpostor: number;
  24642. /**
  24643. * Cloth-Imposter type
  24644. */
  24645. static ClothImpostor: number;
  24646. /**
  24647. * Softbody-Imposter type
  24648. */
  24649. static SoftbodyImpostor: number;
  24650. }
  24651. }
  24652. declare module "babylonjs/Meshes/mesh" {
  24653. import { Observable } from "babylonjs/Misc/observable";
  24654. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24655. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24656. import { Camera } from "babylonjs/Cameras/camera";
  24657. import { Scene } from "babylonjs/scene";
  24658. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24659. import { Color4 } from "babylonjs/Maths/math.color";
  24660. import { Engine } from "babylonjs/Engines/engine";
  24661. import { Node } from "babylonjs/node";
  24662. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24663. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24664. import { Buffer } from "babylonjs/Meshes/buffer";
  24665. import { Geometry } from "babylonjs/Meshes/geometry";
  24666. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24667. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24668. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24669. import { Effect } from "babylonjs/Materials/effect";
  24670. import { Material } from "babylonjs/Materials/material";
  24671. import { Skeleton } from "babylonjs/Bones/skeleton";
  24672. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24673. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24674. import { Path3D } from "babylonjs/Maths/math.path";
  24675. import { Plane } from "babylonjs/Maths/math.plane";
  24676. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24677. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24678. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24679. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24680. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24681. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24682. /**
  24683. * @hidden
  24684. **/
  24685. export class _CreationDataStorage {
  24686. closePath?: boolean;
  24687. closeArray?: boolean;
  24688. idx: number[];
  24689. dashSize: number;
  24690. gapSize: number;
  24691. path3D: Path3D;
  24692. pathArray: Vector3[][];
  24693. arc: number;
  24694. radius: number;
  24695. cap: number;
  24696. tessellation: number;
  24697. }
  24698. /**
  24699. * @hidden
  24700. **/
  24701. class _InstanceDataStorage {
  24702. visibleInstances: any;
  24703. batchCache: _InstancesBatch;
  24704. instancesBufferSize: number;
  24705. instancesBuffer: Nullable<Buffer>;
  24706. instancesData: Float32Array;
  24707. overridenInstanceCount: number;
  24708. isFrozen: boolean;
  24709. previousBatch: Nullable<_InstancesBatch>;
  24710. hardwareInstancedRendering: boolean;
  24711. sideOrientation: number;
  24712. manualUpdate: boolean;
  24713. }
  24714. /**
  24715. * @hidden
  24716. **/
  24717. export class _InstancesBatch {
  24718. mustReturn: boolean;
  24719. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24720. renderSelf: boolean[];
  24721. hardwareInstancedRendering: boolean[];
  24722. }
  24723. /**
  24724. * Class used to represent renderable models
  24725. */
  24726. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24727. /**
  24728. * Mesh side orientation : usually the external or front surface
  24729. */
  24730. static readonly FRONTSIDE: number;
  24731. /**
  24732. * Mesh side orientation : usually the internal or back surface
  24733. */
  24734. static readonly BACKSIDE: number;
  24735. /**
  24736. * Mesh side orientation : both internal and external or front and back surfaces
  24737. */
  24738. static readonly DOUBLESIDE: number;
  24739. /**
  24740. * Mesh side orientation : by default, `FRONTSIDE`
  24741. */
  24742. static readonly DEFAULTSIDE: number;
  24743. /**
  24744. * Mesh cap setting : no cap
  24745. */
  24746. static readonly NO_CAP: number;
  24747. /**
  24748. * Mesh cap setting : one cap at the beginning of the mesh
  24749. */
  24750. static readonly CAP_START: number;
  24751. /**
  24752. * Mesh cap setting : one cap at the end of the mesh
  24753. */
  24754. static readonly CAP_END: number;
  24755. /**
  24756. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24757. */
  24758. static readonly CAP_ALL: number;
  24759. /**
  24760. * Mesh pattern setting : no flip or rotate
  24761. */
  24762. static readonly NO_FLIP: number;
  24763. /**
  24764. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24765. */
  24766. static readonly FLIP_TILE: number;
  24767. /**
  24768. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24769. */
  24770. static readonly ROTATE_TILE: number;
  24771. /**
  24772. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24773. */
  24774. static readonly FLIP_ROW: number;
  24775. /**
  24776. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24777. */
  24778. static readonly ROTATE_ROW: number;
  24779. /**
  24780. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24781. */
  24782. static readonly FLIP_N_ROTATE_TILE: number;
  24783. /**
  24784. * Mesh pattern setting : rotate pattern and rotate
  24785. */
  24786. static readonly FLIP_N_ROTATE_ROW: number;
  24787. /**
  24788. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24789. */
  24790. static readonly CENTER: number;
  24791. /**
  24792. * Mesh tile positioning : part tiles on left
  24793. */
  24794. static readonly LEFT: number;
  24795. /**
  24796. * Mesh tile positioning : part tiles on right
  24797. */
  24798. static readonly RIGHT: number;
  24799. /**
  24800. * Mesh tile positioning : part tiles on top
  24801. */
  24802. static readonly TOP: number;
  24803. /**
  24804. * Mesh tile positioning : part tiles on bottom
  24805. */
  24806. static readonly BOTTOM: number;
  24807. /**
  24808. * Gets the default side orientation.
  24809. * @param orientation the orientation to value to attempt to get
  24810. * @returns the default orientation
  24811. * @hidden
  24812. */
  24813. static _GetDefaultSideOrientation(orientation?: number): number;
  24814. private _internalMeshDataInfo;
  24815. /**
  24816. * An event triggered before rendering the mesh
  24817. */
  24818. get onBeforeRenderObservable(): Observable<Mesh>;
  24819. /**
  24820. * An event triggered before binding the mesh
  24821. */
  24822. get onBeforeBindObservable(): Observable<Mesh>;
  24823. /**
  24824. * An event triggered after rendering the mesh
  24825. */
  24826. get onAfterRenderObservable(): Observable<Mesh>;
  24827. /**
  24828. * An event triggered before drawing the mesh
  24829. */
  24830. get onBeforeDrawObservable(): Observable<Mesh>;
  24831. private _onBeforeDrawObserver;
  24832. /**
  24833. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24834. */
  24835. set onBeforeDraw(callback: () => void);
  24836. get hasInstances(): boolean;
  24837. /**
  24838. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24839. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24840. */
  24841. delayLoadState: number;
  24842. /**
  24843. * Gets the list of instances created from this mesh
  24844. * it is not supposed to be modified manually.
  24845. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24846. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24847. */
  24848. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24849. /**
  24850. * Gets the file containing delay loading data for this mesh
  24851. */
  24852. delayLoadingFile: string;
  24853. /** @hidden */
  24854. _binaryInfo: any;
  24855. /**
  24856. * User defined function used to change how LOD level selection is done
  24857. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24858. */
  24859. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24860. /**
  24861. * Gets or sets the morph target manager
  24862. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24863. */
  24864. get morphTargetManager(): Nullable<MorphTargetManager>;
  24865. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24866. /** @hidden */
  24867. _creationDataStorage: Nullable<_CreationDataStorage>;
  24868. /** @hidden */
  24869. _geometry: Nullable<Geometry>;
  24870. /** @hidden */
  24871. _delayInfo: Array<string>;
  24872. /** @hidden */
  24873. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24874. /** @hidden */
  24875. _instanceDataStorage: _InstanceDataStorage;
  24876. private _effectiveMaterial;
  24877. /** @hidden */
  24878. _shouldGenerateFlatShading: boolean;
  24879. /** @hidden */
  24880. _originalBuilderSideOrientation: number;
  24881. /**
  24882. * Use this property to change the original side orientation defined at construction time
  24883. */
  24884. overrideMaterialSideOrientation: Nullable<number>;
  24885. /**
  24886. * Gets the source mesh (the one used to clone this one from)
  24887. */
  24888. get source(): Nullable<Mesh>;
  24889. /**
  24890. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24891. */
  24892. get isUnIndexed(): boolean;
  24893. set isUnIndexed(value: boolean);
  24894. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24895. get worldMatrixInstancedBuffer(): Float32Array;
  24896. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24897. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24898. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24899. /**
  24900. * @constructor
  24901. * @param name The value used by scene.getMeshByName() to do a lookup.
  24902. * @param scene The scene to add this mesh to.
  24903. * @param parent The parent of this mesh, if it has one
  24904. * @param source An optional Mesh from which geometry is shared, cloned.
  24905. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24906. * When false, achieved by calling a clone(), also passing False.
  24907. * This will make creation of children, recursive.
  24908. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24909. */
  24910. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24911. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24912. doNotInstantiate: boolean;
  24913. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24914. /**
  24915. * Gets the class name
  24916. * @returns the string "Mesh".
  24917. */
  24918. getClassName(): string;
  24919. /** @hidden */
  24920. get _isMesh(): boolean;
  24921. /**
  24922. * Returns a description of this mesh
  24923. * @param fullDetails define if full details about this mesh must be used
  24924. * @returns a descriptive string representing this mesh
  24925. */
  24926. toString(fullDetails?: boolean): string;
  24927. /** @hidden */
  24928. _unBindEffect(): void;
  24929. /**
  24930. * Gets a boolean indicating if this mesh has LOD
  24931. */
  24932. get hasLODLevels(): boolean;
  24933. /**
  24934. * Gets the list of MeshLODLevel associated with the current mesh
  24935. * @returns an array of MeshLODLevel
  24936. */
  24937. getLODLevels(): MeshLODLevel[];
  24938. private _sortLODLevels;
  24939. /**
  24940. * Add a mesh as LOD level triggered at the given distance.
  24941. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24942. * @param distance The distance from the center of the object to show this level
  24943. * @param mesh The mesh to be added as LOD level (can be null)
  24944. * @return This mesh (for chaining)
  24945. */
  24946. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24947. /**
  24948. * Returns the LOD level mesh at the passed distance or null if not found.
  24949. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24950. * @param distance The distance from the center of the object to show this level
  24951. * @returns a Mesh or `null`
  24952. */
  24953. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24954. /**
  24955. * Remove a mesh from the LOD array
  24956. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24957. * @param mesh defines the mesh to be removed
  24958. * @return This mesh (for chaining)
  24959. */
  24960. removeLODLevel(mesh: Mesh): Mesh;
  24961. /**
  24962. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24963. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24964. * @param camera defines the camera to use to compute distance
  24965. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24966. * @return This mesh (for chaining)
  24967. */
  24968. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24969. /**
  24970. * Gets the mesh internal Geometry object
  24971. */
  24972. get geometry(): Nullable<Geometry>;
  24973. /**
  24974. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24975. * @returns the total number of vertices
  24976. */
  24977. getTotalVertices(): number;
  24978. /**
  24979. * Returns the content of an associated vertex buffer
  24980. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24981. * - VertexBuffer.PositionKind
  24982. * - VertexBuffer.UVKind
  24983. * - VertexBuffer.UV2Kind
  24984. * - VertexBuffer.UV3Kind
  24985. * - VertexBuffer.UV4Kind
  24986. * - VertexBuffer.UV5Kind
  24987. * - VertexBuffer.UV6Kind
  24988. * - VertexBuffer.ColorKind
  24989. * - VertexBuffer.MatricesIndicesKind
  24990. * - VertexBuffer.MatricesIndicesExtraKind
  24991. * - VertexBuffer.MatricesWeightsKind
  24992. * - VertexBuffer.MatricesWeightsExtraKind
  24993. * @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
  24994. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24995. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24996. */
  24997. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24998. /**
  24999. * Returns the mesh VertexBuffer object from the requested `kind`
  25000. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25001. * - VertexBuffer.PositionKind
  25002. * - VertexBuffer.NormalKind
  25003. * - VertexBuffer.UVKind
  25004. * - VertexBuffer.UV2Kind
  25005. * - VertexBuffer.UV3Kind
  25006. * - VertexBuffer.UV4Kind
  25007. * - VertexBuffer.UV5Kind
  25008. * - VertexBuffer.UV6Kind
  25009. * - VertexBuffer.ColorKind
  25010. * - VertexBuffer.MatricesIndicesKind
  25011. * - VertexBuffer.MatricesIndicesExtraKind
  25012. * - VertexBuffer.MatricesWeightsKind
  25013. * - VertexBuffer.MatricesWeightsExtraKind
  25014. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25015. */
  25016. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25017. /**
  25018. * Tests if a specific vertex buffer is associated with this mesh
  25019. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25020. * - VertexBuffer.PositionKind
  25021. * - VertexBuffer.NormalKind
  25022. * - VertexBuffer.UVKind
  25023. * - VertexBuffer.UV2Kind
  25024. * - VertexBuffer.UV3Kind
  25025. * - VertexBuffer.UV4Kind
  25026. * - VertexBuffer.UV5Kind
  25027. * - VertexBuffer.UV6Kind
  25028. * - VertexBuffer.ColorKind
  25029. * - VertexBuffer.MatricesIndicesKind
  25030. * - VertexBuffer.MatricesIndicesExtraKind
  25031. * - VertexBuffer.MatricesWeightsKind
  25032. * - VertexBuffer.MatricesWeightsExtraKind
  25033. * @returns a boolean
  25034. */
  25035. isVerticesDataPresent(kind: string): boolean;
  25036. /**
  25037. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25038. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25039. * - VertexBuffer.PositionKind
  25040. * - VertexBuffer.UVKind
  25041. * - VertexBuffer.UV2Kind
  25042. * - VertexBuffer.UV3Kind
  25043. * - VertexBuffer.UV4Kind
  25044. * - VertexBuffer.UV5Kind
  25045. * - VertexBuffer.UV6Kind
  25046. * - VertexBuffer.ColorKind
  25047. * - VertexBuffer.MatricesIndicesKind
  25048. * - VertexBuffer.MatricesIndicesExtraKind
  25049. * - VertexBuffer.MatricesWeightsKind
  25050. * - VertexBuffer.MatricesWeightsExtraKind
  25051. * @returns a boolean
  25052. */
  25053. isVertexBufferUpdatable(kind: string): boolean;
  25054. /**
  25055. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25056. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25057. * - VertexBuffer.PositionKind
  25058. * - VertexBuffer.NormalKind
  25059. * - VertexBuffer.UVKind
  25060. * - VertexBuffer.UV2Kind
  25061. * - VertexBuffer.UV3Kind
  25062. * - VertexBuffer.UV4Kind
  25063. * - VertexBuffer.UV5Kind
  25064. * - VertexBuffer.UV6Kind
  25065. * - VertexBuffer.ColorKind
  25066. * - VertexBuffer.MatricesIndicesKind
  25067. * - VertexBuffer.MatricesIndicesExtraKind
  25068. * - VertexBuffer.MatricesWeightsKind
  25069. * - VertexBuffer.MatricesWeightsExtraKind
  25070. * @returns an array of strings
  25071. */
  25072. getVerticesDataKinds(): string[];
  25073. /**
  25074. * Returns a positive integer : the total number of indices in this mesh geometry.
  25075. * @returns the numner of indices or zero if the mesh has no geometry.
  25076. */
  25077. getTotalIndices(): number;
  25078. /**
  25079. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25080. * @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.
  25081. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25082. * @returns the indices array or an empty array if the mesh has no geometry
  25083. */
  25084. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25085. get isBlocked(): boolean;
  25086. /**
  25087. * Determine if the current mesh is ready to be rendered
  25088. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25089. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25090. * @returns true if all associated assets are ready (material, textures, shaders)
  25091. */
  25092. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25093. /**
  25094. * 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.
  25095. */
  25096. get areNormalsFrozen(): boolean;
  25097. /**
  25098. * 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.
  25099. * @returns the current mesh
  25100. */
  25101. freezeNormals(): Mesh;
  25102. /**
  25103. * 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
  25104. * @returns the current mesh
  25105. */
  25106. unfreezeNormals(): Mesh;
  25107. /**
  25108. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25109. */
  25110. set overridenInstanceCount(count: number);
  25111. /** @hidden */
  25112. _preActivate(): Mesh;
  25113. /** @hidden */
  25114. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25115. /** @hidden */
  25116. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25117. /**
  25118. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25119. * This means the mesh underlying bounding box and sphere are recomputed.
  25120. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25121. * @returns the current mesh
  25122. */
  25123. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25124. /** @hidden */
  25125. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25126. /**
  25127. * This function will subdivide the mesh into multiple submeshes
  25128. * @param count defines the expected number of submeshes
  25129. */
  25130. subdivide(count: number): void;
  25131. /**
  25132. * Copy a FloatArray into a specific associated vertex buffer
  25133. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25134. * - VertexBuffer.PositionKind
  25135. * - VertexBuffer.UVKind
  25136. * - VertexBuffer.UV2Kind
  25137. * - VertexBuffer.UV3Kind
  25138. * - VertexBuffer.UV4Kind
  25139. * - VertexBuffer.UV5Kind
  25140. * - VertexBuffer.UV6Kind
  25141. * - VertexBuffer.ColorKind
  25142. * - VertexBuffer.MatricesIndicesKind
  25143. * - VertexBuffer.MatricesIndicesExtraKind
  25144. * - VertexBuffer.MatricesWeightsKind
  25145. * - VertexBuffer.MatricesWeightsExtraKind
  25146. * @param data defines the data source
  25147. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25148. * @param stride defines the data stride size (can be null)
  25149. * @returns the current mesh
  25150. */
  25151. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25152. /**
  25153. * Delete a vertex buffer associated with this mesh
  25154. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25155. * - VertexBuffer.PositionKind
  25156. * - VertexBuffer.UVKind
  25157. * - VertexBuffer.UV2Kind
  25158. * - VertexBuffer.UV3Kind
  25159. * - VertexBuffer.UV4Kind
  25160. * - VertexBuffer.UV5Kind
  25161. * - VertexBuffer.UV6Kind
  25162. * - VertexBuffer.ColorKind
  25163. * - VertexBuffer.MatricesIndicesKind
  25164. * - VertexBuffer.MatricesIndicesExtraKind
  25165. * - VertexBuffer.MatricesWeightsKind
  25166. * - VertexBuffer.MatricesWeightsExtraKind
  25167. */
  25168. removeVerticesData(kind: string): void;
  25169. /**
  25170. * Flags an associated vertex buffer as updatable
  25171. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25172. * - VertexBuffer.PositionKind
  25173. * - VertexBuffer.UVKind
  25174. * - VertexBuffer.UV2Kind
  25175. * - VertexBuffer.UV3Kind
  25176. * - VertexBuffer.UV4Kind
  25177. * - VertexBuffer.UV5Kind
  25178. * - VertexBuffer.UV6Kind
  25179. * - VertexBuffer.ColorKind
  25180. * - VertexBuffer.MatricesIndicesKind
  25181. * - VertexBuffer.MatricesIndicesExtraKind
  25182. * - VertexBuffer.MatricesWeightsKind
  25183. * - VertexBuffer.MatricesWeightsExtraKind
  25184. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25185. */
  25186. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25187. /**
  25188. * Sets the mesh global Vertex Buffer
  25189. * @param buffer defines the buffer to use
  25190. * @returns the current mesh
  25191. */
  25192. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25193. /**
  25194. * Update a specific associated vertex buffer
  25195. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25196. * - VertexBuffer.PositionKind
  25197. * - VertexBuffer.UVKind
  25198. * - VertexBuffer.UV2Kind
  25199. * - VertexBuffer.UV3Kind
  25200. * - VertexBuffer.UV4Kind
  25201. * - VertexBuffer.UV5Kind
  25202. * - VertexBuffer.UV6Kind
  25203. * - VertexBuffer.ColorKind
  25204. * - VertexBuffer.MatricesIndicesKind
  25205. * - VertexBuffer.MatricesIndicesExtraKind
  25206. * - VertexBuffer.MatricesWeightsKind
  25207. * - VertexBuffer.MatricesWeightsExtraKind
  25208. * @param data defines the data source
  25209. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25210. * @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)
  25211. * @returns the current mesh
  25212. */
  25213. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25214. /**
  25215. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25216. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25217. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25218. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25219. * @returns the current mesh
  25220. */
  25221. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25222. /**
  25223. * Creates a un-shared specific occurence of the geometry for the mesh.
  25224. * @returns the current mesh
  25225. */
  25226. makeGeometryUnique(): Mesh;
  25227. /**
  25228. * Set the index buffer of this mesh
  25229. * @param indices defines the source data
  25230. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25231. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25232. * @returns the current mesh
  25233. */
  25234. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25235. /**
  25236. * Update the current index buffer
  25237. * @param indices defines the source data
  25238. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25239. * @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)
  25240. * @returns the current mesh
  25241. */
  25242. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25243. /**
  25244. * Invert the geometry to move from a right handed system to a left handed one.
  25245. * @returns the current mesh
  25246. */
  25247. toLeftHanded(): Mesh;
  25248. /** @hidden */
  25249. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25250. /** @hidden */
  25251. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25252. /**
  25253. * Registers for this mesh a javascript function called just before the rendering process
  25254. * @param func defines the function to call before rendering this mesh
  25255. * @returns the current mesh
  25256. */
  25257. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25258. /**
  25259. * Disposes a previously registered javascript function called before the rendering
  25260. * @param func defines the function to remove
  25261. * @returns the current mesh
  25262. */
  25263. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25264. /**
  25265. * Registers for this mesh a javascript function called just after the rendering is complete
  25266. * @param func defines the function to call after rendering this mesh
  25267. * @returns the current mesh
  25268. */
  25269. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25270. /**
  25271. * Disposes a previously registered javascript function called after the rendering.
  25272. * @param func defines the function to remove
  25273. * @returns the current mesh
  25274. */
  25275. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25276. /** @hidden */
  25277. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25278. /** @hidden */
  25279. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25280. /** @hidden */
  25281. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25282. /** @hidden */
  25283. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25284. /** @hidden */
  25285. _rebuild(): void;
  25286. /** @hidden */
  25287. _freeze(): void;
  25288. /** @hidden */
  25289. _unFreeze(): void;
  25290. /**
  25291. * 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
  25292. * @param subMesh defines the subMesh to render
  25293. * @param enableAlphaMode defines if alpha mode can be changed
  25294. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25295. * @returns the current mesh
  25296. */
  25297. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25298. private _onBeforeDraw;
  25299. /**
  25300. * Renormalize the mesh and patch it up if there are no weights
  25301. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25302. * However in the case of zero weights then we set just a single influence to 1.
  25303. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25304. */
  25305. cleanMatrixWeights(): void;
  25306. private normalizeSkinFourWeights;
  25307. private normalizeSkinWeightsAndExtra;
  25308. /**
  25309. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25310. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25311. * the user know there was an issue with importing the mesh
  25312. * @returns a validation object with skinned, valid and report string
  25313. */
  25314. validateSkinning(): {
  25315. skinned: boolean;
  25316. valid: boolean;
  25317. report: string;
  25318. };
  25319. /** @hidden */
  25320. _checkDelayState(): Mesh;
  25321. private _queueLoad;
  25322. /**
  25323. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25324. * A mesh is in the frustum if its bounding box intersects the frustum
  25325. * @param frustumPlanes defines the frustum to test
  25326. * @returns true if the mesh is in the frustum planes
  25327. */
  25328. isInFrustum(frustumPlanes: Plane[]): boolean;
  25329. /**
  25330. * Sets the mesh material by the material or multiMaterial `id` property
  25331. * @param id is a string identifying the material or the multiMaterial
  25332. * @returns the current mesh
  25333. */
  25334. setMaterialByID(id: string): Mesh;
  25335. /**
  25336. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25337. * @returns an array of IAnimatable
  25338. */
  25339. getAnimatables(): IAnimatable[];
  25340. /**
  25341. * Modifies the mesh geometry according to the passed transformation matrix.
  25342. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25343. * The mesh normals are modified using the same transformation.
  25344. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25345. * @param transform defines the transform matrix to use
  25346. * @see http://doc.babylonjs.com/resources/baking_transformations
  25347. * @returns the current mesh
  25348. */
  25349. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25350. /**
  25351. * Modifies the mesh geometry according to its own current World Matrix.
  25352. * The mesh World Matrix is then reset.
  25353. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25354. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25355. * @see http://doc.babylonjs.com/resources/baking_transformations
  25356. * @returns the current mesh
  25357. */
  25358. bakeCurrentTransformIntoVertices(): Mesh;
  25359. /** @hidden */
  25360. get _positions(): Nullable<Vector3[]>;
  25361. /** @hidden */
  25362. _resetPointsArrayCache(): Mesh;
  25363. /** @hidden */
  25364. _generatePointsArray(): boolean;
  25365. /**
  25366. * Returns a new Mesh object generated from the current mesh properties.
  25367. * This method must not get confused with createInstance()
  25368. * @param name is a string, the name given to the new mesh
  25369. * @param newParent can be any Node object (default `null`)
  25370. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25371. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25372. * @returns a new mesh
  25373. */
  25374. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  25375. /**
  25376. * Releases resources associated with this mesh.
  25377. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25378. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25379. */
  25380. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25381. /** @hidden */
  25382. _disposeInstanceSpecificData(): void;
  25383. /**
  25384. * Modifies the mesh geometry according to a displacement map.
  25385. * 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.
  25386. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25387. * @param url is a string, the URL from the image file is to be downloaded.
  25388. * @param minHeight is the lower limit of the displacement.
  25389. * @param maxHeight is the upper limit of the displacement.
  25390. * @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.
  25391. * @param uvOffset is an optional vector2 used to offset UV.
  25392. * @param uvScale is an optional vector2 used to scale UV.
  25393. * @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.
  25394. * @returns the Mesh.
  25395. */
  25396. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25397. /**
  25398. * Modifies the mesh geometry according to a displacementMap buffer.
  25399. * 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.
  25400. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25401. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25402. * @param heightMapWidth is the width of the buffer image.
  25403. * @param heightMapHeight is the height of the buffer image.
  25404. * @param minHeight is the lower limit of the displacement.
  25405. * @param maxHeight is the upper limit of the displacement.
  25406. * @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.
  25407. * @param uvOffset is an optional vector2 used to offset UV.
  25408. * @param uvScale is an optional vector2 used to scale UV.
  25409. * @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.
  25410. * @returns the Mesh.
  25411. */
  25412. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25413. /**
  25414. * Modify the mesh to get a flat shading rendering.
  25415. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25416. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25417. * @returns current mesh
  25418. */
  25419. convertToFlatShadedMesh(): Mesh;
  25420. /**
  25421. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25422. * In other words, more vertices, no more indices and a single bigger VBO.
  25423. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25424. * @returns current mesh
  25425. */
  25426. convertToUnIndexedMesh(): Mesh;
  25427. /**
  25428. * Inverses facet orientations.
  25429. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25430. * @param flipNormals will also inverts the normals
  25431. * @returns current mesh
  25432. */
  25433. flipFaces(flipNormals?: boolean): Mesh;
  25434. /**
  25435. * Increase the number of facets and hence vertices in a mesh
  25436. * Vertex normals are interpolated from existing vertex normals
  25437. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25438. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25439. */
  25440. increaseVertices(numberPerEdge: number): void;
  25441. /**
  25442. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25443. * This will undo any application of covertToFlatShadedMesh
  25444. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25445. */
  25446. forceSharedVertices(): void;
  25447. /** @hidden */
  25448. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25449. /** @hidden */
  25450. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25451. /**
  25452. * Creates a new InstancedMesh object from the mesh model.
  25453. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25454. * @param name defines the name of the new instance
  25455. * @returns a new InstancedMesh
  25456. */
  25457. createInstance(name: string): InstancedMesh;
  25458. /**
  25459. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25460. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25461. * @returns the current mesh
  25462. */
  25463. synchronizeInstances(): Mesh;
  25464. /**
  25465. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25466. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25467. * This should be used together with the simplification to avoid disappearing triangles.
  25468. * @param successCallback an optional success callback to be called after the optimization finished.
  25469. * @returns the current mesh
  25470. */
  25471. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25472. /**
  25473. * Serialize current mesh
  25474. * @param serializationObject defines the object which will receive the serialization data
  25475. */
  25476. serialize(serializationObject: any): void;
  25477. /** @hidden */
  25478. _syncGeometryWithMorphTargetManager(): void;
  25479. /** @hidden */
  25480. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25481. /**
  25482. * Returns a new Mesh object parsed from the source provided.
  25483. * @param parsedMesh is the source
  25484. * @param scene defines the hosting scene
  25485. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25486. * @returns a new Mesh
  25487. */
  25488. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25489. /**
  25490. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25491. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25492. * @param name defines the name of the mesh to create
  25493. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25494. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25495. * @param closePath creates a seam between the first and the last points of each path of the path array
  25496. * @param offset is taken in account only if the `pathArray` is containing a single path
  25497. * @param scene defines the hosting scene
  25498. * @param updatable defines if the mesh must be flagged as updatable
  25499. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25500. * @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)
  25501. * @returns a new Mesh
  25502. */
  25503. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25504. /**
  25505. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25506. * @param name defines the name of the mesh to create
  25507. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25508. * @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
  25509. * @param scene defines the hosting scene
  25510. * @param updatable defines if the mesh must be flagged as updatable
  25511. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25512. * @returns a new Mesh
  25513. */
  25514. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25515. /**
  25516. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25517. * @param name defines the name of the mesh to create
  25518. * @param size sets the size (float) of each box side (default 1)
  25519. * @param scene defines the hosting scene
  25520. * @param updatable defines if the mesh must be flagged as updatable
  25521. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25522. * @returns a new Mesh
  25523. */
  25524. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25525. /**
  25526. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25527. * @param name defines the name of the mesh to create
  25528. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25529. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25530. * @param scene defines the hosting scene
  25531. * @param updatable defines if the mesh must be flagged as updatable
  25532. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25533. * @returns a new Mesh
  25534. */
  25535. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25536. /**
  25537. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25538. * @param name defines the name of the mesh to create
  25539. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25540. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25541. * @param scene defines the hosting scene
  25542. * @returns a new Mesh
  25543. */
  25544. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25545. /**
  25546. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25547. * @param name defines the name of the mesh to create
  25548. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25549. * @param diameterTop set the top cap diameter (floats, default 1)
  25550. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25551. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25552. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25553. * @param scene defines the hosting scene
  25554. * @param updatable defines if the mesh must be flagged as updatable
  25555. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25556. * @returns a new Mesh
  25557. */
  25558. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25559. /**
  25560. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25561. * @param name defines the name of the mesh to create
  25562. * @param diameter sets the diameter size (float) of the torus (default 1)
  25563. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25564. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25565. * @param scene defines the hosting scene
  25566. * @param updatable defines if the mesh must be flagged as updatable
  25567. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25568. * @returns a new Mesh
  25569. */
  25570. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25571. /**
  25572. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25573. * @param name defines the name of the mesh to create
  25574. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25575. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25576. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25577. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25578. * @param p the number of windings on X axis (positive integers, default 2)
  25579. * @param q the number of windings on Y axis (positive integers, default 3)
  25580. * @param scene defines the hosting scene
  25581. * @param updatable defines if the mesh must be flagged as updatable
  25582. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25583. * @returns a new Mesh
  25584. */
  25585. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25586. /**
  25587. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25588. * @param name defines the name of the mesh to create
  25589. * @param points is an array successive Vector3
  25590. * @param scene defines the hosting scene
  25591. * @param updatable defines if the mesh must be flagged as updatable
  25592. * @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).
  25593. * @returns a new Mesh
  25594. */
  25595. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25596. /**
  25597. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25598. * @param name defines the name of the mesh to create
  25599. * @param points is an array successive Vector3
  25600. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25601. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25602. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25603. * @param scene defines the hosting scene
  25604. * @param updatable defines if the mesh must be flagged as updatable
  25605. * @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)
  25606. * @returns a new Mesh
  25607. */
  25608. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25609. /**
  25610. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25611. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25612. * 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.
  25613. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25614. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25615. * Remember you can only change the shape positions, not their number when updating a polygon.
  25616. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25617. * @param name defines the name of the mesh to create
  25618. * @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
  25619. * @param scene defines the hosting scene
  25620. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25621. * @param updatable defines if the mesh must be flagged as updatable
  25622. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25623. * @param earcutInjection can be used to inject your own earcut reference
  25624. * @returns a new Mesh
  25625. */
  25626. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25627. /**
  25628. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25629. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25630. * @param name defines the name of the mesh to create
  25631. * @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
  25632. * @param depth defines the height of extrusion
  25633. * @param scene defines the hosting scene
  25634. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25635. * @param updatable defines if the mesh must be flagged as updatable
  25636. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25637. * @param earcutInjection can be used to inject your own earcut reference
  25638. * @returns a new Mesh
  25639. */
  25640. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25641. /**
  25642. * Creates an extruded shape mesh.
  25643. * 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
  25644. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25645. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25646. * @param name defines the name of the mesh to create
  25647. * @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
  25648. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25649. * @param scale is the value to scale the shape
  25650. * @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
  25651. * @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
  25652. * @param scene defines the hosting scene
  25653. * @param updatable defines if the mesh must be flagged as updatable
  25654. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25655. * @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)
  25656. * @returns a new Mesh
  25657. */
  25658. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25659. /**
  25660. * Creates an custom extruded shape mesh.
  25661. * The custom extrusion is a parametric shape.
  25662. * It has no predefined shape. Its final shape will depend on the input parameters.
  25663. * Please consider using the same method from the MeshBuilder class instead
  25664. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25665. * @param name defines the name of the mesh to create
  25666. * @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
  25667. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25668. * @param scaleFunction is a custom Javascript function called on each path point
  25669. * @param rotationFunction is a custom Javascript function called on each path point
  25670. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25671. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25672. * @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
  25673. * @param scene defines the hosting scene
  25674. * @param updatable defines if the mesh must be flagged as updatable
  25675. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25676. * @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)
  25677. * @returns a new Mesh
  25678. */
  25679. 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;
  25680. /**
  25681. * Creates lathe mesh.
  25682. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25683. * Please consider using the same method from the MeshBuilder class instead
  25684. * @param name defines the name of the mesh to create
  25685. * @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
  25686. * @param radius is the radius value of the lathe
  25687. * @param tessellation is the side number of the lathe.
  25688. * @param scene defines the hosting scene
  25689. * @param updatable defines if the mesh must be flagged as updatable
  25690. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25691. * @returns a new Mesh
  25692. */
  25693. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25694. /**
  25695. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25696. * @param name defines the name of the mesh to create
  25697. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25698. * @param scene defines the hosting scene
  25699. * @param updatable defines if the mesh must be flagged as updatable
  25700. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25701. * @returns a new Mesh
  25702. */
  25703. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25704. /**
  25705. * Creates a ground mesh.
  25706. * Please consider using the same method from the MeshBuilder class instead
  25707. * @param name defines the name of the mesh to create
  25708. * @param width set the width of the ground
  25709. * @param height set the height of the ground
  25710. * @param subdivisions sets the number of subdivisions per side
  25711. * @param scene defines the hosting scene
  25712. * @param updatable defines if the mesh must be flagged as updatable
  25713. * @returns a new Mesh
  25714. */
  25715. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25716. /**
  25717. * Creates a tiled ground mesh.
  25718. * Please consider using the same method from the MeshBuilder class instead
  25719. * @param name defines the name of the mesh to create
  25720. * @param xmin set the ground minimum X coordinate
  25721. * @param zmin set the ground minimum Y coordinate
  25722. * @param xmax set the ground maximum X coordinate
  25723. * @param zmax set the ground maximum Z coordinate
  25724. * @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
  25725. * @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
  25726. * @param scene defines the hosting scene
  25727. * @param updatable defines if the mesh must be flagged as updatable
  25728. * @returns a new Mesh
  25729. */
  25730. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25731. w: number;
  25732. h: number;
  25733. }, precision: {
  25734. w: number;
  25735. h: number;
  25736. }, scene: Scene, updatable?: boolean): Mesh;
  25737. /**
  25738. * Creates a ground mesh from a height map.
  25739. * Please consider using the same method from the MeshBuilder class instead
  25740. * @see http://doc.babylonjs.com/babylon101/height_map
  25741. * @param name defines the name of the mesh to create
  25742. * @param url sets the URL of the height map image resource
  25743. * @param width set the ground width size
  25744. * @param height set the ground height size
  25745. * @param subdivisions sets the number of subdivision per side
  25746. * @param minHeight is the minimum altitude on the ground
  25747. * @param maxHeight is the maximum altitude on the ground
  25748. * @param scene defines the hosting scene
  25749. * @param updatable defines if the mesh must be flagged as updatable
  25750. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25751. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25752. * @returns a new Mesh
  25753. */
  25754. 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;
  25755. /**
  25756. * Creates a tube mesh.
  25757. * The tube is a parametric shape.
  25758. * It has no predefined shape. Its final shape will depend on the input parameters.
  25759. * Please consider using the same method from the MeshBuilder class instead
  25760. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25761. * @param name defines the name of the mesh to create
  25762. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25763. * @param radius sets the tube radius size
  25764. * @param tessellation is the number of sides on the tubular surface
  25765. * @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
  25766. * @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
  25767. * @param scene defines the hosting scene
  25768. * @param updatable defines if the mesh must be flagged as updatable
  25769. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25770. * @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)
  25771. * @returns a new Mesh
  25772. */
  25773. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25774. (i: number, distance: number): number;
  25775. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25776. /**
  25777. * Creates a polyhedron mesh.
  25778. * Please consider using the same method from the MeshBuilder class instead.
  25779. * * 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
  25780. * * The parameter `size` (positive float, default 1) sets the polygon size
  25781. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25782. * * 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`
  25783. * * 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
  25784. * * 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)`)
  25785. * * 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
  25786. * * 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
  25787. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25788. * * If you create a double-sided mesh, you can choose what parts of 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
  25789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25790. * @param name defines the name of the mesh to create
  25791. * @param options defines the options used to create the mesh
  25792. * @param scene defines the hosting scene
  25793. * @returns a new Mesh
  25794. */
  25795. static CreatePolyhedron(name: string, options: {
  25796. type?: number;
  25797. size?: number;
  25798. sizeX?: number;
  25799. sizeY?: number;
  25800. sizeZ?: number;
  25801. custom?: any;
  25802. faceUV?: Vector4[];
  25803. faceColors?: Color4[];
  25804. updatable?: boolean;
  25805. sideOrientation?: number;
  25806. }, scene: Scene): Mesh;
  25807. /**
  25808. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25809. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25810. * * 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`)
  25811. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25812. * * 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
  25813. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25814. * * If you create a double-sided mesh, you can choose what parts of 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
  25815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25816. * @param name defines the name of the mesh
  25817. * @param options defines the options used to create the mesh
  25818. * @param scene defines the hosting scene
  25819. * @returns a new Mesh
  25820. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25821. */
  25822. static CreateIcoSphere(name: string, options: {
  25823. radius?: number;
  25824. flat?: boolean;
  25825. subdivisions?: number;
  25826. sideOrientation?: number;
  25827. updatable?: boolean;
  25828. }, scene: Scene): Mesh;
  25829. /**
  25830. * Creates a decal mesh.
  25831. * Please consider using the same method from the MeshBuilder class instead.
  25832. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25833. * @param name defines the name of the mesh
  25834. * @param sourceMesh defines the mesh receiving the decal
  25835. * @param position sets the position of the decal in world coordinates
  25836. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25837. * @param size sets the decal scaling
  25838. * @param angle sets the angle to rotate the decal
  25839. * @returns a new Mesh
  25840. */
  25841. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25842. /**
  25843. * Prepare internal position array for software CPU skinning
  25844. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25845. */
  25846. setPositionsForCPUSkinning(): Float32Array;
  25847. /**
  25848. * Prepare internal normal array for software CPU skinning
  25849. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25850. */
  25851. setNormalsForCPUSkinning(): Float32Array;
  25852. /**
  25853. * Updates the vertex buffer by applying transformation from the bones
  25854. * @param skeleton defines the skeleton to apply to current mesh
  25855. * @returns the current mesh
  25856. */
  25857. applySkeleton(skeleton: Skeleton): Mesh;
  25858. /**
  25859. * 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
  25860. * @param meshes defines the list of meshes to scan
  25861. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25862. */
  25863. static MinMax(meshes: AbstractMesh[]): {
  25864. min: Vector3;
  25865. max: Vector3;
  25866. };
  25867. /**
  25868. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25869. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25870. * @returns a vector3
  25871. */
  25872. static Center(meshesOrMinMaxVector: {
  25873. min: Vector3;
  25874. max: Vector3;
  25875. } | AbstractMesh[]): Vector3;
  25876. /**
  25877. * Merge the array of meshes into a single mesh for performance reasons.
  25878. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25879. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25880. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25881. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25882. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25883. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25884. * @returns a new mesh
  25885. */
  25886. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25887. /** @hidden */
  25888. addInstance(instance: InstancedMesh): void;
  25889. /** @hidden */
  25890. removeInstance(instance: InstancedMesh): void;
  25891. }
  25892. }
  25893. declare module "babylonjs/Cameras/camera" {
  25894. import { SmartArray } from "babylonjs/Misc/smartArray";
  25895. import { Observable } from "babylonjs/Misc/observable";
  25896. import { Nullable } from "babylonjs/types";
  25897. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25898. import { Scene } from "babylonjs/scene";
  25899. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25900. import { Node } from "babylonjs/node";
  25901. import { Mesh } from "babylonjs/Meshes/mesh";
  25902. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25903. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25904. import { Viewport } from "babylonjs/Maths/math.viewport";
  25905. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25906. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25907. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25908. import { Ray } from "babylonjs/Culling/ray";
  25909. /**
  25910. * This is the base class of all the camera used in the application.
  25911. * @see http://doc.babylonjs.com/features/cameras
  25912. */
  25913. export class Camera extends Node {
  25914. /** @hidden */
  25915. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25916. /**
  25917. * This is the default projection mode used by the cameras.
  25918. * It helps recreating a feeling of perspective and better appreciate depth.
  25919. * This is the best way to simulate real life cameras.
  25920. */
  25921. static readonly PERSPECTIVE_CAMERA: number;
  25922. /**
  25923. * This helps creating camera with an orthographic mode.
  25924. * 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.
  25925. */
  25926. static readonly ORTHOGRAPHIC_CAMERA: number;
  25927. /**
  25928. * This is the default FOV mode for perspective cameras.
  25929. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25930. */
  25931. static readonly FOVMODE_VERTICAL_FIXED: number;
  25932. /**
  25933. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25934. */
  25935. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25936. /**
  25937. * This specifies ther is no need for a camera rig.
  25938. * Basically only one eye is rendered corresponding to the camera.
  25939. */
  25940. static readonly RIG_MODE_NONE: number;
  25941. /**
  25942. * Simulates a camera Rig with one blue eye and one red eye.
  25943. * This can be use with 3d blue and red glasses.
  25944. */
  25945. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25946. /**
  25947. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25948. */
  25949. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25950. /**
  25951. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25952. */
  25953. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25954. /**
  25955. * Defines that both eyes of the camera will be rendered over under each other.
  25956. */
  25957. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25958. /**
  25959. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25960. */
  25961. static readonly RIG_MODE_VR: number;
  25962. /**
  25963. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25964. */
  25965. static readonly RIG_MODE_WEBVR: number;
  25966. /**
  25967. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25968. */
  25969. static readonly RIG_MODE_CUSTOM: number;
  25970. /**
  25971. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25972. */
  25973. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25974. /**
  25975. * Define the input manager associated with the camera.
  25976. */
  25977. inputs: CameraInputsManager<Camera>;
  25978. /** @hidden */
  25979. _position: Vector3;
  25980. /**
  25981. * Define the current local position of the camera in the scene
  25982. */
  25983. get position(): Vector3;
  25984. set position(newPosition: Vector3);
  25985. /**
  25986. * The vector the camera should consider as up.
  25987. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25988. */
  25989. upVector: Vector3;
  25990. /**
  25991. * Define the current limit on the left side for an orthographic camera
  25992. * In scene unit
  25993. */
  25994. orthoLeft: Nullable<number>;
  25995. /**
  25996. * Define the current limit on the right side for an orthographic camera
  25997. * In scene unit
  25998. */
  25999. orthoRight: Nullable<number>;
  26000. /**
  26001. * Define the current limit on the bottom side for an orthographic camera
  26002. * In scene unit
  26003. */
  26004. orthoBottom: Nullable<number>;
  26005. /**
  26006. * Define the current limit on the top side for an orthographic camera
  26007. * In scene unit
  26008. */
  26009. orthoTop: Nullable<number>;
  26010. /**
  26011. * Field Of View is set in Radians. (default is 0.8)
  26012. */
  26013. fov: number;
  26014. /**
  26015. * Define the minimum distance the camera can see from.
  26016. * This is important to note that the depth buffer are not infinite and the closer it starts
  26017. * the more your scene might encounter depth fighting issue.
  26018. */
  26019. minZ: number;
  26020. /**
  26021. * Define the maximum distance the camera can see to.
  26022. * This is important to note that the depth buffer are not infinite and the further it end
  26023. * the more your scene might encounter depth fighting issue.
  26024. */
  26025. maxZ: number;
  26026. /**
  26027. * Define the default inertia of the camera.
  26028. * This helps giving a smooth feeling to the camera movement.
  26029. */
  26030. inertia: number;
  26031. /**
  26032. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26033. */
  26034. mode: number;
  26035. /**
  26036. * Define wether the camera is intermediate.
  26037. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26038. */
  26039. isIntermediate: boolean;
  26040. /**
  26041. * Define the viewport of the camera.
  26042. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26043. */
  26044. viewport: Viewport;
  26045. /**
  26046. * Restricts the camera to viewing objects with the same layerMask.
  26047. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26048. */
  26049. layerMask: number;
  26050. /**
  26051. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26052. */
  26053. fovMode: number;
  26054. /**
  26055. * Rig mode of the camera.
  26056. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26057. * This is normally controlled byt the camera themselves as internal use.
  26058. */
  26059. cameraRigMode: number;
  26060. /**
  26061. * Defines the distance between both "eyes" in case of a RIG
  26062. */
  26063. interaxialDistance: number;
  26064. /**
  26065. * Defines if stereoscopic rendering is done side by side or over under.
  26066. */
  26067. isStereoscopicSideBySide: boolean;
  26068. /**
  26069. * 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
  26070. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26071. * else in the scene. (Eg. security camera)
  26072. *
  26073. * 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)
  26074. */
  26075. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26076. /**
  26077. * When set, the camera will render to this render target instead of the default canvas
  26078. *
  26079. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26080. */
  26081. outputRenderTarget: Nullable<RenderTargetTexture>;
  26082. /**
  26083. * Observable triggered when the camera view matrix has changed.
  26084. */
  26085. onViewMatrixChangedObservable: Observable<Camera>;
  26086. /**
  26087. * Observable triggered when the camera Projection matrix has changed.
  26088. */
  26089. onProjectionMatrixChangedObservable: Observable<Camera>;
  26090. /**
  26091. * Observable triggered when the inputs have been processed.
  26092. */
  26093. onAfterCheckInputsObservable: Observable<Camera>;
  26094. /**
  26095. * Observable triggered when reset has been called and applied to the camera.
  26096. */
  26097. onRestoreStateObservable: Observable<Camera>;
  26098. /** @hidden */
  26099. _cameraRigParams: any;
  26100. /** @hidden */
  26101. _rigCameras: Camera[];
  26102. /** @hidden */
  26103. _rigPostProcess: Nullable<PostProcess>;
  26104. protected _webvrViewMatrix: Matrix;
  26105. /** @hidden */
  26106. _skipRendering: boolean;
  26107. /** @hidden */
  26108. _projectionMatrix: Matrix;
  26109. /** @hidden */
  26110. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26111. /** @hidden */
  26112. _activeMeshes: SmartArray<AbstractMesh>;
  26113. protected _globalPosition: Vector3;
  26114. /** @hidden */
  26115. _computedViewMatrix: Matrix;
  26116. private _doNotComputeProjectionMatrix;
  26117. private _transformMatrix;
  26118. private _frustumPlanes;
  26119. private _refreshFrustumPlanes;
  26120. private _storedFov;
  26121. private _stateStored;
  26122. /**
  26123. * Instantiates a new camera object.
  26124. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26125. * @see http://doc.babylonjs.com/features/cameras
  26126. * @param name Defines the name of the camera in the scene
  26127. * @param position Defines the position of the camera
  26128. * @param scene Defines the scene the camera belongs too
  26129. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26130. */
  26131. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26132. /**
  26133. * Store current camera state (fov, position, etc..)
  26134. * @returns the camera
  26135. */
  26136. storeState(): Camera;
  26137. /**
  26138. * Restores the camera state values if it has been stored. You must call storeState() first
  26139. */
  26140. protected _restoreStateValues(): boolean;
  26141. /**
  26142. * Restored camera state. You must call storeState() first.
  26143. * @returns true if restored and false otherwise
  26144. */
  26145. restoreState(): boolean;
  26146. /**
  26147. * Gets the class name of the camera.
  26148. * @returns the class name
  26149. */
  26150. getClassName(): string;
  26151. /** @hidden */
  26152. readonly _isCamera: boolean;
  26153. /**
  26154. * Gets a string representation of the camera useful for debug purpose.
  26155. * @param fullDetails Defines that a more verboe level of logging is required
  26156. * @returns the string representation
  26157. */
  26158. toString(fullDetails?: boolean): string;
  26159. /**
  26160. * Gets the current world space position of the camera.
  26161. */
  26162. get globalPosition(): Vector3;
  26163. /**
  26164. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26165. * @returns the active meshe list
  26166. */
  26167. getActiveMeshes(): SmartArray<AbstractMesh>;
  26168. /**
  26169. * Check wether a mesh is part of the current active mesh list of the camera
  26170. * @param mesh Defines the mesh to check
  26171. * @returns true if active, false otherwise
  26172. */
  26173. isActiveMesh(mesh: Mesh): boolean;
  26174. /**
  26175. * Is this camera ready to be used/rendered
  26176. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26177. * @return true if the camera is ready
  26178. */
  26179. isReady(completeCheck?: boolean): boolean;
  26180. /** @hidden */
  26181. _initCache(): void;
  26182. /** @hidden */
  26183. _updateCache(ignoreParentClass?: boolean): void;
  26184. /** @hidden */
  26185. _isSynchronized(): boolean;
  26186. /** @hidden */
  26187. _isSynchronizedViewMatrix(): boolean;
  26188. /** @hidden */
  26189. _isSynchronizedProjectionMatrix(): boolean;
  26190. /**
  26191. * Attach the input controls to a specific dom element to get the input from.
  26192. * @param element Defines the element the controls should be listened from
  26193. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26194. */
  26195. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26196. /**
  26197. * Detach the current controls from the specified dom element.
  26198. * @param element Defines the element to stop listening the inputs from
  26199. */
  26200. detachControl(element: HTMLElement): void;
  26201. /**
  26202. * Update the camera state according to the different inputs gathered during the frame.
  26203. */
  26204. update(): void;
  26205. /** @hidden */
  26206. _checkInputs(): void;
  26207. /** @hidden */
  26208. get rigCameras(): Camera[];
  26209. /**
  26210. * Gets the post process used by the rig cameras
  26211. */
  26212. get rigPostProcess(): Nullable<PostProcess>;
  26213. /**
  26214. * Internal, gets the first post proces.
  26215. * @returns the first post process to be run on this camera.
  26216. */
  26217. _getFirstPostProcess(): Nullable<PostProcess>;
  26218. private _cascadePostProcessesToRigCams;
  26219. /**
  26220. * Attach a post process to the camera.
  26221. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26222. * @param postProcess The post process to attach to the camera
  26223. * @param insertAt The position of the post process in case several of them are in use in the scene
  26224. * @returns the position the post process has been inserted at
  26225. */
  26226. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26227. /**
  26228. * Detach a post process to the camera.
  26229. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26230. * @param postProcess The post process to detach from the camera
  26231. */
  26232. detachPostProcess(postProcess: PostProcess): void;
  26233. /**
  26234. * Gets the current world matrix of the camera
  26235. */
  26236. getWorldMatrix(): Matrix;
  26237. /** @hidden */
  26238. _getViewMatrix(): Matrix;
  26239. /**
  26240. * Gets the current view matrix of the camera.
  26241. * @param force forces the camera to recompute the matrix without looking at the cached state
  26242. * @returns the view matrix
  26243. */
  26244. getViewMatrix(force?: boolean): Matrix;
  26245. /**
  26246. * Freeze the projection matrix.
  26247. * It will prevent the cache check of the camera projection compute and can speed up perf
  26248. * if no parameter of the camera are meant to change
  26249. * @param projection Defines manually a projection if necessary
  26250. */
  26251. freezeProjectionMatrix(projection?: Matrix): void;
  26252. /**
  26253. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26254. */
  26255. unfreezeProjectionMatrix(): void;
  26256. /**
  26257. * Gets the current projection matrix of the camera.
  26258. * @param force forces the camera to recompute the matrix without looking at the cached state
  26259. * @returns the projection matrix
  26260. */
  26261. getProjectionMatrix(force?: boolean): Matrix;
  26262. /**
  26263. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26264. * @returns a Matrix
  26265. */
  26266. getTransformationMatrix(): Matrix;
  26267. private _updateFrustumPlanes;
  26268. /**
  26269. * Checks if a cullable object (mesh...) is in the camera frustum
  26270. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26271. * @param target The object to check
  26272. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26273. * @returns true if the object is in frustum otherwise false
  26274. */
  26275. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26276. /**
  26277. * Checks if a cullable object (mesh...) is in the camera frustum
  26278. * Unlike isInFrustum this cheks the full bounding box
  26279. * @param target The object to check
  26280. * @returns true if the object is in frustum otherwise false
  26281. */
  26282. isCompletelyInFrustum(target: ICullable): boolean;
  26283. /**
  26284. * Gets a ray in the forward direction from the camera.
  26285. * @param length Defines the length of the ray to create
  26286. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26287. * @param origin Defines the start point of the ray which defaults to the camera position
  26288. * @returns the forward ray
  26289. */
  26290. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26291. /**
  26292. * Releases resources associated with this node.
  26293. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26294. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26295. */
  26296. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26297. /** @hidden */
  26298. _isLeftCamera: boolean;
  26299. /**
  26300. * Gets the left camera of a rig setup in case of Rigged Camera
  26301. */
  26302. get isLeftCamera(): boolean;
  26303. /** @hidden */
  26304. _isRightCamera: boolean;
  26305. /**
  26306. * Gets the right camera of a rig setup in case of Rigged Camera
  26307. */
  26308. get isRightCamera(): boolean;
  26309. /**
  26310. * Gets the left camera of a rig setup in case of Rigged Camera
  26311. */
  26312. get leftCamera(): Nullable<FreeCamera>;
  26313. /**
  26314. * Gets the right camera of a rig setup in case of Rigged Camera
  26315. */
  26316. get rightCamera(): Nullable<FreeCamera>;
  26317. /**
  26318. * Gets the left camera target of a rig setup in case of Rigged Camera
  26319. * @returns the target position
  26320. */
  26321. getLeftTarget(): Nullable<Vector3>;
  26322. /**
  26323. * Gets the right camera target of a rig setup in case of Rigged Camera
  26324. * @returns the target position
  26325. */
  26326. getRightTarget(): Nullable<Vector3>;
  26327. /**
  26328. * @hidden
  26329. */
  26330. setCameraRigMode(mode: number, rigParams: any): void;
  26331. /** @hidden */
  26332. static _setStereoscopicRigMode(camera: Camera): void;
  26333. /** @hidden */
  26334. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26335. /** @hidden */
  26336. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26337. /** @hidden */
  26338. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26339. /** @hidden */
  26340. _getVRProjectionMatrix(): Matrix;
  26341. protected _updateCameraRotationMatrix(): void;
  26342. protected _updateWebVRCameraRotationMatrix(): void;
  26343. /**
  26344. * This function MUST be overwritten by the different WebVR cameras available.
  26345. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26346. * @hidden
  26347. */
  26348. _getWebVRProjectionMatrix(): Matrix;
  26349. /**
  26350. * This function MUST be overwritten by the different WebVR cameras available.
  26351. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26352. * @hidden
  26353. */
  26354. _getWebVRViewMatrix(): Matrix;
  26355. /** @hidden */
  26356. setCameraRigParameter(name: string, value: any): void;
  26357. /**
  26358. * needs to be overridden by children so sub has required properties to be copied
  26359. * @hidden
  26360. */
  26361. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26362. /**
  26363. * May need to be overridden by children
  26364. * @hidden
  26365. */
  26366. _updateRigCameras(): void;
  26367. /** @hidden */
  26368. _setupInputs(): void;
  26369. /**
  26370. * Serialiaze the camera setup to a json represention
  26371. * @returns the JSON representation
  26372. */
  26373. serialize(): any;
  26374. /**
  26375. * Clones the current camera.
  26376. * @param name The cloned camera name
  26377. * @returns the cloned camera
  26378. */
  26379. clone(name: string): Camera;
  26380. /**
  26381. * Gets the direction of the camera relative to a given local axis.
  26382. * @param localAxis Defines the reference axis to provide a relative direction.
  26383. * @return the direction
  26384. */
  26385. getDirection(localAxis: Vector3): Vector3;
  26386. /**
  26387. * Returns the current camera absolute rotation
  26388. */
  26389. get absoluteRotation(): Quaternion;
  26390. /**
  26391. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26392. * @param localAxis Defines the reference axis to provide a relative direction.
  26393. * @param result Defines the vector to store the result in
  26394. */
  26395. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26396. /**
  26397. * Gets a camera constructor for a given camera type
  26398. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26399. * @param name The name of the camera the result will be able to instantiate
  26400. * @param scene The scene the result will construct the camera in
  26401. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26402. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26403. * @returns a factory method to construc the camera
  26404. */
  26405. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26406. /**
  26407. * Compute the world matrix of the camera.
  26408. * @returns the camera world matrix
  26409. */
  26410. computeWorldMatrix(): Matrix;
  26411. /**
  26412. * Parse a JSON and creates the camera from the parsed information
  26413. * @param parsedCamera The JSON to parse
  26414. * @param scene The scene to instantiate the camera in
  26415. * @returns the newly constructed camera
  26416. */
  26417. static Parse(parsedCamera: any, scene: Scene): Camera;
  26418. }
  26419. }
  26420. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26421. import { Nullable } from "babylonjs/types";
  26422. import { Scene } from "babylonjs/scene";
  26423. import { Vector4 } from "babylonjs/Maths/math.vector";
  26424. import { Mesh } from "babylonjs/Meshes/mesh";
  26425. /**
  26426. * Class containing static functions to help procedurally build meshes
  26427. */
  26428. export class DiscBuilder {
  26429. /**
  26430. * Creates a plane polygonal mesh. By default, this is a disc
  26431. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26432. * * 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
  26433. * * 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
  26434. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26435. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26436. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26437. * @param name defines the name of the mesh
  26438. * @param options defines the options used to create the mesh
  26439. * @param scene defines the hosting scene
  26440. * @returns the plane polygonal mesh
  26441. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26442. */
  26443. static CreateDisc(name: string, options: {
  26444. radius?: number;
  26445. tessellation?: number;
  26446. arc?: number;
  26447. updatable?: boolean;
  26448. sideOrientation?: number;
  26449. frontUVs?: Vector4;
  26450. backUVs?: Vector4;
  26451. }, scene?: Nullable<Scene>): Mesh;
  26452. }
  26453. }
  26454. declare module "babylonjs/Materials/fresnelParameters" {
  26455. import { Color3 } from "babylonjs/Maths/math.color";
  26456. /**
  26457. * This represents all the required information to add a fresnel effect on a material:
  26458. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26459. */
  26460. export class FresnelParameters {
  26461. private _isEnabled;
  26462. /**
  26463. * Define if the fresnel effect is enable or not.
  26464. */
  26465. get isEnabled(): boolean;
  26466. set isEnabled(value: boolean);
  26467. /**
  26468. * Define the color used on edges (grazing angle)
  26469. */
  26470. leftColor: Color3;
  26471. /**
  26472. * Define the color used on center
  26473. */
  26474. rightColor: Color3;
  26475. /**
  26476. * Define bias applied to computed fresnel term
  26477. */
  26478. bias: number;
  26479. /**
  26480. * Defined the power exponent applied to fresnel term
  26481. */
  26482. power: number;
  26483. /**
  26484. * Clones the current fresnel and its valuues
  26485. * @returns a clone fresnel configuration
  26486. */
  26487. clone(): FresnelParameters;
  26488. /**
  26489. * Serializes the current fresnel parameters to a JSON representation.
  26490. * @return the JSON serialization
  26491. */
  26492. serialize(): any;
  26493. /**
  26494. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26495. * @param parsedFresnelParameters Define the JSON representation
  26496. * @returns the parsed parameters
  26497. */
  26498. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26499. }
  26500. }
  26501. declare module "babylonjs/Materials/pushMaterial" {
  26502. import { Nullable } from "babylonjs/types";
  26503. import { Scene } from "babylonjs/scene";
  26504. import { Matrix } from "babylonjs/Maths/math.vector";
  26505. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26506. import { Mesh } from "babylonjs/Meshes/mesh";
  26507. import { Material } from "babylonjs/Materials/material";
  26508. import { Effect } from "babylonjs/Materials/effect";
  26509. /**
  26510. * Base class of materials working in push mode in babylon JS
  26511. * @hidden
  26512. */
  26513. export class PushMaterial extends Material {
  26514. protected _activeEffect: Effect;
  26515. protected _normalMatrix: Matrix;
  26516. /**
  26517. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26518. * This means that the material can keep using a previous shader while a new one is being compiled.
  26519. * This is mostly used when shader parallel compilation is supported (true by default)
  26520. */
  26521. allowShaderHotSwapping: boolean;
  26522. constructor(name: string, scene: Scene);
  26523. getEffect(): Effect;
  26524. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26525. /**
  26526. * Binds the given world matrix to the active effect
  26527. *
  26528. * @param world the matrix to bind
  26529. */
  26530. bindOnlyWorldMatrix(world: Matrix): void;
  26531. /**
  26532. * Binds the given normal matrix to the active effect
  26533. *
  26534. * @param normalMatrix the matrix to bind
  26535. */
  26536. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26537. bind(world: Matrix, mesh?: Mesh): void;
  26538. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26539. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26540. }
  26541. }
  26542. declare module "babylonjs/Materials/materialFlags" {
  26543. /**
  26544. * This groups all the flags used to control the materials channel.
  26545. */
  26546. export class MaterialFlags {
  26547. private static _DiffuseTextureEnabled;
  26548. /**
  26549. * Are diffuse textures enabled in the application.
  26550. */
  26551. static get DiffuseTextureEnabled(): boolean;
  26552. static set DiffuseTextureEnabled(value: boolean);
  26553. private static _AmbientTextureEnabled;
  26554. /**
  26555. * Are ambient textures enabled in the application.
  26556. */
  26557. static get AmbientTextureEnabled(): boolean;
  26558. static set AmbientTextureEnabled(value: boolean);
  26559. private static _OpacityTextureEnabled;
  26560. /**
  26561. * Are opacity textures enabled in the application.
  26562. */
  26563. static get OpacityTextureEnabled(): boolean;
  26564. static set OpacityTextureEnabled(value: boolean);
  26565. private static _ReflectionTextureEnabled;
  26566. /**
  26567. * Are reflection textures enabled in the application.
  26568. */
  26569. static get ReflectionTextureEnabled(): boolean;
  26570. static set ReflectionTextureEnabled(value: boolean);
  26571. private static _EmissiveTextureEnabled;
  26572. /**
  26573. * Are emissive textures enabled in the application.
  26574. */
  26575. static get EmissiveTextureEnabled(): boolean;
  26576. static set EmissiveTextureEnabled(value: boolean);
  26577. private static _SpecularTextureEnabled;
  26578. /**
  26579. * Are specular textures enabled in the application.
  26580. */
  26581. static get SpecularTextureEnabled(): boolean;
  26582. static set SpecularTextureEnabled(value: boolean);
  26583. private static _BumpTextureEnabled;
  26584. /**
  26585. * Are bump textures enabled in the application.
  26586. */
  26587. static get BumpTextureEnabled(): boolean;
  26588. static set BumpTextureEnabled(value: boolean);
  26589. private static _LightmapTextureEnabled;
  26590. /**
  26591. * Are lightmap textures enabled in the application.
  26592. */
  26593. static get LightmapTextureEnabled(): boolean;
  26594. static set LightmapTextureEnabled(value: boolean);
  26595. private static _RefractionTextureEnabled;
  26596. /**
  26597. * Are refraction textures enabled in the application.
  26598. */
  26599. static get RefractionTextureEnabled(): boolean;
  26600. static set RefractionTextureEnabled(value: boolean);
  26601. private static _ColorGradingTextureEnabled;
  26602. /**
  26603. * Are color grading textures enabled in the application.
  26604. */
  26605. static get ColorGradingTextureEnabled(): boolean;
  26606. static set ColorGradingTextureEnabled(value: boolean);
  26607. private static _FresnelEnabled;
  26608. /**
  26609. * Are fresnels enabled in the application.
  26610. */
  26611. static get FresnelEnabled(): boolean;
  26612. static set FresnelEnabled(value: boolean);
  26613. private static _ClearCoatTextureEnabled;
  26614. /**
  26615. * Are clear coat textures enabled in the application.
  26616. */
  26617. static get ClearCoatTextureEnabled(): boolean;
  26618. static set ClearCoatTextureEnabled(value: boolean);
  26619. private static _ClearCoatBumpTextureEnabled;
  26620. /**
  26621. * Are clear coat bump textures enabled in the application.
  26622. */
  26623. static get ClearCoatBumpTextureEnabled(): boolean;
  26624. static set ClearCoatBumpTextureEnabled(value: boolean);
  26625. private static _ClearCoatTintTextureEnabled;
  26626. /**
  26627. * Are clear coat tint textures enabled in the application.
  26628. */
  26629. static get ClearCoatTintTextureEnabled(): boolean;
  26630. static set ClearCoatTintTextureEnabled(value: boolean);
  26631. private static _SheenTextureEnabled;
  26632. /**
  26633. * Are sheen textures enabled in the application.
  26634. */
  26635. static get SheenTextureEnabled(): boolean;
  26636. static set SheenTextureEnabled(value: boolean);
  26637. private static _AnisotropicTextureEnabled;
  26638. /**
  26639. * Are anisotropic textures enabled in the application.
  26640. */
  26641. static get AnisotropicTextureEnabled(): boolean;
  26642. static set AnisotropicTextureEnabled(value: boolean);
  26643. private static _ThicknessTextureEnabled;
  26644. /**
  26645. * Are thickness textures enabled in the application.
  26646. */
  26647. static get ThicknessTextureEnabled(): boolean;
  26648. static set ThicknessTextureEnabled(value: boolean);
  26649. }
  26650. }
  26651. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26652. /** @hidden */
  26653. export var defaultFragmentDeclaration: {
  26654. name: string;
  26655. shader: string;
  26656. };
  26657. }
  26658. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26659. /** @hidden */
  26660. export var defaultUboDeclaration: {
  26661. name: string;
  26662. shader: string;
  26663. };
  26664. }
  26665. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26666. /** @hidden */
  26667. export var lightFragmentDeclaration: {
  26668. name: string;
  26669. shader: string;
  26670. };
  26671. }
  26672. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26673. /** @hidden */
  26674. export var lightUboDeclaration: {
  26675. name: string;
  26676. shader: string;
  26677. };
  26678. }
  26679. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26680. /** @hidden */
  26681. export var lightsFragmentFunctions: {
  26682. name: string;
  26683. shader: string;
  26684. };
  26685. }
  26686. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26687. /** @hidden */
  26688. export var shadowsFragmentFunctions: {
  26689. name: string;
  26690. shader: string;
  26691. };
  26692. }
  26693. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26694. /** @hidden */
  26695. export var fresnelFunction: {
  26696. name: string;
  26697. shader: string;
  26698. };
  26699. }
  26700. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26701. /** @hidden */
  26702. export var reflectionFunction: {
  26703. name: string;
  26704. shader: string;
  26705. };
  26706. }
  26707. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26708. /** @hidden */
  26709. export var bumpFragmentFunctions: {
  26710. name: string;
  26711. shader: string;
  26712. };
  26713. }
  26714. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26715. /** @hidden */
  26716. export var logDepthDeclaration: {
  26717. name: string;
  26718. shader: string;
  26719. };
  26720. }
  26721. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26722. /** @hidden */
  26723. export var bumpFragment: {
  26724. name: string;
  26725. shader: string;
  26726. };
  26727. }
  26728. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26729. /** @hidden */
  26730. export var depthPrePass: {
  26731. name: string;
  26732. shader: string;
  26733. };
  26734. }
  26735. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26736. /** @hidden */
  26737. export var lightFragment: {
  26738. name: string;
  26739. shader: string;
  26740. };
  26741. }
  26742. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  26743. /** @hidden */
  26744. export var logDepthFragment: {
  26745. name: string;
  26746. shader: string;
  26747. };
  26748. }
  26749. declare module "babylonjs/Shaders/default.fragment" {
  26750. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  26751. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26752. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26753. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26754. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26755. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  26756. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26757. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  26758. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26759. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26760. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26761. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26762. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26763. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26764. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26765. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26766. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26767. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26768. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  26769. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  26770. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  26771. /** @hidden */
  26772. export var defaultPixelShader: {
  26773. name: string;
  26774. shader: string;
  26775. };
  26776. }
  26777. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  26778. /** @hidden */
  26779. export var defaultVertexDeclaration: {
  26780. name: string;
  26781. shader: string;
  26782. };
  26783. }
  26784. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  26785. /** @hidden */
  26786. export var bumpVertexDeclaration: {
  26787. name: string;
  26788. shader: string;
  26789. };
  26790. }
  26791. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  26792. /** @hidden */
  26793. export var bumpVertex: {
  26794. name: string;
  26795. shader: string;
  26796. };
  26797. }
  26798. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  26799. /** @hidden */
  26800. export var fogVertex: {
  26801. name: string;
  26802. shader: string;
  26803. };
  26804. }
  26805. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  26806. /** @hidden */
  26807. export var shadowsVertex: {
  26808. name: string;
  26809. shader: string;
  26810. };
  26811. }
  26812. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  26813. /** @hidden */
  26814. export var pointCloudVertex: {
  26815. name: string;
  26816. shader: string;
  26817. };
  26818. }
  26819. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  26820. /** @hidden */
  26821. export var logDepthVertex: {
  26822. name: string;
  26823. shader: string;
  26824. };
  26825. }
  26826. declare module "babylonjs/Shaders/default.vertex" {
  26827. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  26828. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26829. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26830. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  26831. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  26832. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  26833. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  26834. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  26835. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26836. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26837. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  26838. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  26839. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26840. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  26841. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  26842. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  26843. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  26844. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  26845. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  26846. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  26847. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  26848. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  26849. /** @hidden */
  26850. export var defaultVertexShader: {
  26851. name: string;
  26852. shader: string;
  26853. };
  26854. }
  26855. declare module "babylonjs/Materials/standardMaterial" {
  26856. import { SmartArray } from "babylonjs/Misc/smartArray";
  26857. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26858. import { Nullable } from "babylonjs/types";
  26859. import { Scene } from "babylonjs/scene";
  26860. import { Matrix } from "babylonjs/Maths/math.vector";
  26861. import { Color3 } from "babylonjs/Maths/math.color";
  26862. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26864. import { Mesh } from "babylonjs/Meshes/mesh";
  26865. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  26866. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  26867. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  26868. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26869. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  26870. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26871. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26872. import "babylonjs/Shaders/default.fragment";
  26873. import "babylonjs/Shaders/default.vertex";
  26874. /** @hidden */
  26875. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26876. MAINUV1: boolean;
  26877. MAINUV2: boolean;
  26878. DIFFUSE: boolean;
  26879. DIFFUSEDIRECTUV: number;
  26880. AMBIENT: boolean;
  26881. AMBIENTDIRECTUV: number;
  26882. OPACITY: boolean;
  26883. OPACITYDIRECTUV: number;
  26884. OPACITYRGB: boolean;
  26885. REFLECTION: boolean;
  26886. EMISSIVE: boolean;
  26887. EMISSIVEDIRECTUV: number;
  26888. SPECULAR: boolean;
  26889. SPECULARDIRECTUV: number;
  26890. BUMP: boolean;
  26891. BUMPDIRECTUV: number;
  26892. PARALLAX: boolean;
  26893. PARALLAXOCCLUSION: boolean;
  26894. SPECULAROVERALPHA: boolean;
  26895. CLIPPLANE: boolean;
  26896. CLIPPLANE2: boolean;
  26897. CLIPPLANE3: boolean;
  26898. CLIPPLANE4: boolean;
  26899. CLIPPLANE5: boolean;
  26900. CLIPPLANE6: boolean;
  26901. ALPHATEST: boolean;
  26902. DEPTHPREPASS: boolean;
  26903. ALPHAFROMDIFFUSE: boolean;
  26904. POINTSIZE: boolean;
  26905. FOG: boolean;
  26906. SPECULARTERM: boolean;
  26907. DIFFUSEFRESNEL: boolean;
  26908. OPACITYFRESNEL: boolean;
  26909. REFLECTIONFRESNEL: boolean;
  26910. REFRACTIONFRESNEL: boolean;
  26911. EMISSIVEFRESNEL: boolean;
  26912. FRESNEL: boolean;
  26913. NORMAL: boolean;
  26914. UV1: boolean;
  26915. UV2: boolean;
  26916. VERTEXCOLOR: boolean;
  26917. VERTEXALPHA: boolean;
  26918. NUM_BONE_INFLUENCERS: number;
  26919. BonesPerMesh: number;
  26920. BONETEXTURE: boolean;
  26921. INSTANCES: boolean;
  26922. GLOSSINESS: boolean;
  26923. ROUGHNESS: boolean;
  26924. EMISSIVEASILLUMINATION: boolean;
  26925. LINKEMISSIVEWITHDIFFUSE: boolean;
  26926. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26927. LIGHTMAP: boolean;
  26928. LIGHTMAPDIRECTUV: number;
  26929. OBJECTSPACE_NORMALMAP: boolean;
  26930. USELIGHTMAPASSHADOWMAP: boolean;
  26931. REFLECTIONMAP_3D: boolean;
  26932. REFLECTIONMAP_SPHERICAL: boolean;
  26933. REFLECTIONMAP_PLANAR: boolean;
  26934. REFLECTIONMAP_CUBIC: boolean;
  26935. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26936. REFLECTIONMAP_PROJECTION: boolean;
  26937. REFLECTIONMAP_SKYBOX: boolean;
  26938. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  26939. REFLECTIONMAP_EXPLICIT: boolean;
  26940. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26941. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26942. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26943. INVERTCUBICMAP: boolean;
  26944. LOGARITHMICDEPTH: boolean;
  26945. REFRACTION: boolean;
  26946. REFRACTIONMAP_3D: boolean;
  26947. REFLECTIONOVERALPHA: boolean;
  26948. TWOSIDEDLIGHTING: boolean;
  26949. SHADOWFLOAT: boolean;
  26950. MORPHTARGETS: boolean;
  26951. MORPHTARGETS_NORMAL: boolean;
  26952. MORPHTARGETS_TANGENT: boolean;
  26953. MORPHTARGETS_UV: boolean;
  26954. NUM_MORPH_INFLUENCERS: number;
  26955. NONUNIFORMSCALING: boolean;
  26956. PREMULTIPLYALPHA: boolean;
  26957. IMAGEPROCESSING: boolean;
  26958. VIGNETTE: boolean;
  26959. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26960. VIGNETTEBLENDMODEOPAQUE: boolean;
  26961. TONEMAPPING: boolean;
  26962. TONEMAPPING_ACES: boolean;
  26963. CONTRAST: boolean;
  26964. COLORCURVES: boolean;
  26965. COLORGRADING: boolean;
  26966. COLORGRADING3D: boolean;
  26967. SAMPLER3DGREENDEPTH: boolean;
  26968. SAMPLER3DBGRMAP: boolean;
  26969. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26970. MULTIVIEW: boolean;
  26971. /**
  26972. * If the reflection texture on this material is in linear color space
  26973. * @hidden
  26974. */
  26975. IS_REFLECTION_LINEAR: boolean;
  26976. /**
  26977. * If the refraction texture on this material is in linear color space
  26978. * @hidden
  26979. */
  26980. IS_REFRACTION_LINEAR: boolean;
  26981. EXPOSURE: boolean;
  26982. constructor();
  26983. setReflectionMode(modeToEnable: string): void;
  26984. }
  26985. /**
  26986. * This is the default material used in Babylon. It is the best trade off between quality
  26987. * and performances.
  26988. * @see http://doc.babylonjs.com/babylon101/materials
  26989. */
  26990. export class StandardMaterial extends PushMaterial {
  26991. private _diffuseTexture;
  26992. /**
  26993. * The basic texture of the material as viewed under a light.
  26994. */
  26995. diffuseTexture: Nullable<BaseTexture>;
  26996. private _ambientTexture;
  26997. /**
  26998. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26999. */
  27000. ambientTexture: Nullable<BaseTexture>;
  27001. private _opacityTexture;
  27002. /**
  27003. * Define the transparency of the material from a texture.
  27004. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27005. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27006. */
  27007. opacityTexture: Nullable<BaseTexture>;
  27008. private _reflectionTexture;
  27009. /**
  27010. * Define the texture used to display the reflection.
  27011. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27012. */
  27013. reflectionTexture: Nullable<BaseTexture>;
  27014. private _emissiveTexture;
  27015. /**
  27016. * Define texture of the material as if self lit.
  27017. * This will be mixed in the final result even in the absence of light.
  27018. */
  27019. emissiveTexture: Nullable<BaseTexture>;
  27020. private _specularTexture;
  27021. /**
  27022. * Define how the color and intensity of the highlight given by the light in the material.
  27023. */
  27024. specularTexture: Nullable<BaseTexture>;
  27025. private _bumpTexture;
  27026. /**
  27027. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27028. * 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.
  27029. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27030. */
  27031. bumpTexture: Nullable<BaseTexture>;
  27032. private _lightmapTexture;
  27033. /**
  27034. * Complex lighting can be computationally expensive to compute at runtime.
  27035. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27036. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27037. */
  27038. lightmapTexture: Nullable<BaseTexture>;
  27039. private _refractionTexture;
  27040. /**
  27041. * Define the texture used to display the refraction.
  27042. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27043. */
  27044. refractionTexture: Nullable<BaseTexture>;
  27045. /**
  27046. * The color of the material lit by the environmental background lighting.
  27047. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27048. */
  27049. ambientColor: Color3;
  27050. /**
  27051. * The basic color of the material as viewed under a light.
  27052. */
  27053. diffuseColor: Color3;
  27054. /**
  27055. * Define how the color and intensity of the highlight given by the light in the material.
  27056. */
  27057. specularColor: Color3;
  27058. /**
  27059. * Define the color of the material as if self lit.
  27060. * This will be mixed in the final result even in the absence of light.
  27061. */
  27062. emissiveColor: Color3;
  27063. /**
  27064. * Defines how sharp are the highlights in the material.
  27065. * The bigger the value the sharper giving a more glossy feeling to the result.
  27066. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27067. */
  27068. specularPower: number;
  27069. private _useAlphaFromDiffuseTexture;
  27070. /**
  27071. * Does the transparency come from the diffuse texture alpha channel.
  27072. */
  27073. useAlphaFromDiffuseTexture: boolean;
  27074. private _useEmissiveAsIllumination;
  27075. /**
  27076. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27077. */
  27078. useEmissiveAsIllumination: boolean;
  27079. private _linkEmissiveWithDiffuse;
  27080. /**
  27081. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27082. * the emissive level when the final color is close to one.
  27083. */
  27084. linkEmissiveWithDiffuse: boolean;
  27085. private _useSpecularOverAlpha;
  27086. /**
  27087. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27088. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27089. */
  27090. useSpecularOverAlpha: boolean;
  27091. private _useReflectionOverAlpha;
  27092. /**
  27093. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27094. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27095. */
  27096. useReflectionOverAlpha: boolean;
  27097. private _disableLighting;
  27098. /**
  27099. * Does lights from the scene impacts this material.
  27100. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27101. */
  27102. disableLighting: boolean;
  27103. private _useObjectSpaceNormalMap;
  27104. /**
  27105. * Allows using an object space normal map (instead of tangent space).
  27106. */
  27107. useObjectSpaceNormalMap: boolean;
  27108. private _useParallax;
  27109. /**
  27110. * Is parallax enabled or not.
  27111. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27112. */
  27113. useParallax: boolean;
  27114. private _useParallaxOcclusion;
  27115. /**
  27116. * Is parallax occlusion enabled or not.
  27117. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27118. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27119. */
  27120. useParallaxOcclusion: boolean;
  27121. /**
  27122. * 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.
  27123. */
  27124. parallaxScaleBias: number;
  27125. private _roughness;
  27126. /**
  27127. * Helps to define how blurry the reflections should appears in the material.
  27128. */
  27129. roughness: number;
  27130. /**
  27131. * In case of refraction, define the value of the index of refraction.
  27132. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27133. */
  27134. indexOfRefraction: number;
  27135. /**
  27136. * Invert the refraction texture alongside the y axis.
  27137. * It can be useful with procedural textures or probe for instance.
  27138. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27139. */
  27140. invertRefractionY: boolean;
  27141. /**
  27142. * Defines the alpha limits in alpha test mode.
  27143. */
  27144. alphaCutOff: number;
  27145. private _useLightmapAsShadowmap;
  27146. /**
  27147. * In case of light mapping, define whether the map contains light or shadow informations.
  27148. */
  27149. useLightmapAsShadowmap: boolean;
  27150. private _diffuseFresnelParameters;
  27151. /**
  27152. * Define the diffuse fresnel parameters of the material.
  27153. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27154. */
  27155. diffuseFresnelParameters: FresnelParameters;
  27156. private _opacityFresnelParameters;
  27157. /**
  27158. * Define the opacity fresnel parameters of the material.
  27159. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27160. */
  27161. opacityFresnelParameters: FresnelParameters;
  27162. private _reflectionFresnelParameters;
  27163. /**
  27164. * Define the reflection fresnel parameters of the material.
  27165. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27166. */
  27167. reflectionFresnelParameters: FresnelParameters;
  27168. private _refractionFresnelParameters;
  27169. /**
  27170. * Define the refraction fresnel parameters of the material.
  27171. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27172. */
  27173. refractionFresnelParameters: FresnelParameters;
  27174. private _emissiveFresnelParameters;
  27175. /**
  27176. * Define the emissive fresnel parameters of the material.
  27177. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27178. */
  27179. emissiveFresnelParameters: FresnelParameters;
  27180. private _useReflectionFresnelFromSpecular;
  27181. /**
  27182. * If true automatically deducts the fresnels values from the material specularity.
  27183. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27184. */
  27185. useReflectionFresnelFromSpecular: boolean;
  27186. private _useGlossinessFromSpecularMapAlpha;
  27187. /**
  27188. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27189. */
  27190. useGlossinessFromSpecularMapAlpha: boolean;
  27191. private _maxSimultaneousLights;
  27192. /**
  27193. * Defines the maximum number of lights that can be used in the material
  27194. */
  27195. maxSimultaneousLights: number;
  27196. private _invertNormalMapX;
  27197. /**
  27198. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27199. */
  27200. invertNormalMapX: boolean;
  27201. private _invertNormalMapY;
  27202. /**
  27203. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27204. */
  27205. invertNormalMapY: boolean;
  27206. private _twoSidedLighting;
  27207. /**
  27208. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27209. */
  27210. twoSidedLighting: boolean;
  27211. /**
  27212. * Default configuration related to image processing available in the standard Material.
  27213. */
  27214. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27215. /**
  27216. * Gets the image processing configuration used either in this material.
  27217. */
  27218. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27219. /**
  27220. * Sets the Default image processing configuration used either in the this material.
  27221. *
  27222. * If sets to null, the scene one is in use.
  27223. */
  27224. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27225. /**
  27226. * Keep track of the image processing observer to allow dispose and replace.
  27227. */
  27228. private _imageProcessingObserver;
  27229. /**
  27230. * Attaches a new image processing configuration to the Standard Material.
  27231. * @param configuration
  27232. */
  27233. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27234. /**
  27235. * Gets wether the color curves effect is enabled.
  27236. */
  27237. get cameraColorCurvesEnabled(): boolean;
  27238. /**
  27239. * Sets wether the color curves effect is enabled.
  27240. */
  27241. set cameraColorCurvesEnabled(value: boolean);
  27242. /**
  27243. * Gets wether the color grading effect is enabled.
  27244. */
  27245. get cameraColorGradingEnabled(): boolean;
  27246. /**
  27247. * Gets wether the color grading effect is enabled.
  27248. */
  27249. set cameraColorGradingEnabled(value: boolean);
  27250. /**
  27251. * Gets wether tonemapping is enabled or not.
  27252. */
  27253. get cameraToneMappingEnabled(): boolean;
  27254. /**
  27255. * Sets wether tonemapping is enabled or not
  27256. */
  27257. set cameraToneMappingEnabled(value: boolean);
  27258. /**
  27259. * The camera exposure used on this material.
  27260. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27261. * This corresponds to a photographic exposure.
  27262. */
  27263. get cameraExposure(): number;
  27264. /**
  27265. * The camera exposure used on this material.
  27266. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27267. * This corresponds to a photographic exposure.
  27268. */
  27269. set cameraExposure(value: number);
  27270. /**
  27271. * Gets The camera contrast used on this material.
  27272. */
  27273. get cameraContrast(): number;
  27274. /**
  27275. * Sets The camera contrast used on this material.
  27276. */
  27277. set cameraContrast(value: number);
  27278. /**
  27279. * Gets the Color Grading 2D Lookup Texture.
  27280. */
  27281. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27282. /**
  27283. * Sets the Color Grading 2D Lookup Texture.
  27284. */
  27285. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27286. /**
  27287. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27288. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27289. * 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;
  27290. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27291. */
  27292. get cameraColorCurves(): Nullable<ColorCurves>;
  27293. /**
  27294. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27295. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27296. * 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;
  27297. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27298. */
  27299. set cameraColorCurves(value: Nullable<ColorCurves>);
  27300. /**
  27301. * Custom callback helping to override the default shader used in the material.
  27302. */
  27303. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27304. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27305. protected _worldViewProjectionMatrix: Matrix;
  27306. protected _globalAmbientColor: Color3;
  27307. protected _useLogarithmicDepth: boolean;
  27308. protected _rebuildInParallel: boolean;
  27309. /**
  27310. * Instantiates a new standard material.
  27311. * This is the default material used in Babylon. It is the best trade off between quality
  27312. * and performances.
  27313. * @see http://doc.babylonjs.com/babylon101/materials
  27314. * @param name Define the name of the material in the scene
  27315. * @param scene Define the scene the material belong to
  27316. */
  27317. constructor(name: string, scene: Scene);
  27318. /**
  27319. * Gets a boolean indicating that current material needs to register RTT
  27320. */
  27321. get hasRenderTargetTextures(): boolean;
  27322. /**
  27323. * Gets the current class name of the material e.g. "StandardMaterial"
  27324. * Mainly use in serialization.
  27325. * @returns the class name
  27326. */
  27327. getClassName(): string;
  27328. /**
  27329. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27330. * You can try switching to logarithmic depth.
  27331. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27332. */
  27333. get useLogarithmicDepth(): boolean;
  27334. set useLogarithmicDepth(value: boolean);
  27335. /**
  27336. * Specifies if the material will require alpha blending
  27337. * @returns a boolean specifying if alpha blending is needed
  27338. */
  27339. needAlphaBlending(): boolean;
  27340. /**
  27341. * Specifies if this material should be rendered in alpha test mode
  27342. * @returns a boolean specifying if an alpha test is needed.
  27343. */
  27344. needAlphaTesting(): boolean;
  27345. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27346. /**
  27347. * Get the texture used for alpha test purpose.
  27348. * @returns the diffuse texture in case of the standard material.
  27349. */
  27350. getAlphaTestTexture(): Nullable<BaseTexture>;
  27351. /**
  27352. * Get if the submesh is ready to be used and all its information available.
  27353. * Child classes can use it to update shaders
  27354. * @param mesh defines the mesh to check
  27355. * @param subMesh defines which submesh to check
  27356. * @param useInstances specifies that instances should be used
  27357. * @returns a boolean indicating that the submesh is ready or not
  27358. */
  27359. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27360. /**
  27361. * Builds the material UBO layouts.
  27362. * Used internally during the effect preparation.
  27363. */
  27364. buildUniformLayout(): void;
  27365. /**
  27366. * Unbinds the material from the mesh
  27367. */
  27368. unbind(): void;
  27369. /**
  27370. * Binds the submesh to this material by preparing the effect and shader to draw
  27371. * @param world defines the world transformation matrix
  27372. * @param mesh defines the mesh containing the submesh
  27373. * @param subMesh defines the submesh to bind the material to
  27374. */
  27375. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27376. /**
  27377. * Get the list of animatables in the material.
  27378. * @returns the list of animatables object used in the material
  27379. */
  27380. getAnimatables(): IAnimatable[];
  27381. /**
  27382. * Gets the active textures from the material
  27383. * @returns an array of textures
  27384. */
  27385. getActiveTextures(): BaseTexture[];
  27386. /**
  27387. * Specifies if the material uses a texture
  27388. * @param texture defines the texture to check against the material
  27389. * @returns a boolean specifying if the material uses the texture
  27390. */
  27391. hasTexture(texture: BaseTexture): boolean;
  27392. /**
  27393. * Disposes the material
  27394. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27395. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27396. */
  27397. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27398. /**
  27399. * Makes a duplicate of the material, and gives it a new name
  27400. * @param name defines the new name for the duplicated material
  27401. * @returns the cloned material
  27402. */
  27403. clone(name: string): StandardMaterial;
  27404. /**
  27405. * Serializes this material in a JSON representation
  27406. * @returns the serialized material object
  27407. */
  27408. serialize(): any;
  27409. /**
  27410. * Creates a standard material from parsed material data
  27411. * @param source defines the JSON representation of the material
  27412. * @param scene defines the hosting scene
  27413. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27414. * @returns a new standard material
  27415. */
  27416. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27417. /**
  27418. * Are diffuse textures enabled in the application.
  27419. */
  27420. static get DiffuseTextureEnabled(): boolean;
  27421. static set DiffuseTextureEnabled(value: boolean);
  27422. /**
  27423. * Are ambient textures enabled in the application.
  27424. */
  27425. static get AmbientTextureEnabled(): boolean;
  27426. static set AmbientTextureEnabled(value: boolean);
  27427. /**
  27428. * Are opacity textures enabled in the application.
  27429. */
  27430. static get OpacityTextureEnabled(): boolean;
  27431. static set OpacityTextureEnabled(value: boolean);
  27432. /**
  27433. * Are reflection textures enabled in the application.
  27434. */
  27435. static get ReflectionTextureEnabled(): boolean;
  27436. static set ReflectionTextureEnabled(value: boolean);
  27437. /**
  27438. * Are emissive textures enabled in the application.
  27439. */
  27440. static get EmissiveTextureEnabled(): boolean;
  27441. static set EmissiveTextureEnabled(value: boolean);
  27442. /**
  27443. * Are specular textures enabled in the application.
  27444. */
  27445. static get SpecularTextureEnabled(): boolean;
  27446. static set SpecularTextureEnabled(value: boolean);
  27447. /**
  27448. * Are bump textures enabled in the application.
  27449. */
  27450. static get BumpTextureEnabled(): boolean;
  27451. static set BumpTextureEnabled(value: boolean);
  27452. /**
  27453. * Are lightmap textures enabled in the application.
  27454. */
  27455. static get LightmapTextureEnabled(): boolean;
  27456. static set LightmapTextureEnabled(value: boolean);
  27457. /**
  27458. * Are refraction textures enabled in the application.
  27459. */
  27460. static get RefractionTextureEnabled(): boolean;
  27461. static set RefractionTextureEnabled(value: boolean);
  27462. /**
  27463. * Are color grading textures enabled in the application.
  27464. */
  27465. static get ColorGradingTextureEnabled(): boolean;
  27466. static set ColorGradingTextureEnabled(value: boolean);
  27467. /**
  27468. * Are fresnels enabled in the application.
  27469. */
  27470. static get FresnelEnabled(): boolean;
  27471. static set FresnelEnabled(value: boolean);
  27472. }
  27473. }
  27474. declare module "babylonjs/Particles/solidParticleSystem" {
  27475. import { Nullable } from "babylonjs/types";
  27476. import { Vector3 } from "babylonjs/Maths/math.vector";
  27477. import { Mesh } from "babylonjs/Meshes/mesh";
  27478. import { Scene, IDisposable } from "babylonjs/scene";
  27479. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27480. import { Material } from "babylonjs/Materials/material";
  27481. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27482. /**
  27483. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27484. *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.
  27485. * The SPS is also a particle system. It provides some methods to manage the particles.
  27486. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27487. *
  27488. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27489. */
  27490. export class SolidParticleSystem implements IDisposable {
  27491. /**
  27492. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27493. * Example : var p = SPS.particles[i];
  27494. */
  27495. particles: SolidParticle[];
  27496. /**
  27497. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27498. */
  27499. nbParticles: number;
  27500. /**
  27501. * If the particles must ever face the camera (default false). Useful for planar particles.
  27502. */
  27503. billboard: boolean;
  27504. /**
  27505. * Recompute normals when adding a shape
  27506. */
  27507. recomputeNormals: boolean;
  27508. /**
  27509. * This a counter ofr your own usage. It's not set by any SPS functions.
  27510. */
  27511. counter: number;
  27512. /**
  27513. * The SPS name. This name is also given to the underlying mesh.
  27514. */
  27515. name: string;
  27516. /**
  27517. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27518. */
  27519. mesh: Mesh;
  27520. /**
  27521. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27522. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27523. */
  27524. vars: any;
  27525. /**
  27526. * This array is populated when the SPS is set as 'pickable'.
  27527. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27528. * Each element of this array is an object `{idx: int, faceId: int}`.
  27529. * `idx` is the picked particle index in the `SPS.particles` array
  27530. * `faceId` is the picked face index counted within this particle.
  27531. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27532. */
  27533. pickedParticles: {
  27534. idx: number;
  27535. faceId: number;
  27536. }[];
  27537. /**
  27538. * This array is populated when `enableDepthSort` is set to true.
  27539. * Each element of this array is an instance of the class DepthSortedParticle.
  27540. */
  27541. depthSortedParticles: DepthSortedParticle[];
  27542. /**
  27543. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27544. * @hidden
  27545. */
  27546. _bSphereOnly: boolean;
  27547. /**
  27548. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27549. * @hidden
  27550. */
  27551. _bSphereRadiusFactor: number;
  27552. private _scene;
  27553. private _positions;
  27554. private _indices;
  27555. private _normals;
  27556. private _colors;
  27557. private _uvs;
  27558. private _indices32;
  27559. private _positions32;
  27560. private _normals32;
  27561. private _fixedNormal32;
  27562. private _colors32;
  27563. private _uvs32;
  27564. private _index;
  27565. private _updatable;
  27566. private _pickable;
  27567. private _isVisibilityBoxLocked;
  27568. private _alwaysVisible;
  27569. private _depthSort;
  27570. private _expandable;
  27571. private _shapeCounter;
  27572. private _copy;
  27573. private _color;
  27574. private _computeParticleColor;
  27575. private _computeParticleTexture;
  27576. private _computeParticleRotation;
  27577. private _computeParticleVertex;
  27578. private _computeBoundingBox;
  27579. private _depthSortParticles;
  27580. private _camera;
  27581. private _mustUnrotateFixedNormals;
  27582. private _particlesIntersect;
  27583. private _needs32Bits;
  27584. private _isNotBuilt;
  27585. private _lastParticleId;
  27586. private _idxOfId;
  27587. private _multimaterialEnabled;
  27588. private _useModelMaterial;
  27589. private _indicesByMaterial;
  27590. private _materialIndexes;
  27591. private _depthSortFunction;
  27592. private _materialSortFunction;
  27593. private _materials;
  27594. private _multimaterial;
  27595. private _materialIndexesById;
  27596. private _defaultMaterial;
  27597. private _autoUpdateSubMeshes;
  27598. /**
  27599. * Creates a SPS (Solid Particle System) object.
  27600. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27601. * @param scene (Scene) is the scene in which the SPS is added.
  27602. * @param options defines the options of the sps e.g.
  27603. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27604. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27605. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27606. * * 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.
  27607. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27608. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27609. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27610. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27611. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27612. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27613. */
  27614. constructor(name: string, scene: Scene, options?: {
  27615. updatable?: boolean;
  27616. isPickable?: boolean;
  27617. enableDepthSort?: boolean;
  27618. particleIntersection?: boolean;
  27619. boundingSphereOnly?: boolean;
  27620. bSphereRadiusFactor?: number;
  27621. expandable?: boolean;
  27622. useModelMaterial?: boolean;
  27623. enableMultiMaterial?: boolean;
  27624. });
  27625. /**
  27626. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27627. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27628. * @returns the created mesh
  27629. */
  27630. buildMesh(): Mesh;
  27631. /**
  27632. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27633. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27634. * Thus the particles generated from `digest()` have their property `position` set yet.
  27635. * @param mesh ( Mesh ) is the mesh to be digested
  27636. * @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
  27637. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27638. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27639. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27640. * @returns the current SPS
  27641. */
  27642. digest(mesh: Mesh, options?: {
  27643. facetNb?: number;
  27644. number?: number;
  27645. delta?: number;
  27646. storage?: [];
  27647. }): SolidParticleSystem;
  27648. /**
  27649. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27650. * @hidden
  27651. */
  27652. private _unrotateFixedNormals;
  27653. /**
  27654. * Resets the temporary working copy particle
  27655. * @hidden
  27656. */
  27657. private _resetCopy;
  27658. /**
  27659. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27660. * @param p the current index in the positions array to be updated
  27661. * @param ind the current index in the indices array
  27662. * @param shape a Vector3 array, the shape geometry
  27663. * @param positions the positions array to be updated
  27664. * @param meshInd the shape indices array
  27665. * @param indices the indices array to be updated
  27666. * @param meshUV the shape uv array
  27667. * @param uvs the uv array to be updated
  27668. * @param meshCol the shape color array
  27669. * @param colors the color array to be updated
  27670. * @param meshNor the shape normals array
  27671. * @param normals the normals array to be updated
  27672. * @param idx the particle index
  27673. * @param idxInShape the particle index in its shape
  27674. * @param options the addShape() method passed options
  27675. * @model the particle model
  27676. * @hidden
  27677. */
  27678. private _meshBuilder;
  27679. /**
  27680. * Returns a shape Vector3 array from positions float array
  27681. * @param positions float array
  27682. * @returns a vector3 array
  27683. * @hidden
  27684. */
  27685. private _posToShape;
  27686. /**
  27687. * Returns a shapeUV array from a float uvs (array deep copy)
  27688. * @param uvs as a float array
  27689. * @returns a shapeUV array
  27690. * @hidden
  27691. */
  27692. private _uvsToShapeUV;
  27693. /**
  27694. * Adds a new particle object in the particles array
  27695. * @param idx particle index in particles array
  27696. * @param id particle id
  27697. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27698. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27699. * @param model particle ModelShape object
  27700. * @param shapeId model shape identifier
  27701. * @param idxInShape index of the particle in the current model
  27702. * @param bInfo model bounding info object
  27703. * @param storage target storage array, if any
  27704. * @hidden
  27705. */
  27706. private _addParticle;
  27707. /**
  27708. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27709. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27710. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27711. * @param nb (positive integer) the number of particles to be created from this model
  27712. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27713. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27714. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27715. * @returns the number of shapes in the system
  27716. */
  27717. addShape(mesh: Mesh, nb: number, options?: {
  27718. positionFunction?: any;
  27719. vertexFunction?: any;
  27720. storage?: [];
  27721. }): number;
  27722. /**
  27723. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27724. * @hidden
  27725. */
  27726. private _rebuildParticle;
  27727. /**
  27728. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27729. * @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.
  27730. * @returns the SPS.
  27731. */
  27732. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27733. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27734. * Returns an array with the removed particles.
  27735. * 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.
  27736. * The SPS can't be empty so at least one particle needs to remain in place.
  27737. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27738. * @param start index of the first particle to remove
  27739. * @param end index of the last particle to remove (included)
  27740. * @returns an array populated with the removed particles
  27741. */
  27742. removeParticles(start: number, end: number): SolidParticle[];
  27743. /**
  27744. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27745. * @param solidParticleArray an array populated with Solid Particles objects
  27746. * @returns the SPS
  27747. */
  27748. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27749. /**
  27750. * Creates a new particle and modifies the SPS mesh geometry :
  27751. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27752. * - calls _addParticle() to populate the particle array
  27753. * factorized code from addShape() and insertParticlesFromArray()
  27754. * @param idx particle index in the particles array
  27755. * @param i particle index in its shape
  27756. * @param modelShape particle ModelShape object
  27757. * @param shape shape vertex array
  27758. * @param meshInd shape indices array
  27759. * @param meshUV shape uv array
  27760. * @param meshCol shape color array
  27761. * @param meshNor shape normals array
  27762. * @param bbInfo shape bounding info
  27763. * @param storage target particle storage
  27764. * @options addShape() passed options
  27765. * @hidden
  27766. */
  27767. private _insertNewParticle;
  27768. /**
  27769. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27770. * This method calls `updateParticle()` for each particle of the SPS.
  27771. * For an animated SPS, it is usually called within the render loop.
  27772. * 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.
  27773. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27774. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27775. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27776. * @returns the SPS.
  27777. */
  27778. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27779. /**
  27780. * Disposes the SPS.
  27781. */
  27782. dispose(): void;
  27783. /**
  27784. * Returns a SolidParticle object from its identifier : particle.id
  27785. * @param id (integer) the particle Id
  27786. * @returns the searched particle or null if not found in the SPS.
  27787. */
  27788. getParticleById(id: number): Nullable<SolidParticle>;
  27789. /**
  27790. * Returns a new array populated with the particles having the passed shapeId.
  27791. * @param shapeId (integer) the shape identifier
  27792. * @returns a new solid particle array
  27793. */
  27794. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27795. /**
  27796. * Populates the passed array "ref" with the particles having the passed shapeId.
  27797. * @param shapeId the shape identifier
  27798. * @returns the SPS
  27799. * @param ref
  27800. */
  27801. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27802. /**
  27803. * Computes the required SubMeshes according the materials assigned to the particles.
  27804. * @returns the solid particle system.
  27805. * Does nothing if called before the SPS mesh is built.
  27806. */
  27807. computeSubMeshes(): SolidParticleSystem;
  27808. /**
  27809. * Sorts the solid particles by material when MultiMaterial is enabled.
  27810. * Updates the indices32 array.
  27811. * Updates the indicesByMaterial array.
  27812. * Updates the mesh indices array.
  27813. * @returns the SPS
  27814. * @hidden
  27815. */
  27816. private _sortParticlesByMaterial;
  27817. /**
  27818. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27819. * @hidden
  27820. */
  27821. private _setMaterialIndexesById;
  27822. /**
  27823. * Returns an array with unique values of Materials from the passed array
  27824. * @param array the material array to be checked and filtered
  27825. * @hidden
  27826. */
  27827. private _filterUniqueMaterialId;
  27828. /**
  27829. * Sets a new Standard Material as _defaultMaterial if not already set.
  27830. * @hidden
  27831. */
  27832. private _setDefaultMaterial;
  27833. /**
  27834. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27835. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27836. * @returns the SPS.
  27837. */
  27838. refreshVisibleSize(): SolidParticleSystem;
  27839. /**
  27840. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27841. * @param size the size (float) of the visibility box
  27842. * note : this doesn't lock the SPS mesh bounding box.
  27843. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27844. */
  27845. setVisibilityBox(size: number): void;
  27846. /**
  27847. * Gets whether the SPS as always visible or not
  27848. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27849. */
  27850. get isAlwaysVisible(): boolean;
  27851. /**
  27852. * Sets the SPS as always visible or not
  27853. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27854. */
  27855. set isAlwaysVisible(val: boolean);
  27856. /**
  27857. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27858. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27859. */
  27860. set isVisibilityBoxLocked(val: boolean);
  27861. /**
  27862. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27863. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27864. */
  27865. get isVisibilityBoxLocked(): boolean;
  27866. /**
  27867. * Tells to `setParticles()` to compute the particle rotations or not.
  27868. * Default value : true. The SPS is faster when it's set to false.
  27869. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27870. */
  27871. set computeParticleRotation(val: boolean);
  27872. /**
  27873. * Tells to `setParticles()` to compute the particle colors or not.
  27874. * Default value : true. The SPS is faster when it's set to false.
  27875. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27876. */
  27877. set computeParticleColor(val: boolean);
  27878. set computeParticleTexture(val: boolean);
  27879. /**
  27880. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27881. * Default value : false. The SPS is faster when it's set to false.
  27882. * Note : the particle custom vertex positions aren't stored values.
  27883. */
  27884. set computeParticleVertex(val: boolean);
  27885. /**
  27886. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27887. */
  27888. set computeBoundingBox(val: boolean);
  27889. /**
  27890. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27891. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27892. * Default : `true`
  27893. */
  27894. set depthSortParticles(val: boolean);
  27895. /**
  27896. * Gets if `setParticles()` computes the particle rotations or not.
  27897. * Default value : true. The SPS is faster when it's set to false.
  27898. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27899. */
  27900. get computeParticleRotation(): boolean;
  27901. /**
  27902. * Gets if `setParticles()` computes the particle colors or not.
  27903. * Default value : true. The SPS is faster when it's set to false.
  27904. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27905. */
  27906. get computeParticleColor(): boolean;
  27907. /**
  27908. * Gets if `setParticles()` computes the particle textures or not.
  27909. * Default value : true. The SPS is faster when it's set to false.
  27910. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27911. */
  27912. get computeParticleTexture(): boolean;
  27913. /**
  27914. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27915. * Default value : false. The SPS is faster when it's set to false.
  27916. * Note : the particle custom vertex positions aren't stored values.
  27917. */
  27918. get computeParticleVertex(): boolean;
  27919. /**
  27920. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27921. */
  27922. get computeBoundingBox(): boolean;
  27923. /**
  27924. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27925. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27926. * Default : `true`
  27927. */
  27928. get depthSortParticles(): boolean;
  27929. /**
  27930. * Gets if the SPS is created as expandable at construction time.
  27931. * Default : `false`
  27932. */
  27933. get expandable(): boolean;
  27934. /**
  27935. * Gets if the SPS supports the Multi Materials
  27936. */
  27937. get multimaterialEnabled(): boolean;
  27938. /**
  27939. * Gets if the SPS uses the model materials for its own multimaterial.
  27940. */
  27941. get useModelMaterial(): boolean;
  27942. /**
  27943. * The SPS used material array.
  27944. */
  27945. get materials(): Material[];
  27946. /**
  27947. * Sets the SPS MultiMaterial from the passed materials.
  27948. * Note : the passed array is internally copied and not used then by reference.
  27949. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27950. */
  27951. setMultiMaterial(materials: Material[]): void;
  27952. /**
  27953. * The SPS computed multimaterial object
  27954. */
  27955. get multimaterial(): MultiMaterial;
  27956. set multimaterial(mm: MultiMaterial);
  27957. /**
  27958. * If the subMeshes must be updated on the next call to setParticles()
  27959. */
  27960. get autoUpdateSubMeshes(): boolean;
  27961. set autoUpdateSubMeshes(val: boolean);
  27962. /**
  27963. * This function does nothing. It may be overwritten to set all the particle first values.
  27964. * The SPS doesn't call this function, you may have to call it by your own.
  27965. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27966. */
  27967. initParticles(): void;
  27968. /**
  27969. * This function does nothing. It may be overwritten to recycle a particle.
  27970. * The SPS doesn't call this function, you may have to call it by your own.
  27971. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27972. * @param particle The particle to recycle
  27973. * @returns the recycled particle
  27974. */
  27975. recycleParticle(particle: SolidParticle): SolidParticle;
  27976. /**
  27977. * Updates a particle : this function should be overwritten by the user.
  27978. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27979. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27980. * @example : just set a particle position or velocity and recycle conditions
  27981. * @param particle The particle to update
  27982. * @returns the updated particle
  27983. */
  27984. updateParticle(particle: SolidParticle): SolidParticle;
  27985. /**
  27986. * Updates a vertex of a particle : it can be overwritten by the user.
  27987. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27988. * @param particle the current particle
  27989. * @param vertex the current index of the current particle
  27990. * @param pt the index of the current vertex in the particle shape
  27991. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27992. * @example : just set a vertex particle position
  27993. * @returns the updated vertex
  27994. */
  27995. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27996. /**
  27997. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27998. * This does nothing and may be overwritten by the user.
  27999. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28000. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28001. * @param update the boolean update value actually passed to setParticles()
  28002. */
  28003. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28004. /**
  28005. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28006. * This will be passed three parameters.
  28007. * This does nothing and may be overwritten by the user.
  28008. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28009. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28010. * @param update the boolean update value actually passed to setParticles()
  28011. */
  28012. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28013. }
  28014. }
  28015. declare module "babylonjs/Particles/solidParticle" {
  28016. import { Nullable } from "babylonjs/types";
  28017. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28018. import { Color4 } from "babylonjs/Maths/math.color";
  28019. import { Mesh } from "babylonjs/Meshes/mesh";
  28020. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28021. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28022. import { Plane } from "babylonjs/Maths/math.plane";
  28023. import { Material } from "babylonjs/Materials/material";
  28024. /**
  28025. * Represents one particle of a solid particle system.
  28026. */
  28027. export class SolidParticle {
  28028. /**
  28029. * particle global index
  28030. */
  28031. idx: number;
  28032. /**
  28033. * particle identifier
  28034. */
  28035. id: number;
  28036. /**
  28037. * The color of the particle
  28038. */
  28039. color: Nullable<Color4>;
  28040. /**
  28041. * The world space position of the particle.
  28042. */
  28043. position: Vector3;
  28044. /**
  28045. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28046. */
  28047. rotation: Vector3;
  28048. /**
  28049. * The world space rotation quaternion of the particle.
  28050. */
  28051. rotationQuaternion: Nullable<Quaternion>;
  28052. /**
  28053. * The scaling of the particle.
  28054. */
  28055. scaling: Vector3;
  28056. /**
  28057. * The uvs of the particle.
  28058. */
  28059. uvs: Vector4;
  28060. /**
  28061. * The current speed of the particle.
  28062. */
  28063. velocity: Vector3;
  28064. /**
  28065. * The pivot point in the particle local space.
  28066. */
  28067. pivot: Vector3;
  28068. /**
  28069. * Must the particle be translated from its pivot point in its local space ?
  28070. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28071. * Default : false
  28072. */
  28073. translateFromPivot: boolean;
  28074. /**
  28075. * Is the particle active or not ?
  28076. */
  28077. alive: boolean;
  28078. /**
  28079. * Is the particle visible or not ?
  28080. */
  28081. isVisible: boolean;
  28082. /**
  28083. * Index of this particle in the global "positions" array (Internal use)
  28084. * @hidden
  28085. */
  28086. _pos: number;
  28087. /**
  28088. * @hidden Index of this particle in the global "indices" array (Internal use)
  28089. */
  28090. _ind: number;
  28091. /**
  28092. * @hidden ModelShape of this particle (Internal use)
  28093. */
  28094. _model: ModelShape;
  28095. /**
  28096. * ModelShape id of this particle
  28097. */
  28098. shapeId: number;
  28099. /**
  28100. * Index of the particle in its shape id
  28101. */
  28102. idxInShape: number;
  28103. /**
  28104. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28105. */
  28106. _modelBoundingInfo: BoundingInfo;
  28107. /**
  28108. * @hidden Particle BoundingInfo object (Internal use)
  28109. */
  28110. _boundingInfo: BoundingInfo;
  28111. /**
  28112. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28113. */
  28114. _sps: SolidParticleSystem;
  28115. /**
  28116. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28117. */
  28118. _stillInvisible: boolean;
  28119. /**
  28120. * @hidden Last computed particle rotation matrix
  28121. */
  28122. _rotationMatrix: number[];
  28123. /**
  28124. * Parent particle Id, if any.
  28125. * Default null.
  28126. */
  28127. parentId: Nullable<number>;
  28128. /**
  28129. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28130. */
  28131. materialIndex: Nullable<number>;
  28132. /**
  28133. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28134. * The possible values are :
  28135. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28136. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28137. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28138. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28139. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28140. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28141. * */
  28142. cullingStrategy: number;
  28143. /**
  28144. * @hidden Internal global position in the SPS.
  28145. */
  28146. _globalPosition: Vector3;
  28147. /**
  28148. * Creates a Solid Particle object.
  28149. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28150. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28151. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28152. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28153. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28154. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28155. * @param shapeId (integer) is the model shape identifier in the SPS.
  28156. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28157. * @param sps defines the sps it is associated to
  28158. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28159. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28160. */
  28161. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28162. /**
  28163. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28164. * @param target the particle target
  28165. * @returns the current particle
  28166. */
  28167. copyToRef(target: SolidParticle): SolidParticle;
  28168. /**
  28169. * Legacy support, changed scale to scaling
  28170. */
  28171. get scale(): Vector3;
  28172. /**
  28173. * Legacy support, changed scale to scaling
  28174. */
  28175. set scale(scale: Vector3);
  28176. /**
  28177. * Legacy support, changed quaternion to rotationQuaternion
  28178. */
  28179. get quaternion(): Nullable<Quaternion>;
  28180. /**
  28181. * Legacy support, changed quaternion to rotationQuaternion
  28182. */
  28183. set quaternion(q: Nullable<Quaternion>);
  28184. /**
  28185. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28186. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28187. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28188. * @returns true if it intersects
  28189. */
  28190. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28191. /**
  28192. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28193. * A particle is in the frustum if its bounding box intersects the frustum
  28194. * @param frustumPlanes defines the frustum to test
  28195. * @returns true if the particle is in the frustum planes
  28196. */
  28197. isInFrustum(frustumPlanes: Plane[]): boolean;
  28198. /**
  28199. * get the rotation matrix of the particle
  28200. * @hidden
  28201. */
  28202. getRotationMatrix(m: Matrix): void;
  28203. }
  28204. /**
  28205. * Represents the shape of the model used by one particle of a solid particle system.
  28206. * SPS internal tool, don't use it manually.
  28207. */
  28208. export class ModelShape {
  28209. /**
  28210. * The shape id
  28211. * @hidden
  28212. */
  28213. shapeID: number;
  28214. /**
  28215. * flat array of model positions (internal use)
  28216. * @hidden
  28217. */
  28218. _shape: Vector3[];
  28219. /**
  28220. * flat array of model UVs (internal use)
  28221. * @hidden
  28222. */
  28223. _shapeUV: number[];
  28224. /**
  28225. * color array of the model
  28226. * @hidden
  28227. */
  28228. _shapeColors: number[];
  28229. /**
  28230. * indices array of the model
  28231. * @hidden
  28232. */
  28233. _indices: number[];
  28234. /**
  28235. * normals array of the model
  28236. * @hidden
  28237. */
  28238. _normals: number[];
  28239. /**
  28240. * length of the shape in the model indices array (internal use)
  28241. * @hidden
  28242. */
  28243. _indicesLength: number;
  28244. /**
  28245. * Custom position function (internal use)
  28246. * @hidden
  28247. */
  28248. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28249. /**
  28250. * Custom vertex function (internal use)
  28251. * @hidden
  28252. */
  28253. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28254. /**
  28255. * Model material (internal use)
  28256. * @hidden
  28257. */
  28258. _material: Nullable<Material>;
  28259. /**
  28260. * 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.
  28261. * SPS internal tool, don't use it manually.
  28262. * @hidden
  28263. */
  28264. 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>);
  28265. }
  28266. /**
  28267. * Represents a Depth Sorted Particle in the solid particle system.
  28268. * @hidden
  28269. */
  28270. export class DepthSortedParticle {
  28271. /**
  28272. * Index of the particle in the "indices" array
  28273. */
  28274. ind: number;
  28275. /**
  28276. * Length of the particle shape in the "indices" array
  28277. */
  28278. indicesLength: number;
  28279. /**
  28280. * Squared distance from the particle to the camera
  28281. */
  28282. sqDistance: number;
  28283. /**
  28284. * Material index when used with MultiMaterials
  28285. */
  28286. materialIndex: number;
  28287. /**
  28288. * Creates a new sorted particle
  28289. * @param materialIndex
  28290. */
  28291. constructor(ind: number, indLength: number, materialIndex: number);
  28292. }
  28293. }
  28294. declare module "babylonjs/Collisions/meshCollisionData" {
  28295. import { Collider } from "babylonjs/Collisions/collider";
  28296. import { Vector3 } from "babylonjs/Maths/math.vector";
  28297. import { Nullable } from "babylonjs/types";
  28298. import { Observer } from "babylonjs/Misc/observable";
  28299. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28300. /**
  28301. * @hidden
  28302. */
  28303. export class _MeshCollisionData {
  28304. _checkCollisions: boolean;
  28305. _collisionMask: number;
  28306. _collisionGroup: number;
  28307. _collider: Nullable<Collider>;
  28308. _oldPositionForCollisions: Vector3;
  28309. _diffPositionForCollisions: Vector3;
  28310. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28311. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28312. }
  28313. }
  28314. declare module "babylonjs/Meshes/abstractMesh" {
  28315. import { Observable } from "babylonjs/Misc/observable";
  28316. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28317. import { Camera } from "babylonjs/Cameras/camera";
  28318. import { Scene, IDisposable } from "babylonjs/scene";
  28319. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28320. import { Node } from "babylonjs/node";
  28321. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28322. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28323. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28324. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28325. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28326. import { Material } from "babylonjs/Materials/material";
  28327. import { Light } from "babylonjs/Lights/light";
  28328. import { Skeleton } from "babylonjs/Bones/skeleton";
  28329. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28330. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28331. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28332. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28333. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28334. import { Plane } from "babylonjs/Maths/math.plane";
  28335. import { Ray } from "babylonjs/Culling/ray";
  28336. import { Collider } from "babylonjs/Collisions/collider";
  28337. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28338. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28339. /** @hidden */
  28340. class _FacetDataStorage {
  28341. facetPositions: Vector3[];
  28342. facetNormals: Vector3[];
  28343. facetPartitioning: number[][];
  28344. facetNb: number;
  28345. partitioningSubdivisions: number;
  28346. partitioningBBoxRatio: number;
  28347. facetDataEnabled: boolean;
  28348. facetParameters: any;
  28349. bbSize: Vector3;
  28350. subDiv: {
  28351. max: number;
  28352. X: number;
  28353. Y: number;
  28354. Z: number;
  28355. };
  28356. facetDepthSort: boolean;
  28357. facetDepthSortEnabled: boolean;
  28358. depthSortedIndices: IndicesArray;
  28359. depthSortedFacets: {
  28360. ind: number;
  28361. sqDistance: number;
  28362. }[];
  28363. facetDepthSortFunction: (f1: {
  28364. ind: number;
  28365. sqDistance: number;
  28366. }, f2: {
  28367. ind: number;
  28368. sqDistance: number;
  28369. }) => number;
  28370. facetDepthSortFrom: Vector3;
  28371. facetDepthSortOrigin: Vector3;
  28372. invertedMatrix: Matrix;
  28373. }
  28374. /**
  28375. * @hidden
  28376. **/
  28377. class _InternalAbstractMeshDataInfo {
  28378. _hasVertexAlpha: boolean;
  28379. _useVertexColors: boolean;
  28380. _numBoneInfluencers: number;
  28381. _applyFog: boolean;
  28382. _receiveShadows: boolean;
  28383. _facetData: _FacetDataStorage;
  28384. _visibility: number;
  28385. _skeleton: Nullable<Skeleton>;
  28386. _layerMask: number;
  28387. _computeBonesUsingShaders: boolean;
  28388. _isActive: boolean;
  28389. _onlyForInstances: boolean;
  28390. _isActiveIntermediate: boolean;
  28391. _onlyForInstancesIntermediate: boolean;
  28392. _actAsRegularMesh: boolean;
  28393. }
  28394. /**
  28395. * Class used to store all common mesh properties
  28396. */
  28397. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28398. /** No occlusion */
  28399. static OCCLUSION_TYPE_NONE: number;
  28400. /** Occlusion set to optimisitic */
  28401. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28402. /** Occlusion set to strict */
  28403. static OCCLUSION_TYPE_STRICT: number;
  28404. /** Use an accurante occlusion algorithm */
  28405. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28406. /** Use a conservative occlusion algorithm */
  28407. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28408. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28409. * Test order :
  28410. * Is the bounding sphere outside the frustum ?
  28411. * If not, are the bounding box vertices outside the frustum ?
  28412. * It not, then the cullable object is in the frustum.
  28413. */
  28414. static readonly CULLINGSTRATEGY_STANDARD: number;
  28415. /** Culling strategy : Bounding Sphere Only.
  28416. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28417. * It's also less accurate than the standard because some not visible objects can still be selected.
  28418. * Test : is the bounding sphere outside the frustum ?
  28419. * If not, then the cullable object is in the frustum.
  28420. */
  28421. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28422. /** Culling strategy : Optimistic Inclusion.
  28423. * This in an inclusion test first, then the standard exclusion test.
  28424. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28425. * 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.
  28426. * Anyway, it's as accurate as the standard strategy.
  28427. * Test :
  28428. * Is the cullable object bounding sphere center in the frustum ?
  28429. * If not, apply the default culling strategy.
  28430. */
  28431. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28432. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28433. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28434. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28435. * 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.
  28436. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28437. * Test :
  28438. * Is the cullable object bounding sphere center in the frustum ?
  28439. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28440. */
  28441. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28442. /**
  28443. * No billboard
  28444. */
  28445. static get BILLBOARDMODE_NONE(): number;
  28446. /** Billboard on X axis */
  28447. static get BILLBOARDMODE_X(): number;
  28448. /** Billboard on Y axis */
  28449. static get BILLBOARDMODE_Y(): number;
  28450. /** Billboard on Z axis */
  28451. static get BILLBOARDMODE_Z(): number;
  28452. /** Billboard on all axes */
  28453. static get BILLBOARDMODE_ALL(): number;
  28454. /** Billboard on using position instead of orientation */
  28455. static get BILLBOARDMODE_USE_POSITION(): number;
  28456. /** @hidden */
  28457. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28458. /**
  28459. * The culling strategy to use to check whether the mesh must be rendered or not.
  28460. * This value can be changed at any time and will be used on the next render mesh selection.
  28461. * The possible values are :
  28462. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28463. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28464. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28465. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28466. * Please read each static variable documentation to get details about the culling process.
  28467. * */
  28468. cullingStrategy: number;
  28469. /**
  28470. * Gets the number of facets in the mesh
  28471. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28472. */
  28473. get facetNb(): number;
  28474. /**
  28475. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28476. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28477. */
  28478. get partitioningSubdivisions(): number;
  28479. set partitioningSubdivisions(nb: number);
  28480. /**
  28481. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28482. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28483. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28484. */
  28485. get partitioningBBoxRatio(): number;
  28486. set partitioningBBoxRatio(ratio: number);
  28487. /**
  28488. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28489. * Works only for updatable meshes.
  28490. * Doesn't work with multi-materials
  28491. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28492. */
  28493. get mustDepthSortFacets(): boolean;
  28494. set mustDepthSortFacets(sort: boolean);
  28495. /**
  28496. * The location (Vector3) where the facet depth sort must be computed from.
  28497. * By default, the active camera position.
  28498. * Used only when facet depth sort is enabled
  28499. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28500. */
  28501. get facetDepthSortFrom(): Vector3;
  28502. set facetDepthSortFrom(location: Vector3);
  28503. /**
  28504. * gets a boolean indicating if facetData is enabled
  28505. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28506. */
  28507. get isFacetDataEnabled(): boolean;
  28508. /** @hidden */
  28509. _updateNonUniformScalingState(value: boolean): boolean;
  28510. /**
  28511. * An event triggered when this mesh collides with another one
  28512. */
  28513. onCollideObservable: Observable<AbstractMesh>;
  28514. /** Set a function to call when this mesh collides with another one */
  28515. set onCollide(callback: () => void);
  28516. /**
  28517. * An event triggered when the collision's position changes
  28518. */
  28519. onCollisionPositionChangeObservable: Observable<Vector3>;
  28520. /** Set a function to call when the collision's position changes */
  28521. set onCollisionPositionChange(callback: () => void);
  28522. /**
  28523. * An event triggered when material is changed
  28524. */
  28525. onMaterialChangedObservable: Observable<AbstractMesh>;
  28526. /**
  28527. * Gets or sets the orientation for POV movement & rotation
  28528. */
  28529. definedFacingForward: boolean;
  28530. /** @hidden */
  28531. _occlusionQuery: Nullable<WebGLQuery>;
  28532. /** @hidden */
  28533. _renderingGroup: Nullable<RenderingGroup>;
  28534. /**
  28535. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28536. */
  28537. get visibility(): number;
  28538. /**
  28539. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28540. */
  28541. set visibility(value: number);
  28542. /** Gets or sets the alpha index used to sort transparent meshes
  28543. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28544. */
  28545. alphaIndex: number;
  28546. /**
  28547. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28548. */
  28549. isVisible: boolean;
  28550. /**
  28551. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28552. */
  28553. isPickable: boolean;
  28554. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28555. showSubMeshesBoundingBox: boolean;
  28556. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28557. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28558. */
  28559. isBlocker: boolean;
  28560. /**
  28561. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28562. */
  28563. enablePointerMoveEvents: boolean;
  28564. /**
  28565. * Specifies the rendering group id for this mesh (0 by default)
  28566. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28567. */
  28568. renderingGroupId: number;
  28569. private _material;
  28570. /** Gets or sets current material */
  28571. get material(): Nullable<Material>;
  28572. set material(value: Nullable<Material>);
  28573. /**
  28574. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28575. * @see http://doc.babylonjs.com/babylon101/shadows
  28576. */
  28577. get receiveShadows(): boolean;
  28578. set receiveShadows(value: boolean);
  28579. /** Defines color to use when rendering outline */
  28580. outlineColor: Color3;
  28581. /** Define width to use when rendering outline */
  28582. outlineWidth: number;
  28583. /** Defines color to use when rendering overlay */
  28584. overlayColor: Color3;
  28585. /** Defines alpha to use when rendering overlay */
  28586. overlayAlpha: number;
  28587. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28588. get hasVertexAlpha(): boolean;
  28589. set hasVertexAlpha(value: boolean);
  28590. /** 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) */
  28591. get useVertexColors(): boolean;
  28592. set useVertexColors(value: boolean);
  28593. /**
  28594. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28595. */
  28596. get computeBonesUsingShaders(): boolean;
  28597. set computeBonesUsingShaders(value: boolean);
  28598. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28599. get numBoneInfluencers(): number;
  28600. set numBoneInfluencers(value: number);
  28601. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28602. get applyFog(): boolean;
  28603. set applyFog(value: boolean);
  28604. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28605. useOctreeForRenderingSelection: boolean;
  28606. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28607. useOctreeForPicking: boolean;
  28608. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28609. useOctreeForCollisions: boolean;
  28610. /**
  28611. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28612. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28613. */
  28614. get layerMask(): number;
  28615. set layerMask(value: number);
  28616. /**
  28617. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28618. */
  28619. alwaysSelectAsActiveMesh: boolean;
  28620. /**
  28621. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28622. */
  28623. doNotSyncBoundingInfo: boolean;
  28624. /**
  28625. * Gets or sets the current action manager
  28626. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28627. */
  28628. actionManager: Nullable<AbstractActionManager>;
  28629. private _meshCollisionData;
  28630. /**
  28631. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28632. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28633. */
  28634. ellipsoid: Vector3;
  28635. /**
  28636. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28637. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28638. */
  28639. ellipsoidOffset: Vector3;
  28640. /**
  28641. * Gets or sets a collision mask used to mask collisions (default is -1).
  28642. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28643. */
  28644. get collisionMask(): number;
  28645. set collisionMask(mask: number);
  28646. /**
  28647. * Gets or sets the current collision group mask (-1 by default).
  28648. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28649. */
  28650. get collisionGroup(): number;
  28651. set collisionGroup(mask: number);
  28652. /**
  28653. * Defines edge width used when edgesRenderer is enabled
  28654. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28655. */
  28656. edgesWidth: number;
  28657. /**
  28658. * Defines edge color used when edgesRenderer is enabled
  28659. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28660. */
  28661. edgesColor: Color4;
  28662. /** @hidden */
  28663. _edgesRenderer: Nullable<IEdgesRenderer>;
  28664. /** @hidden */
  28665. _masterMesh: Nullable<AbstractMesh>;
  28666. /** @hidden */
  28667. _boundingInfo: Nullable<BoundingInfo>;
  28668. /** @hidden */
  28669. _renderId: number;
  28670. /**
  28671. * Gets or sets the list of subMeshes
  28672. * @see http://doc.babylonjs.com/how_to/multi_materials
  28673. */
  28674. subMeshes: SubMesh[];
  28675. /** @hidden */
  28676. _intersectionsInProgress: AbstractMesh[];
  28677. /** @hidden */
  28678. _unIndexed: boolean;
  28679. /** @hidden */
  28680. _lightSources: Light[];
  28681. /** Gets the list of lights affecting that mesh */
  28682. get lightSources(): Light[];
  28683. /** @hidden */
  28684. get _positions(): Nullable<Vector3[]>;
  28685. /** @hidden */
  28686. _waitingData: {
  28687. lods: Nullable<any>;
  28688. actions: Nullable<any>;
  28689. freezeWorldMatrix: Nullable<boolean>;
  28690. };
  28691. /** @hidden */
  28692. _bonesTransformMatrices: Nullable<Float32Array>;
  28693. /** @hidden */
  28694. _transformMatrixTexture: Nullable<RawTexture>;
  28695. /**
  28696. * Gets or sets a skeleton to apply skining transformations
  28697. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28698. */
  28699. set skeleton(value: Nullable<Skeleton>);
  28700. get skeleton(): Nullable<Skeleton>;
  28701. /**
  28702. * An event triggered when the mesh is rebuilt.
  28703. */
  28704. onRebuildObservable: Observable<AbstractMesh>;
  28705. /**
  28706. * Creates a new AbstractMesh
  28707. * @param name defines the name of the mesh
  28708. * @param scene defines the hosting scene
  28709. */
  28710. constructor(name: string, scene?: Nullable<Scene>);
  28711. /**
  28712. * Returns the string "AbstractMesh"
  28713. * @returns "AbstractMesh"
  28714. */
  28715. getClassName(): string;
  28716. /**
  28717. * Gets a string representation of the current mesh
  28718. * @param fullDetails defines a boolean indicating if full details must be included
  28719. * @returns a string representation of the current mesh
  28720. */
  28721. toString(fullDetails?: boolean): string;
  28722. /**
  28723. * @hidden
  28724. */
  28725. protected _getEffectiveParent(): Nullable<Node>;
  28726. /** @hidden */
  28727. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28728. /** @hidden */
  28729. _rebuild(): void;
  28730. /** @hidden */
  28731. _resyncLightSources(): void;
  28732. /** @hidden */
  28733. _resyncLightSource(light: Light): void;
  28734. /** @hidden */
  28735. _unBindEffect(): void;
  28736. /** @hidden */
  28737. _removeLightSource(light: Light, dispose: boolean): void;
  28738. private _markSubMeshesAsDirty;
  28739. /** @hidden */
  28740. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28741. /** @hidden */
  28742. _markSubMeshesAsAttributesDirty(): void;
  28743. /** @hidden */
  28744. _markSubMeshesAsMiscDirty(): void;
  28745. /**
  28746. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28747. */
  28748. get scaling(): Vector3;
  28749. set scaling(newScaling: Vector3);
  28750. /**
  28751. * Returns true if the mesh is blocked. Implemented by child classes
  28752. */
  28753. get isBlocked(): boolean;
  28754. /**
  28755. * Returns the mesh itself by default. Implemented by child classes
  28756. * @param camera defines the camera to use to pick the right LOD level
  28757. * @returns the currentAbstractMesh
  28758. */
  28759. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28760. /**
  28761. * Returns 0 by default. Implemented by child classes
  28762. * @returns an integer
  28763. */
  28764. getTotalVertices(): number;
  28765. /**
  28766. * Returns a positive integer : the total number of indices in this mesh geometry.
  28767. * @returns the numner of indices or zero if the mesh has no geometry.
  28768. */
  28769. getTotalIndices(): number;
  28770. /**
  28771. * Returns null by default. Implemented by child classes
  28772. * @returns null
  28773. */
  28774. getIndices(): Nullable<IndicesArray>;
  28775. /**
  28776. * Returns the array of the requested vertex data kind. Implemented by child classes
  28777. * @param kind defines the vertex data kind to use
  28778. * @returns null
  28779. */
  28780. getVerticesData(kind: string): Nullable<FloatArray>;
  28781. /**
  28782. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28783. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28784. * Note that a new underlying VertexBuffer object is created each call.
  28785. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28786. * @param kind defines vertex data kind:
  28787. * * VertexBuffer.PositionKind
  28788. * * VertexBuffer.UVKind
  28789. * * VertexBuffer.UV2Kind
  28790. * * VertexBuffer.UV3Kind
  28791. * * VertexBuffer.UV4Kind
  28792. * * VertexBuffer.UV5Kind
  28793. * * VertexBuffer.UV6Kind
  28794. * * VertexBuffer.ColorKind
  28795. * * VertexBuffer.MatricesIndicesKind
  28796. * * VertexBuffer.MatricesIndicesExtraKind
  28797. * * VertexBuffer.MatricesWeightsKind
  28798. * * VertexBuffer.MatricesWeightsExtraKind
  28799. * @param data defines the data source
  28800. * @param updatable defines if the data must be flagged as updatable (or static)
  28801. * @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
  28802. * @returns the current mesh
  28803. */
  28804. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28805. /**
  28806. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28807. * If the mesh has no geometry, it is simply returned as it is.
  28808. * @param kind defines vertex data kind:
  28809. * * VertexBuffer.PositionKind
  28810. * * VertexBuffer.UVKind
  28811. * * VertexBuffer.UV2Kind
  28812. * * VertexBuffer.UV3Kind
  28813. * * VertexBuffer.UV4Kind
  28814. * * VertexBuffer.UV5Kind
  28815. * * VertexBuffer.UV6Kind
  28816. * * VertexBuffer.ColorKind
  28817. * * VertexBuffer.MatricesIndicesKind
  28818. * * VertexBuffer.MatricesIndicesExtraKind
  28819. * * VertexBuffer.MatricesWeightsKind
  28820. * * VertexBuffer.MatricesWeightsExtraKind
  28821. * @param data defines the data source
  28822. * @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
  28823. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28824. * @returns the current mesh
  28825. */
  28826. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28827. /**
  28828. * Sets the mesh indices,
  28829. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28830. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28831. * @param totalVertices Defines the total number of vertices
  28832. * @returns the current mesh
  28833. */
  28834. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28835. /**
  28836. * Gets a boolean indicating if specific vertex data is present
  28837. * @param kind defines the vertex data kind to use
  28838. * @returns true is data kind is present
  28839. */
  28840. isVerticesDataPresent(kind: string): boolean;
  28841. /**
  28842. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28843. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28844. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28845. * @returns a BoundingInfo
  28846. */
  28847. getBoundingInfo(): BoundingInfo;
  28848. /**
  28849. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28850. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28851. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28852. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28853. * @returns the current mesh
  28854. */
  28855. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28856. /**
  28857. * Overwrite the current bounding info
  28858. * @param boundingInfo defines the new bounding info
  28859. * @returns the current mesh
  28860. */
  28861. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28862. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28863. get useBones(): boolean;
  28864. /** @hidden */
  28865. _preActivate(): void;
  28866. /** @hidden */
  28867. _preActivateForIntermediateRendering(renderId: number): void;
  28868. /** @hidden */
  28869. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28870. /** @hidden */
  28871. _postActivate(): void;
  28872. /** @hidden */
  28873. _freeze(): void;
  28874. /** @hidden */
  28875. _unFreeze(): void;
  28876. /**
  28877. * Gets the current world matrix
  28878. * @returns a Matrix
  28879. */
  28880. getWorldMatrix(): Matrix;
  28881. /** @hidden */
  28882. _getWorldMatrixDeterminant(): number;
  28883. /**
  28884. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28885. */
  28886. get isAnInstance(): boolean;
  28887. /**
  28888. * Gets a boolean indicating if this mesh has instances
  28889. */
  28890. get hasInstances(): boolean;
  28891. /**
  28892. * Perform relative position change from the point of view of behind the front of the mesh.
  28893. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28894. * Supports definition of mesh facing forward or backward
  28895. * @param amountRight defines the distance on the right axis
  28896. * @param amountUp defines the distance on the up axis
  28897. * @param amountForward defines the distance on the forward axis
  28898. * @returns the current mesh
  28899. */
  28900. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28901. /**
  28902. * Calculate relative position change from the point of view of behind the front of the mesh.
  28903. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28904. * Supports definition of mesh facing forward or backward
  28905. * @param amountRight defines the distance on the right axis
  28906. * @param amountUp defines the distance on the up axis
  28907. * @param amountForward defines the distance on the forward axis
  28908. * @returns the new displacement vector
  28909. */
  28910. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28911. /**
  28912. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28913. * Supports definition of mesh facing forward or backward
  28914. * @param flipBack defines the flip
  28915. * @param twirlClockwise defines the twirl
  28916. * @param tiltRight defines the tilt
  28917. * @returns the current mesh
  28918. */
  28919. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28920. /**
  28921. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28922. * Supports definition of mesh facing forward or backward.
  28923. * @param flipBack defines the flip
  28924. * @param twirlClockwise defines the twirl
  28925. * @param tiltRight defines the tilt
  28926. * @returns the new rotation vector
  28927. */
  28928. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28929. /**
  28930. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28931. * This means the mesh underlying bounding box and sphere are recomputed.
  28932. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28933. * @returns the current mesh
  28934. */
  28935. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28936. /** @hidden */
  28937. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28938. /** @hidden */
  28939. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28940. /** @hidden */
  28941. _updateBoundingInfo(): AbstractMesh;
  28942. /** @hidden */
  28943. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28944. /** @hidden */
  28945. protected _afterComputeWorldMatrix(): void;
  28946. /** @hidden */
  28947. get _effectiveMesh(): AbstractMesh;
  28948. /**
  28949. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28950. * A mesh is in the frustum if its bounding box intersects the frustum
  28951. * @param frustumPlanes defines the frustum to test
  28952. * @returns true if the mesh is in the frustum planes
  28953. */
  28954. isInFrustum(frustumPlanes: Plane[]): boolean;
  28955. /**
  28956. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28957. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28958. * @param frustumPlanes defines the frustum to test
  28959. * @returns true if the mesh is completely in the frustum planes
  28960. */
  28961. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28962. /**
  28963. * True if the mesh intersects another mesh or a SolidParticle object
  28964. * @param mesh defines a target mesh or SolidParticle to test
  28965. * @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)
  28966. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28967. * @returns true if there is an intersection
  28968. */
  28969. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28970. /**
  28971. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28972. * @param point defines the point to test
  28973. * @returns true if there is an intersection
  28974. */
  28975. intersectsPoint(point: Vector3): boolean;
  28976. /**
  28977. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28978. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28979. */
  28980. get checkCollisions(): boolean;
  28981. set checkCollisions(collisionEnabled: boolean);
  28982. /**
  28983. * Gets Collider object used to compute collisions (not physics)
  28984. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28985. */
  28986. get collider(): Nullable<Collider>;
  28987. /**
  28988. * Move the mesh using collision engine
  28989. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28990. * @param displacement defines the requested displacement vector
  28991. * @returns the current mesh
  28992. */
  28993. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28994. private _onCollisionPositionChange;
  28995. /** @hidden */
  28996. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28997. /** @hidden */
  28998. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28999. /** @hidden */
  29000. _checkCollision(collider: Collider): AbstractMesh;
  29001. /** @hidden */
  29002. _generatePointsArray(): boolean;
  29003. /**
  29004. * Checks if the passed Ray intersects with the mesh
  29005. * @param ray defines the ray to use
  29006. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29007. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29008. * @returns the picking info
  29009. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29010. */
  29011. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29012. /**
  29013. * Clones the current mesh
  29014. * @param name defines the mesh name
  29015. * @param newParent defines the new mesh parent
  29016. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29017. * @returns the new mesh
  29018. */
  29019. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29020. /**
  29021. * Disposes all the submeshes of the current meshnp
  29022. * @returns the current mesh
  29023. */
  29024. releaseSubMeshes(): AbstractMesh;
  29025. /**
  29026. * Releases resources associated with this abstract mesh.
  29027. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29028. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29029. */
  29030. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29031. /**
  29032. * Adds the passed mesh as a child to the current mesh
  29033. * @param mesh defines the child mesh
  29034. * @returns the current mesh
  29035. */
  29036. addChild(mesh: AbstractMesh): AbstractMesh;
  29037. /**
  29038. * Removes the passed mesh from the current mesh children list
  29039. * @param mesh defines the child mesh
  29040. * @returns the current mesh
  29041. */
  29042. removeChild(mesh: AbstractMesh): AbstractMesh;
  29043. /** @hidden */
  29044. private _initFacetData;
  29045. /**
  29046. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29047. * This method can be called within the render loop.
  29048. * 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
  29049. * @returns the current mesh
  29050. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29051. */
  29052. updateFacetData(): AbstractMesh;
  29053. /**
  29054. * Returns the facetLocalNormals array.
  29055. * The normals are expressed in the mesh local spac
  29056. * @returns an array of Vector3
  29057. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29058. */
  29059. getFacetLocalNormals(): Vector3[];
  29060. /**
  29061. * Returns the facetLocalPositions array.
  29062. * The facet positions are expressed in the mesh local space
  29063. * @returns an array of Vector3
  29064. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29065. */
  29066. getFacetLocalPositions(): Vector3[];
  29067. /**
  29068. * Returns the facetLocalPartioning array
  29069. * @returns an array of array of numbers
  29070. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29071. */
  29072. getFacetLocalPartitioning(): number[][];
  29073. /**
  29074. * Returns the i-th facet position in the world system.
  29075. * This method allocates a new Vector3 per call
  29076. * @param i defines the facet index
  29077. * @returns a new Vector3
  29078. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29079. */
  29080. getFacetPosition(i: number): Vector3;
  29081. /**
  29082. * Sets the reference Vector3 with the i-th facet position in the world system
  29083. * @param i defines the facet index
  29084. * @param ref defines the target vector
  29085. * @returns the current mesh
  29086. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29087. */
  29088. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29089. /**
  29090. * Returns the i-th facet normal in the world system.
  29091. * This method allocates a new Vector3 per call
  29092. * @param i defines the facet index
  29093. * @returns a new Vector3
  29094. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29095. */
  29096. getFacetNormal(i: number): Vector3;
  29097. /**
  29098. * Sets the reference Vector3 with the i-th facet normal in the world system
  29099. * @param i defines the facet index
  29100. * @param ref defines the target vector
  29101. * @returns the current mesh
  29102. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29103. */
  29104. getFacetNormalToRef(i: number, ref: Vector3): this;
  29105. /**
  29106. * 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)
  29107. * @param x defines x coordinate
  29108. * @param y defines y coordinate
  29109. * @param z defines z coordinate
  29110. * @returns the array of facet indexes
  29111. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29112. */
  29113. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29114. /**
  29115. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29116. * @param projected sets as the (x,y,z) world projection on the facet
  29117. * @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
  29118. * @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
  29119. * @param x defines x coordinate
  29120. * @param y defines y coordinate
  29121. * @param z defines z coordinate
  29122. * @returns the face index if found (or null instead)
  29123. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29124. */
  29125. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29126. /**
  29127. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29128. * @param projected sets as the (x,y,z) local projection on the facet
  29129. * @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
  29130. * @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
  29131. * @param x defines x coordinate
  29132. * @param y defines y coordinate
  29133. * @param z defines z coordinate
  29134. * @returns the face index if found (or null instead)
  29135. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29136. */
  29137. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29138. /**
  29139. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29140. * @returns the parameters
  29141. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29142. */
  29143. getFacetDataParameters(): any;
  29144. /**
  29145. * Disables the feature FacetData and frees the related memory
  29146. * @returns the current mesh
  29147. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29148. */
  29149. disableFacetData(): AbstractMesh;
  29150. /**
  29151. * Updates the AbstractMesh indices array
  29152. * @param indices defines the data source
  29153. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29154. * @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)
  29155. * @returns the current mesh
  29156. */
  29157. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29158. /**
  29159. * Creates new normals data for the mesh
  29160. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29161. * @returns the current mesh
  29162. */
  29163. createNormals(updatable: boolean): AbstractMesh;
  29164. /**
  29165. * Align the mesh with a normal
  29166. * @param normal defines the normal to use
  29167. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29168. * @returns the current mesh
  29169. */
  29170. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29171. /** @hidden */
  29172. _checkOcclusionQuery(): boolean;
  29173. /**
  29174. * Disables the mesh edge rendering mode
  29175. * @returns the currentAbstractMesh
  29176. */
  29177. disableEdgesRendering(): AbstractMesh;
  29178. /**
  29179. * Enables the edge rendering mode on the mesh.
  29180. * This mode makes the mesh edges visible
  29181. * @param epsilon defines the maximal distance between two angles to detect a face
  29182. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29183. * @returns the currentAbstractMesh
  29184. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29185. */
  29186. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29187. }
  29188. }
  29189. declare module "babylonjs/Actions/actionEvent" {
  29190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29191. import { Nullable } from "babylonjs/types";
  29192. import { Sprite } from "babylonjs/Sprites/sprite";
  29193. import { Scene } from "babylonjs/scene";
  29194. import { Vector2 } from "babylonjs/Maths/math.vector";
  29195. /**
  29196. * Interface used to define ActionEvent
  29197. */
  29198. export interface IActionEvent {
  29199. /** The mesh or sprite that triggered the action */
  29200. source: any;
  29201. /** The X mouse cursor position at the time of the event */
  29202. pointerX: number;
  29203. /** The Y mouse cursor position at the time of the event */
  29204. pointerY: number;
  29205. /** The mesh that is currently pointed at (can be null) */
  29206. meshUnderPointer: Nullable<AbstractMesh>;
  29207. /** the original (browser) event that triggered the ActionEvent */
  29208. sourceEvent?: any;
  29209. /** additional data for the event */
  29210. additionalData?: any;
  29211. }
  29212. /**
  29213. * ActionEvent is the event being sent when an action is triggered.
  29214. */
  29215. export class ActionEvent implements IActionEvent {
  29216. /** The mesh or sprite that triggered the action */
  29217. source: any;
  29218. /** The X mouse cursor position at the time of the event */
  29219. pointerX: number;
  29220. /** The Y mouse cursor position at the time of the event */
  29221. pointerY: number;
  29222. /** The mesh that is currently pointed at (can be null) */
  29223. meshUnderPointer: Nullable<AbstractMesh>;
  29224. /** the original (browser) event that triggered the ActionEvent */
  29225. sourceEvent?: any;
  29226. /** additional data for the event */
  29227. additionalData?: any;
  29228. /**
  29229. * Creates a new ActionEvent
  29230. * @param source The mesh or sprite that triggered the action
  29231. * @param pointerX The X mouse cursor position at the time of the event
  29232. * @param pointerY The Y mouse cursor position at the time of the event
  29233. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29234. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29235. * @param additionalData additional data for the event
  29236. */
  29237. constructor(
  29238. /** The mesh or sprite that triggered the action */
  29239. source: any,
  29240. /** The X mouse cursor position at the time of the event */
  29241. pointerX: number,
  29242. /** The Y mouse cursor position at the time of the event */
  29243. pointerY: number,
  29244. /** The mesh that is currently pointed at (can be null) */
  29245. meshUnderPointer: Nullable<AbstractMesh>,
  29246. /** the original (browser) event that triggered the ActionEvent */
  29247. sourceEvent?: any,
  29248. /** additional data for the event */
  29249. additionalData?: any);
  29250. /**
  29251. * Helper function to auto-create an ActionEvent from a source mesh.
  29252. * @param source The source mesh that triggered the event
  29253. * @param evt The original (browser) event
  29254. * @param additionalData additional data for the event
  29255. * @returns the new ActionEvent
  29256. */
  29257. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29258. /**
  29259. * Helper function to auto-create an ActionEvent from a source sprite
  29260. * @param source The source sprite that triggered the event
  29261. * @param scene Scene associated with the sprite
  29262. * @param evt The original (browser) event
  29263. * @param additionalData additional data for the event
  29264. * @returns the new ActionEvent
  29265. */
  29266. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29267. /**
  29268. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29269. * @param scene the scene where the event occurred
  29270. * @param evt The original (browser) event
  29271. * @returns the new ActionEvent
  29272. */
  29273. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29274. /**
  29275. * Helper function to auto-create an ActionEvent from a primitive
  29276. * @param prim defines the target primitive
  29277. * @param pointerPos defines the pointer position
  29278. * @param evt The original (browser) event
  29279. * @param additionalData additional data for the event
  29280. * @returns the new ActionEvent
  29281. */
  29282. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29283. }
  29284. }
  29285. declare module "babylonjs/Actions/abstractActionManager" {
  29286. import { IDisposable } from "babylonjs/scene";
  29287. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29288. import { IAction } from "babylonjs/Actions/action";
  29289. import { Nullable } from "babylonjs/types";
  29290. /**
  29291. * Abstract class used to decouple action Manager from scene and meshes.
  29292. * Do not instantiate.
  29293. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29294. */
  29295. export abstract class AbstractActionManager implements IDisposable {
  29296. /** Gets the list of active triggers */
  29297. static Triggers: {
  29298. [key: string]: number;
  29299. };
  29300. /** Gets the cursor to use when hovering items */
  29301. hoverCursor: string;
  29302. /** Gets the list of actions */
  29303. actions: IAction[];
  29304. /**
  29305. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29306. */
  29307. isRecursive: boolean;
  29308. /**
  29309. * Releases all associated resources
  29310. */
  29311. abstract dispose(): void;
  29312. /**
  29313. * Does this action manager has pointer triggers
  29314. */
  29315. abstract get hasPointerTriggers(): boolean;
  29316. /**
  29317. * Does this action manager has pick triggers
  29318. */
  29319. abstract get hasPickTriggers(): boolean;
  29320. /**
  29321. * Process a specific trigger
  29322. * @param trigger defines the trigger to process
  29323. * @param evt defines the event details to be processed
  29324. */
  29325. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29326. /**
  29327. * Does this action manager handles actions of any of the given triggers
  29328. * @param triggers defines the triggers to be tested
  29329. * @return a boolean indicating whether one (or more) of the triggers is handled
  29330. */
  29331. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29332. /**
  29333. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29334. * speed.
  29335. * @param triggerA defines the trigger to be tested
  29336. * @param triggerB defines the trigger to be tested
  29337. * @return a boolean indicating whether one (or more) of the triggers is handled
  29338. */
  29339. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29340. /**
  29341. * Does this action manager handles actions of a given trigger
  29342. * @param trigger defines the trigger to be tested
  29343. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29344. * @return whether the trigger is handled
  29345. */
  29346. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29347. /**
  29348. * Serialize this manager to a JSON object
  29349. * @param name defines the property name to store this manager
  29350. * @returns a JSON representation of this manager
  29351. */
  29352. abstract serialize(name: string): any;
  29353. /**
  29354. * Registers an action to this action manager
  29355. * @param action defines the action to be registered
  29356. * @return the action amended (prepared) after registration
  29357. */
  29358. abstract registerAction(action: IAction): Nullable<IAction>;
  29359. /**
  29360. * Unregisters an action to this action manager
  29361. * @param action defines the action to be unregistered
  29362. * @return a boolean indicating whether the action has been unregistered
  29363. */
  29364. abstract unregisterAction(action: IAction): Boolean;
  29365. /**
  29366. * Does exist one action manager with at least one trigger
  29367. **/
  29368. static get HasTriggers(): boolean;
  29369. /**
  29370. * Does exist one action manager with at least one pick trigger
  29371. **/
  29372. static get HasPickTriggers(): boolean;
  29373. /**
  29374. * Does exist one action manager that handles actions of a given trigger
  29375. * @param trigger defines the trigger to be tested
  29376. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29377. **/
  29378. static HasSpecificTrigger(trigger: number): boolean;
  29379. }
  29380. }
  29381. declare module "babylonjs/node" {
  29382. import { Scene } from "babylonjs/scene";
  29383. import { Nullable } from "babylonjs/types";
  29384. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29385. import { Engine } from "babylonjs/Engines/engine";
  29386. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29387. import { Observable } from "babylonjs/Misc/observable";
  29388. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29389. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29390. import { Animatable } from "babylonjs/Animations/animatable";
  29391. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29392. import { Animation } from "babylonjs/Animations/animation";
  29393. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29394. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29395. /**
  29396. * Defines how a node can be built from a string name.
  29397. */
  29398. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29399. /**
  29400. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29401. */
  29402. export class Node implements IBehaviorAware<Node> {
  29403. /** @hidden */
  29404. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29405. private static _NodeConstructors;
  29406. /**
  29407. * Add a new node constructor
  29408. * @param type defines the type name of the node to construct
  29409. * @param constructorFunc defines the constructor function
  29410. */
  29411. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29412. /**
  29413. * Returns a node constructor based on type name
  29414. * @param type defines the type name
  29415. * @param name defines the new node name
  29416. * @param scene defines the hosting scene
  29417. * @param options defines optional options to transmit to constructors
  29418. * @returns the new constructor or null
  29419. */
  29420. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29421. /**
  29422. * Gets or sets the name of the node
  29423. */
  29424. name: string;
  29425. /**
  29426. * Gets or sets the id of the node
  29427. */
  29428. id: string;
  29429. /**
  29430. * Gets or sets the unique id of the node
  29431. */
  29432. uniqueId: number;
  29433. /**
  29434. * Gets or sets a string used to store user defined state for the node
  29435. */
  29436. state: string;
  29437. /**
  29438. * Gets or sets an object used to store user defined information for the node
  29439. */
  29440. metadata: any;
  29441. /**
  29442. * For internal use only. Please do not use.
  29443. */
  29444. reservedDataStore: any;
  29445. /**
  29446. * List of inspectable custom properties (used by the Inspector)
  29447. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29448. */
  29449. inspectableCustomProperties: IInspectable[];
  29450. private _doNotSerialize;
  29451. /**
  29452. * Gets or sets a boolean used to define if the node must be serialized
  29453. */
  29454. get doNotSerialize(): boolean;
  29455. set doNotSerialize(value: boolean);
  29456. /** @hidden */
  29457. _isDisposed: boolean;
  29458. /**
  29459. * Gets a list of Animations associated with the node
  29460. */
  29461. animations: import("babylonjs/Animations/animation").Animation[];
  29462. protected _ranges: {
  29463. [name: string]: Nullable<AnimationRange>;
  29464. };
  29465. /**
  29466. * Callback raised when the node is ready to be used
  29467. */
  29468. onReady: Nullable<(node: Node) => void>;
  29469. private _isEnabled;
  29470. private _isParentEnabled;
  29471. private _isReady;
  29472. /** @hidden */
  29473. _currentRenderId: number;
  29474. private _parentUpdateId;
  29475. /** @hidden */
  29476. _childUpdateId: number;
  29477. /** @hidden */
  29478. _waitingParentId: Nullable<string>;
  29479. /** @hidden */
  29480. _scene: Scene;
  29481. /** @hidden */
  29482. _cache: any;
  29483. private _parentNode;
  29484. private _children;
  29485. /** @hidden */
  29486. _worldMatrix: Matrix;
  29487. /** @hidden */
  29488. _worldMatrixDeterminant: number;
  29489. /** @hidden */
  29490. _worldMatrixDeterminantIsDirty: boolean;
  29491. /** @hidden */
  29492. private _sceneRootNodesIndex;
  29493. /**
  29494. * Gets a boolean indicating if the node has been disposed
  29495. * @returns true if the node was disposed
  29496. */
  29497. isDisposed(): boolean;
  29498. /**
  29499. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29500. * @see https://doc.babylonjs.com/how_to/parenting
  29501. */
  29502. set parent(parent: Nullable<Node>);
  29503. get parent(): Nullable<Node>;
  29504. /** @hidden */
  29505. _addToSceneRootNodes(): void;
  29506. /** @hidden */
  29507. _removeFromSceneRootNodes(): void;
  29508. private _animationPropertiesOverride;
  29509. /**
  29510. * Gets or sets the animation properties override
  29511. */
  29512. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29513. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29514. /**
  29515. * Gets a string idenfifying the name of the class
  29516. * @returns "Node" string
  29517. */
  29518. getClassName(): string;
  29519. /** @hidden */
  29520. readonly _isNode: boolean;
  29521. /**
  29522. * An event triggered when the mesh is disposed
  29523. */
  29524. onDisposeObservable: Observable<Node>;
  29525. private _onDisposeObserver;
  29526. /**
  29527. * Sets a callback that will be raised when the node will be disposed
  29528. */
  29529. set onDispose(callback: () => void);
  29530. /**
  29531. * Creates a new Node
  29532. * @param name the name and id to be given to this node
  29533. * @param scene the scene this node will be added to
  29534. */
  29535. constructor(name: string, scene?: Nullable<Scene>);
  29536. /**
  29537. * Gets the scene of the node
  29538. * @returns a scene
  29539. */
  29540. getScene(): Scene;
  29541. /**
  29542. * Gets the engine of the node
  29543. * @returns a Engine
  29544. */
  29545. getEngine(): Engine;
  29546. private _behaviors;
  29547. /**
  29548. * Attach a behavior to the node
  29549. * @see http://doc.babylonjs.com/features/behaviour
  29550. * @param behavior defines the behavior to attach
  29551. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29552. * @returns the current Node
  29553. */
  29554. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29555. /**
  29556. * Remove an attached behavior
  29557. * @see http://doc.babylonjs.com/features/behaviour
  29558. * @param behavior defines the behavior to attach
  29559. * @returns the current Node
  29560. */
  29561. removeBehavior(behavior: Behavior<Node>): Node;
  29562. /**
  29563. * Gets the list of attached behaviors
  29564. * @see http://doc.babylonjs.com/features/behaviour
  29565. */
  29566. get behaviors(): Behavior<Node>[];
  29567. /**
  29568. * Gets an attached behavior by name
  29569. * @param name defines the name of the behavior to look for
  29570. * @see http://doc.babylonjs.com/features/behaviour
  29571. * @returns null if behavior was not found else the requested behavior
  29572. */
  29573. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29574. /**
  29575. * Returns the latest update of the World matrix
  29576. * @returns a Matrix
  29577. */
  29578. getWorldMatrix(): Matrix;
  29579. /** @hidden */
  29580. _getWorldMatrixDeterminant(): number;
  29581. /**
  29582. * Returns directly the latest state of the mesh World matrix.
  29583. * A Matrix is returned.
  29584. */
  29585. get worldMatrixFromCache(): Matrix;
  29586. /** @hidden */
  29587. _initCache(): void;
  29588. /** @hidden */
  29589. updateCache(force?: boolean): void;
  29590. /** @hidden */
  29591. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29592. /** @hidden */
  29593. _updateCache(ignoreParentClass?: boolean): void;
  29594. /** @hidden */
  29595. _isSynchronized(): boolean;
  29596. /** @hidden */
  29597. _markSyncedWithParent(): void;
  29598. /** @hidden */
  29599. isSynchronizedWithParent(): boolean;
  29600. /** @hidden */
  29601. isSynchronized(): boolean;
  29602. /**
  29603. * Is this node ready to be used/rendered
  29604. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29605. * @return true if the node is ready
  29606. */
  29607. isReady(completeCheck?: boolean): boolean;
  29608. /**
  29609. * Is this node enabled?
  29610. * 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
  29611. * @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
  29612. * @return whether this node (and its parent) is enabled
  29613. */
  29614. isEnabled(checkAncestors?: boolean): boolean;
  29615. /** @hidden */
  29616. protected _syncParentEnabledState(): void;
  29617. /**
  29618. * Set the enabled state of this node
  29619. * @param value defines the new enabled state
  29620. */
  29621. setEnabled(value: boolean): void;
  29622. /**
  29623. * Is this node a descendant of the given node?
  29624. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29625. * @param ancestor defines the parent node to inspect
  29626. * @returns a boolean indicating if this node is a descendant of the given node
  29627. */
  29628. isDescendantOf(ancestor: Node): boolean;
  29629. /** @hidden */
  29630. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29631. /**
  29632. * Will return all nodes that have this node as ascendant
  29633. * @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
  29634. * @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
  29635. * @return all children nodes of all types
  29636. */
  29637. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29638. /**
  29639. * Get all child-meshes of this node
  29640. * @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)
  29641. * @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
  29642. * @returns an array of AbstractMesh
  29643. */
  29644. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29645. /**
  29646. * Get all direct children of this node
  29647. * @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
  29648. * @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)
  29649. * @returns an array of Node
  29650. */
  29651. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29652. /** @hidden */
  29653. _setReady(state: boolean): void;
  29654. /**
  29655. * Get an animation by name
  29656. * @param name defines the name of the animation to look for
  29657. * @returns null if not found else the requested animation
  29658. */
  29659. getAnimationByName(name: string): Nullable<Animation>;
  29660. /**
  29661. * Creates an animation range for this node
  29662. * @param name defines the name of the range
  29663. * @param from defines the starting key
  29664. * @param to defines the end key
  29665. */
  29666. createAnimationRange(name: string, from: number, to: number): void;
  29667. /**
  29668. * Delete a specific animation range
  29669. * @param name defines the name of the range to delete
  29670. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29671. */
  29672. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29673. /**
  29674. * Get an animation range by name
  29675. * @param name defines the name of the animation range to look for
  29676. * @returns null if not found else the requested animation range
  29677. */
  29678. getAnimationRange(name: string): Nullable<AnimationRange>;
  29679. /**
  29680. * Gets the list of all animation ranges defined on this node
  29681. * @returns an array
  29682. */
  29683. getAnimationRanges(): Nullable<AnimationRange>[];
  29684. /**
  29685. * Will start the animation sequence
  29686. * @param name defines the range frames for animation sequence
  29687. * @param loop defines if the animation should loop (false by default)
  29688. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29689. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29690. * @returns the object created for this animation. If range does not exist, it will return null
  29691. */
  29692. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29693. /**
  29694. * Serialize animation ranges into a JSON compatible object
  29695. * @returns serialization object
  29696. */
  29697. serializeAnimationRanges(): any;
  29698. /**
  29699. * Computes the world matrix of the node
  29700. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29701. * @returns the world matrix
  29702. */
  29703. computeWorldMatrix(force?: boolean): Matrix;
  29704. /**
  29705. * Releases resources associated with this node.
  29706. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29707. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29708. */
  29709. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29710. /**
  29711. * Parse animation range data from a serialization object and store them into a given node
  29712. * @param node defines where to store the animation ranges
  29713. * @param parsedNode defines the serialization object to read data from
  29714. * @param scene defines the hosting scene
  29715. */
  29716. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29717. /**
  29718. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29719. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29720. * @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
  29721. * @returns the new bounding vectors
  29722. */
  29723. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29724. min: Vector3;
  29725. max: Vector3;
  29726. };
  29727. }
  29728. }
  29729. declare module "babylonjs/Animations/animation" {
  29730. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29731. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29732. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29733. import { Nullable } from "babylonjs/types";
  29734. import { Scene } from "babylonjs/scene";
  29735. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29736. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29737. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29738. import { Node } from "babylonjs/node";
  29739. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29740. import { Size } from "babylonjs/Maths/math.size";
  29741. import { Animatable } from "babylonjs/Animations/animatable";
  29742. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  29743. /**
  29744. * @hidden
  29745. */
  29746. export class _IAnimationState {
  29747. key: number;
  29748. repeatCount: number;
  29749. workValue?: any;
  29750. loopMode?: number;
  29751. offsetValue?: any;
  29752. highLimitValue?: any;
  29753. }
  29754. /**
  29755. * Class used to store any kind of animation
  29756. */
  29757. export class Animation {
  29758. /**Name of the animation */
  29759. name: string;
  29760. /**Property to animate */
  29761. targetProperty: string;
  29762. /**The frames per second of the animation */
  29763. framePerSecond: number;
  29764. /**The data type of the animation */
  29765. dataType: number;
  29766. /**The loop mode of the animation */
  29767. loopMode?: number | undefined;
  29768. /**Specifies if blending should be enabled */
  29769. enableBlending?: boolean | undefined;
  29770. /**
  29771. * Use matrix interpolation instead of using direct key value when animating matrices
  29772. */
  29773. static AllowMatricesInterpolation: boolean;
  29774. /**
  29775. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29776. */
  29777. static AllowMatrixDecomposeForInterpolation: boolean;
  29778. /**
  29779. * Stores the key frames of the animation
  29780. */
  29781. private _keys;
  29782. /**
  29783. * Stores the easing function of the animation
  29784. */
  29785. private _easingFunction;
  29786. /**
  29787. * @hidden Internal use only
  29788. */
  29789. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  29790. /**
  29791. * The set of event that will be linked to this animation
  29792. */
  29793. private _events;
  29794. /**
  29795. * Stores an array of target property paths
  29796. */
  29797. targetPropertyPath: string[];
  29798. /**
  29799. * Stores the blending speed of the animation
  29800. */
  29801. blendingSpeed: number;
  29802. /**
  29803. * Stores the animation ranges for the animation
  29804. */
  29805. private _ranges;
  29806. /**
  29807. * @hidden Internal use
  29808. */
  29809. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29810. /**
  29811. * Sets up an animation
  29812. * @param property The property to animate
  29813. * @param animationType The animation type to apply
  29814. * @param framePerSecond The frames per second of the animation
  29815. * @param easingFunction The easing function used in the animation
  29816. * @returns The created animation
  29817. */
  29818. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29819. /**
  29820. * Create and start an animation on a node
  29821. * @param name defines the name of the global animation that will be run on all nodes
  29822. * @param node defines the root node where the animation will take place
  29823. * @param targetProperty defines property to animate
  29824. * @param framePerSecond defines the number of frame per second yo use
  29825. * @param totalFrame defines the number of frames in total
  29826. * @param from defines the initial value
  29827. * @param to defines the final value
  29828. * @param loopMode defines which loop mode you want to use (off by default)
  29829. * @param easingFunction defines the easing function to use (linear by default)
  29830. * @param onAnimationEnd defines the callback to call when animation end
  29831. * @returns the animatable created for this animation
  29832. */
  29833. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29834. /**
  29835. * Create and start an animation on a node and its descendants
  29836. * @param name defines the name of the global animation that will be run on all nodes
  29837. * @param node defines the root node where the animation will take place
  29838. * @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
  29839. * @param targetProperty defines property to animate
  29840. * @param framePerSecond defines the number of frame per second to use
  29841. * @param totalFrame defines the number of frames in total
  29842. * @param from defines the initial value
  29843. * @param to defines the final value
  29844. * @param loopMode defines which loop mode you want to use (off by default)
  29845. * @param easingFunction defines the easing function to use (linear by default)
  29846. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29847. * @returns the list of animatables created for all nodes
  29848. * @example https://www.babylonjs-playground.com/#MH0VLI
  29849. */
  29850. 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[]>;
  29851. /**
  29852. * Creates a new animation, merges it with the existing animations and starts it
  29853. * @param name Name of the animation
  29854. * @param node Node which contains the scene that begins the animations
  29855. * @param targetProperty Specifies which property to animate
  29856. * @param framePerSecond The frames per second of the animation
  29857. * @param totalFrame The total number of frames
  29858. * @param from The frame at the beginning of the animation
  29859. * @param to The frame at the end of the animation
  29860. * @param loopMode Specifies the loop mode of the animation
  29861. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29862. * @param onAnimationEnd Callback to run once the animation is complete
  29863. * @returns Nullable animation
  29864. */
  29865. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29866. /**
  29867. * Transition property of an host to the target Value
  29868. * @param property The property to transition
  29869. * @param targetValue The target Value of the property
  29870. * @param host The object where the property to animate belongs
  29871. * @param scene Scene used to run the animation
  29872. * @param frameRate Framerate (in frame/s) to use
  29873. * @param transition The transition type we want to use
  29874. * @param duration The duration of the animation, in milliseconds
  29875. * @param onAnimationEnd Callback trigger at the end of the animation
  29876. * @returns Nullable animation
  29877. */
  29878. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29879. /**
  29880. * Return the array of runtime animations currently using this animation
  29881. */
  29882. get runtimeAnimations(): RuntimeAnimation[];
  29883. /**
  29884. * Specifies if any of the runtime animations are currently running
  29885. */
  29886. get hasRunningRuntimeAnimations(): boolean;
  29887. /**
  29888. * Initializes the animation
  29889. * @param name Name of the animation
  29890. * @param targetProperty Property to animate
  29891. * @param framePerSecond The frames per second of the animation
  29892. * @param dataType The data type of the animation
  29893. * @param loopMode The loop mode of the animation
  29894. * @param enableBlending Specifies if blending should be enabled
  29895. */
  29896. constructor(
  29897. /**Name of the animation */
  29898. name: string,
  29899. /**Property to animate */
  29900. targetProperty: string,
  29901. /**The frames per second of the animation */
  29902. framePerSecond: number,
  29903. /**The data type of the animation */
  29904. dataType: number,
  29905. /**The loop mode of the animation */
  29906. loopMode?: number | undefined,
  29907. /**Specifies if blending should be enabled */
  29908. enableBlending?: boolean | undefined);
  29909. /**
  29910. * Converts the animation to a string
  29911. * @param fullDetails support for multiple levels of logging within scene loading
  29912. * @returns String form of the animation
  29913. */
  29914. toString(fullDetails?: boolean): string;
  29915. /**
  29916. * Add an event to this animation
  29917. * @param event Event to add
  29918. */
  29919. addEvent(event: AnimationEvent): void;
  29920. /**
  29921. * Remove all events found at the given frame
  29922. * @param frame The frame to remove events from
  29923. */
  29924. removeEvents(frame: number): void;
  29925. /**
  29926. * Retrieves all the events from the animation
  29927. * @returns Events from the animation
  29928. */
  29929. getEvents(): AnimationEvent[];
  29930. /**
  29931. * Creates an animation range
  29932. * @param name Name of the animation range
  29933. * @param from Starting frame of the animation range
  29934. * @param to Ending frame of the animation
  29935. */
  29936. createRange(name: string, from: number, to: number): void;
  29937. /**
  29938. * Deletes an animation range by name
  29939. * @param name Name of the animation range to delete
  29940. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29941. */
  29942. deleteRange(name: string, deleteFrames?: boolean): void;
  29943. /**
  29944. * Gets the animation range by name, or null if not defined
  29945. * @param name Name of the animation range
  29946. * @returns Nullable animation range
  29947. */
  29948. getRange(name: string): Nullable<AnimationRange>;
  29949. /**
  29950. * Gets the key frames from the animation
  29951. * @returns The key frames of the animation
  29952. */
  29953. getKeys(): Array<IAnimationKey>;
  29954. /**
  29955. * Gets the highest frame rate of the animation
  29956. * @returns Highest frame rate of the animation
  29957. */
  29958. getHighestFrame(): number;
  29959. /**
  29960. * Gets the easing function of the animation
  29961. * @returns Easing function of the animation
  29962. */
  29963. getEasingFunction(): IEasingFunction;
  29964. /**
  29965. * Sets the easing function of the animation
  29966. * @param easingFunction A custom mathematical formula for animation
  29967. */
  29968. setEasingFunction(easingFunction: EasingFunction): void;
  29969. /**
  29970. * Interpolates a scalar linearly
  29971. * @param startValue Start value of the animation curve
  29972. * @param endValue End value of the animation curve
  29973. * @param gradient Scalar amount to interpolate
  29974. * @returns Interpolated scalar value
  29975. */
  29976. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29977. /**
  29978. * Interpolates a scalar cubically
  29979. * @param startValue Start value of the animation curve
  29980. * @param outTangent End tangent of the animation
  29981. * @param endValue End value of the animation curve
  29982. * @param inTangent Start tangent of the animation curve
  29983. * @param gradient Scalar amount to interpolate
  29984. * @returns Interpolated scalar value
  29985. */
  29986. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29987. /**
  29988. * Interpolates a quaternion using a spherical linear interpolation
  29989. * @param startValue Start value of the animation curve
  29990. * @param endValue End value of the animation curve
  29991. * @param gradient Scalar amount to interpolate
  29992. * @returns Interpolated quaternion value
  29993. */
  29994. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29995. /**
  29996. * Interpolates a quaternion cubically
  29997. * @param startValue Start value of the animation curve
  29998. * @param outTangent End tangent of the animation curve
  29999. * @param endValue End value of the animation curve
  30000. * @param inTangent Start tangent of the animation curve
  30001. * @param gradient Scalar amount to interpolate
  30002. * @returns Interpolated quaternion value
  30003. */
  30004. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30005. /**
  30006. * Interpolates a Vector3 linearl
  30007. * @param startValue Start value of the animation curve
  30008. * @param endValue End value of the animation curve
  30009. * @param gradient Scalar amount to interpolate
  30010. * @returns Interpolated scalar value
  30011. */
  30012. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30013. /**
  30014. * Interpolates a Vector3 cubically
  30015. * @param startValue Start value of the animation curve
  30016. * @param outTangent End tangent of the animation
  30017. * @param endValue End value of the animation curve
  30018. * @param inTangent Start tangent of the animation curve
  30019. * @param gradient Scalar amount to interpolate
  30020. * @returns InterpolatedVector3 value
  30021. */
  30022. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30023. /**
  30024. * Interpolates a Vector2 linearly
  30025. * @param startValue Start value of the animation curve
  30026. * @param endValue End value of the animation curve
  30027. * @param gradient Scalar amount to interpolate
  30028. * @returns Interpolated Vector2 value
  30029. */
  30030. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30031. /**
  30032. * Interpolates a Vector2 cubically
  30033. * @param startValue Start value of the animation curve
  30034. * @param outTangent End tangent of the animation
  30035. * @param endValue End value of the animation curve
  30036. * @param inTangent Start tangent of the animation curve
  30037. * @param gradient Scalar amount to interpolate
  30038. * @returns Interpolated Vector2 value
  30039. */
  30040. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30041. /**
  30042. * Interpolates a size linearly
  30043. * @param startValue Start value of the animation curve
  30044. * @param endValue End value of the animation curve
  30045. * @param gradient Scalar amount to interpolate
  30046. * @returns Interpolated Size value
  30047. */
  30048. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30049. /**
  30050. * Interpolates a Color3 linearly
  30051. * @param startValue Start value of the animation curve
  30052. * @param endValue End value of the animation curve
  30053. * @param gradient Scalar amount to interpolate
  30054. * @returns Interpolated Color3 value
  30055. */
  30056. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30057. /**
  30058. * Interpolates a Color4 linearly
  30059. * @param startValue Start value of the animation curve
  30060. * @param endValue End value of the animation curve
  30061. * @param gradient Scalar amount to interpolate
  30062. * @returns Interpolated Color3 value
  30063. */
  30064. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30065. /**
  30066. * @hidden Internal use only
  30067. */
  30068. _getKeyValue(value: any): any;
  30069. /**
  30070. * @hidden Internal use only
  30071. */
  30072. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30073. /**
  30074. * Defines the function to use to interpolate matrices
  30075. * @param startValue defines the start matrix
  30076. * @param endValue defines the end matrix
  30077. * @param gradient defines the gradient between both matrices
  30078. * @param result defines an optional target matrix where to store the interpolation
  30079. * @returns the interpolated matrix
  30080. */
  30081. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30082. /**
  30083. * Makes a copy of the animation
  30084. * @returns Cloned animation
  30085. */
  30086. clone(): Animation;
  30087. /**
  30088. * Sets the key frames of the animation
  30089. * @param values The animation key frames to set
  30090. */
  30091. setKeys(values: Array<IAnimationKey>): void;
  30092. /**
  30093. * Serializes the animation to an object
  30094. * @returns Serialized object
  30095. */
  30096. serialize(): any;
  30097. /**
  30098. * Float animation type
  30099. */
  30100. static readonly ANIMATIONTYPE_FLOAT: number;
  30101. /**
  30102. * Vector3 animation type
  30103. */
  30104. static readonly ANIMATIONTYPE_VECTOR3: number;
  30105. /**
  30106. * Quaternion animation type
  30107. */
  30108. static readonly ANIMATIONTYPE_QUATERNION: number;
  30109. /**
  30110. * Matrix animation type
  30111. */
  30112. static readonly ANIMATIONTYPE_MATRIX: number;
  30113. /**
  30114. * Color3 animation type
  30115. */
  30116. static readonly ANIMATIONTYPE_COLOR3: number;
  30117. /**
  30118. * Color3 animation type
  30119. */
  30120. static readonly ANIMATIONTYPE_COLOR4: number;
  30121. /**
  30122. * Vector2 animation type
  30123. */
  30124. static readonly ANIMATIONTYPE_VECTOR2: number;
  30125. /**
  30126. * Size animation type
  30127. */
  30128. static readonly ANIMATIONTYPE_SIZE: number;
  30129. /**
  30130. * Relative Loop Mode
  30131. */
  30132. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30133. /**
  30134. * Cycle Loop Mode
  30135. */
  30136. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30137. /**
  30138. * Constant Loop Mode
  30139. */
  30140. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30141. /** @hidden */
  30142. static _UniversalLerp(left: any, right: any, amount: number): any;
  30143. /**
  30144. * Parses an animation object and creates an animation
  30145. * @param parsedAnimation Parsed animation object
  30146. * @returns Animation object
  30147. */
  30148. static Parse(parsedAnimation: any): Animation;
  30149. /**
  30150. * Appends the serialized animations from the source animations
  30151. * @param source Source containing the animations
  30152. * @param destination Target to store the animations
  30153. */
  30154. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30155. }
  30156. }
  30157. declare module "babylonjs/Animations/animatable.interface" {
  30158. import { Nullable } from "babylonjs/types";
  30159. import { Animation } from "babylonjs/Animations/animation";
  30160. /**
  30161. * Interface containing an array of animations
  30162. */
  30163. export interface IAnimatable {
  30164. /**
  30165. * Array of animations
  30166. */
  30167. animations: Nullable<Array<Animation>>;
  30168. }
  30169. }
  30170. declare module "babylonjs/Misc/decorators" {
  30171. import { Nullable } from "babylonjs/types";
  30172. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30173. import { Scene } from "babylonjs/scene";
  30174. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30175. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30176. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30177. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30178. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30179. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30180. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30181. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30182. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30183. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30184. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30185. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30186. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30187. /**
  30188. * Decorator used to define property that can be serialized as reference to a camera
  30189. * @param sourceName defines the name of the property to decorate
  30190. */
  30191. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30192. /**
  30193. * Class used to help serialization objects
  30194. */
  30195. export class SerializationHelper {
  30196. /** @hidden */
  30197. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30198. /** @hidden */
  30199. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30200. /** @hidden */
  30201. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30202. /** @hidden */
  30203. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30204. /**
  30205. * Appends the serialized animations from the source animations
  30206. * @param source Source containing the animations
  30207. * @param destination Target to store the animations
  30208. */
  30209. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30210. /**
  30211. * Static function used to serialized a specific entity
  30212. * @param entity defines the entity to serialize
  30213. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30214. * @returns a JSON compatible object representing the serialization of the entity
  30215. */
  30216. static Serialize<T>(entity: T, serializationObject?: any): any;
  30217. /**
  30218. * Creates a new entity from a serialization data object
  30219. * @param creationFunction defines a function used to instanciated the new entity
  30220. * @param source defines the source serialization data
  30221. * @param scene defines the hosting scene
  30222. * @param rootUrl defines the root url for resources
  30223. * @returns a new entity
  30224. */
  30225. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30226. /**
  30227. * Clones an object
  30228. * @param creationFunction defines the function used to instanciate the new object
  30229. * @param source defines the source object
  30230. * @returns the cloned object
  30231. */
  30232. static Clone<T>(creationFunction: () => T, source: T): T;
  30233. /**
  30234. * Instanciates a new object based on a source one (some data will be shared between both object)
  30235. * @param creationFunction defines the function used to instanciate the new object
  30236. * @param source defines the source object
  30237. * @returns the new object
  30238. */
  30239. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30240. }
  30241. }
  30242. declare module "babylonjs/Misc/guid" {
  30243. /**
  30244. * Class used to manipulate GUIDs
  30245. */
  30246. export class GUID {
  30247. /**
  30248. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30249. * Be aware Math.random() could cause collisions, but:
  30250. * "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"
  30251. * @returns a pseudo random id
  30252. */
  30253. static RandomId(): string;
  30254. }
  30255. }
  30256. declare module "babylonjs/Materials/Textures/baseTexture" {
  30257. import { Observable } from "babylonjs/Misc/observable";
  30258. import { Nullable } from "babylonjs/types";
  30259. import { Scene } from "babylonjs/scene";
  30260. import { Matrix } from "babylonjs/Maths/math.vector";
  30261. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30262. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30263. import { ISize } from "babylonjs/Maths/math.size";
  30264. import "babylonjs/Misc/fileTools";
  30265. /**
  30266. * Base class of all the textures in babylon.
  30267. * It groups all the common properties the materials, post process, lights... might need
  30268. * in order to make a correct use of the texture.
  30269. */
  30270. export class BaseTexture implements IAnimatable {
  30271. /**
  30272. * Default anisotropic filtering level for the application.
  30273. * It is set to 4 as a good tradeoff between perf and quality.
  30274. */
  30275. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30276. /**
  30277. * Gets or sets the unique id of the texture
  30278. */
  30279. uniqueId: number;
  30280. /**
  30281. * Define the name of the texture.
  30282. */
  30283. name: string;
  30284. /**
  30285. * Gets or sets an object used to store user defined information.
  30286. */
  30287. metadata: any;
  30288. /**
  30289. * For internal use only. Please do not use.
  30290. */
  30291. reservedDataStore: any;
  30292. private _hasAlpha;
  30293. /**
  30294. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30295. */
  30296. set hasAlpha(value: boolean);
  30297. get hasAlpha(): boolean;
  30298. /**
  30299. * Defines if the alpha value should be determined via the rgb values.
  30300. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30301. */
  30302. getAlphaFromRGB: boolean;
  30303. /**
  30304. * Intensity or strength of the texture.
  30305. * It is commonly used by materials to fine tune the intensity of the texture
  30306. */
  30307. level: number;
  30308. /**
  30309. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30310. * This is part of the texture as textures usually maps to one uv set.
  30311. */
  30312. coordinatesIndex: number;
  30313. private _coordinatesMode;
  30314. /**
  30315. * How a texture is mapped.
  30316. *
  30317. * | Value | Type | Description |
  30318. * | ----- | ----------------------------------- | ----------- |
  30319. * | 0 | EXPLICIT_MODE | |
  30320. * | 1 | SPHERICAL_MODE | |
  30321. * | 2 | PLANAR_MODE | |
  30322. * | 3 | CUBIC_MODE | |
  30323. * | 4 | PROJECTION_MODE | |
  30324. * | 5 | SKYBOX_MODE | |
  30325. * | 6 | INVCUBIC_MODE | |
  30326. * | 7 | EQUIRECTANGULAR_MODE | |
  30327. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30328. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30329. */
  30330. set coordinatesMode(value: number);
  30331. get coordinatesMode(): number;
  30332. /**
  30333. * | Value | Type | Description |
  30334. * | ----- | ------------------ | ----------- |
  30335. * | 0 | CLAMP_ADDRESSMODE | |
  30336. * | 1 | WRAP_ADDRESSMODE | |
  30337. * | 2 | MIRROR_ADDRESSMODE | |
  30338. */
  30339. wrapU: number;
  30340. /**
  30341. * | Value | Type | Description |
  30342. * | ----- | ------------------ | ----------- |
  30343. * | 0 | CLAMP_ADDRESSMODE | |
  30344. * | 1 | WRAP_ADDRESSMODE | |
  30345. * | 2 | MIRROR_ADDRESSMODE | |
  30346. */
  30347. wrapV: number;
  30348. /**
  30349. * | Value | Type | Description |
  30350. * | ----- | ------------------ | ----------- |
  30351. * | 0 | CLAMP_ADDRESSMODE | |
  30352. * | 1 | WRAP_ADDRESSMODE | |
  30353. * | 2 | MIRROR_ADDRESSMODE | |
  30354. */
  30355. wrapR: number;
  30356. /**
  30357. * With compliant hardware and browser (supporting anisotropic filtering)
  30358. * this defines the level of anisotropic filtering in the texture.
  30359. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30360. */
  30361. anisotropicFilteringLevel: number;
  30362. /**
  30363. * Define if the texture is a cube texture or if false a 2d texture.
  30364. */
  30365. get isCube(): boolean;
  30366. set isCube(value: boolean);
  30367. /**
  30368. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30369. */
  30370. get is3D(): boolean;
  30371. set is3D(value: boolean);
  30372. /**
  30373. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30374. */
  30375. get is2DArray(): boolean;
  30376. set is2DArray(value: boolean);
  30377. /**
  30378. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30379. * HDR texture are usually stored in linear space.
  30380. * This only impacts the PBR and Background materials
  30381. */
  30382. gammaSpace: boolean;
  30383. /**
  30384. * Gets or sets whether or not the texture contains RGBD data.
  30385. */
  30386. get isRGBD(): boolean;
  30387. set isRGBD(value: boolean);
  30388. /**
  30389. * Is Z inverted in the texture (useful in a cube texture).
  30390. */
  30391. invertZ: boolean;
  30392. /**
  30393. * Are mip maps generated for this texture or not.
  30394. */
  30395. get noMipmap(): boolean;
  30396. /**
  30397. * @hidden
  30398. */
  30399. lodLevelInAlpha: boolean;
  30400. /**
  30401. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30402. */
  30403. get lodGenerationOffset(): number;
  30404. set lodGenerationOffset(value: number);
  30405. /**
  30406. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30407. */
  30408. get lodGenerationScale(): number;
  30409. set lodGenerationScale(value: number);
  30410. /**
  30411. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30412. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30413. * average roughness values.
  30414. */
  30415. get linearSpecularLOD(): boolean;
  30416. set linearSpecularLOD(value: boolean);
  30417. /**
  30418. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30419. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30420. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30421. */
  30422. get irradianceTexture(): Nullable<BaseTexture>;
  30423. set irradianceTexture(value: Nullable<BaseTexture>);
  30424. /**
  30425. * Define if the texture is a render target.
  30426. */
  30427. isRenderTarget: boolean;
  30428. /**
  30429. * Define the unique id of the texture in the scene.
  30430. */
  30431. get uid(): string;
  30432. /**
  30433. * Return a string representation of the texture.
  30434. * @returns the texture as a string
  30435. */
  30436. toString(): string;
  30437. /**
  30438. * Get the class name of the texture.
  30439. * @returns "BaseTexture"
  30440. */
  30441. getClassName(): string;
  30442. /**
  30443. * Define the list of animation attached to the texture.
  30444. */
  30445. animations: import("babylonjs/Animations/animation").Animation[];
  30446. /**
  30447. * An event triggered when the texture is disposed.
  30448. */
  30449. onDisposeObservable: Observable<BaseTexture>;
  30450. private _onDisposeObserver;
  30451. /**
  30452. * Callback triggered when the texture has been disposed.
  30453. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30454. */
  30455. set onDispose(callback: () => void);
  30456. /**
  30457. * Define the current state of the loading sequence when in delayed load mode.
  30458. */
  30459. delayLoadState: number;
  30460. private _scene;
  30461. /** @hidden */
  30462. _texture: Nullable<InternalTexture>;
  30463. private _uid;
  30464. /**
  30465. * Define if the texture is preventinga material to render or not.
  30466. * If not and the texture is not ready, the engine will use a default black texture instead.
  30467. */
  30468. get isBlocking(): boolean;
  30469. /**
  30470. * Instantiates a new BaseTexture.
  30471. * Base class of all the textures in babylon.
  30472. * It groups all the common properties the materials, post process, lights... might need
  30473. * in order to make a correct use of the texture.
  30474. * @param scene Define the scene the texture blongs to
  30475. */
  30476. constructor(scene: Nullable<Scene>);
  30477. /**
  30478. * Get the scene the texture belongs to.
  30479. * @returns the scene or null if undefined
  30480. */
  30481. getScene(): Nullable<Scene>;
  30482. /**
  30483. * Get the texture transform matrix used to offset tile the texture for istance.
  30484. * @returns the transformation matrix
  30485. */
  30486. getTextureMatrix(): Matrix;
  30487. /**
  30488. * Get the texture reflection matrix used to rotate/transform the reflection.
  30489. * @returns the reflection matrix
  30490. */
  30491. getReflectionTextureMatrix(): Matrix;
  30492. /**
  30493. * Get the underlying lower level texture from Babylon.
  30494. * @returns the insternal texture
  30495. */
  30496. getInternalTexture(): Nullable<InternalTexture>;
  30497. /**
  30498. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30499. * @returns true if ready or not blocking
  30500. */
  30501. isReadyOrNotBlocking(): boolean;
  30502. /**
  30503. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30504. * @returns true if fully ready
  30505. */
  30506. isReady(): boolean;
  30507. private _cachedSize;
  30508. /**
  30509. * Get the size of the texture.
  30510. * @returns the texture size.
  30511. */
  30512. getSize(): ISize;
  30513. /**
  30514. * Get the base size of the texture.
  30515. * It can be different from the size if the texture has been resized for POT for instance
  30516. * @returns the base size
  30517. */
  30518. getBaseSize(): ISize;
  30519. /**
  30520. * Update the sampling mode of the texture.
  30521. * Default is Trilinear mode.
  30522. *
  30523. * | Value | Type | Description |
  30524. * | ----- | ------------------ | ----------- |
  30525. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30526. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30527. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30528. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30529. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30530. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30531. * | 7 | NEAREST_LINEAR | |
  30532. * | 8 | NEAREST_NEAREST | |
  30533. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30534. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30535. * | 11 | LINEAR_LINEAR | |
  30536. * | 12 | LINEAR_NEAREST | |
  30537. *
  30538. * > _mag_: magnification filter (close to the viewer)
  30539. * > _min_: minification filter (far from the viewer)
  30540. * > _mip_: filter used between mip map levels
  30541. *@param samplingMode Define the new sampling mode of the texture
  30542. */
  30543. updateSamplingMode(samplingMode: number): void;
  30544. /**
  30545. * Scales the texture if is `canRescale()`
  30546. * @param ratio the resize factor we want to use to rescale
  30547. */
  30548. scale(ratio: number): void;
  30549. /**
  30550. * Get if the texture can rescale.
  30551. */
  30552. get canRescale(): boolean;
  30553. /** @hidden */
  30554. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30555. /** @hidden */
  30556. _rebuild(): void;
  30557. /**
  30558. * Triggers the load sequence in delayed load mode.
  30559. */
  30560. delayLoad(): void;
  30561. /**
  30562. * Clones the texture.
  30563. * @returns the cloned texture
  30564. */
  30565. clone(): Nullable<BaseTexture>;
  30566. /**
  30567. * Get the texture underlying type (INT, FLOAT...)
  30568. */
  30569. get textureType(): number;
  30570. /**
  30571. * Get the texture underlying format (RGB, RGBA...)
  30572. */
  30573. get textureFormat(): number;
  30574. /**
  30575. * Indicates that textures need to be re-calculated for all materials
  30576. */
  30577. protected _markAllSubMeshesAsTexturesDirty(): void;
  30578. /**
  30579. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30580. * This will returns an RGBA array buffer containing either in values (0-255) or
  30581. * float values (0-1) depending of the underlying buffer type.
  30582. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30583. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30584. * @param buffer defines a user defined buffer to fill with data (can be null)
  30585. * @returns The Array buffer containing the pixels data.
  30586. */
  30587. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30588. /**
  30589. * Release and destroy the underlying lower level texture aka internalTexture.
  30590. */
  30591. releaseInternalTexture(): void;
  30592. /** @hidden */
  30593. get _lodTextureHigh(): Nullable<BaseTexture>;
  30594. /** @hidden */
  30595. get _lodTextureMid(): Nullable<BaseTexture>;
  30596. /** @hidden */
  30597. get _lodTextureLow(): Nullable<BaseTexture>;
  30598. /**
  30599. * Dispose the texture and release its associated resources.
  30600. */
  30601. dispose(): void;
  30602. /**
  30603. * Serialize the texture into a JSON representation that can be parsed later on.
  30604. * @returns the JSON representation of the texture
  30605. */
  30606. serialize(): any;
  30607. /**
  30608. * Helper function to be called back once a list of texture contains only ready textures.
  30609. * @param textures Define the list of textures to wait for
  30610. * @param callback Define the callback triggered once the entire list will be ready
  30611. */
  30612. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30613. }
  30614. }
  30615. declare module "babylonjs/Materials/effect" {
  30616. import { Observable } from "babylonjs/Misc/observable";
  30617. import { Nullable } from "babylonjs/types";
  30618. import { IDisposable } from "babylonjs/scene";
  30619. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30620. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30621. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30622. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30623. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30624. import { Engine } from "babylonjs/Engines/engine";
  30625. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30626. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30627. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30628. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30629. /**
  30630. * Options to be used when creating an effect.
  30631. */
  30632. export interface IEffectCreationOptions {
  30633. /**
  30634. * Atrributes that will be used in the shader.
  30635. */
  30636. attributes: string[];
  30637. /**
  30638. * Uniform varible names that will be set in the shader.
  30639. */
  30640. uniformsNames: string[];
  30641. /**
  30642. * Uniform buffer variable names that will be set in the shader.
  30643. */
  30644. uniformBuffersNames: string[];
  30645. /**
  30646. * Sampler texture variable names that will be set in the shader.
  30647. */
  30648. samplers: string[];
  30649. /**
  30650. * Define statements that will be set in the shader.
  30651. */
  30652. defines: any;
  30653. /**
  30654. * Possible fallbacks for this effect to improve performance when needed.
  30655. */
  30656. fallbacks: Nullable<IEffectFallbacks>;
  30657. /**
  30658. * Callback that will be called when the shader is compiled.
  30659. */
  30660. onCompiled: Nullable<(effect: Effect) => void>;
  30661. /**
  30662. * Callback that will be called if an error occurs during shader compilation.
  30663. */
  30664. onError: Nullable<(effect: Effect, errors: string) => void>;
  30665. /**
  30666. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30667. */
  30668. indexParameters?: any;
  30669. /**
  30670. * Max number of lights that can be used in the shader.
  30671. */
  30672. maxSimultaneousLights?: number;
  30673. /**
  30674. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30675. */
  30676. transformFeedbackVaryings?: Nullable<string[]>;
  30677. }
  30678. /**
  30679. * Effect containing vertex and fragment shader that can be executed on an object.
  30680. */
  30681. export class Effect implements IDisposable {
  30682. /**
  30683. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30684. */
  30685. static ShadersRepository: string;
  30686. /**
  30687. * Name of the effect.
  30688. */
  30689. name: any;
  30690. /**
  30691. * String container all the define statements that should be set on the shader.
  30692. */
  30693. defines: string;
  30694. /**
  30695. * Callback that will be called when the shader is compiled.
  30696. */
  30697. onCompiled: Nullable<(effect: Effect) => void>;
  30698. /**
  30699. * Callback that will be called if an error occurs during shader compilation.
  30700. */
  30701. onError: Nullable<(effect: Effect, errors: string) => void>;
  30702. /**
  30703. * Callback that will be called when effect is bound.
  30704. */
  30705. onBind: Nullable<(effect: Effect) => void>;
  30706. /**
  30707. * Unique ID of the effect.
  30708. */
  30709. uniqueId: number;
  30710. /**
  30711. * Observable that will be called when the shader is compiled.
  30712. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30713. */
  30714. onCompileObservable: Observable<Effect>;
  30715. /**
  30716. * Observable that will be called if an error occurs during shader compilation.
  30717. */
  30718. onErrorObservable: Observable<Effect>;
  30719. /** @hidden */
  30720. _onBindObservable: Nullable<Observable<Effect>>;
  30721. /**
  30722. * Observable that will be called when effect is bound.
  30723. */
  30724. get onBindObservable(): Observable<Effect>;
  30725. /** @hidden */
  30726. _bonesComputationForcedToCPU: boolean;
  30727. private static _uniqueIdSeed;
  30728. private _engine;
  30729. private _uniformBuffersNames;
  30730. private _uniformsNames;
  30731. private _samplerList;
  30732. private _samplers;
  30733. private _isReady;
  30734. private _compilationError;
  30735. private _allFallbacksProcessed;
  30736. private _attributesNames;
  30737. private _attributes;
  30738. private _attributeLocationByName;
  30739. private _uniforms;
  30740. /**
  30741. * Key for the effect.
  30742. * @hidden
  30743. */
  30744. _key: string;
  30745. private _indexParameters;
  30746. private _fallbacks;
  30747. private _vertexSourceCode;
  30748. private _fragmentSourceCode;
  30749. private _vertexSourceCodeOverride;
  30750. private _fragmentSourceCodeOverride;
  30751. private _transformFeedbackVaryings;
  30752. /**
  30753. * Compiled shader to webGL program.
  30754. * @hidden
  30755. */
  30756. _pipelineContext: Nullable<IPipelineContext>;
  30757. private _valueCache;
  30758. private static _baseCache;
  30759. /**
  30760. * Instantiates an effect.
  30761. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30762. * @param baseName Name of the effect.
  30763. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30764. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30765. * @param samplers List of sampler variables that will be passed to the shader.
  30766. * @param engine Engine to be used to render the effect
  30767. * @param defines Define statements to be added to the shader.
  30768. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30769. * @param onCompiled Callback that will be called when the shader is compiled.
  30770. * @param onError Callback that will be called if an error occurs during shader compilation.
  30771. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30772. */
  30773. 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);
  30774. private _useFinalCode;
  30775. /**
  30776. * Unique key for this effect
  30777. */
  30778. get key(): string;
  30779. /**
  30780. * If the effect has been compiled and prepared.
  30781. * @returns if the effect is compiled and prepared.
  30782. */
  30783. isReady(): boolean;
  30784. private _isReadyInternal;
  30785. /**
  30786. * The engine the effect was initialized with.
  30787. * @returns the engine.
  30788. */
  30789. getEngine(): Engine;
  30790. /**
  30791. * The pipeline context for this effect
  30792. * @returns the associated pipeline context
  30793. */
  30794. getPipelineContext(): Nullable<IPipelineContext>;
  30795. /**
  30796. * The set of names of attribute variables for the shader.
  30797. * @returns An array of attribute names.
  30798. */
  30799. getAttributesNames(): string[];
  30800. /**
  30801. * Returns the attribute at the given index.
  30802. * @param index The index of the attribute.
  30803. * @returns The location of the attribute.
  30804. */
  30805. getAttributeLocation(index: number): number;
  30806. /**
  30807. * Returns the attribute based on the name of the variable.
  30808. * @param name of the attribute to look up.
  30809. * @returns the attribute location.
  30810. */
  30811. getAttributeLocationByName(name: string): number;
  30812. /**
  30813. * The number of attributes.
  30814. * @returns the numnber of attributes.
  30815. */
  30816. getAttributesCount(): number;
  30817. /**
  30818. * Gets the index of a uniform variable.
  30819. * @param uniformName of the uniform to look up.
  30820. * @returns the index.
  30821. */
  30822. getUniformIndex(uniformName: string): number;
  30823. /**
  30824. * Returns the attribute based on the name of the variable.
  30825. * @param uniformName of the uniform to look up.
  30826. * @returns the location of the uniform.
  30827. */
  30828. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30829. /**
  30830. * Returns an array of sampler variable names
  30831. * @returns The array of sampler variable neames.
  30832. */
  30833. getSamplers(): string[];
  30834. /**
  30835. * The error from the last compilation.
  30836. * @returns the error string.
  30837. */
  30838. getCompilationError(): string;
  30839. /**
  30840. * Gets a boolean indicating that all fallbacks were used during compilation
  30841. * @returns true if all fallbacks were used
  30842. */
  30843. allFallbacksProcessed(): boolean;
  30844. /**
  30845. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30846. * @param func The callback to be used.
  30847. */
  30848. executeWhenCompiled(func: (effect: Effect) => void): void;
  30849. private _checkIsReady;
  30850. private _loadShader;
  30851. /**
  30852. * Recompiles the webGL program
  30853. * @param vertexSourceCode The source code for the vertex shader.
  30854. * @param fragmentSourceCode The source code for the fragment shader.
  30855. * @param onCompiled Callback called when completed.
  30856. * @param onError Callback called on error.
  30857. * @hidden
  30858. */
  30859. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30860. /**
  30861. * Prepares the effect
  30862. * @hidden
  30863. */
  30864. _prepareEffect(): void;
  30865. private _processCompilationErrors;
  30866. /**
  30867. * Checks if the effect is supported. (Must be called after compilation)
  30868. */
  30869. get isSupported(): boolean;
  30870. /**
  30871. * Binds a texture to the engine to be used as output of the shader.
  30872. * @param channel Name of the output variable.
  30873. * @param texture Texture to bind.
  30874. * @hidden
  30875. */
  30876. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30877. /**
  30878. * Sets a texture on the engine to be used in the shader.
  30879. * @param channel Name of the sampler variable.
  30880. * @param texture Texture to set.
  30881. */
  30882. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30883. /**
  30884. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30885. * @param channel Name of the sampler variable.
  30886. * @param texture Texture to set.
  30887. */
  30888. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30889. /**
  30890. * Sets an array of textures on the engine to be used in the shader.
  30891. * @param channel Name of the variable.
  30892. * @param textures Textures to set.
  30893. */
  30894. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30895. /**
  30896. * 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)
  30897. * @param channel Name of the sampler variable.
  30898. * @param postProcess Post process to get the input texture from.
  30899. */
  30900. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30901. /**
  30902. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30903. * 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)
  30904. * @param channel Name of the sampler variable.
  30905. * @param postProcess Post process to get the output texture from.
  30906. */
  30907. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30908. /** @hidden */
  30909. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30910. /** @hidden */
  30911. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30912. /** @hidden */
  30913. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30914. /** @hidden */
  30915. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30916. /**
  30917. * Binds a buffer to a uniform.
  30918. * @param buffer Buffer to bind.
  30919. * @param name Name of the uniform variable to bind to.
  30920. */
  30921. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30922. /**
  30923. * Binds block to a uniform.
  30924. * @param blockName Name of the block to bind.
  30925. * @param index Index to bind.
  30926. */
  30927. bindUniformBlock(blockName: string, index: number): void;
  30928. /**
  30929. * Sets an interger value on a uniform variable.
  30930. * @param uniformName Name of the variable.
  30931. * @param value Value to be set.
  30932. * @returns this effect.
  30933. */
  30934. setInt(uniformName: string, value: number): Effect;
  30935. /**
  30936. * Sets an int array on a uniform variable.
  30937. * @param uniformName Name of the variable.
  30938. * @param array array to be set.
  30939. * @returns this effect.
  30940. */
  30941. setIntArray(uniformName: string, array: Int32Array): Effect;
  30942. /**
  30943. * 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)
  30944. * @param uniformName Name of the variable.
  30945. * @param array array to be set.
  30946. * @returns this effect.
  30947. */
  30948. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30949. /**
  30950. * 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)
  30951. * @param uniformName Name of the variable.
  30952. * @param array array to be set.
  30953. * @returns this effect.
  30954. */
  30955. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30956. /**
  30957. * 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)
  30958. * @param uniformName Name of the variable.
  30959. * @param array array to be set.
  30960. * @returns this effect.
  30961. */
  30962. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30963. /**
  30964. * Sets an float array on a uniform variable.
  30965. * @param uniformName Name of the variable.
  30966. * @param array array to be set.
  30967. * @returns this effect.
  30968. */
  30969. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30970. /**
  30971. * 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)
  30972. * @param uniformName Name of the variable.
  30973. * @param array array to be set.
  30974. * @returns this effect.
  30975. */
  30976. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30977. /**
  30978. * 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)
  30979. * @param uniformName Name of the variable.
  30980. * @param array array to be set.
  30981. * @returns this effect.
  30982. */
  30983. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30984. /**
  30985. * 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)
  30986. * @param uniformName Name of the variable.
  30987. * @param array array to be set.
  30988. * @returns this effect.
  30989. */
  30990. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30991. /**
  30992. * Sets an array on a uniform variable.
  30993. * @param uniformName Name of the variable.
  30994. * @param array array to be set.
  30995. * @returns this effect.
  30996. */
  30997. setArray(uniformName: string, array: number[]): Effect;
  30998. /**
  30999. * 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)
  31000. * @param uniformName Name of the variable.
  31001. * @param array array to be set.
  31002. * @returns this effect.
  31003. */
  31004. setArray2(uniformName: string, array: number[]): Effect;
  31005. /**
  31006. * 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)
  31007. * @param uniformName Name of the variable.
  31008. * @param array array to be set.
  31009. * @returns this effect.
  31010. */
  31011. setArray3(uniformName: string, array: number[]): Effect;
  31012. /**
  31013. * 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)
  31014. * @param uniformName Name of the variable.
  31015. * @param array array to be set.
  31016. * @returns this effect.
  31017. */
  31018. setArray4(uniformName: string, array: number[]): Effect;
  31019. /**
  31020. * Sets matrices on a uniform variable.
  31021. * @param uniformName Name of the variable.
  31022. * @param matrices matrices to be set.
  31023. * @returns this effect.
  31024. */
  31025. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31026. /**
  31027. * Sets matrix on a uniform variable.
  31028. * @param uniformName Name of the variable.
  31029. * @param matrix matrix to be set.
  31030. * @returns this effect.
  31031. */
  31032. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31033. /**
  31034. * 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)
  31035. * @param uniformName Name of the variable.
  31036. * @param matrix matrix to be set.
  31037. * @returns this effect.
  31038. */
  31039. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31040. /**
  31041. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31042. * @param uniformName Name of the variable.
  31043. * @param matrix matrix to be set.
  31044. * @returns this effect.
  31045. */
  31046. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31047. /**
  31048. * Sets a float on a uniform variable.
  31049. * @param uniformName Name of the variable.
  31050. * @param value value to be set.
  31051. * @returns this effect.
  31052. */
  31053. setFloat(uniformName: string, value: number): Effect;
  31054. /**
  31055. * Sets a boolean on a uniform variable.
  31056. * @param uniformName Name of the variable.
  31057. * @param bool value to be set.
  31058. * @returns this effect.
  31059. */
  31060. setBool(uniformName: string, bool: boolean): Effect;
  31061. /**
  31062. * Sets a Vector2 on a uniform variable.
  31063. * @param uniformName Name of the variable.
  31064. * @param vector2 vector2 to be set.
  31065. * @returns this effect.
  31066. */
  31067. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31068. /**
  31069. * Sets a float2 on a uniform variable.
  31070. * @param uniformName Name of the variable.
  31071. * @param x First float in float2.
  31072. * @param y Second float in float2.
  31073. * @returns this effect.
  31074. */
  31075. setFloat2(uniformName: string, x: number, y: number): Effect;
  31076. /**
  31077. * Sets a Vector3 on a uniform variable.
  31078. * @param uniformName Name of the variable.
  31079. * @param vector3 Value to be set.
  31080. * @returns this effect.
  31081. */
  31082. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31083. /**
  31084. * Sets a float3 on a uniform variable.
  31085. * @param uniformName Name of the variable.
  31086. * @param x First float in float3.
  31087. * @param y Second float in float3.
  31088. * @param z Third float in float3.
  31089. * @returns this effect.
  31090. */
  31091. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31092. /**
  31093. * Sets a Vector4 on a uniform variable.
  31094. * @param uniformName Name of the variable.
  31095. * @param vector4 Value to be set.
  31096. * @returns this effect.
  31097. */
  31098. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31099. /**
  31100. * Sets a float4 on a uniform variable.
  31101. * @param uniformName Name of the variable.
  31102. * @param x First float in float4.
  31103. * @param y Second float in float4.
  31104. * @param z Third float in float4.
  31105. * @param w Fourth float in float4.
  31106. * @returns this effect.
  31107. */
  31108. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31109. /**
  31110. * Sets a Color3 on a uniform variable.
  31111. * @param uniformName Name of the variable.
  31112. * @param color3 Value to be set.
  31113. * @returns this effect.
  31114. */
  31115. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31116. /**
  31117. * Sets a Color4 on a uniform variable.
  31118. * @param uniformName Name of the variable.
  31119. * @param color3 Value to be set.
  31120. * @param alpha Alpha value to be set.
  31121. * @returns this effect.
  31122. */
  31123. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31124. /**
  31125. * Sets a Color4 on a uniform variable
  31126. * @param uniformName defines the name of the variable
  31127. * @param color4 defines the value to be set
  31128. * @returns this effect.
  31129. */
  31130. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31131. /** Release all associated resources */
  31132. dispose(): void;
  31133. /**
  31134. * This function will add a new shader to the shader store
  31135. * @param name the name of the shader
  31136. * @param pixelShader optional pixel shader content
  31137. * @param vertexShader optional vertex shader content
  31138. */
  31139. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31140. /**
  31141. * Store of each shader (The can be looked up using effect.key)
  31142. */
  31143. static ShadersStore: {
  31144. [key: string]: string;
  31145. };
  31146. /**
  31147. * Store of each included file for a shader (The can be looked up using effect.key)
  31148. */
  31149. static IncludesShadersStore: {
  31150. [key: string]: string;
  31151. };
  31152. /**
  31153. * Resets the cache of effects.
  31154. */
  31155. static ResetCache(): void;
  31156. }
  31157. }
  31158. declare module "babylonjs/Engines/engineCapabilities" {
  31159. /**
  31160. * Interface used to describe the capabilities of the engine relatively to the current browser
  31161. */
  31162. export interface EngineCapabilities {
  31163. /** Maximum textures units per fragment shader */
  31164. maxTexturesImageUnits: number;
  31165. /** Maximum texture units per vertex shader */
  31166. maxVertexTextureImageUnits: number;
  31167. /** Maximum textures units in the entire pipeline */
  31168. maxCombinedTexturesImageUnits: number;
  31169. /** Maximum texture size */
  31170. maxTextureSize: number;
  31171. /** Maximum texture samples */
  31172. maxSamples?: number;
  31173. /** Maximum cube texture size */
  31174. maxCubemapTextureSize: number;
  31175. /** Maximum render texture size */
  31176. maxRenderTextureSize: number;
  31177. /** Maximum number of vertex attributes */
  31178. maxVertexAttribs: number;
  31179. /** Maximum number of varyings */
  31180. maxVaryingVectors: number;
  31181. /** Maximum number of uniforms per vertex shader */
  31182. maxVertexUniformVectors: number;
  31183. /** Maximum number of uniforms per fragment shader */
  31184. maxFragmentUniformVectors: number;
  31185. /** Defines if standard derivates (dx/dy) are supported */
  31186. standardDerivatives: boolean;
  31187. /** Defines if s3tc texture compression is supported */
  31188. s3tc?: WEBGL_compressed_texture_s3tc;
  31189. /** Defines if pvrtc texture compression is supported */
  31190. pvrtc: any;
  31191. /** Defines if etc1 texture compression is supported */
  31192. etc1: any;
  31193. /** Defines if etc2 texture compression is supported */
  31194. etc2: any;
  31195. /** Defines if astc texture compression is supported */
  31196. astc: any;
  31197. /** Defines if float textures are supported */
  31198. textureFloat: boolean;
  31199. /** Defines if vertex array objects are supported */
  31200. vertexArrayObject: boolean;
  31201. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31202. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31203. /** Gets the maximum level of anisotropy supported */
  31204. maxAnisotropy: number;
  31205. /** Defines if instancing is supported */
  31206. instancedArrays: boolean;
  31207. /** Defines if 32 bits indices are supported */
  31208. uintIndices: boolean;
  31209. /** Defines if high precision shaders are supported */
  31210. highPrecisionShaderSupported: boolean;
  31211. /** Defines if depth reading in the fragment shader is supported */
  31212. fragmentDepthSupported: boolean;
  31213. /** Defines if float texture linear filtering is supported*/
  31214. textureFloatLinearFiltering: boolean;
  31215. /** Defines if rendering to float textures is supported */
  31216. textureFloatRender: boolean;
  31217. /** Defines if half float textures are supported*/
  31218. textureHalfFloat: boolean;
  31219. /** Defines if half float texture linear filtering is supported*/
  31220. textureHalfFloatLinearFiltering: boolean;
  31221. /** Defines if rendering to half float textures is supported */
  31222. textureHalfFloatRender: boolean;
  31223. /** Defines if textureLOD shader command is supported */
  31224. textureLOD: boolean;
  31225. /** Defines if draw buffers extension is supported */
  31226. drawBuffersExtension: boolean;
  31227. /** Defines if depth textures are supported */
  31228. depthTextureExtension: boolean;
  31229. /** Defines if float color buffer are supported */
  31230. colorBufferFloat: boolean;
  31231. /** Gets disjoint timer query extension (null if not supported) */
  31232. timerQuery?: EXT_disjoint_timer_query;
  31233. /** Defines if timestamp can be used with timer query */
  31234. canUseTimestampForTimerQuery: boolean;
  31235. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31236. multiview?: any;
  31237. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31238. oculusMultiview?: any;
  31239. /** Function used to let the system compiles shaders in background */
  31240. parallelShaderCompile?: {
  31241. COMPLETION_STATUS_KHR: number;
  31242. };
  31243. /** Max number of texture samples for MSAA */
  31244. maxMSAASamples: number;
  31245. /** Defines if the blend min max extension is supported */
  31246. blendMinMax: boolean;
  31247. }
  31248. }
  31249. declare module "babylonjs/States/depthCullingState" {
  31250. import { Nullable } from "babylonjs/types";
  31251. /**
  31252. * @hidden
  31253. **/
  31254. export class DepthCullingState {
  31255. private _isDepthTestDirty;
  31256. private _isDepthMaskDirty;
  31257. private _isDepthFuncDirty;
  31258. private _isCullFaceDirty;
  31259. private _isCullDirty;
  31260. private _isZOffsetDirty;
  31261. private _isFrontFaceDirty;
  31262. private _depthTest;
  31263. private _depthMask;
  31264. private _depthFunc;
  31265. private _cull;
  31266. private _cullFace;
  31267. private _zOffset;
  31268. private _frontFace;
  31269. /**
  31270. * Initializes the state.
  31271. */
  31272. constructor();
  31273. get isDirty(): boolean;
  31274. get zOffset(): number;
  31275. set zOffset(value: number);
  31276. get cullFace(): Nullable<number>;
  31277. set cullFace(value: Nullable<number>);
  31278. get cull(): Nullable<boolean>;
  31279. set cull(value: Nullable<boolean>);
  31280. get depthFunc(): Nullable<number>;
  31281. set depthFunc(value: Nullable<number>);
  31282. get depthMask(): boolean;
  31283. set depthMask(value: boolean);
  31284. get depthTest(): boolean;
  31285. set depthTest(value: boolean);
  31286. get frontFace(): Nullable<number>;
  31287. set frontFace(value: Nullable<number>);
  31288. reset(): void;
  31289. apply(gl: WebGLRenderingContext): void;
  31290. }
  31291. }
  31292. declare module "babylonjs/States/stencilState" {
  31293. /**
  31294. * @hidden
  31295. **/
  31296. export class StencilState {
  31297. /** 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 */
  31298. static readonly ALWAYS: number;
  31299. /** Passed to stencilOperation to specify that stencil value must be kept */
  31300. static readonly KEEP: number;
  31301. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31302. static readonly REPLACE: number;
  31303. private _isStencilTestDirty;
  31304. private _isStencilMaskDirty;
  31305. private _isStencilFuncDirty;
  31306. private _isStencilOpDirty;
  31307. private _stencilTest;
  31308. private _stencilMask;
  31309. private _stencilFunc;
  31310. private _stencilFuncRef;
  31311. private _stencilFuncMask;
  31312. private _stencilOpStencilFail;
  31313. private _stencilOpDepthFail;
  31314. private _stencilOpStencilDepthPass;
  31315. get isDirty(): boolean;
  31316. get stencilFunc(): number;
  31317. set stencilFunc(value: number);
  31318. get stencilFuncRef(): number;
  31319. set stencilFuncRef(value: number);
  31320. get stencilFuncMask(): number;
  31321. set stencilFuncMask(value: number);
  31322. get stencilOpStencilFail(): number;
  31323. set stencilOpStencilFail(value: number);
  31324. get stencilOpDepthFail(): number;
  31325. set stencilOpDepthFail(value: number);
  31326. get stencilOpStencilDepthPass(): number;
  31327. set stencilOpStencilDepthPass(value: number);
  31328. get stencilMask(): number;
  31329. set stencilMask(value: number);
  31330. get stencilTest(): boolean;
  31331. set stencilTest(value: boolean);
  31332. constructor();
  31333. reset(): void;
  31334. apply(gl: WebGLRenderingContext): void;
  31335. }
  31336. }
  31337. declare module "babylonjs/States/alphaCullingState" {
  31338. /**
  31339. * @hidden
  31340. **/
  31341. export class AlphaState {
  31342. private _isAlphaBlendDirty;
  31343. private _isBlendFunctionParametersDirty;
  31344. private _isBlendEquationParametersDirty;
  31345. private _isBlendConstantsDirty;
  31346. private _alphaBlend;
  31347. private _blendFunctionParameters;
  31348. private _blendEquationParameters;
  31349. private _blendConstants;
  31350. /**
  31351. * Initializes the state.
  31352. */
  31353. constructor();
  31354. get isDirty(): boolean;
  31355. get alphaBlend(): boolean;
  31356. set alphaBlend(value: boolean);
  31357. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31358. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31359. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31360. reset(): void;
  31361. apply(gl: WebGLRenderingContext): void;
  31362. }
  31363. }
  31364. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31365. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31366. /** @hidden */
  31367. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31368. attributeProcessor(attribute: string): string;
  31369. varyingProcessor(varying: string, isFragment: boolean): string;
  31370. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31371. }
  31372. }
  31373. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31374. /**
  31375. * Interface for attribute information associated with buffer instanciation
  31376. */
  31377. export interface InstancingAttributeInfo {
  31378. /**
  31379. * Name of the GLSL attribute
  31380. * if attribute index is not specified, this is used to retrieve the index from the effect
  31381. */
  31382. attributeName: string;
  31383. /**
  31384. * Index/offset of the attribute in the vertex shader
  31385. * if not specified, this will be computes from the name.
  31386. */
  31387. index?: number;
  31388. /**
  31389. * size of the attribute, 1, 2, 3 or 4
  31390. */
  31391. attributeSize: number;
  31392. /**
  31393. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31394. */
  31395. offset: number;
  31396. /**
  31397. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31398. * default to 1
  31399. */
  31400. divisor?: number;
  31401. /**
  31402. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31403. * default is FLOAT
  31404. */
  31405. attributeType?: number;
  31406. /**
  31407. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31408. */
  31409. normalized?: boolean;
  31410. }
  31411. }
  31412. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31413. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31414. import { Nullable } from "babylonjs/types";
  31415. module "babylonjs/Engines/thinEngine" {
  31416. interface ThinEngine {
  31417. /**
  31418. * Update a video texture
  31419. * @param texture defines the texture to update
  31420. * @param video defines the video element to use
  31421. * @param invertY defines if data must be stored with Y axis inverted
  31422. */
  31423. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31424. }
  31425. }
  31426. }
  31427. declare module "babylonjs/Materials/Textures/videoTexture" {
  31428. import { Observable } from "babylonjs/Misc/observable";
  31429. import { Nullable } from "babylonjs/types";
  31430. import { Scene } from "babylonjs/scene";
  31431. import { Texture } from "babylonjs/Materials/Textures/texture";
  31432. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31433. /**
  31434. * Settings for finer control over video usage
  31435. */
  31436. export interface VideoTextureSettings {
  31437. /**
  31438. * Applies `autoplay` to video, if specified
  31439. */
  31440. autoPlay?: boolean;
  31441. /**
  31442. * Applies `loop` to video, if specified
  31443. */
  31444. loop?: boolean;
  31445. /**
  31446. * Automatically updates internal texture from video at every frame in the render loop
  31447. */
  31448. autoUpdateTexture: boolean;
  31449. /**
  31450. * Image src displayed during the video loading or until the user interacts with the video.
  31451. */
  31452. poster?: string;
  31453. }
  31454. /**
  31455. * If you want to display a video in your scene, this is the special texture for that.
  31456. * This special texture works similar to other textures, with the exception of a few parameters.
  31457. * @see https://doc.babylonjs.com/how_to/video_texture
  31458. */
  31459. export class VideoTexture extends Texture {
  31460. /**
  31461. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31462. */
  31463. readonly autoUpdateTexture: boolean;
  31464. /**
  31465. * The video instance used by the texture internally
  31466. */
  31467. readonly video: HTMLVideoElement;
  31468. private _onUserActionRequestedObservable;
  31469. /**
  31470. * Event triggerd when a dom action is required by the user to play the video.
  31471. * This happens due to recent changes in browser policies preventing video to auto start.
  31472. */
  31473. get onUserActionRequestedObservable(): Observable<Texture>;
  31474. private _generateMipMaps;
  31475. private _engine;
  31476. private _stillImageCaptured;
  31477. private _displayingPosterTexture;
  31478. private _settings;
  31479. private _createInternalTextureOnEvent;
  31480. private _frameId;
  31481. /**
  31482. * Creates a video texture.
  31483. * If you want to display a video in your scene, this is the special texture for that.
  31484. * This special texture works similar to other textures, with the exception of a few parameters.
  31485. * @see https://doc.babylonjs.com/how_to/video_texture
  31486. * @param name optional name, will detect from video source, if not defined
  31487. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31488. * @param scene is obviously the current scene.
  31489. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31490. * @param invertY is false by default but can be used to invert video on Y axis
  31491. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31492. * @param settings allows finer control over video usage
  31493. */
  31494. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31495. private _getName;
  31496. private _getVideo;
  31497. private _createInternalTexture;
  31498. private reset;
  31499. /**
  31500. * @hidden Internal method to initiate `update`.
  31501. */
  31502. _rebuild(): void;
  31503. /**
  31504. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31505. */
  31506. update(): void;
  31507. /**
  31508. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31509. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31510. */
  31511. updateTexture(isVisible: boolean): void;
  31512. protected _updateInternalTexture: () => void;
  31513. /**
  31514. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31515. * @param url New url.
  31516. */
  31517. updateURL(url: string): void;
  31518. /**
  31519. * Dispose the texture and release its associated resources.
  31520. */
  31521. dispose(): void;
  31522. /**
  31523. * Creates a video texture straight from a stream.
  31524. * @param scene Define the scene the texture should be created in
  31525. * @param stream Define the stream the texture should be created from
  31526. * @returns The created video texture as a promise
  31527. */
  31528. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31529. /**
  31530. * Creates a video texture straight from your WebCam video feed.
  31531. * @param scene Define the scene the texture should be created in
  31532. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31533. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31534. * @returns The created video texture as a promise
  31535. */
  31536. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31537. minWidth: number;
  31538. maxWidth: number;
  31539. minHeight: number;
  31540. maxHeight: number;
  31541. deviceId: string;
  31542. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31543. /**
  31544. * Creates a video texture straight from your WebCam video feed.
  31545. * @param scene Define the scene the texture should be created in
  31546. * @param onReady Define a callback to triggered once the texture will be ready
  31547. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31548. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31549. */
  31550. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31551. minWidth: number;
  31552. maxWidth: number;
  31553. minHeight: number;
  31554. maxHeight: number;
  31555. deviceId: string;
  31556. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31557. }
  31558. }
  31559. declare module "babylonjs/Engines/thinEngine" {
  31560. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31561. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31562. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31563. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31564. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31565. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31566. import { Observable } from "babylonjs/Misc/observable";
  31567. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31568. import { StencilState } from "babylonjs/States/stencilState";
  31569. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31570. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31571. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31572. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31573. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31574. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31575. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31576. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31577. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31578. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31579. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31580. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31581. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31582. import { WebRequest } from "babylonjs/Misc/webRequest";
  31583. import { LoadFileError } from "babylonjs/Misc/fileTools";
  31584. /**
  31585. * Defines the interface used by objects working like Scene
  31586. * @hidden
  31587. */
  31588. interface ISceneLike {
  31589. _addPendingData(data: any): void;
  31590. _removePendingData(data: any): void;
  31591. offlineProvider: IOfflineProvider;
  31592. }
  31593. /** Interface defining initialization parameters for Engine class */
  31594. export interface EngineOptions extends WebGLContextAttributes {
  31595. /**
  31596. * Defines if the engine should no exceed a specified device ratio
  31597. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31598. */
  31599. limitDeviceRatio?: number;
  31600. /**
  31601. * Defines if webvr should be enabled automatically
  31602. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31603. */
  31604. autoEnableWebVR?: boolean;
  31605. /**
  31606. * Defines if webgl2 should be turned off even if supported
  31607. * @see http://doc.babylonjs.com/features/webgl2
  31608. */
  31609. disableWebGL2Support?: boolean;
  31610. /**
  31611. * Defines if webaudio should be initialized as well
  31612. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31613. */
  31614. audioEngine?: boolean;
  31615. /**
  31616. * Defines if animations should run using a deterministic lock step
  31617. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31618. */
  31619. deterministicLockstep?: boolean;
  31620. /** Defines the maximum steps to use with deterministic lock step mode */
  31621. lockstepMaxSteps?: number;
  31622. /** Defines the seconds between each deterministic lock step */
  31623. timeStep?: number;
  31624. /**
  31625. * Defines that engine should ignore context lost events
  31626. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31627. */
  31628. doNotHandleContextLost?: boolean;
  31629. /**
  31630. * Defines that engine should ignore modifying touch action attribute and style
  31631. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31632. */
  31633. doNotHandleTouchAction?: boolean;
  31634. /**
  31635. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31636. */
  31637. useHighPrecisionFloats?: boolean;
  31638. }
  31639. /**
  31640. * The base engine class (root of all engines)
  31641. */
  31642. export class ThinEngine {
  31643. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31644. static ExceptionList: ({
  31645. key: string;
  31646. capture: string;
  31647. captureConstraint: number;
  31648. targets: string[];
  31649. } | {
  31650. key: string;
  31651. capture: null;
  31652. captureConstraint: null;
  31653. targets: string[];
  31654. })[];
  31655. /** @hidden */
  31656. static _TextureLoaders: IInternalTextureLoader[];
  31657. /**
  31658. * Returns the current npm package of the sdk
  31659. */
  31660. static get NpmPackage(): string;
  31661. /**
  31662. * Returns the current version of the framework
  31663. */
  31664. static get Version(): string;
  31665. /**
  31666. * Returns a string describing the current engine
  31667. */
  31668. get description(): string;
  31669. /**
  31670. * Gets or sets the epsilon value used by collision engine
  31671. */
  31672. static CollisionsEpsilon: number;
  31673. /**
  31674. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31675. */
  31676. static get ShadersRepository(): string;
  31677. static set ShadersRepository(value: string);
  31678. /**
  31679. * Gets or sets the textures that the engine should not attempt to load as compressed
  31680. */
  31681. protected _excludedCompressedTextures: string[];
  31682. /**
  31683. * Filters the compressed texture formats to only include
  31684. * files that are not included in the skippable list
  31685. *
  31686. * @param url the current extension
  31687. * @param textureFormatInUse the current compressed texture format
  31688. * @returns "format" string
  31689. */
  31690. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  31691. /** @hidden */
  31692. _shaderProcessor: IShaderProcessor;
  31693. /**
  31694. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31695. */
  31696. forcePOTTextures: boolean;
  31697. /**
  31698. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31699. */
  31700. isFullscreen: boolean;
  31701. /**
  31702. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31703. */
  31704. cullBackFaces: boolean;
  31705. /**
  31706. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31707. */
  31708. renderEvenInBackground: boolean;
  31709. /**
  31710. * Gets or sets a boolean indicating that cache can be kept between frames
  31711. */
  31712. preventCacheWipeBetweenFrames: boolean;
  31713. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31714. validateShaderPrograms: boolean;
  31715. /**
  31716. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31717. * This can provide greater z depth for distant objects.
  31718. */
  31719. useReverseDepthBuffer: boolean;
  31720. /**
  31721. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31722. */
  31723. disableUniformBuffers: boolean;
  31724. /** @hidden */
  31725. _uniformBuffers: UniformBuffer[];
  31726. /**
  31727. * Gets a boolean indicating that the engine supports uniform buffers
  31728. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31729. */
  31730. get supportsUniformBuffers(): boolean;
  31731. /** @hidden */
  31732. _gl: WebGLRenderingContext;
  31733. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31734. protected _windowIsBackground: boolean;
  31735. protected _webGLVersion: number;
  31736. protected _creationOptions: EngineOptions;
  31737. protected _highPrecisionShadersAllowed: boolean;
  31738. /** @hidden */
  31739. get _shouldUseHighPrecisionShader(): boolean;
  31740. /**
  31741. * Gets a boolean indicating that only power of 2 textures are supported
  31742. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31743. */
  31744. get needPOTTextures(): boolean;
  31745. /** @hidden */
  31746. _badOS: boolean;
  31747. /** @hidden */
  31748. _badDesktopOS: boolean;
  31749. private _hardwareScalingLevel;
  31750. /** @hidden */
  31751. _caps: EngineCapabilities;
  31752. private _isStencilEnable;
  31753. private _glVersion;
  31754. private _glRenderer;
  31755. private _glVendor;
  31756. /** @hidden */
  31757. _videoTextureSupported: boolean;
  31758. protected _renderingQueueLaunched: boolean;
  31759. protected _activeRenderLoops: (() => void)[];
  31760. /**
  31761. * Observable signaled when a context lost event is raised
  31762. */
  31763. onContextLostObservable: Observable<ThinEngine>;
  31764. /**
  31765. * Observable signaled when a context restored event is raised
  31766. */
  31767. onContextRestoredObservable: Observable<ThinEngine>;
  31768. private _onContextLost;
  31769. private _onContextRestored;
  31770. protected _contextWasLost: boolean;
  31771. /** @hidden */
  31772. _doNotHandleContextLost: boolean;
  31773. /**
  31774. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31775. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31776. */
  31777. get doNotHandleContextLost(): boolean;
  31778. set doNotHandleContextLost(value: boolean);
  31779. /**
  31780. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31781. */
  31782. disableVertexArrayObjects: boolean;
  31783. /** @hidden */
  31784. protected _colorWrite: boolean;
  31785. /** @hidden */
  31786. protected _colorWriteChanged: boolean;
  31787. /** @hidden */
  31788. protected _depthCullingState: DepthCullingState;
  31789. /** @hidden */
  31790. protected _stencilState: StencilState;
  31791. /** @hidden */
  31792. _alphaState: AlphaState;
  31793. /** @hidden */
  31794. _alphaMode: number;
  31795. /** @hidden */
  31796. _alphaEquation: number;
  31797. /** @hidden */
  31798. _internalTexturesCache: InternalTexture[];
  31799. /** @hidden */
  31800. protected _activeChannel: number;
  31801. private _currentTextureChannel;
  31802. /** @hidden */
  31803. protected _boundTexturesCache: {
  31804. [key: string]: Nullable<InternalTexture>;
  31805. };
  31806. /** @hidden */
  31807. protected _currentEffect: Nullable<Effect>;
  31808. /** @hidden */
  31809. protected _currentProgram: Nullable<WebGLProgram>;
  31810. private _compiledEffects;
  31811. private _vertexAttribArraysEnabled;
  31812. /** @hidden */
  31813. protected _cachedViewport: Nullable<IViewportLike>;
  31814. private _cachedVertexArrayObject;
  31815. /** @hidden */
  31816. protected _cachedVertexBuffers: any;
  31817. /** @hidden */
  31818. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31819. /** @hidden */
  31820. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31821. /** @hidden */
  31822. _currentRenderTarget: Nullable<InternalTexture>;
  31823. private _uintIndicesCurrentlySet;
  31824. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31825. /** @hidden */
  31826. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31827. private _currentBufferPointers;
  31828. private _currentInstanceLocations;
  31829. private _currentInstanceBuffers;
  31830. private _textureUnits;
  31831. /** @hidden */
  31832. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31833. /** @hidden */
  31834. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31835. /** @hidden */
  31836. _boundRenderFunction: any;
  31837. private _vaoRecordInProgress;
  31838. private _mustWipeVertexAttributes;
  31839. private _emptyTexture;
  31840. private _emptyCubeTexture;
  31841. private _emptyTexture3D;
  31842. private _emptyTexture2DArray;
  31843. /** @hidden */
  31844. _frameHandler: number;
  31845. private _nextFreeTextureSlots;
  31846. private _maxSimultaneousTextures;
  31847. private _activeRequests;
  31848. protected _texturesSupported: string[];
  31849. /** @hidden */
  31850. _textureFormatInUse: Nullable<string>;
  31851. protected get _supportsHardwareTextureRescaling(): boolean;
  31852. /**
  31853. * Gets the list of texture formats supported
  31854. */
  31855. get texturesSupported(): Array<string>;
  31856. /**
  31857. * Gets the list of texture formats in use
  31858. */
  31859. get textureFormatInUse(): Nullable<string>;
  31860. /**
  31861. * Gets the current viewport
  31862. */
  31863. get currentViewport(): Nullable<IViewportLike>;
  31864. /**
  31865. * Gets the default empty texture
  31866. */
  31867. get emptyTexture(): InternalTexture;
  31868. /**
  31869. * Gets the default empty 3D texture
  31870. */
  31871. get emptyTexture3D(): InternalTexture;
  31872. /**
  31873. * Gets the default empty 2D array texture
  31874. */
  31875. get emptyTexture2DArray(): InternalTexture;
  31876. /**
  31877. * Gets the default empty cube texture
  31878. */
  31879. get emptyCubeTexture(): InternalTexture;
  31880. /**
  31881. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31882. */
  31883. readonly premultipliedAlpha: boolean;
  31884. /**
  31885. * Observable event triggered before each texture is initialized
  31886. */
  31887. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  31888. /**
  31889. * Creates a new engine
  31890. * @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
  31891. * @param antialias defines enable antialiasing (default: false)
  31892. * @param options defines further options to be sent to the getContext() function
  31893. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31894. */
  31895. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31896. private _rebuildInternalTextures;
  31897. private _rebuildEffects;
  31898. /**
  31899. * Gets a boolean indicating if all created effects are ready
  31900. * @returns true if all effects are ready
  31901. */
  31902. areAllEffectsReady(): boolean;
  31903. protected _rebuildBuffers(): void;
  31904. private _initGLContext;
  31905. /**
  31906. * Gets version of the current webGL context
  31907. */
  31908. get webGLVersion(): number;
  31909. /**
  31910. * Gets a string idenfifying the name of the class
  31911. * @returns "Engine" string
  31912. */
  31913. getClassName(): string;
  31914. /**
  31915. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31916. */
  31917. get isStencilEnable(): boolean;
  31918. /** @hidden */
  31919. _prepareWorkingCanvas(): void;
  31920. /**
  31921. * Reset the texture cache to empty state
  31922. */
  31923. resetTextureCache(): void;
  31924. /**
  31925. * Gets an object containing information about the current webGL context
  31926. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31927. */
  31928. getGlInfo(): {
  31929. vendor: string;
  31930. renderer: string;
  31931. version: string;
  31932. };
  31933. /**
  31934. * Defines the hardware scaling level.
  31935. * By default the hardware scaling level is computed from the window device ratio.
  31936. * 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.
  31937. * @param level defines the level to use
  31938. */
  31939. setHardwareScalingLevel(level: number): void;
  31940. /**
  31941. * Gets the current hardware scaling level.
  31942. * By default the hardware scaling level is computed from the window device ratio.
  31943. * 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.
  31944. * @returns a number indicating the current hardware scaling level
  31945. */
  31946. getHardwareScalingLevel(): number;
  31947. /**
  31948. * Gets the list of loaded textures
  31949. * @returns an array containing all loaded textures
  31950. */
  31951. getLoadedTexturesCache(): InternalTexture[];
  31952. /**
  31953. * Gets the object containing all engine capabilities
  31954. * @returns the EngineCapabilities object
  31955. */
  31956. getCaps(): EngineCapabilities;
  31957. /**
  31958. * stop executing a render loop function and remove it from the execution array
  31959. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31960. */
  31961. stopRenderLoop(renderFunction?: () => void): void;
  31962. /** @hidden */
  31963. _renderLoop(): void;
  31964. /**
  31965. * Gets the HTML canvas attached with the current webGL context
  31966. * @returns a HTML canvas
  31967. */
  31968. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31969. /**
  31970. * Gets host window
  31971. * @returns the host window object
  31972. */
  31973. getHostWindow(): Nullable<Window>;
  31974. /**
  31975. * Gets the current render width
  31976. * @param useScreen defines if screen size must be used (or the current render target if any)
  31977. * @returns a number defining the current render width
  31978. */
  31979. getRenderWidth(useScreen?: boolean): number;
  31980. /**
  31981. * Gets the current render height
  31982. * @param useScreen defines if screen size must be used (or the current render target if any)
  31983. * @returns a number defining the current render height
  31984. */
  31985. getRenderHeight(useScreen?: boolean): number;
  31986. /**
  31987. * Can be used to override the current requestAnimationFrame requester.
  31988. * @hidden
  31989. */
  31990. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31991. /**
  31992. * Register and execute a render loop. The engine can have more than one render function
  31993. * @param renderFunction defines the function to continuously execute
  31994. */
  31995. runRenderLoop(renderFunction: () => void): void;
  31996. /**
  31997. * Clear the current render buffer or the current render target (if any is set up)
  31998. * @param color defines the color to use
  31999. * @param backBuffer defines if the back buffer must be cleared
  32000. * @param depth defines if the depth buffer must be cleared
  32001. * @param stencil defines if the stencil buffer must be cleared
  32002. */
  32003. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32004. private _viewportCached;
  32005. /** @hidden */
  32006. _viewport(x: number, y: number, width: number, height: number): void;
  32007. /**
  32008. * Set the WebGL's viewport
  32009. * @param viewport defines the viewport element to be used
  32010. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32011. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32012. */
  32013. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32014. /**
  32015. * Begin a new frame
  32016. */
  32017. beginFrame(): void;
  32018. /**
  32019. * Enf the current frame
  32020. */
  32021. endFrame(): void;
  32022. /**
  32023. * Resize the view according to the canvas' size
  32024. */
  32025. resize(): void;
  32026. /**
  32027. * Force a specific size of the canvas
  32028. * @param width defines the new canvas' width
  32029. * @param height defines the new canvas' height
  32030. */
  32031. setSize(width: number, height: number): void;
  32032. /**
  32033. * Binds the frame buffer to the specified texture.
  32034. * @param texture The texture to render to or null for the default canvas
  32035. * @param faceIndex The face of the texture to render to in case of cube texture
  32036. * @param requiredWidth The width of the target to render to
  32037. * @param requiredHeight The height of the target to render to
  32038. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32039. * @param depthStencilTexture The depth stencil texture to use to render
  32040. * @param lodLevel defines le lod level to bind to the frame buffer
  32041. */
  32042. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  32043. /** @hidden */
  32044. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32045. /**
  32046. * Unbind the current render target texture from the webGL context
  32047. * @param texture defines the render target texture to unbind
  32048. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32049. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32050. */
  32051. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32052. /**
  32053. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32054. */
  32055. flushFramebuffer(): void;
  32056. /**
  32057. * Unbind the current render target and bind the default framebuffer
  32058. */
  32059. restoreDefaultFramebuffer(): void;
  32060. /** @hidden */
  32061. protected _resetVertexBufferBinding(): void;
  32062. /**
  32063. * Creates a vertex buffer
  32064. * @param data the data for the vertex buffer
  32065. * @returns the new WebGL static buffer
  32066. */
  32067. createVertexBuffer(data: DataArray): DataBuffer;
  32068. private _createVertexBuffer;
  32069. /**
  32070. * Creates a dynamic vertex buffer
  32071. * @param data the data for the dynamic vertex buffer
  32072. * @returns the new WebGL dynamic buffer
  32073. */
  32074. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32075. protected _resetIndexBufferBinding(): void;
  32076. /**
  32077. * Creates a new index buffer
  32078. * @param indices defines the content of the index buffer
  32079. * @param updatable defines if the index buffer must be updatable
  32080. * @returns a new webGL buffer
  32081. */
  32082. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32083. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32084. /**
  32085. * Bind a webGL buffer to the webGL context
  32086. * @param buffer defines the buffer to bind
  32087. */
  32088. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32089. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32090. private bindBuffer;
  32091. /**
  32092. * update the bound buffer with the given data
  32093. * @param data defines the data to update
  32094. */
  32095. updateArrayBuffer(data: Float32Array): void;
  32096. private _vertexAttribPointer;
  32097. private _bindIndexBufferWithCache;
  32098. private _bindVertexBuffersAttributes;
  32099. /**
  32100. * Records a vertex array object
  32101. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32102. * @param vertexBuffers defines the list of vertex buffers to store
  32103. * @param indexBuffer defines the index buffer to store
  32104. * @param effect defines the effect to store
  32105. * @returns the new vertex array object
  32106. */
  32107. recordVertexArrayObject(vertexBuffers: {
  32108. [key: string]: VertexBuffer;
  32109. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32110. /**
  32111. * Bind a specific vertex array object
  32112. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32113. * @param vertexArrayObject defines the vertex array object to bind
  32114. * @param indexBuffer defines the index buffer to bind
  32115. */
  32116. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32117. /**
  32118. * Bind webGl buffers directly to the webGL context
  32119. * @param vertexBuffer defines the vertex buffer to bind
  32120. * @param indexBuffer defines the index buffer to bind
  32121. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32122. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32123. * @param effect defines the effect associated with the vertex buffer
  32124. */
  32125. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32126. private _unbindVertexArrayObject;
  32127. /**
  32128. * Bind a list of vertex buffers to the webGL context
  32129. * @param vertexBuffers defines the list of vertex buffers to bind
  32130. * @param indexBuffer defines the index buffer to bind
  32131. * @param effect defines the effect associated with the vertex buffers
  32132. */
  32133. bindBuffers(vertexBuffers: {
  32134. [key: string]: Nullable<VertexBuffer>;
  32135. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32136. /**
  32137. * Unbind all instance attributes
  32138. */
  32139. unbindInstanceAttributes(): void;
  32140. /**
  32141. * Release and free the memory of a vertex array object
  32142. * @param vao defines the vertex array object to delete
  32143. */
  32144. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32145. /** @hidden */
  32146. _releaseBuffer(buffer: DataBuffer): boolean;
  32147. protected _deleteBuffer(buffer: DataBuffer): void;
  32148. /**
  32149. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32150. * @param instancesBuffer defines the webGL buffer to update and bind
  32151. * @param data defines the data to store in the buffer
  32152. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32153. */
  32154. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32155. /**
  32156. * Bind the content of a webGL buffer used with instanciation
  32157. * @param instancesBuffer defines the webGL buffer to bind
  32158. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32159. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  32160. */
  32161. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32162. /**
  32163. * Disable the instance attribute corresponding to the name in parameter
  32164. * @param name defines the name of the attribute to disable
  32165. */
  32166. disableInstanceAttributeByName(name: string): void;
  32167. /**
  32168. * Disable the instance attribute corresponding to the location in parameter
  32169. * @param attributeLocation defines the attribute location of the attribute to disable
  32170. */
  32171. disableInstanceAttribute(attributeLocation: number): void;
  32172. /**
  32173. * Disable the attribute corresponding to the location in parameter
  32174. * @param attributeLocation defines the attribute location of the attribute to disable
  32175. */
  32176. disableAttributeByIndex(attributeLocation: number): void;
  32177. /**
  32178. * Send a draw order
  32179. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32180. * @param indexStart defines the starting index
  32181. * @param indexCount defines the number of index to draw
  32182. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32183. */
  32184. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32185. /**
  32186. * Draw a list of points
  32187. * @param verticesStart defines the index of first vertex to draw
  32188. * @param verticesCount defines the count of vertices to draw
  32189. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32190. */
  32191. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32192. /**
  32193. * Draw a list of unindexed primitives
  32194. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32195. * @param verticesStart defines the index of first vertex to draw
  32196. * @param verticesCount defines the count of vertices to draw
  32197. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32198. */
  32199. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32200. /**
  32201. * Draw a list of indexed primitives
  32202. * @param fillMode defines the primitive to use
  32203. * @param indexStart defines the starting index
  32204. * @param indexCount defines the number of index to draw
  32205. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32206. */
  32207. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32208. /**
  32209. * Draw a list of unindexed primitives
  32210. * @param fillMode defines the primitive to use
  32211. * @param verticesStart defines the index of first vertex to draw
  32212. * @param verticesCount defines the count of vertices to draw
  32213. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32214. */
  32215. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32216. private _drawMode;
  32217. /** @hidden */
  32218. protected _reportDrawCall(): void;
  32219. /** @hidden */
  32220. _releaseEffect(effect: Effect): void;
  32221. /** @hidden */
  32222. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32223. /**
  32224. * Create a new effect (used to store vertex/fragment shaders)
  32225. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32226. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32227. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32228. * @param samplers defines an array of string used to represent textures
  32229. * @param defines defines the string containing the defines to use to compile the shaders
  32230. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32231. * @param onCompiled defines a function to call when the effect creation is successful
  32232. * @param onError defines a function to call when the effect creation has failed
  32233. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32234. * @returns the new Effect
  32235. */
  32236. 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;
  32237. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32238. private _compileShader;
  32239. private _compileRawShader;
  32240. /**
  32241. * Directly creates a webGL program
  32242. * @param pipelineContext defines the pipeline context to attach to
  32243. * @param vertexCode defines the vertex shader code to use
  32244. * @param fragmentCode defines the fragment shader code to use
  32245. * @param context defines the webGL context to use (if not set, the current one will be used)
  32246. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32247. * @returns the new webGL program
  32248. */
  32249. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32250. /**
  32251. * Creates a webGL program
  32252. * @param pipelineContext defines the pipeline context to attach to
  32253. * @param vertexCode defines the vertex shader code to use
  32254. * @param fragmentCode defines the fragment shader code to use
  32255. * @param defines defines the string containing the defines to use to compile the shaders
  32256. * @param context defines the webGL context to use (if not set, the current one will be used)
  32257. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32258. * @returns the new webGL program
  32259. */
  32260. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32261. /**
  32262. * Creates a new pipeline context
  32263. * @returns the new pipeline
  32264. */
  32265. createPipelineContext(): IPipelineContext;
  32266. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32267. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32268. /** @hidden */
  32269. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32270. /** @hidden */
  32271. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32272. /** @hidden */
  32273. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32274. /**
  32275. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32276. * @param pipelineContext defines the pipeline context to use
  32277. * @param uniformsNames defines the list of uniform names
  32278. * @returns an array of webGL uniform locations
  32279. */
  32280. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32281. /**
  32282. * Gets the lsit of active attributes for a given webGL program
  32283. * @param pipelineContext defines the pipeline context to use
  32284. * @param attributesNames defines the list of attribute names to get
  32285. * @returns an array of indices indicating the offset of each attribute
  32286. */
  32287. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32288. /**
  32289. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32290. * @param effect defines the effect to activate
  32291. */
  32292. enableEffect(effect: Nullable<Effect>): void;
  32293. /**
  32294. * Set the value of an uniform to a number (int)
  32295. * @param uniform defines the webGL uniform location where to store the value
  32296. * @param value defines the int number to store
  32297. */
  32298. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32299. /**
  32300. * Set the value of an uniform to an array of int32
  32301. * @param uniform defines the webGL uniform location where to store the value
  32302. * @param array defines the array of int32 to store
  32303. */
  32304. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32305. /**
  32306. * Set the value of an uniform to an array of int32 (stored as vec2)
  32307. * @param uniform defines the webGL uniform location where to store the value
  32308. * @param array defines the array of int32 to store
  32309. */
  32310. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32311. /**
  32312. * Set the value of an uniform to an array of int32 (stored as vec3)
  32313. * @param uniform defines the webGL uniform location where to store the value
  32314. * @param array defines the array of int32 to store
  32315. */
  32316. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32317. /**
  32318. * Set the value of an uniform to an array of int32 (stored as vec4)
  32319. * @param uniform defines the webGL uniform location where to store the value
  32320. * @param array defines the array of int32 to store
  32321. */
  32322. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32323. /**
  32324. * Set the value of an uniform to an array of number
  32325. * @param uniform defines the webGL uniform location where to store the value
  32326. * @param array defines the array of number to store
  32327. */
  32328. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32329. /**
  32330. * Set the value of an uniform to an array of number (stored as vec2)
  32331. * @param uniform defines the webGL uniform location where to store the value
  32332. * @param array defines the array of number to store
  32333. */
  32334. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32335. /**
  32336. * Set the value of an uniform to an array of number (stored as vec3)
  32337. * @param uniform defines the webGL uniform location where to store the value
  32338. * @param array defines the array of number to store
  32339. */
  32340. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32341. /**
  32342. * Set the value of an uniform to an array of number (stored as vec4)
  32343. * @param uniform defines the webGL uniform location where to store the value
  32344. * @param array defines the array of number to store
  32345. */
  32346. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32347. /**
  32348. * Set the value of an uniform to an array of float32 (stored as matrices)
  32349. * @param uniform defines the webGL uniform location where to store the value
  32350. * @param matrices defines the array of float32 to store
  32351. */
  32352. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32353. /**
  32354. * Set the value of an uniform to a matrix (3x3)
  32355. * @param uniform defines the webGL uniform location where to store the value
  32356. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32357. */
  32358. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32359. /**
  32360. * Set the value of an uniform to a matrix (2x2)
  32361. * @param uniform defines the webGL uniform location where to store the value
  32362. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32363. */
  32364. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32365. /**
  32366. * Set the value of an uniform to a number (float)
  32367. * @param uniform defines the webGL uniform location where to store the value
  32368. * @param value defines the float number to store
  32369. */
  32370. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32371. /**
  32372. * Set the value of an uniform to a vec2
  32373. * @param uniform defines the webGL uniform location where to store the value
  32374. * @param x defines the 1st component of the value
  32375. * @param y defines the 2nd component of the value
  32376. */
  32377. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32378. /**
  32379. * Set the value of an uniform to a vec3
  32380. * @param uniform defines the webGL uniform location where to store the value
  32381. * @param x defines the 1st component of the value
  32382. * @param y defines the 2nd component of the value
  32383. * @param z defines the 3rd component of the value
  32384. */
  32385. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32386. /**
  32387. * Set the value of an uniform to a vec4
  32388. * @param uniform defines the webGL uniform location where to store the value
  32389. * @param x defines the 1st component of the value
  32390. * @param y defines the 2nd component of the value
  32391. * @param z defines the 3rd component of the value
  32392. * @param w defines the 4th component of the value
  32393. */
  32394. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32395. /**
  32396. * Apply all cached states (depth, culling, stencil and alpha)
  32397. */
  32398. applyStates(): void;
  32399. /**
  32400. * Enable or disable color writing
  32401. * @param enable defines the state to set
  32402. */
  32403. setColorWrite(enable: boolean): void;
  32404. /**
  32405. * Gets a boolean indicating if color writing is enabled
  32406. * @returns the current color writing state
  32407. */
  32408. getColorWrite(): boolean;
  32409. /**
  32410. * Gets the depth culling state manager
  32411. */
  32412. get depthCullingState(): DepthCullingState;
  32413. /**
  32414. * Gets the alpha state manager
  32415. */
  32416. get alphaState(): AlphaState;
  32417. /**
  32418. * Gets the stencil state manager
  32419. */
  32420. get stencilState(): StencilState;
  32421. /**
  32422. * Clears the list of texture accessible through engine.
  32423. * This can help preventing texture load conflict due to name collision.
  32424. */
  32425. clearInternalTexturesCache(): void;
  32426. /**
  32427. * Force the entire cache to be cleared
  32428. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32429. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32430. */
  32431. wipeCaches(bruteForce?: boolean): void;
  32432. /** @hidden */
  32433. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32434. min: number;
  32435. mag: number;
  32436. };
  32437. /** @hidden */
  32438. _createTexture(): WebGLTexture;
  32439. /**
  32440. * Usually called from Texture.ts.
  32441. * Passed information to create a WebGLTexture
  32442. * @param urlArg defines a value which contains one of the following:
  32443. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32444. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32445. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32446. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32447. * @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)
  32448. * @param scene needed for loading to the correct scene
  32449. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32450. * @param onLoad optional callback to be called upon successful completion
  32451. * @param onError optional callback to be called upon failure
  32452. * @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
  32453. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32454. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32455. * @param forcedExtension defines the extension to use to pick the right loader
  32456. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32457. * @param mimeType defines an optional mime type
  32458. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32459. */
  32460. 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;
  32461. /**
  32462. * Loads an image as an HTMLImageElement.
  32463. * @param input url string, ArrayBuffer, or Blob to load
  32464. * @param onLoad callback called when the image successfully loads
  32465. * @param onError callback called when the image fails to load
  32466. * @param offlineProvider offline provider for caching
  32467. * @param mimeType optional mime type
  32468. * @returns the HTMLImageElement of the loaded image
  32469. * @hidden
  32470. */
  32471. 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>;
  32472. /**
  32473. * @hidden
  32474. */
  32475. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32476. /**
  32477. * Creates a raw texture
  32478. * @param data defines the data to store in the texture
  32479. * @param width defines the width of the texture
  32480. * @param height defines the height of the texture
  32481. * @param format defines the format of the data
  32482. * @param generateMipMaps defines if the engine should generate the mip levels
  32483. * @param invertY defines if data must be stored with Y axis inverted
  32484. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32485. * @param compression defines the compression used (null by default)
  32486. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32487. * @returns the raw texture inside an InternalTexture
  32488. */
  32489. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32490. /**
  32491. * Creates a new raw cube texture
  32492. * @param data defines the array of data to use to create each face
  32493. * @param size defines the size of the textures
  32494. * @param format defines the format of the data
  32495. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32496. * @param generateMipMaps defines if the engine should generate the mip levels
  32497. * @param invertY defines if data must be stored with Y axis inverted
  32498. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32499. * @param compression defines the compression used (null by default)
  32500. * @returns the cube texture as an InternalTexture
  32501. */
  32502. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32503. /**
  32504. * Creates a new raw 3D texture
  32505. * @param data defines the data used to create the texture
  32506. * @param width defines the width of the texture
  32507. * @param height defines the height of the texture
  32508. * @param depth defines the depth of the texture
  32509. * @param format defines the format of the texture
  32510. * @param generateMipMaps defines if the engine must generate mip levels
  32511. * @param invertY defines if data must be stored with Y axis inverted
  32512. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32513. * @param compression defines the compressed used (can be null)
  32514. * @param textureType defines the compressed used (can be null)
  32515. * @returns a new raw 3D texture (stored in an InternalTexture)
  32516. */
  32517. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32518. /**
  32519. * Creates a new raw 2D array texture
  32520. * @param data defines the data used to create the texture
  32521. * @param width defines the width of the texture
  32522. * @param height defines the height of the texture
  32523. * @param depth defines the number of layers of the texture
  32524. * @param format defines the format of the texture
  32525. * @param generateMipMaps defines if the engine must generate mip levels
  32526. * @param invertY defines if data must be stored with Y axis inverted
  32527. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32528. * @param compression defines the compressed used (can be null)
  32529. * @param textureType defines the compressed used (can be null)
  32530. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32531. */
  32532. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32533. private _unpackFlipYCached;
  32534. /**
  32535. * In case you are sharing the context with other applications, it might
  32536. * be interested to not cache the unpack flip y state to ensure a consistent
  32537. * value would be set.
  32538. */
  32539. enableUnpackFlipYCached: boolean;
  32540. /** @hidden */
  32541. _unpackFlipY(value: boolean): void;
  32542. /** @hidden */
  32543. _getUnpackAlignement(): number;
  32544. private _getTextureTarget;
  32545. /**
  32546. * Update the sampling mode of a given texture
  32547. * @param samplingMode defines the required sampling mode
  32548. * @param texture defines the texture to update
  32549. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32550. */
  32551. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32552. /**
  32553. * Update the sampling mode of a given texture
  32554. * @param texture defines the texture to update
  32555. * @param wrapU defines the texture wrap mode of the u coordinates
  32556. * @param wrapV defines the texture wrap mode of the v coordinates
  32557. * @param wrapR defines the texture wrap mode of the r coordinates
  32558. */
  32559. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32560. /** @hidden */
  32561. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32562. width: number;
  32563. height: number;
  32564. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32565. /** @hidden */
  32566. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32567. /** @hidden */
  32568. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32569. /** @hidden */
  32570. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32571. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32572. private _prepareWebGLTexture;
  32573. /** @hidden */
  32574. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32575. private _getDepthStencilBuffer;
  32576. /** @hidden */
  32577. _releaseFramebufferObjects(texture: InternalTexture): void;
  32578. /** @hidden */
  32579. _releaseTexture(texture: InternalTexture): void;
  32580. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32581. protected _setProgram(program: WebGLProgram): void;
  32582. protected _boundUniforms: {
  32583. [key: number]: WebGLUniformLocation;
  32584. };
  32585. /**
  32586. * Binds an effect to the webGL context
  32587. * @param effect defines the effect to bind
  32588. */
  32589. bindSamplers(effect: Effect): void;
  32590. private _activateCurrentTexture;
  32591. /** @hidden */
  32592. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32593. /** @hidden */
  32594. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32595. /**
  32596. * Unbind all textures from the webGL context
  32597. */
  32598. unbindAllTextures(): void;
  32599. /**
  32600. * Sets a texture to the according uniform.
  32601. * @param channel The texture channel
  32602. * @param uniform The uniform to set
  32603. * @param texture The texture to apply
  32604. */
  32605. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32606. private _bindSamplerUniformToChannel;
  32607. private _getTextureWrapMode;
  32608. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32609. /**
  32610. * Sets an array of texture to the webGL context
  32611. * @param channel defines the channel where the texture array must be set
  32612. * @param uniform defines the associated uniform location
  32613. * @param textures defines the array of textures to bind
  32614. */
  32615. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32616. /** @hidden */
  32617. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32618. private _setTextureParameterFloat;
  32619. private _setTextureParameterInteger;
  32620. /**
  32621. * Unbind all vertex attributes from the webGL context
  32622. */
  32623. unbindAllAttributes(): void;
  32624. /**
  32625. * 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
  32626. */
  32627. releaseEffects(): void;
  32628. /**
  32629. * Dispose and release all associated resources
  32630. */
  32631. dispose(): void;
  32632. /**
  32633. * Attach a new callback raised when context lost event is fired
  32634. * @param callback defines the callback to call
  32635. */
  32636. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32637. /**
  32638. * Attach a new callback raised when context restored event is fired
  32639. * @param callback defines the callback to call
  32640. */
  32641. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32642. /**
  32643. * Get the current error code of the webGL context
  32644. * @returns the error code
  32645. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32646. */
  32647. getError(): number;
  32648. private _canRenderToFloatFramebuffer;
  32649. private _canRenderToHalfFloatFramebuffer;
  32650. private _canRenderToFramebuffer;
  32651. /** @hidden */
  32652. _getWebGLTextureType(type: number): number;
  32653. /** @hidden */
  32654. _getInternalFormat(format: number): number;
  32655. /** @hidden */
  32656. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32657. /** @hidden */
  32658. _getRGBAMultiSampleBufferFormat(type: number): number;
  32659. /** @hidden */
  32660. _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;
  32661. /**
  32662. * Loads a file from a url
  32663. * @param url url to load
  32664. * @param onSuccess callback called when the file successfully loads
  32665. * @param onProgress callback called while file is loading (if the server supports this mode)
  32666. * @param offlineProvider defines the offline provider for caching
  32667. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32668. * @param onError callback called when the file fails to load
  32669. * @returns a file request object
  32670. * @hidden
  32671. */
  32672. 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;
  32673. /**
  32674. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32675. * @param x defines the x coordinate of the rectangle where pixels must be read
  32676. * @param y defines the y coordinate of the rectangle where pixels must be read
  32677. * @param width defines the width of the rectangle where pixels must be read
  32678. * @param height defines the height of the rectangle where pixels must be read
  32679. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  32680. * @returns a Uint8Array containing RGBA colors
  32681. */
  32682. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32683. private static _isSupported;
  32684. /**
  32685. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32686. * @returns true if the engine can be created
  32687. * @ignorenaming
  32688. */
  32689. static isSupported(): boolean;
  32690. /**
  32691. * Find the next highest power of two.
  32692. * @param x Number to start search from.
  32693. * @return Next highest power of two.
  32694. */
  32695. static CeilingPOT(x: number): number;
  32696. /**
  32697. * Find the next lowest power of two.
  32698. * @param x Number to start search from.
  32699. * @return Next lowest power of two.
  32700. */
  32701. static FloorPOT(x: number): number;
  32702. /**
  32703. * Find the nearest power of two.
  32704. * @param x Number to start search from.
  32705. * @return Next nearest power of two.
  32706. */
  32707. static NearestPOT(x: number): number;
  32708. /**
  32709. * Get the closest exponent of two
  32710. * @param value defines the value to approximate
  32711. * @param max defines the maximum value to return
  32712. * @param mode defines how to define the closest value
  32713. * @returns closest exponent of two of the given value
  32714. */
  32715. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32716. /**
  32717. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32718. * @param func - the function to be called
  32719. * @param requester - the object that will request the next frame. Falls back to window.
  32720. * @returns frame number
  32721. */
  32722. static QueueNewFrame(func: () => void, requester?: any): number;
  32723. /**
  32724. * Gets host document
  32725. * @returns the host document object
  32726. */
  32727. getHostDocument(): Nullable<Document>;
  32728. }
  32729. }
  32730. declare module "babylonjs/Maths/sphericalPolynomial" {
  32731. import { Vector3 } from "babylonjs/Maths/math.vector";
  32732. import { Color3 } from "babylonjs/Maths/math.color";
  32733. /**
  32734. * Class representing spherical harmonics coefficients to the 3rd degree
  32735. */
  32736. export class SphericalHarmonics {
  32737. /**
  32738. * Defines whether or not the harmonics have been prescaled for rendering.
  32739. */
  32740. preScaled: boolean;
  32741. /**
  32742. * The l0,0 coefficients of the spherical harmonics
  32743. */
  32744. l00: Vector3;
  32745. /**
  32746. * The l1,-1 coefficients of the spherical harmonics
  32747. */
  32748. l1_1: Vector3;
  32749. /**
  32750. * The l1,0 coefficients of the spherical harmonics
  32751. */
  32752. l10: Vector3;
  32753. /**
  32754. * The l1,1 coefficients of the spherical harmonics
  32755. */
  32756. l11: Vector3;
  32757. /**
  32758. * The l2,-2 coefficients of the spherical harmonics
  32759. */
  32760. l2_2: Vector3;
  32761. /**
  32762. * The l2,-1 coefficients of the spherical harmonics
  32763. */
  32764. l2_1: Vector3;
  32765. /**
  32766. * The l2,0 coefficients of the spherical harmonics
  32767. */
  32768. l20: Vector3;
  32769. /**
  32770. * The l2,1 coefficients of the spherical harmonics
  32771. */
  32772. l21: Vector3;
  32773. /**
  32774. * The l2,2 coefficients of the spherical harmonics
  32775. */
  32776. l22: Vector3;
  32777. /**
  32778. * Adds a light to the spherical harmonics
  32779. * @param direction the direction of the light
  32780. * @param color the color of the light
  32781. * @param deltaSolidAngle the delta solid angle of the light
  32782. */
  32783. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32784. /**
  32785. * Scales the spherical harmonics by the given amount
  32786. * @param scale the amount to scale
  32787. */
  32788. scaleInPlace(scale: number): void;
  32789. /**
  32790. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32791. *
  32792. * ```
  32793. * E_lm = A_l * L_lm
  32794. * ```
  32795. *
  32796. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32797. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32798. * the scaling factors are given in equation 9.
  32799. */
  32800. convertIncidentRadianceToIrradiance(): void;
  32801. /**
  32802. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32803. *
  32804. * ```
  32805. * L = (1/pi) * E * rho
  32806. * ```
  32807. *
  32808. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32809. */
  32810. convertIrradianceToLambertianRadiance(): void;
  32811. /**
  32812. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32813. * required operations at run time.
  32814. *
  32815. * This is simply done by scaling back the SH with Ylm constants parameter.
  32816. * The trigonometric part being applied by the shader at run time.
  32817. */
  32818. preScaleForRendering(): void;
  32819. /**
  32820. * Constructs a spherical harmonics from an array.
  32821. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32822. * @returns the spherical harmonics
  32823. */
  32824. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32825. /**
  32826. * Gets the spherical harmonics from polynomial
  32827. * @param polynomial the spherical polynomial
  32828. * @returns the spherical harmonics
  32829. */
  32830. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32831. }
  32832. /**
  32833. * Class representing spherical polynomial coefficients to the 3rd degree
  32834. */
  32835. export class SphericalPolynomial {
  32836. private _harmonics;
  32837. /**
  32838. * The spherical harmonics used to create the polynomials.
  32839. */
  32840. get preScaledHarmonics(): SphericalHarmonics;
  32841. /**
  32842. * The x coefficients of the spherical polynomial
  32843. */
  32844. x: Vector3;
  32845. /**
  32846. * The y coefficients of the spherical polynomial
  32847. */
  32848. y: Vector3;
  32849. /**
  32850. * The z coefficients of the spherical polynomial
  32851. */
  32852. z: Vector3;
  32853. /**
  32854. * The xx coefficients of the spherical polynomial
  32855. */
  32856. xx: Vector3;
  32857. /**
  32858. * The yy coefficients of the spherical polynomial
  32859. */
  32860. yy: Vector3;
  32861. /**
  32862. * The zz coefficients of the spherical polynomial
  32863. */
  32864. zz: Vector3;
  32865. /**
  32866. * The xy coefficients of the spherical polynomial
  32867. */
  32868. xy: Vector3;
  32869. /**
  32870. * The yz coefficients of the spherical polynomial
  32871. */
  32872. yz: Vector3;
  32873. /**
  32874. * The zx coefficients of the spherical polynomial
  32875. */
  32876. zx: Vector3;
  32877. /**
  32878. * Adds an ambient color to the spherical polynomial
  32879. * @param color the color to add
  32880. */
  32881. addAmbient(color: Color3): void;
  32882. /**
  32883. * Scales the spherical polynomial by the given amount
  32884. * @param scale the amount to scale
  32885. */
  32886. scaleInPlace(scale: number): void;
  32887. /**
  32888. * Gets the spherical polynomial from harmonics
  32889. * @param harmonics the spherical harmonics
  32890. * @returns the spherical polynomial
  32891. */
  32892. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32893. /**
  32894. * Constructs a spherical polynomial from an array.
  32895. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32896. * @returns the spherical polynomial
  32897. */
  32898. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32899. }
  32900. }
  32901. declare module "babylonjs/Materials/Textures/internalTexture" {
  32902. import { Observable } from "babylonjs/Misc/observable";
  32903. import { Nullable, int } from "babylonjs/types";
  32904. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  32905. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32906. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  32907. /**
  32908. * Defines the source of the internal texture
  32909. */
  32910. export enum InternalTextureSource {
  32911. /**
  32912. * The source of the texture data is unknown
  32913. */
  32914. Unknown = 0,
  32915. /**
  32916. * Texture data comes from an URL
  32917. */
  32918. Url = 1,
  32919. /**
  32920. * Texture data is only used for temporary storage
  32921. */
  32922. Temp = 2,
  32923. /**
  32924. * Texture data comes from raw data (ArrayBuffer)
  32925. */
  32926. Raw = 3,
  32927. /**
  32928. * Texture content is dynamic (video or dynamic texture)
  32929. */
  32930. Dynamic = 4,
  32931. /**
  32932. * Texture content is generated by rendering to it
  32933. */
  32934. RenderTarget = 5,
  32935. /**
  32936. * Texture content is part of a multi render target process
  32937. */
  32938. MultiRenderTarget = 6,
  32939. /**
  32940. * Texture data comes from a cube data file
  32941. */
  32942. Cube = 7,
  32943. /**
  32944. * Texture data comes from a raw cube data
  32945. */
  32946. CubeRaw = 8,
  32947. /**
  32948. * Texture data come from a prefiltered cube data file
  32949. */
  32950. CubePrefiltered = 9,
  32951. /**
  32952. * Texture content is raw 3D data
  32953. */
  32954. Raw3D = 10,
  32955. /**
  32956. * Texture content is raw 2D array data
  32957. */
  32958. Raw2DArray = 11,
  32959. /**
  32960. * Texture content is a depth texture
  32961. */
  32962. Depth = 12,
  32963. /**
  32964. * Texture data comes from a raw cube data encoded with RGBD
  32965. */
  32966. CubeRawRGBD = 13
  32967. }
  32968. /**
  32969. * Class used to store data associated with WebGL texture data for the engine
  32970. * This class should not be used directly
  32971. */
  32972. export class InternalTexture {
  32973. /** @hidden */
  32974. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32975. /**
  32976. * Defines if the texture is ready
  32977. */
  32978. isReady: boolean;
  32979. /**
  32980. * Defines if the texture is a cube texture
  32981. */
  32982. isCube: boolean;
  32983. /**
  32984. * Defines if the texture contains 3D data
  32985. */
  32986. is3D: boolean;
  32987. /**
  32988. * Defines if the texture contains 2D array data
  32989. */
  32990. is2DArray: boolean;
  32991. /**
  32992. * Defines if the texture contains multiview data
  32993. */
  32994. isMultiview: boolean;
  32995. /**
  32996. * Gets the URL used to load this texture
  32997. */
  32998. url: string;
  32999. /**
  33000. * Gets the sampling mode of the texture
  33001. */
  33002. samplingMode: number;
  33003. /**
  33004. * Gets a boolean indicating if the texture needs mipmaps generation
  33005. */
  33006. generateMipMaps: boolean;
  33007. /**
  33008. * Gets the number of samples used by the texture (WebGL2+ only)
  33009. */
  33010. samples: number;
  33011. /**
  33012. * Gets the type of the texture (int, float...)
  33013. */
  33014. type: number;
  33015. /**
  33016. * Gets the format of the texture (RGB, RGBA...)
  33017. */
  33018. format: number;
  33019. /**
  33020. * Observable called when the texture is loaded
  33021. */
  33022. onLoadedObservable: Observable<InternalTexture>;
  33023. /**
  33024. * Gets the width of the texture
  33025. */
  33026. width: number;
  33027. /**
  33028. * Gets the height of the texture
  33029. */
  33030. height: number;
  33031. /**
  33032. * Gets the depth of the texture
  33033. */
  33034. depth: number;
  33035. /**
  33036. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33037. */
  33038. baseWidth: number;
  33039. /**
  33040. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33041. */
  33042. baseHeight: number;
  33043. /**
  33044. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33045. */
  33046. baseDepth: number;
  33047. /**
  33048. * Gets a boolean indicating if the texture is inverted on Y axis
  33049. */
  33050. invertY: boolean;
  33051. /** @hidden */
  33052. _invertVScale: boolean;
  33053. /** @hidden */
  33054. _associatedChannel: number;
  33055. /** @hidden */
  33056. _source: InternalTextureSource;
  33057. /** @hidden */
  33058. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33059. /** @hidden */
  33060. _bufferView: Nullable<ArrayBufferView>;
  33061. /** @hidden */
  33062. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33063. /** @hidden */
  33064. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33065. /** @hidden */
  33066. _size: number;
  33067. /** @hidden */
  33068. _extension: string;
  33069. /** @hidden */
  33070. _files: Nullable<string[]>;
  33071. /** @hidden */
  33072. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33073. /** @hidden */
  33074. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33075. /** @hidden */
  33076. _framebuffer: Nullable<WebGLFramebuffer>;
  33077. /** @hidden */
  33078. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33079. /** @hidden */
  33080. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33081. /** @hidden */
  33082. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33083. /** @hidden */
  33084. _attachments: Nullable<number[]>;
  33085. /** @hidden */
  33086. _cachedCoordinatesMode: Nullable<number>;
  33087. /** @hidden */
  33088. _cachedWrapU: Nullable<number>;
  33089. /** @hidden */
  33090. _cachedWrapV: Nullable<number>;
  33091. /** @hidden */
  33092. _cachedWrapR: Nullable<number>;
  33093. /** @hidden */
  33094. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33095. /** @hidden */
  33096. _isDisabled: boolean;
  33097. /** @hidden */
  33098. _compression: Nullable<string>;
  33099. /** @hidden */
  33100. _generateStencilBuffer: boolean;
  33101. /** @hidden */
  33102. _generateDepthBuffer: boolean;
  33103. /** @hidden */
  33104. _comparisonFunction: number;
  33105. /** @hidden */
  33106. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33107. /** @hidden */
  33108. _lodGenerationScale: number;
  33109. /** @hidden */
  33110. _lodGenerationOffset: number;
  33111. /** @hidden */
  33112. _colorTextureArray: Nullable<WebGLTexture>;
  33113. /** @hidden */
  33114. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33115. /** @hidden */
  33116. _lodTextureHigh: Nullable<BaseTexture>;
  33117. /** @hidden */
  33118. _lodTextureMid: Nullable<BaseTexture>;
  33119. /** @hidden */
  33120. _lodTextureLow: Nullable<BaseTexture>;
  33121. /** @hidden */
  33122. _isRGBD: boolean;
  33123. /** @hidden */
  33124. _linearSpecularLOD: boolean;
  33125. /** @hidden */
  33126. _irradianceTexture: Nullable<BaseTexture>;
  33127. /** @hidden */
  33128. _webGLTexture: Nullable<WebGLTexture>;
  33129. /** @hidden */
  33130. _references: number;
  33131. private _engine;
  33132. /**
  33133. * Gets the Engine the texture belongs to.
  33134. * @returns The babylon engine
  33135. */
  33136. getEngine(): ThinEngine;
  33137. /**
  33138. * Gets the data source type of the texture
  33139. */
  33140. get source(): InternalTextureSource;
  33141. /**
  33142. * Creates a new InternalTexture
  33143. * @param engine defines the engine to use
  33144. * @param source defines the type of data that will be used
  33145. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33146. */
  33147. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33148. /**
  33149. * Increments the number of references (ie. the number of Texture that point to it)
  33150. */
  33151. incrementReferences(): void;
  33152. /**
  33153. * Change the size of the texture (not the size of the content)
  33154. * @param width defines the new width
  33155. * @param height defines the new height
  33156. * @param depth defines the new depth (1 by default)
  33157. */
  33158. updateSize(width: int, height: int, depth?: int): void;
  33159. /** @hidden */
  33160. _rebuild(): void;
  33161. /** @hidden */
  33162. _swapAndDie(target: InternalTexture): void;
  33163. /**
  33164. * Dispose the current allocated resources
  33165. */
  33166. dispose(): void;
  33167. }
  33168. }
  33169. declare module "babylonjs/Audio/analyser" {
  33170. import { Scene } from "babylonjs/scene";
  33171. /**
  33172. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33173. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33174. */
  33175. export class Analyser {
  33176. /**
  33177. * Gets or sets the smoothing
  33178. * @ignorenaming
  33179. */
  33180. SMOOTHING: number;
  33181. /**
  33182. * Gets or sets the FFT table size
  33183. * @ignorenaming
  33184. */
  33185. FFT_SIZE: number;
  33186. /**
  33187. * Gets or sets the bar graph amplitude
  33188. * @ignorenaming
  33189. */
  33190. BARGRAPHAMPLITUDE: number;
  33191. /**
  33192. * Gets or sets the position of the debug canvas
  33193. * @ignorenaming
  33194. */
  33195. DEBUGCANVASPOS: {
  33196. x: number;
  33197. y: number;
  33198. };
  33199. /**
  33200. * Gets or sets the debug canvas size
  33201. * @ignorenaming
  33202. */
  33203. DEBUGCANVASSIZE: {
  33204. width: number;
  33205. height: number;
  33206. };
  33207. private _byteFreqs;
  33208. private _byteTime;
  33209. private _floatFreqs;
  33210. private _webAudioAnalyser;
  33211. private _debugCanvas;
  33212. private _debugCanvasContext;
  33213. private _scene;
  33214. private _registerFunc;
  33215. private _audioEngine;
  33216. /**
  33217. * Creates a new analyser
  33218. * @param scene defines hosting scene
  33219. */
  33220. constructor(scene: Scene);
  33221. /**
  33222. * Get the number of data values you will have to play with for the visualization
  33223. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33224. * @returns a number
  33225. */
  33226. getFrequencyBinCount(): number;
  33227. /**
  33228. * Gets the current frequency data as a byte array
  33229. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33230. * @returns a Uint8Array
  33231. */
  33232. getByteFrequencyData(): Uint8Array;
  33233. /**
  33234. * Gets the current waveform as a byte array
  33235. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33236. * @returns a Uint8Array
  33237. */
  33238. getByteTimeDomainData(): Uint8Array;
  33239. /**
  33240. * Gets the current frequency data as a float array
  33241. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33242. * @returns a Float32Array
  33243. */
  33244. getFloatFrequencyData(): Float32Array;
  33245. /**
  33246. * Renders the debug canvas
  33247. */
  33248. drawDebugCanvas(): void;
  33249. /**
  33250. * Stops rendering the debug canvas and removes it
  33251. */
  33252. stopDebugCanvas(): void;
  33253. /**
  33254. * Connects two audio nodes
  33255. * @param inputAudioNode defines first node to connect
  33256. * @param outputAudioNode defines second node to connect
  33257. */
  33258. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33259. /**
  33260. * Releases all associated resources
  33261. */
  33262. dispose(): void;
  33263. }
  33264. }
  33265. declare module "babylonjs/Audio/audioEngine" {
  33266. import { IDisposable } from "babylonjs/scene";
  33267. import { Analyser } from "babylonjs/Audio/analyser";
  33268. import { Nullable } from "babylonjs/types";
  33269. import { Observable } from "babylonjs/Misc/observable";
  33270. /**
  33271. * This represents an audio engine and it is responsible
  33272. * to play, synchronize and analyse sounds throughout the application.
  33273. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33274. */
  33275. export interface IAudioEngine extends IDisposable {
  33276. /**
  33277. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33278. */
  33279. readonly canUseWebAudio: boolean;
  33280. /**
  33281. * Gets the current AudioContext if available.
  33282. */
  33283. readonly audioContext: Nullable<AudioContext>;
  33284. /**
  33285. * The master gain node defines the global audio volume of your audio engine.
  33286. */
  33287. readonly masterGain: GainNode;
  33288. /**
  33289. * Gets whether or not mp3 are supported by your browser.
  33290. */
  33291. readonly isMP3supported: boolean;
  33292. /**
  33293. * Gets whether or not ogg are supported by your browser.
  33294. */
  33295. readonly isOGGsupported: boolean;
  33296. /**
  33297. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33298. * @ignoreNaming
  33299. */
  33300. WarnedWebAudioUnsupported: boolean;
  33301. /**
  33302. * Defines if the audio engine relies on a custom unlocked button.
  33303. * In this case, the embedded button will not be displayed.
  33304. */
  33305. useCustomUnlockedButton: boolean;
  33306. /**
  33307. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33308. */
  33309. readonly unlocked: boolean;
  33310. /**
  33311. * Event raised when audio has been unlocked on the browser.
  33312. */
  33313. onAudioUnlockedObservable: Observable<AudioEngine>;
  33314. /**
  33315. * Event raised when audio has been locked on the browser.
  33316. */
  33317. onAudioLockedObservable: Observable<AudioEngine>;
  33318. /**
  33319. * Flags the audio engine in Locked state.
  33320. * This happens due to new browser policies preventing audio to autoplay.
  33321. */
  33322. lock(): void;
  33323. /**
  33324. * Unlocks the audio engine once a user action has been done on the dom.
  33325. * This is helpful to resume play once browser policies have been satisfied.
  33326. */
  33327. unlock(): void;
  33328. }
  33329. /**
  33330. * This represents the default audio engine used in babylon.
  33331. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33332. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33333. */
  33334. export class AudioEngine implements IAudioEngine {
  33335. private _audioContext;
  33336. private _audioContextInitialized;
  33337. private _muteButton;
  33338. private _hostElement;
  33339. /**
  33340. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33341. */
  33342. canUseWebAudio: boolean;
  33343. /**
  33344. * The master gain node defines the global audio volume of your audio engine.
  33345. */
  33346. masterGain: GainNode;
  33347. /**
  33348. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33349. * @ignoreNaming
  33350. */
  33351. WarnedWebAudioUnsupported: boolean;
  33352. /**
  33353. * Gets whether or not mp3 are supported by your browser.
  33354. */
  33355. isMP3supported: boolean;
  33356. /**
  33357. * Gets whether or not ogg are supported by your browser.
  33358. */
  33359. isOGGsupported: boolean;
  33360. /**
  33361. * Gets whether audio has been unlocked on the device.
  33362. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33363. * a user interaction has happened.
  33364. */
  33365. unlocked: boolean;
  33366. /**
  33367. * Defines if the audio engine relies on a custom unlocked button.
  33368. * In this case, the embedded button will not be displayed.
  33369. */
  33370. useCustomUnlockedButton: boolean;
  33371. /**
  33372. * Event raised when audio has been unlocked on the browser.
  33373. */
  33374. onAudioUnlockedObservable: Observable<AudioEngine>;
  33375. /**
  33376. * Event raised when audio has been locked on the browser.
  33377. */
  33378. onAudioLockedObservable: Observable<AudioEngine>;
  33379. /**
  33380. * Gets the current AudioContext if available.
  33381. */
  33382. get audioContext(): Nullable<AudioContext>;
  33383. private _connectedAnalyser;
  33384. /**
  33385. * Instantiates a new audio engine.
  33386. *
  33387. * There should be only one per page as some browsers restrict the number
  33388. * of audio contexts you can create.
  33389. * @param hostElement defines the host element where to display the mute icon if necessary
  33390. */
  33391. constructor(hostElement?: Nullable<HTMLElement>);
  33392. /**
  33393. * Flags the audio engine in Locked state.
  33394. * This happens due to new browser policies preventing audio to autoplay.
  33395. */
  33396. lock(): void;
  33397. /**
  33398. * Unlocks the audio engine once a user action has been done on the dom.
  33399. * This is helpful to resume play once browser policies have been satisfied.
  33400. */
  33401. unlock(): void;
  33402. private _resumeAudioContext;
  33403. private _initializeAudioContext;
  33404. private _tryToRun;
  33405. private _triggerRunningState;
  33406. private _triggerSuspendedState;
  33407. private _displayMuteButton;
  33408. private _moveButtonToTopLeft;
  33409. private _onResize;
  33410. private _hideMuteButton;
  33411. /**
  33412. * Destroy and release the resources associated with the audio ccontext.
  33413. */
  33414. dispose(): void;
  33415. /**
  33416. * Gets the global volume sets on the master gain.
  33417. * @returns the global volume if set or -1 otherwise
  33418. */
  33419. getGlobalVolume(): number;
  33420. /**
  33421. * Sets the global volume of your experience (sets on the master gain).
  33422. * @param newVolume Defines the new global volume of the application
  33423. */
  33424. setGlobalVolume(newVolume: number): void;
  33425. /**
  33426. * Connect the audio engine to an audio analyser allowing some amazing
  33427. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33428. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33429. * @param analyser The analyser to connect to the engine
  33430. */
  33431. connectToAnalyser(analyser: Analyser): void;
  33432. }
  33433. }
  33434. declare module "babylonjs/Loading/loadingScreen" {
  33435. /**
  33436. * Interface used to present a loading screen while loading a scene
  33437. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33438. */
  33439. export interface ILoadingScreen {
  33440. /**
  33441. * Function called to display the loading screen
  33442. */
  33443. displayLoadingUI: () => void;
  33444. /**
  33445. * Function called to hide the loading screen
  33446. */
  33447. hideLoadingUI: () => void;
  33448. /**
  33449. * Gets or sets the color to use for the background
  33450. */
  33451. loadingUIBackgroundColor: string;
  33452. /**
  33453. * Gets or sets the text to display while loading
  33454. */
  33455. loadingUIText: string;
  33456. }
  33457. /**
  33458. * Class used for the default loading screen
  33459. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33460. */
  33461. export class DefaultLoadingScreen implements ILoadingScreen {
  33462. private _renderingCanvas;
  33463. private _loadingText;
  33464. private _loadingDivBackgroundColor;
  33465. private _loadingDiv;
  33466. private _loadingTextDiv;
  33467. /** Gets or sets the logo url to use for the default loading screen */
  33468. static DefaultLogoUrl: string;
  33469. /** Gets or sets the spinner url to use for the default loading screen */
  33470. static DefaultSpinnerUrl: string;
  33471. /**
  33472. * Creates a new default loading screen
  33473. * @param _renderingCanvas defines the canvas used to render the scene
  33474. * @param _loadingText defines the default text to display
  33475. * @param _loadingDivBackgroundColor defines the default background color
  33476. */
  33477. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33478. /**
  33479. * Function called to display the loading screen
  33480. */
  33481. displayLoadingUI(): void;
  33482. /**
  33483. * Function called to hide the loading screen
  33484. */
  33485. hideLoadingUI(): void;
  33486. /**
  33487. * Gets or sets the text to display while loading
  33488. */
  33489. set loadingUIText(text: string);
  33490. get loadingUIText(): string;
  33491. /**
  33492. * Gets or sets the color to use for the background
  33493. */
  33494. get loadingUIBackgroundColor(): string;
  33495. set loadingUIBackgroundColor(color: string);
  33496. private _resizeLoadingUI;
  33497. }
  33498. }
  33499. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33500. /**
  33501. * Interface for any object that can request an animation frame
  33502. */
  33503. export interface ICustomAnimationFrameRequester {
  33504. /**
  33505. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33506. */
  33507. renderFunction?: Function;
  33508. /**
  33509. * Called to request the next frame to render to
  33510. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33511. */
  33512. requestAnimationFrame: Function;
  33513. /**
  33514. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33515. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33516. */
  33517. requestID?: number;
  33518. }
  33519. }
  33520. declare module "babylonjs/Misc/performanceMonitor" {
  33521. /**
  33522. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33523. */
  33524. export class PerformanceMonitor {
  33525. private _enabled;
  33526. private _rollingFrameTime;
  33527. private _lastFrameTimeMs;
  33528. /**
  33529. * constructor
  33530. * @param frameSampleSize The number of samples required to saturate the sliding window
  33531. */
  33532. constructor(frameSampleSize?: number);
  33533. /**
  33534. * Samples current frame
  33535. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33536. */
  33537. sampleFrame(timeMs?: number): void;
  33538. /**
  33539. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33540. */
  33541. get averageFrameTime(): number;
  33542. /**
  33543. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33544. */
  33545. get averageFrameTimeVariance(): number;
  33546. /**
  33547. * Returns the frame time of the most recent frame
  33548. */
  33549. get instantaneousFrameTime(): number;
  33550. /**
  33551. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33552. */
  33553. get averageFPS(): number;
  33554. /**
  33555. * Returns the average framerate in frames per second using the most recent frame time
  33556. */
  33557. get instantaneousFPS(): number;
  33558. /**
  33559. * Returns true if enough samples have been taken to completely fill the sliding window
  33560. */
  33561. get isSaturated(): boolean;
  33562. /**
  33563. * Enables contributions to the sliding window sample set
  33564. */
  33565. enable(): void;
  33566. /**
  33567. * Disables contributions to the sliding window sample set
  33568. * Samples will not be interpolated over the disabled period
  33569. */
  33570. disable(): void;
  33571. /**
  33572. * Returns true if sampling is enabled
  33573. */
  33574. get isEnabled(): boolean;
  33575. /**
  33576. * Resets performance monitor
  33577. */
  33578. reset(): void;
  33579. }
  33580. /**
  33581. * RollingAverage
  33582. *
  33583. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33584. */
  33585. export class RollingAverage {
  33586. /**
  33587. * Current average
  33588. */
  33589. average: number;
  33590. /**
  33591. * Current variance
  33592. */
  33593. variance: number;
  33594. protected _samples: Array<number>;
  33595. protected _sampleCount: number;
  33596. protected _pos: number;
  33597. protected _m2: number;
  33598. /**
  33599. * constructor
  33600. * @param length The number of samples required to saturate the sliding window
  33601. */
  33602. constructor(length: number);
  33603. /**
  33604. * Adds a sample to the sample set
  33605. * @param v The sample value
  33606. */
  33607. add(v: number): void;
  33608. /**
  33609. * Returns previously added values or null if outside of history or outside the sliding window domain
  33610. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33611. * @return Value previously recorded with add() or null if outside of range
  33612. */
  33613. history(i: number): number;
  33614. /**
  33615. * Returns true if enough samples have been taken to completely fill the sliding window
  33616. * @return true if sample-set saturated
  33617. */
  33618. isSaturated(): boolean;
  33619. /**
  33620. * Resets the rolling average (equivalent to 0 samples taken so far)
  33621. */
  33622. reset(): void;
  33623. /**
  33624. * Wraps a value around the sample range boundaries
  33625. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33626. * @return Wrapped position in sample range
  33627. */
  33628. protected _wrapPosition(i: number): number;
  33629. }
  33630. }
  33631. declare module "babylonjs/Misc/perfCounter" {
  33632. /**
  33633. * This class is used to track a performance counter which is number based.
  33634. * The user has access to many properties which give statistics of different nature.
  33635. *
  33636. * The implementer can track two kinds of Performance Counter: time and count.
  33637. * 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.
  33638. * 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.
  33639. */
  33640. export class PerfCounter {
  33641. /**
  33642. * Gets or sets a global boolean to turn on and off all the counters
  33643. */
  33644. static Enabled: boolean;
  33645. /**
  33646. * Returns the smallest value ever
  33647. */
  33648. get min(): number;
  33649. /**
  33650. * Returns the biggest value ever
  33651. */
  33652. get max(): number;
  33653. /**
  33654. * Returns the average value since the performance counter is running
  33655. */
  33656. get average(): number;
  33657. /**
  33658. * Returns the average value of the last second the counter was monitored
  33659. */
  33660. get lastSecAverage(): number;
  33661. /**
  33662. * Returns the current value
  33663. */
  33664. get current(): number;
  33665. /**
  33666. * Gets the accumulated total
  33667. */
  33668. get total(): number;
  33669. /**
  33670. * Gets the total value count
  33671. */
  33672. get count(): number;
  33673. /**
  33674. * Creates a new counter
  33675. */
  33676. constructor();
  33677. /**
  33678. * Call this method to start monitoring a new frame.
  33679. * 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.
  33680. */
  33681. fetchNewFrame(): void;
  33682. /**
  33683. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33684. * @param newCount the count value to add to the monitored count
  33685. * @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.
  33686. */
  33687. addCount(newCount: number, fetchResult: boolean): void;
  33688. /**
  33689. * Start monitoring this performance counter
  33690. */
  33691. beginMonitoring(): void;
  33692. /**
  33693. * Compute the time lapsed since the previous beginMonitoring() call.
  33694. * @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
  33695. */
  33696. endMonitoring(newFrame?: boolean): void;
  33697. private _fetchResult;
  33698. private _startMonitoringTime;
  33699. private _min;
  33700. private _max;
  33701. private _average;
  33702. private _current;
  33703. private _totalValueCount;
  33704. private _totalAccumulated;
  33705. private _lastSecAverage;
  33706. private _lastSecAccumulated;
  33707. private _lastSecTime;
  33708. private _lastSecValueCount;
  33709. }
  33710. }
  33711. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  33712. module "babylonjs/Engines/thinEngine" {
  33713. interface ThinEngine {
  33714. /**
  33715. * Sets alpha constants used by some alpha blending modes
  33716. * @param r defines the red component
  33717. * @param g defines the green component
  33718. * @param b defines the blue component
  33719. * @param a defines the alpha component
  33720. */
  33721. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33722. /**
  33723. * Sets the current alpha mode
  33724. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33725. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33726. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33727. */
  33728. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33729. /**
  33730. * Gets the current alpha mode
  33731. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33732. * @returns the current alpha mode
  33733. */
  33734. getAlphaMode(): number;
  33735. /**
  33736. * Sets the current alpha equation
  33737. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33738. */
  33739. setAlphaEquation(equation: number): void;
  33740. /**
  33741. * Gets the current alpha equation.
  33742. * @returns the current alpha equation
  33743. */
  33744. getAlphaEquation(): number;
  33745. }
  33746. }
  33747. }
  33748. declare module "babylonjs/Engines/engine" {
  33749. import { Observable } from "babylonjs/Misc/observable";
  33750. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  33751. import { Scene } from "babylonjs/scene";
  33752. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33753. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  33754. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33755. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  33756. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  33757. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  33758. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  33759. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  33760. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  33761. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33762. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  33763. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  33764. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33765. import "babylonjs/Engines/Extensions/engine.alpha";
  33766. import { Material } from "babylonjs/Materials/material";
  33767. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33768. /**
  33769. * Defines the interface used by display changed events
  33770. */
  33771. export interface IDisplayChangedEventArgs {
  33772. /** Gets the vrDisplay object (if any) */
  33773. vrDisplay: Nullable<any>;
  33774. /** Gets a boolean indicating if webVR is supported */
  33775. vrSupported: boolean;
  33776. }
  33777. /**
  33778. * Defines the interface used by objects containing a viewport (like a camera)
  33779. */
  33780. interface IViewportOwnerLike {
  33781. /**
  33782. * Gets or sets the viewport
  33783. */
  33784. viewport: IViewportLike;
  33785. }
  33786. /**
  33787. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33788. */
  33789. export class Engine extends ThinEngine {
  33790. /** Defines that alpha blending is disabled */
  33791. static readonly ALPHA_DISABLE: number;
  33792. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33793. static readonly ALPHA_ADD: number;
  33794. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33795. static readonly ALPHA_COMBINE: number;
  33796. /** Defines that alpha blending to DEST - SRC * DEST */
  33797. static readonly ALPHA_SUBTRACT: number;
  33798. /** Defines that alpha blending to SRC * DEST */
  33799. static readonly ALPHA_MULTIPLY: number;
  33800. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33801. static readonly ALPHA_MAXIMIZED: number;
  33802. /** Defines that alpha blending to SRC + DEST */
  33803. static readonly ALPHA_ONEONE: number;
  33804. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33805. static readonly ALPHA_PREMULTIPLIED: number;
  33806. /**
  33807. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33808. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33809. */
  33810. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33811. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33812. static readonly ALPHA_INTERPOLATE: number;
  33813. /**
  33814. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33815. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33816. */
  33817. static readonly ALPHA_SCREENMODE: number;
  33818. /** Defines that the ressource is not delayed*/
  33819. static readonly DELAYLOADSTATE_NONE: number;
  33820. /** Defines that the ressource was successfully delay loaded */
  33821. static readonly DELAYLOADSTATE_LOADED: number;
  33822. /** Defines that the ressource is currently delay loading */
  33823. static readonly DELAYLOADSTATE_LOADING: number;
  33824. /** Defines that the ressource is delayed and has not started loading */
  33825. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33826. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33827. static readonly NEVER: number;
  33828. /** 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 */
  33829. static readonly ALWAYS: number;
  33830. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33831. static readonly LESS: number;
  33832. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33833. static readonly EQUAL: number;
  33834. /** 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 */
  33835. static readonly LEQUAL: number;
  33836. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33837. static readonly GREATER: number;
  33838. /** 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 */
  33839. static readonly GEQUAL: number;
  33840. /** 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 */
  33841. static readonly NOTEQUAL: number;
  33842. /** Passed to stencilOperation to specify that stencil value must be kept */
  33843. static readonly KEEP: number;
  33844. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33845. static readonly REPLACE: number;
  33846. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33847. static readonly INCR: number;
  33848. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33849. static readonly DECR: number;
  33850. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33851. static readonly INVERT: number;
  33852. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33853. static readonly INCR_WRAP: number;
  33854. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33855. static readonly DECR_WRAP: number;
  33856. /** Texture is not repeating outside of 0..1 UVs */
  33857. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33858. /** Texture is repeating outside of 0..1 UVs */
  33859. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33860. /** Texture is repeating and mirrored */
  33861. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33862. /** ALPHA */
  33863. static readonly TEXTUREFORMAT_ALPHA: number;
  33864. /** LUMINANCE */
  33865. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33866. /** LUMINANCE_ALPHA */
  33867. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33868. /** RGB */
  33869. static readonly TEXTUREFORMAT_RGB: number;
  33870. /** RGBA */
  33871. static readonly TEXTUREFORMAT_RGBA: number;
  33872. /** RED */
  33873. static readonly TEXTUREFORMAT_RED: number;
  33874. /** RED (2nd reference) */
  33875. static readonly TEXTUREFORMAT_R: number;
  33876. /** RG */
  33877. static readonly TEXTUREFORMAT_RG: number;
  33878. /** RED_INTEGER */
  33879. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33880. /** RED_INTEGER (2nd reference) */
  33881. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33882. /** RG_INTEGER */
  33883. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33884. /** RGB_INTEGER */
  33885. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33886. /** RGBA_INTEGER */
  33887. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33888. /** UNSIGNED_BYTE */
  33889. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33890. /** UNSIGNED_BYTE (2nd reference) */
  33891. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33892. /** FLOAT */
  33893. static readonly TEXTURETYPE_FLOAT: number;
  33894. /** HALF_FLOAT */
  33895. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33896. /** BYTE */
  33897. static readonly TEXTURETYPE_BYTE: number;
  33898. /** SHORT */
  33899. static readonly TEXTURETYPE_SHORT: number;
  33900. /** UNSIGNED_SHORT */
  33901. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33902. /** INT */
  33903. static readonly TEXTURETYPE_INT: number;
  33904. /** UNSIGNED_INT */
  33905. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33906. /** UNSIGNED_SHORT_4_4_4_4 */
  33907. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33908. /** UNSIGNED_SHORT_5_5_5_1 */
  33909. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33910. /** UNSIGNED_SHORT_5_6_5 */
  33911. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33912. /** UNSIGNED_INT_2_10_10_10_REV */
  33913. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33914. /** UNSIGNED_INT_24_8 */
  33915. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33916. /** UNSIGNED_INT_10F_11F_11F_REV */
  33917. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33918. /** UNSIGNED_INT_5_9_9_9_REV */
  33919. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33920. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33921. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33922. /** nearest is mag = nearest and min = nearest and mip = linear */
  33923. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33924. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33925. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33926. /** Trilinear is mag = linear and min = linear and mip = linear */
  33927. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33928. /** nearest is mag = nearest and min = nearest and mip = linear */
  33929. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33930. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33931. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33932. /** Trilinear is mag = linear and min = linear and mip = linear */
  33933. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33934. /** mag = nearest and min = nearest and mip = nearest */
  33935. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33936. /** mag = nearest and min = linear and mip = nearest */
  33937. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33938. /** mag = nearest and min = linear and mip = linear */
  33939. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33940. /** mag = nearest and min = linear and mip = none */
  33941. static readonly TEXTURE_NEAREST_LINEAR: number;
  33942. /** mag = nearest and min = nearest and mip = none */
  33943. static readonly TEXTURE_NEAREST_NEAREST: number;
  33944. /** mag = linear and min = nearest and mip = nearest */
  33945. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33946. /** mag = linear and min = nearest and mip = linear */
  33947. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33948. /** mag = linear and min = linear and mip = none */
  33949. static readonly TEXTURE_LINEAR_LINEAR: number;
  33950. /** mag = linear and min = nearest and mip = none */
  33951. static readonly TEXTURE_LINEAR_NEAREST: number;
  33952. /** Explicit coordinates mode */
  33953. static readonly TEXTURE_EXPLICIT_MODE: number;
  33954. /** Spherical coordinates mode */
  33955. static readonly TEXTURE_SPHERICAL_MODE: number;
  33956. /** Planar coordinates mode */
  33957. static readonly TEXTURE_PLANAR_MODE: number;
  33958. /** Cubic coordinates mode */
  33959. static readonly TEXTURE_CUBIC_MODE: number;
  33960. /** Projection coordinates mode */
  33961. static readonly TEXTURE_PROJECTION_MODE: number;
  33962. /** Skybox coordinates mode */
  33963. static readonly TEXTURE_SKYBOX_MODE: number;
  33964. /** Inverse Cubic coordinates mode */
  33965. static readonly TEXTURE_INVCUBIC_MODE: number;
  33966. /** Equirectangular coordinates mode */
  33967. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33968. /** Equirectangular Fixed coordinates mode */
  33969. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33970. /** Equirectangular Fixed Mirrored coordinates mode */
  33971. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33972. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33973. static readonly SCALEMODE_FLOOR: number;
  33974. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33975. static readonly SCALEMODE_NEAREST: number;
  33976. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33977. static readonly SCALEMODE_CEILING: number;
  33978. /**
  33979. * Returns the current npm package of the sdk
  33980. */
  33981. static get NpmPackage(): string;
  33982. /**
  33983. * Returns the current version of the framework
  33984. */
  33985. static get Version(): string;
  33986. /** Gets the list of created engines */
  33987. static get Instances(): Engine[];
  33988. /**
  33989. * Gets the latest created engine
  33990. */
  33991. static get LastCreatedEngine(): Nullable<Engine>;
  33992. /**
  33993. * Gets the latest created scene
  33994. */
  33995. static get LastCreatedScene(): Nullable<Scene>;
  33996. /**
  33997. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33998. * @param flag defines which part of the materials must be marked as dirty
  33999. * @param predicate defines a predicate used to filter which materials should be affected
  34000. */
  34001. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34002. /**
  34003. * Method called to create the default loading screen.
  34004. * This can be overriden in your own app.
  34005. * @param canvas The rendering canvas element
  34006. * @returns The loading screen
  34007. */
  34008. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34009. /**
  34010. * Method called to create the default rescale post process on each engine.
  34011. */
  34012. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34013. /**
  34014. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34015. **/
  34016. enableOfflineSupport: boolean;
  34017. /**
  34018. * 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)
  34019. **/
  34020. disableManifestCheck: boolean;
  34021. /**
  34022. * Gets the list of created scenes
  34023. */
  34024. scenes: Scene[];
  34025. /**
  34026. * Event raised when a new scene is created
  34027. */
  34028. onNewSceneAddedObservable: Observable<Scene>;
  34029. /**
  34030. * Gets the list of created postprocesses
  34031. */
  34032. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34033. /**
  34034. * Gets a boolean indicating if the pointer is currently locked
  34035. */
  34036. isPointerLock: boolean;
  34037. /**
  34038. * Observable event triggered each time the rendering canvas is resized
  34039. */
  34040. onResizeObservable: Observable<Engine>;
  34041. /**
  34042. * Observable event triggered each time the canvas loses focus
  34043. */
  34044. onCanvasBlurObservable: Observable<Engine>;
  34045. /**
  34046. * Observable event triggered each time the canvas gains focus
  34047. */
  34048. onCanvasFocusObservable: Observable<Engine>;
  34049. /**
  34050. * Observable event triggered each time the canvas receives pointerout event
  34051. */
  34052. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34053. /**
  34054. * Observable raised when the engine begins a new frame
  34055. */
  34056. onBeginFrameObservable: Observable<Engine>;
  34057. /**
  34058. * If set, will be used to request the next animation frame for the render loop
  34059. */
  34060. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34061. /**
  34062. * Observable raised when the engine ends the current frame
  34063. */
  34064. onEndFrameObservable: Observable<Engine>;
  34065. /**
  34066. * Observable raised when the engine is about to compile a shader
  34067. */
  34068. onBeforeShaderCompilationObservable: Observable<Engine>;
  34069. /**
  34070. * Observable raised when the engine has jsut compiled a shader
  34071. */
  34072. onAfterShaderCompilationObservable: Observable<Engine>;
  34073. /**
  34074. * Gets the audio engine
  34075. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34076. * @ignorenaming
  34077. */
  34078. static audioEngine: IAudioEngine;
  34079. /**
  34080. * Default AudioEngine factory responsible of creating the Audio Engine.
  34081. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34082. */
  34083. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34084. /**
  34085. * Default offline support factory responsible of creating a tool used to store data locally.
  34086. * By default, this will create a Database object if the workload has been embedded.
  34087. */
  34088. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34089. private _loadingScreen;
  34090. private _pointerLockRequested;
  34091. private _dummyFramebuffer;
  34092. private _rescalePostProcess;
  34093. private _deterministicLockstep;
  34094. private _lockstepMaxSteps;
  34095. private _timeStep;
  34096. protected get _supportsHardwareTextureRescaling(): boolean;
  34097. private _fps;
  34098. private _deltaTime;
  34099. /** @hidden */
  34100. _drawCalls: PerfCounter;
  34101. /**
  34102. * Turn this value on if you want to pause FPS computation when in background
  34103. */
  34104. disablePerformanceMonitorInBackground: boolean;
  34105. private _performanceMonitor;
  34106. /**
  34107. * Gets the performance monitor attached to this engine
  34108. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34109. */
  34110. get performanceMonitor(): PerformanceMonitor;
  34111. private _onFocus;
  34112. private _onBlur;
  34113. private _onCanvasPointerOut;
  34114. private _onCanvasBlur;
  34115. private _onCanvasFocus;
  34116. private _onFullscreenChange;
  34117. private _onPointerLockChange;
  34118. /**
  34119. * Gets the HTML element used to attach event listeners
  34120. * @returns a HTML element
  34121. */
  34122. getInputElement(): Nullable<HTMLElement>;
  34123. /**
  34124. * Creates a new engine
  34125. * @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
  34126. * @param antialias defines enable antialiasing (default: false)
  34127. * @param options defines further options to be sent to the getContext() function
  34128. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34129. */
  34130. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34131. /**
  34132. * Gets current aspect ratio
  34133. * @param viewportOwner defines the camera to use to get the aspect ratio
  34134. * @param useScreen defines if screen size must be used (or the current render target if any)
  34135. * @returns a number defining the aspect ratio
  34136. */
  34137. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34138. /**
  34139. * Gets current screen aspect ratio
  34140. * @returns a number defining the aspect ratio
  34141. */
  34142. getScreenAspectRatio(): number;
  34143. /**
  34144. * Gets the client rect of the HTML canvas attached with the current webGL context
  34145. * @returns a client rectanglee
  34146. */
  34147. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34148. /**
  34149. * Gets the client rect of the HTML element used for events
  34150. * @returns a client rectanglee
  34151. */
  34152. getInputElementClientRect(): Nullable<ClientRect>;
  34153. /**
  34154. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34155. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34156. * @returns true if engine is in deterministic lock step mode
  34157. */
  34158. isDeterministicLockStep(): boolean;
  34159. /**
  34160. * Gets the max steps when engine is running in deterministic lock step
  34161. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34162. * @returns the max steps
  34163. */
  34164. getLockstepMaxSteps(): number;
  34165. /**
  34166. * Returns the time in ms between steps when using deterministic lock step.
  34167. * @returns time step in (ms)
  34168. */
  34169. getTimeStep(): number;
  34170. /**
  34171. * Force the mipmap generation for the given render target texture
  34172. * @param texture defines the render target texture to use
  34173. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34174. */
  34175. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34176. /** States */
  34177. /**
  34178. * Set various states to the webGL context
  34179. * @param culling defines backface culling state
  34180. * @param zOffset defines the value to apply to zOffset (0 by default)
  34181. * @param force defines if states must be applied even if cache is up to date
  34182. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34183. */
  34184. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34185. /**
  34186. * Set the z offset to apply to current rendering
  34187. * @param value defines the offset to apply
  34188. */
  34189. setZOffset(value: number): void;
  34190. /**
  34191. * Gets the current value of the zOffset
  34192. * @returns the current zOffset state
  34193. */
  34194. getZOffset(): number;
  34195. /**
  34196. * Enable or disable depth buffering
  34197. * @param enable defines the state to set
  34198. */
  34199. setDepthBuffer(enable: boolean): void;
  34200. /**
  34201. * Gets a boolean indicating if depth writing is enabled
  34202. * @returns the current depth writing state
  34203. */
  34204. getDepthWrite(): boolean;
  34205. /**
  34206. * Enable or disable depth writing
  34207. * @param enable defines the state to set
  34208. */
  34209. setDepthWrite(enable: boolean): void;
  34210. /**
  34211. * Gets a boolean indicating if stencil buffer is enabled
  34212. * @returns the current stencil buffer state
  34213. */
  34214. getStencilBuffer(): boolean;
  34215. /**
  34216. * Enable or disable the stencil buffer
  34217. * @param enable defines if the stencil buffer must be enabled or disabled
  34218. */
  34219. setStencilBuffer(enable: boolean): void;
  34220. /**
  34221. * Gets the current stencil mask
  34222. * @returns a number defining the new stencil mask to use
  34223. */
  34224. getStencilMask(): number;
  34225. /**
  34226. * Sets the current stencil mask
  34227. * @param mask defines the new stencil mask to use
  34228. */
  34229. setStencilMask(mask: number): void;
  34230. /**
  34231. * Gets the current stencil function
  34232. * @returns a number defining the stencil function to use
  34233. */
  34234. getStencilFunction(): number;
  34235. /**
  34236. * Gets the current stencil reference value
  34237. * @returns a number defining the stencil reference value to use
  34238. */
  34239. getStencilFunctionReference(): number;
  34240. /**
  34241. * Gets the current stencil mask
  34242. * @returns a number defining the stencil mask to use
  34243. */
  34244. getStencilFunctionMask(): number;
  34245. /**
  34246. * Sets the current stencil function
  34247. * @param stencilFunc defines the new stencil function to use
  34248. */
  34249. setStencilFunction(stencilFunc: number): void;
  34250. /**
  34251. * Sets the current stencil reference
  34252. * @param reference defines the new stencil reference to use
  34253. */
  34254. setStencilFunctionReference(reference: number): void;
  34255. /**
  34256. * Sets the current stencil mask
  34257. * @param mask defines the new stencil mask to use
  34258. */
  34259. setStencilFunctionMask(mask: number): void;
  34260. /**
  34261. * Gets the current stencil operation when stencil fails
  34262. * @returns a number defining stencil operation to use when stencil fails
  34263. */
  34264. getStencilOperationFail(): number;
  34265. /**
  34266. * Gets the current stencil operation when depth fails
  34267. * @returns a number defining stencil operation to use when depth fails
  34268. */
  34269. getStencilOperationDepthFail(): number;
  34270. /**
  34271. * Gets the current stencil operation when stencil passes
  34272. * @returns a number defining stencil operation to use when stencil passes
  34273. */
  34274. getStencilOperationPass(): number;
  34275. /**
  34276. * Sets the stencil operation to use when stencil fails
  34277. * @param operation defines the stencil operation to use when stencil fails
  34278. */
  34279. setStencilOperationFail(operation: number): void;
  34280. /**
  34281. * Sets the stencil operation to use when depth fails
  34282. * @param operation defines the stencil operation to use when depth fails
  34283. */
  34284. setStencilOperationDepthFail(operation: number): void;
  34285. /**
  34286. * Sets the stencil operation to use when stencil passes
  34287. * @param operation defines the stencil operation to use when stencil passes
  34288. */
  34289. setStencilOperationPass(operation: number): void;
  34290. /**
  34291. * Sets a boolean indicating if the dithering state is enabled or disabled
  34292. * @param value defines the dithering state
  34293. */
  34294. setDitheringState(value: boolean): void;
  34295. /**
  34296. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34297. * @param value defines the rasterizer state
  34298. */
  34299. setRasterizerState(value: boolean): void;
  34300. /**
  34301. * Gets the current depth function
  34302. * @returns a number defining the depth function
  34303. */
  34304. getDepthFunction(): Nullable<number>;
  34305. /**
  34306. * Sets the current depth function
  34307. * @param depthFunc defines the function to use
  34308. */
  34309. setDepthFunction(depthFunc: number): void;
  34310. /**
  34311. * Sets the current depth function to GREATER
  34312. */
  34313. setDepthFunctionToGreater(): void;
  34314. /**
  34315. * Sets the current depth function to GEQUAL
  34316. */
  34317. setDepthFunctionToGreaterOrEqual(): void;
  34318. /**
  34319. * Sets the current depth function to LESS
  34320. */
  34321. setDepthFunctionToLess(): void;
  34322. /**
  34323. * Sets the current depth function to LEQUAL
  34324. */
  34325. setDepthFunctionToLessOrEqual(): void;
  34326. private _cachedStencilBuffer;
  34327. private _cachedStencilFunction;
  34328. private _cachedStencilMask;
  34329. private _cachedStencilOperationPass;
  34330. private _cachedStencilOperationFail;
  34331. private _cachedStencilOperationDepthFail;
  34332. private _cachedStencilReference;
  34333. /**
  34334. * Caches the the state of the stencil buffer
  34335. */
  34336. cacheStencilState(): void;
  34337. /**
  34338. * Restores the state of the stencil buffer
  34339. */
  34340. restoreStencilState(): void;
  34341. /**
  34342. * Directly set the WebGL Viewport
  34343. * @param x defines the x coordinate of the viewport (in screen space)
  34344. * @param y defines the y coordinate of the viewport (in screen space)
  34345. * @param width defines the width of the viewport (in screen space)
  34346. * @param height defines the height of the viewport (in screen space)
  34347. * @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
  34348. */
  34349. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34350. /**
  34351. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34352. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34353. * @param y defines the y-coordinate of the corner of the clear rectangle
  34354. * @param width defines the width of the clear rectangle
  34355. * @param height defines the height of the clear rectangle
  34356. * @param clearColor defines the clear color
  34357. */
  34358. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34359. /**
  34360. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34361. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34362. * @param y defines the y-coordinate of the corner of the clear rectangle
  34363. * @param width defines the width of the clear rectangle
  34364. * @param height defines the height of the clear rectangle
  34365. */
  34366. enableScissor(x: number, y: number, width: number, height: number): void;
  34367. /**
  34368. * Disable previously set scissor test rectangle
  34369. */
  34370. disableScissor(): void;
  34371. protected _reportDrawCall(): void;
  34372. /**
  34373. * Initializes a webVR display and starts listening to display change events
  34374. * The onVRDisplayChangedObservable will be notified upon these changes
  34375. * @returns The onVRDisplayChangedObservable
  34376. */
  34377. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34378. /** @hidden */
  34379. _prepareVRComponent(): void;
  34380. /** @hidden */
  34381. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34382. /** @hidden */
  34383. _submitVRFrame(): void;
  34384. /**
  34385. * Call this function to leave webVR mode
  34386. * Will do nothing if webVR is not supported or if there is no webVR device
  34387. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34388. */
  34389. disableVR(): void;
  34390. /**
  34391. * Gets a boolean indicating that the system is in VR mode and is presenting
  34392. * @returns true if VR mode is engaged
  34393. */
  34394. isVRPresenting(): boolean;
  34395. /** @hidden */
  34396. _requestVRFrame(): void;
  34397. /** @hidden */
  34398. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34399. /**
  34400. * Gets the source code of the vertex shader associated with a specific webGL program
  34401. * @param program defines the program to use
  34402. * @returns a string containing the source code of the vertex shader associated with the program
  34403. */
  34404. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34405. /**
  34406. * Gets the source code of the fragment shader associated with a specific webGL program
  34407. * @param program defines the program to use
  34408. * @returns a string containing the source code of the fragment shader associated with the program
  34409. */
  34410. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34411. /**
  34412. * Sets a depth stencil texture from a render target to the according uniform.
  34413. * @param channel The texture channel
  34414. * @param uniform The uniform to set
  34415. * @param texture The render target texture containing the depth stencil texture to apply
  34416. */
  34417. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34418. /**
  34419. * Sets a texture to the webGL context from a postprocess
  34420. * @param channel defines the channel to use
  34421. * @param postProcess defines the source postprocess
  34422. */
  34423. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34424. /**
  34425. * Binds the output of the passed in post process to the texture channel specified
  34426. * @param channel The channel the texture should be bound to
  34427. * @param postProcess The post process which's output should be bound
  34428. */
  34429. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34430. /** @hidden */
  34431. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34432. protected _rebuildBuffers(): void;
  34433. /** @hidden */
  34434. _renderFrame(): void;
  34435. _renderLoop(): void;
  34436. /** @hidden */
  34437. _renderViews(): boolean;
  34438. /**
  34439. * Toggle full screen mode
  34440. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34441. */
  34442. switchFullscreen(requestPointerLock: boolean): void;
  34443. /**
  34444. * Enters full screen mode
  34445. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34446. */
  34447. enterFullscreen(requestPointerLock: boolean): void;
  34448. /**
  34449. * Exits full screen mode
  34450. */
  34451. exitFullscreen(): void;
  34452. /**
  34453. * Enters Pointerlock mode
  34454. */
  34455. enterPointerlock(): void;
  34456. /**
  34457. * Exits Pointerlock mode
  34458. */
  34459. exitPointerlock(): void;
  34460. /**
  34461. * Begin a new frame
  34462. */
  34463. beginFrame(): void;
  34464. /**
  34465. * Enf the current frame
  34466. */
  34467. endFrame(): void;
  34468. resize(): void;
  34469. /**
  34470. * Set the compressed texture format to use, based on the formats you have, and the formats
  34471. * supported by the hardware / browser.
  34472. *
  34473. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  34474. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  34475. * to API arguments needed to compressed textures. This puts the burden on the container
  34476. * generator to house the arcane code for determining these for current & future formats.
  34477. *
  34478. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  34479. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  34480. *
  34481. * Note: The result of this call is not taken into account when a texture is base64.
  34482. *
  34483. * @param formatsAvailable defines the list of those format families you have created
  34484. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  34485. *
  34486. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  34487. * @returns The extension selected.
  34488. */
  34489. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  34490. /**
  34491. * Set the compressed texture extensions or file names to skip.
  34492. *
  34493. * @param skippedFiles defines the list of those texture files you want to skip
  34494. * Example: [".dds", ".env", "myfile.png"]
  34495. */
  34496. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  34497. /**
  34498. * Force a specific size of the canvas
  34499. * @param width defines the new canvas' width
  34500. * @param height defines the new canvas' height
  34501. */
  34502. setSize(width: number, height: number): void;
  34503. /**
  34504. * Updates a dynamic vertex buffer.
  34505. * @param vertexBuffer the vertex buffer to update
  34506. * @param data the data used to update the vertex buffer
  34507. * @param byteOffset the byte offset of the data
  34508. * @param byteLength the byte length of the data
  34509. */
  34510. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34511. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34512. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34513. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34514. _releaseTexture(texture: InternalTexture): void;
  34515. /**
  34516. * @hidden
  34517. * Rescales a texture
  34518. * @param source input texutre
  34519. * @param destination destination texture
  34520. * @param scene scene to use to render the resize
  34521. * @param internalFormat format to use when resizing
  34522. * @param onComplete callback to be called when resize has completed
  34523. */
  34524. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34525. /**
  34526. * Gets the current framerate
  34527. * @returns a number representing the framerate
  34528. */
  34529. getFps(): number;
  34530. /**
  34531. * Gets the time spent between current and previous frame
  34532. * @returns a number representing the delta time in ms
  34533. */
  34534. getDeltaTime(): number;
  34535. private _measureFps;
  34536. /** @hidden */
  34537. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34538. /**
  34539. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  34540. * @param renderTarget The render target to set the frame buffer for
  34541. */
  34542. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  34543. /**
  34544. * Update a dynamic index buffer
  34545. * @param indexBuffer defines the target index buffer
  34546. * @param indices defines the data to update
  34547. * @param offset defines the offset in the target index buffer where update should start
  34548. */
  34549. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34550. /**
  34551. * Updates the sample count of a render target texture
  34552. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34553. * @param texture defines the texture to update
  34554. * @param samples defines the sample count to set
  34555. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34556. */
  34557. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34558. /**
  34559. * Updates a depth texture Comparison Mode and Function.
  34560. * If the comparison Function is equal to 0, the mode will be set to none.
  34561. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34562. * @param texture The texture to set the comparison function for
  34563. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34564. */
  34565. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34566. /**
  34567. * Creates a webGL buffer to use with instanciation
  34568. * @param capacity defines the size of the buffer
  34569. * @returns the webGL buffer
  34570. */
  34571. createInstancesBuffer(capacity: number): DataBuffer;
  34572. /**
  34573. * Delete a webGL buffer used with instanciation
  34574. * @param buffer defines the webGL buffer to delete
  34575. */
  34576. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34577. /** @hidden */
  34578. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34579. dispose(): void;
  34580. private _disableTouchAction;
  34581. /**
  34582. * Display the loading screen
  34583. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34584. */
  34585. displayLoadingUI(): void;
  34586. /**
  34587. * Hide the loading screen
  34588. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34589. */
  34590. hideLoadingUI(): void;
  34591. /**
  34592. * Gets the current loading screen object
  34593. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34594. */
  34595. get loadingScreen(): ILoadingScreen;
  34596. /**
  34597. * Sets the current loading screen object
  34598. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34599. */
  34600. set loadingScreen(loadingScreen: ILoadingScreen);
  34601. /**
  34602. * Sets the current loading screen text
  34603. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34604. */
  34605. set loadingUIText(text: string);
  34606. /**
  34607. * Sets the current loading screen background color
  34608. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34609. */
  34610. set loadingUIBackgroundColor(color: string);
  34611. /** Pointerlock and fullscreen */
  34612. /**
  34613. * Ask the browser to promote the current element to pointerlock mode
  34614. * @param element defines the DOM element to promote
  34615. */
  34616. static _RequestPointerlock(element: HTMLElement): void;
  34617. /**
  34618. * Asks the browser to exit pointerlock mode
  34619. */
  34620. static _ExitPointerlock(): void;
  34621. /**
  34622. * Ask the browser to promote the current element to fullscreen rendering mode
  34623. * @param element defines the DOM element to promote
  34624. */
  34625. static _RequestFullscreen(element: HTMLElement): void;
  34626. /**
  34627. * Asks the browser to exit fullscreen mode
  34628. */
  34629. static _ExitFullscreen(): void;
  34630. }
  34631. }
  34632. declare module "babylonjs/Engines/engineStore" {
  34633. import { Nullable } from "babylonjs/types";
  34634. import { Engine } from "babylonjs/Engines/engine";
  34635. import { Scene } from "babylonjs/scene";
  34636. /**
  34637. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34638. * during the life time of the application.
  34639. */
  34640. export class EngineStore {
  34641. /** Gets the list of created engines */
  34642. static Instances: import("babylonjs/Engines/engine").Engine[];
  34643. /** @hidden */
  34644. static _LastCreatedScene: Nullable<Scene>;
  34645. /**
  34646. * Gets the latest created engine
  34647. */
  34648. static get LastCreatedEngine(): Nullable<Engine>;
  34649. /**
  34650. * Gets the latest created scene
  34651. */
  34652. static get LastCreatedScene(): Nullable<Scene>;
  34653. /**
  34654. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34655. * @ignorenaming
  34656. */
  34657. static UseFallbackTexture: boolean;
  34658. /**
  34659. * Texture content used if a texture cannot loaded
  34660. * @ignorenaming
  34661. */
  34662. static FallbackTexture: string;
  34663. }
  34664. }
  34665. declare module "babylonjs/Misc/promise" {
  34666. /**
  34667. * Helper class that provides a small promise polyfill
  34668. */
  34669. export class PromisePolyfill {
  34670. /**
  34671. * Static function used to check if the polyfill is required
  34672. * If this is the case then the function will inject the polyfill to window.Promise
  34673. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34674. */
  34675. static Apply(force?: boolean): void;
  34676. }
  34677. }
  34678. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34679. /**
  34680. * Interface for screenshot methods with describe argument called `size` as object with options
  34681. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34682. */
  34683. export interface IScreenshotSize {
  34684. /**
  34685. * number in pixels for canvas height
  34686. */
  34687. height?: number;
  34688. /**
  34689. * multiplier allowing render at a higher or lower resolution
  34690. * If value is defined then height and width will be ignored and taken from camera
  34691. */
  34692. precision?: number;
  34693. /**
  34694. * number in pixels for canvas width
  34695. */
  34696. width?: number;
  34697. }
  34698. }
  34699. declare module "babylonjs/Misc/tools" {
  34700. import { Nullable, float } from "babylonjs/types";
  34701. import { DomManagement } from "babylonjs/Misc/domManagement";
  34702. import { WebRequest } from "babylonjs/Misc/webRequest";
  34703. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34704. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34705. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34706. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34707. import { Camera } from "babylonjs/Cameras/camera";
  34708. import { Engine } from "babylonjs/Engines/engine";
  34709. interface IColor4Like {
  34710. r: float;
  34711. g: float;
  34712. b: float;
  34713. a: float;
  34714. }
  34715. /**
  34716. * Class containing a set of static utilities functions
  34717. */
  34718. export class Tools {
  34719. /**
  34720. * Gets or sets the base URL to use to load assets
  34721. */
  34722. static get BaseUrl(): string;
  34723. static set BaseUrl(value: string);
  34724. /**
  34725. * Enable/Disable Custom HTTP Request Headers globally.
  34726. * default = false
  34727. * @see CustomRequestHeaders
  34728. */
  34729. static UseCustomRequestHeaders: boolean;
  34730. /**
  34731. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34732. * i.e. when loading files, where the server/service expects an Authorization header
  34733. */
  34734. static CustomRequestHeaders: {
  34735. [key: string]: string;
  34736. };
  34737. /**
  34738. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34739. */
  34740. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34741. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34742. /**
  34743. * Default behaviour for cors in the application.
  34744. * It can be a string if the expected behavior is identical in the entire app.
  34745. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34746. */
  34747. static CorsBehavior: string | ((url: string | string[]) => string);
  34748. /**
  34749. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34750. * @ignorenaming
  34751. */
  34752. static get UseFallbackTexture(): boolean;
  34753. static set UseFallbackTexture(value: boolean);
  34754. /**
  34755. * Use this object to register external classes like custom textures or material
  34756. * to allow the laoders to instantiate them
  34757. */
  34758. static get RegisteredExternalClasses(): {
  34759. [key: string]: Object;
  34760. };
  34761. static set RegisteredExternalClasses(classes: {
  34762. [key: string]: Object;
  34763. });
  34764. /**
  34765. * Texture content used if a texture cannot loaded
  34766. * @ignorenaming
  34767. */
  34768. static get fallbackTexture(): string;
  34769. static set fallbackTexture(value: string);
  34770. /**
  34771. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34772. * @param u defines the coordinate on X axis
  34773. * @param v defines the coordinate on Y axis
  34774. * @param width defines the width of the source data
  34775. * @param height defines the height of the source data
  34776. * @param pixels defines the source byte array
  34777. * @param color defines the output color
  34778. */
  34779. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34780. /**
  34781. * Interpolates between a and b via alpha
  34782. * @param a The lower value (returned when alpha = 0)
  34783. * @param b The upper value (returned when alpha = 1)
  34784. * @param alpha The interpolation-factor
  34785. * @return The mixed value
  34786. */
  34787. static Mix(a: number, b: number, alpha: number): number;
  34788. /**
  34789. * Tries to instantiate a new object from a given class name
  34790. * @param className defines the class name to instantiate
  34791. * @returns the new object or null if the system was not able to do the instantiation
  34792. */
  34793. static Instantiate(className: string): any;
  34794. /**
  34795. * Provides a slice function that will work even on IE
  34796. * @param data defines the array to slice
  34797. * @param start defines the start of the data (optional)
  34798. * @param end defines the end of the data (optional)
  34799. * @returns the new sliced array
  34800. */
  34801. static Slice<T>(data: T, start?: number, end?: number): T;
  34802. /**
  34803. * Polyfill for setImmediate
  34804. * @param action defines the action to execute after the current execution block
  34805. */
  34806. static SetImmediate(action: () => void): void;
  34807. /**
  34808. * Function indicating if a number is an exponent of 2
  34809. * @param value defines the value to test
  34810. * @returns true if the value is an exponent of 2
  34811. */
  34812. static IsExponentOfTwo(value: number): boolean;
  34813. private static _tmpFloatArray;
  34814. /**
  34815. * Returns the nearest 32-bit single precision float representation of a Number
  34816. * @param value A Number. If the parameter is of a different type, it will get converted
  34817. * to a number or to NaN if it cannot be converted
  34818. * @returns number
  34819. */
  34820. static FloatRound(value: number): number;
  34821. /**
  34822. * Extracts the filename from a path
  34823. * @param path defines the path to use
  34824. * @returns the filename
  34825. */
  34826. static GetFilename(path: string): string;
  34827. /**
  34828. * Extracts the "folder" part of a path (everything before the filename).
  34829. * @param uri The URI to extract the info from
  34830. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34831. * @returns The "folder" part of the path
  34832. */
  34833. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34834. /**
  34835. * Extracts text content from a DOM element hierarchy
  34836. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34837. */
  34838. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34839. /**
  34840. * Convert an angle in radians to degrees
  34841. * @param angle defines the angle to convert
  34842. * @returns the angle in degrees
  34843. */
  34844. static ToDegrees(angle: number): number;
  34845. /**
  34846. * Convert an angle in degrees to radians
  34847. * @param angle defines the angle to convert
  34848. * @returns the angle in radians
  34849. */
  34850. static ToRadians(angle: number): number;
  34851. /**
  34852. * Returns an array if obj is not an array
  34853. * @param obj defines the object to evaluate as an array
  34854. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34855. * @returns either obj directly if obj is an array or a new array containing obj
  34856. */
  34857. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34858. /**
  34859. * Gets the pointer prefix to use
  34860. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34861. */
  34862. static GetPointerPrefix(): string;
  34863. /**
  34864. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34865. * @param url define the url we are trying
  34866. * @param element define the dom element where to configure the cors policy
  34867. */
  34868. static SetCorsBehavior(url: string | string[], element: {
  34869. crossOrigin: string | null;
  34870. }): void;
  34871. /**
  34872. * Removes unwanted characters from an url
  34873. * @param url defines the url to clean
  34874. * @returns the cleaned url
  34875. */
  34876. static CleanUrl(url: string): string;
  34877. /**
  34878. * Gets or sets a function used to pre-process url before using them to load assets
  34879. */
  34880. static get PreprocessUrl(): (url: string) => string;
  34881. static set PreprocessUrl(processor: (url: string) => string);
  34882. /**
  34883. * Loads an image as an HTMLImageElement.
  34884. * @param input url string, ArrayBuffer, or Blob to load
  34885. * @param onLoad callback called when the image successfully loads
  34886. * @param onError callback called when the image fails to load
  34887. * @param offlineProvider offline provider for caching
  34888. * @param mimeType optional mime type
  34889. * @returns the HTMLImageElement of the loaded image
  34890. */
  34891. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34892. /**
  34893. * Loads a file from a url
  34894. * @param url url string, ArrayBuffer, or Blob to load
  34895. * @param onSuccess callback called when the file successfully loads
  34896. * @param onProgress callback called while file is loading (if the server supports this mode)
  34897. * @param offlineProvider defines the offline provider for caching
  34898. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34899. * @param onError callback called when the file fails to load
  34900. * @returns a file request object
  34901. */
  34902. 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;
  34903. /**
  34904. * Loads a file from a url
  34905. * @param url the file url to load
  34906. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  34907. */
  34908. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  34909. /**
  34910. * Load a script (identified by an url). When the url returns, the
  34911. * content of this file is added into a new script element, attached to the DOM (body element)
  34912. * @param scriptUrl defines the url of the script to laod
  34913. * @param onSuccess defines the callback called when the script is loaded
  34914. * @param onError defines the callback to call if an error occurs
  34915. * @param scriptId defines the id of the script element
  34916. */
  34917. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34918. /**
  34919. * Load an asynchronous script (identified by an url). When the url returns, the
  34920. * content of this file is added into a new script element, attached to the DOM (body element)
  34921. * @param scriptUrl defines the url of the script to laod
  34922. * @param scriptId defines the id of the script element
  34923. * @returns a promise request object
  34924. */
  34925. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34926. /**
  34927. * Loads a file from a blob
  34928. * @param fileToLoad defines the blob to use
  34929. * @param callback defines the callback to call when data is loaded
  34930. * @param progressCallback defines the callback to call during loading process
  34931. * @returns a file request object
  34932. */
  34933. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34934. /**
  34935. * Reads a file from a File object
  34936. * @param file defines the file to load
  34937. * @param onSuccess defines the callback to call when data is loaded
  34938. * @param onProgress defines the callback to call during loading process
  34939. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34940. * @param onError defines the callback to call when an error occurs
  34941. * @returns a file request object
  34942. */
  34943. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34944. /**
  34945. * Creates a data url from a given string content
  34946. * @param content defines the content to convert
  34947. * @returns the new data url link
  34948. */
  34949. static FileAsURL(content: string): string;
  34950. /**
  34951. * Format the given number to a specific decimal format
  34952. * @param value defines the number to format
  34953. * @param decimals defines the number of decimals to use
  34954. * @returns the formatted string
  34955. */
  34956. static Format(value: number, decimals?: number): string;
  34957. /**
  34958. * Tries to copy an object by duplicating every property
  34959. * @param source defines the source object
  34960. * @param destination defines the target object
  34961. * @param doNotCopyList defines a list of properties to avoid
  34962. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34963. */
  34964. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34965. /**
  34966. * Gets a boolean indicating if the given object has no own property
  34967. * @param obj defines the object to test
  34968. * @returns true if object has no own property
  34969. */
  34970. static IsEmpty(obj: any): boolean;
  34971. /**
  34972. * Function used to register events at window level
  34973. * @param windowElement defines the Window object to use
  34974. * @param events defines the events to register
  34975. */
  34976. static RegisterTopRootEvents(windowElement: Window, events: {
  34977. name: string;
  34978. handler: Nullable<(e: FocusEvent) => any>;
  34979. }[]): void;
  34980. /**
  34981. * Function used to unregister events from window level
  34982. * @param windowElement defines the Window object to use
  34983. * @param events defines the events to unregister
  34984. */
  34985. static UnregisterTopRootEvents(windowElement: Window, events: {
  34986. name: string;
  34987. handler: Nullable<(e: FocusEvent) => any>;
  34988. }[]): void;
  34989. /**
  34990. * @ignore
  34991. */
  34992. static _ScreenshotCanvas: HTMLCanvasElement;
  34993. /**
  34994. * Dumps the current bound framebuffer
  34995. * @param width defines the rendering width
  34996. * @param height defines the rendering height
  34997. * @param engine defines the hosting engine
  34998. * @param successCallback defines the callback triggered once the data are available
  34999. * @param mimeType defines the mime type of the result
  35000. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35001. */
  35002. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35003. /**
  35004. * Converts the canvas data to blob.
  35005. * This acts as a polyfill for browsers not supporting the to blob function.
  35006. * @param canvas Defines the canvas to extract the data from
  35007. * @param successCallback Defines the callback triggered once the data are available
  35008. * @param mimeType Defines the mime type of the result
  35009. */
  35010. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35011. /**
  35012. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35013. * @param successCallback defines the callback triggered once the data are available
  35014. * @param mimeType defines the mime type of the result
  35015. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35016. */
  35017. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35018. /**
  35019. * Downloads a blob in the browser
  35020. * @param blob defines the blob to download
  35021. * @param fileName defines the name of the downloaded file
  35022. */
  35023. static Download(blob: Blob, fileName: string): void;
  35024. /**
  35025. * Captures a screenshot of the current rendering
  35026. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35027. * @param engine defines the rendering engine
  35028. * @param camera defines the source camera
  35029. * @param size This parameter can be set to a single number or to an object with the
  35030. * following (optional) properties: precision, width, height. If a single number is passed,
  35031. * it will be used for both width and height. If an object is passed, the screenshot size
  35032. * will be derived from the parameters. The precision property is a multiplier allowing
  35033. * rendering at a higher or lower resolution
  35034. * @param successCallback defines the callback receives a single parameter which contains the
  35035. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35036. * src parameter of an <img> to display it
  35037. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35038. * Check your browser for supported MIME types
  35039. */
  35040. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35041. /**
  35042. * Captures a screenshot of the current rendering
  35043. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35044. * @param engine defines the rendering engine
  35045. * @param camera defines the source camera
  35046. * @param size This parameter can be set to a single number or to an object with the
  35047. * following (optional) properties: precision, width, height. If a single number is passed,
  35048. * it will be used for both width and height. If an object is passed, the screenshot size
  35049. * will be derived from the parameters. The precision property is a multiplier allowing
  35050. * rendering at a higher or lower resolution
  35051. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35052. * Check your browser for supported MIME types
  35053. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35054. * to the src parameter of an <img> to display it
  35055. */
  35056. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35057. /**
  35058. * Generates an image screenshot from the specified camera.
  35059. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35060. * @param engine The engine to use for rendering
  35061. * @param camera The camera to use for rendering
  35062. * @param size This parameter can be set to a single number or to an object with the
  35063. * following (optional) properties: precision, width, height. If a single number is passed,
  35064. * it will be used for both width and height. If an object is passed, the screenshot size
  35065. * will be derived from the parameters. The precision property is a multiplier allowing
  35066. * rendering at a higher or lower resolution
  35067. * @param successCallback The callback receives a single parameter which contains the
  35068. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35069. * src parameter of an <img> to display it
  35070. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35071. * Check your browser for supported MIME types
  35072. * @param samples Texture samples (default: 1)
  35073. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35074. * @param fileName A name for for the downloaded file.
  35075. */
  35076. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35077. /**
  35078. * Generates an image screenshot from the specified camera.
  35079. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35080. * @param engine The engine to use for rendering
  35081. * @param camera The camera to use for rendering
  35082. * @param size This parameter can be set to a single number or to an object with the
  35083. * following (optional) properties: precision, width, height. If a single number is passed,
  35084. * it will be used for both width and height. If an object is passed, the screenshot size
  35085. * will be derived from the parameters. The precision property is a multiplier allowing
  35086. * rendering at a higher or lower resolution
  35087. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35088. * Check your browser for supported MIME types
  35089. * @param samples Texture samples (default: 1)
  35090. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35091. * @param fileName A name for for the downloaded file.
  35092. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35093. * to the src parameter of an <img> to display it
  35094. */
  35095. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35096. /**
  35097. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35098. * Be aware Math.random() could cause collisions, but:
  35099. * "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"
  35100. * @returns a pseudo random id
  35101. */
  35102. static RandomId(): string;
  35103. /**
  35104. * Test if the given uri is a base64 string
  35105. * @param uri The uri to test
  35106. * @return True if the uri is a base64 string or false otherwise
  35107. */
  35108. static IsBase64(uri: string): boolean;
  35109. /**
  35110. * Decode the given base64 uri.
  35111. * @param uri The uri to decode
  35112. * @return The decoded base64 data.
  35113. */
  35114. static DecodeBase64(uri: string): ArrayBuffer;
  35115. /**
  35116. * Gets the absolute url.
  35117. * @param url the input url
  35118. * @return the absolute url
  35119. */
  35120. static GetAbsoluteUrl(url: string): string;
  35121. /**
  35122. * No log
  35123. */
  35124. static readonly NoneLogLevel: number;
  35125. /**
  35126. * Only message logs
  35127. */
  35128. static readonly MessageLogLevel: number;
  35129. /**
  35130. * Only warning logs
  35131. */
  35132. static readonly WarningLogLevel: number;
  35133. /**
  35134. * Only error logs
  35135. */
  35136. static readonly ErrorLogLevel: number;
  35137. /**
  35138. * All logs
  35139. */
  35140. static readonly AllLogLevel: number;
  35141. /**
  35142. * Gets a value indicating the number of loading errors
  35143. * @ignorenaming
  35144. */
  35145. static get errorsCount(): number;
  35146. /**
  35147. * Callback called when a new log is added
  35148. */
  35149. static OnNewCacheEntry: (entry: string) => void;
  35150. /**
  35151. * Log a message to the console
  35152. * @param message defines the message to log
  35153. */
  35154. static Log(message: string): void;
  35155. /**
  35156. * Write a warning message to the console
  35157. * @param message defines the message to log
  35158. */
  35159. static Warn(message: string): void;
  35160. /**
  35161. * Write an error message to the console
  35162. * @param message defines the message to log
  35163. */
  35164. static Error(message: string): void;
  35165. /**
  35166. * Gets current log cache (list of logs)
  35167. */
  35168. static get LogCache(): string;
  35169. /**
  35170. * Clears the log cache
  35171. */
  35172. static ClearLogCache(): void;
  35173. /**
  35174. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35175. */
  35176. static set LogLevels(level: number);
  35177. /**
  35178. * Checks if the window object exists
  35179. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35180. */
  35181. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35182. /**
  35183. * No performance log
  35184. */
  35185. static readonly PerformanceNoneLogLevel: number;
  35186. /**
  35187. * Use user marks to log performance
  35188. */
  35189. static readonly PerformanceUserMarkLogLevel: number;
  35190. /**
  35191. * Log performance to the console
  35192. */
  35193. static readonly PerformanceConsoleLogLevel: number;
  35194. private static _performance;
  35195. /**
  35196. * Sets the current performance log level
  35197. */
  35198. static set PerformanceLogLevel(level: number);
  35199. private static _StartPerformanceCounterDisabled;
  35200. private static _EndPerformanceCounterDisabled;
  35201. private static _StartUserMark;
  35202. private static _EndUserMark;
  35203. private static _StartPerformanceConsole;
  35204. private static _EndPerformanceConsole;
  35205. /**
  35206. * Starts a performance counter
  35207. */
  35208. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35209. /**
  35210. * Ends a specific performance coutner
  35211. */
  35212. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35213. /**
  35214. * Gets either window.performance.now() if supported or Date.now() else
  35215. */
  35216. static get Now(): number;
  35217. /**
  35218. * This method will return the name of the class used to create the instance of the given object.
  35219. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35220. * @param object the object to get the class name from
  35221. * @param isType defines if the object is actually a type
  35222. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35223. */
  35224. static GetClassName(object: any, isType?: boolean): string;
  35225. /**
  35226. * Gets the first element of an array satisfying a given predicate
  35227. * @param array defines the array to browse
  35228. * @param predicate defines the predicate to use
  35229. * @returns null if not found or the element
  35230. */
  35231. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35232. /**
  35233. * This method will return the name of the full name of the class, including its owning module (if any).
  35234. * 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).
  35235. * @param object the object to get the class name from
  35236. * @param isType defines if the object is actually a type
  35237. * @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.
  35238. * @ignorenaming
  35239. */
  35240. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35241. /**
  35242. * Returns a promise that resolves after the given amount of time.
  35243. * @param delay Number of milliseconds to delay
  35244. * @returns Promise that resolves after the given amount of time
  35245. */
  35246. static DelayAsync(delay: number): Promise<void>;
  35247. }
  35248. /**
  35249. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35250. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35251. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35252. * @param name The name of the class, case should be preserved
  35253. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35254. */
  35255. export function className(name: string, module?: string): (target: Object) => void;
  35256. /**
  35257. * An implementation of a loop for asynchronous functions.
  35258. */
  35259. export class AsyncLoop {
  35260. /**
  35261. * Defines the number of iterations for the loop
  35262. */
  35263. iterations: number;
  35264. /**
  35265. * Defines the current index of the loop.
  35266. */
  35267. index: number;
  35268. private _done;
  35269. private _fn;
  35270. private _successCallback;
  35271. /**
  35272. * Constructor.
  35273. * @param iterations the number of iterations.
  35274. * @param func the function to run each iteration
  35275. * @param successCallback the callback that will be called upon succesful execution
  35276. * @param offset starting offset.
  35277. */
  35278. constructor(
  35279. /**
  35280. * Defines the number of iterations for the loop
  35281. */
  35282. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35283. /**
  35284. * Execute the next iteration. Must be called after the last iteration was finished.
  35285. */
  35286. executeNext(): void;
  35287. /**
  35288. * Break the loop and run the success callback.
  35289. */
  35290. breakLoop(): void;
  35291. /**
  35292. * Create and run an async loop.
  35293. * @param iterations the number of iterations.
  35294. * @param fn the function to run each iteration
  35295. * @param successCallback the callback that will be called upon succesful execution
  35296. * @param offset starting offset.
  35297. * @returns the created async loop object
  35298. */
  35299. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35300. /**
  35301. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35302. * @param iterations total number of iterations
  35303. * @param syncedIterations number of synchronous iterations in each async iteration.
  35304. * @param fn the function to call each iteration.
  35305. * @param callback a success call back that will be called when iterating stops.
  35306. * @param breakFunction a break condition (optional)
  35307. * @param timeout timeout settings for the setTimeout function. default - 0.
  35308. * @returns the created async loop object
  35309. */
  35310. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35311. }
  35312. }
  35313. declare module "babylonjs/Misc/stringDictionary" {
  35314. import { Nullable } from "babylonjs/types";
  35315. /**
  35316. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35317. * The underlying implementation relies on an associative array to ensure the best performances.
  35318. * The value can be anything including 'null' but except 'undefined'
  35319. */
  35320. export class StringDictionary<T> {
  35321. /**
  35322. * This will clear this dictionary and copy the content from the 'source' one.
  35323. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35324. * @param source the dictionary to take the content from and copy to this dictionary
  35325. */
  35326. copyFrom(source: StringDictionary<T>): void;
  35327. /**
  35328. * Get a value based from its key
  35329. * @param key the given key to get the matching value from
  35330. * @return the value if found, otherwise undefined is returned
  35331. */
  35332. get(key: string): T | undefined;
  35333. /**
  35334. * Get a value from its key or add it if it doesn't exist.
  35335. * This method will ensure you that a given key/data will be present in the dictionary.
  35336. * @param key the given key to get the matching value from
  35337. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35338. * The factory will only be invoked if there's no data for the given key.
  35339. * @return the value corresponding to the key.
  35340. */
  35341. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35342. /**
  35343. * Get a value from its key if present in the dictionary otherwise add it
  35344. * @param key the key to get the value from
  35345. * @param val if there's no such key/value pair in the dictionary add it with this value
  35346. * @return the value corresponding to the key
  35347. */
  35348. getOrAdd(key: string, val: T): T;
  35349. /**
  35350. * Check if there's a given key in the dictionary
  35351. * @param key the key to check for
  35352. * @return true if the key is present, false otherwise
  35353. */
  35354. contains(key: string): boolean;
  35355. /**
  35356. * Add a new key and its corresponding value
  35357. * @param key the key to add
  35358. * @param value the value corresponding to the key
  35359. * @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
  35360. */
  35361. add(key: string, value: T): boolean;
  35362. /**
  35363. * Update a specific value associated to a key
  35364. * @param key defines the key to use
  35365. * @param value defines the value to store
  35366. * @returns true if the value was updated (or false if the key was not found)
  35367. */
  35368. set(key: string, value: T): boolean;
  35369. /**
  35370. * Get the element of the given key and remove it from the dictionary
  35371. * @param key defines the key to search
  35372. * @returns the value associated with the key or null if not found
  35373. */
  35374. getAndRemove(key: string): Nullable<T>;
  35375. /**
  35376. * Remove a key/value from the dictionary.
  35377. * @param key the key to remove
  35378. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35379. */
  35380. remove(key: string): boolean;
  35381. /**
  35382. * Clear the whole content of the dictionary
  35383. */
  35384. clear(): void;
  35385. /**
  35386. * Gets the current count
  35387. */
  35388. get count(): number;
  35389. /**
  35390. * Execute a callback on each key/val of the dictionary.
  35391. * Note that you can remove any element in this dictionary in the callback implementation
  35392. * @param callback the callback to execute on a given key/value pair
  35393. */
  35394. forEach(callback: (key: string, val: T) => void): void;
  35395. /**
  35396. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35397. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35398. * Note that you can remove any element in this dictionary in the callback implementation
  35399. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35400. * @returns the first item
  35401. */
  35402. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35403. private _count;
  35404. private _data;
  35405. }
  35406. }
  35407. declare module "babylonjs/Collisions/collisionCoordinator" {
  35408. import { Nullable } from "babylonjs/types";
  35409. import { Scene } from "babylonjs/scene";
  35410. import { Vector3 } from "babylonjs/Maths/math.vector";
  35411. import { Collider } from "babylonjs/Collisions/collider";
  35412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35413. /** @hidden */
  35414. export interface ICollisionCoordinator {
  35415. createCollider(): Collider;
  35416. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35417. init(scene: Scene): void;
  35418. }
  35419. /** @hidden */
  35420. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35421. private _scene;
  35422. private _scaledPosition;
  35423. private _scaledVelocity;
  35424. private _finalPosition;
  35425. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35426. createCollider(): Collider;
  35427. init(scene: Scene): void;
  35428. private _collideWithWorld;
  35429. }
  35430. }
  35431. declare module "babylonjs/Inputs/scene.inputManager" {
  35432. import { Nullable } from "babylonjs/types";
  35433. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35434. import { Vector2 } from "babylonjs/Maths/math.vector";
  35435. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35436. import { Scene } from "babylonjs/scene";
  35437. /**
  35438. * Class used to manage all inputs for the scene.
  35439. */
  35440. export class InputManager {
  35441. /** The distance in pixel that you have to move to prevent some events */
  35442. static DragMovementThreshold: number;
  35443. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35444. static LongPressDelay: number;
  35445. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35446. static DoubleClickDelay: number;
  35447. /** If you need to check double click without raising a single click at first click, enable this flag */
  35448. static ExclusiveDoubleClickMode: boolean;
  35449. private _wheelEventName;
  35450. private _onPointerMove;
  35451. private _onPointerDown;
  35452. private _onPointerUp;
  35453. private _initClickEvent;
  35454. private _initActionManager;
  35455. private _delayedSimpleClick;
  35456. private _delayedSimpleClickTimeout;
  35457. private _previousDelayedSimpleClickTimeout;
  35458. private _meshPickProceed;
  35459. private _previousButtonPressed;
  35460. private _currentPickResult;
  35461. private _previousPickResult;
  35462. private _totalPointersPressed;
  35463. private _doubleClickOccured;
  35464. private _pointerOverMesh;
  35465. private _pickedDownMesh;
  35466. private _pickedUpMesh;
  35467. private _pointerX;
  35468. private _pointerY;
  35469. private _unTranslatedPointerX;
  35470. private _unTranslatedPointerY;
  35471. private _startingPointerPosition;
  35472. private _previousStartingPointerPosition;
  35473. private _startingPointerTime;
  35474. private _previousStartingPointerTime;
  35475. private _pointerCaptures;
  35476. private _onKeyDown;
  35477. private _onKeyUp;
  35478. private _onCanvasFocusObserver;
  35479. private _onCanvasBlurObserver;
  35480. private _scene;
  35481. /**
  35482. * Creates a new InputManager
  35483. * @param scene defines the hosting scene
  35484. */
  35485. constructor(scene: Scene);
  35486. /**
  35487. * Gets the mesh that is currently under the pointer
  35488. */
  35489. get meshUnderPointer(): Nullable<AbstractMesh>;
  35490. /**
  35491. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35492. */
  35493. get unTranslatedPointer(): Vector2;
  35494. /**
  35495. * Gets or sets the current on-screen X position of the pointer
  35496. */
  35497. get pointerX(): number;
  35498. set pointerX(value: number);
  35499. /**
  35500. * Gets or sets the current on-screen Y position of the pointer
  35501. */
  35502. get pointerY(): number;
  35503. set pointerY(value: number);
  35504. private _updatePointerPosition;
  35505. private _processPointerMove;
  35506. private _setRayOnPointerInfo;
  35507. private _checkPrePointerObservable;
  35508. /**
  35509. * Use this method to simulate a pointer move on a mesh
  35510. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35511. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35512. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35513. */
  35514. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35515. /**
  35516. * Use this method to simulate a pointer down on a mesh
  35517. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35518. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35519. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35520. */
  35521. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35522. private _processPointerDown;
  35523. /** @hidden */
  35524. _isPointerSwiping(): boolean;
  35525. /**
  35526. * Use this method to simulate a pointer up on a mesh
  35527. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35528. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35529. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35530. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35531. */
  35532. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35533. private _processPointerUp;
  35534. /**
  35535. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35536. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35537. * @returns true if the pointer was captured
  35538. */
  35539. isPointerCaptured(pointerId?: number): boolean;
  35540. /**
  35541. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35542. * @param attachUp defines if you want to attach events to pointerup
  35543. * @param attachDown defines if you want to attach events to pointerdown
  35544. * @param attachMove defines if you want to attach events to pointermove
  35545. */
  35546. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35547. /**
  35548. * Detaches all event handlers
  35549. */
  35550. detachControl(): void;
  35551. /**
  35552. * Force the value of meshUnderPointer
  35553. * @param mesh defines the mesh to use
  35554. */
  35555. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35556. /**
  35557. * Gets the mesh under the pointer
  35558. * @returns a Mesh or null if no mesh is under the pointer
  35559. */
  35560. getPointerOverMesh(): Nullable<AbstractMesh>;
  35561. }
  35562. }
  35563. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35564. /**
  35565. * Helper class used to generate session unique ID
  35566. */
  35567. export class UniqueIdGenerator {
  35568. private static _UniqueIdCounter;
  35569. /**
  35570. * Gets an unique (relatively to the current scene) Id
  35571. */
  35572. static get UniqueId(): number;
  35573. }
  35574. }
  35575. declare module "babylonjs/Animations/animationGroup" {
  35576. import { Animatable } from "babylonjs/Animations/animatable";
  35577. import { Animation } from "babylonjs/Animations/animation";
  35578. import { Scene, IDisposable } from "babylonjs/scene";
  35579. import { Observable } from "babylonjs/Misc/observable";
  35580. import { Nullable } from "babylonjs/types";
  35581. import "babylonjs/Animations/animatable";
  35582. /**
  35583. * This class defines the direct association between an animation and a target
  35584. */
  35585. export class TargetedAnimation {
  35586. /**
  35587. * Animation to perform
  35588. */
  35589. animation: Animation;
  35590. /**
  35591. * Target to animate
  35592. */
  35593. target: any;
  35594. /**
  35595. * Serialize the object
  35596. * @returns the JSON object representing the current entity
  35597. */
  35598. serialize(): any;
  35599. }
  35600. /**
  35601. * Use this class to create coordinated animations on multiple targets
  35602. */
  35603. export class AnimationGroup implements IDisposable {
  35604. /** The name of the animation group */
  35605. name: string;
  35606. private _scene;
  35607. private _targetedAnimations;
  35608. private _animatables;
  35609. private _from;
  35610. private _to;
  35611. private _isStarted;
  35612. private _isPaused;
  35613. private _speedRatio;
  35614. private _loopAnimation;
  35615. /**
  35616. * Gets or sets the unique id of the node
  35617. */
  35618. uniqueId: number;
  35619. /**
  35620. * This observable will notify when one animation have ended
  35621. */
  35622. onAnimationEndObservable: Observable<TargetedAnimation>;
  35623. /**
  35624. * Observer raised when one animation loops
  35625. */
  35626. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35627. /**
  35628. * Observer raised when all animations have looped
  35629. */
  35630. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35631. /**
  35632. * This observable will notify when all animations have ended.
  35633. */
  35634. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35635. /**
  35636. * This observable will notify when all animations have paused.
  35637. */
  35638. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35639. /**
  35640. * This observable will notify when all animations are playing.
  35641. */
  35642. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35643. /**
  35644. * Gets the first frame
  35645. */
  35646. get from(): number;
  35647. /**
  35648. * Gets the last frame
  35649. */
  35650. get to(): number;
  35651. /**
  35652. * Define if the animations are started
  35653. */
  35654. get isStarted(): boolean;
  35655. /**
  35656. * Gets a value indicating that the current group is playing
  35657. */
  35658. get isPlaying(): boolean;
  35659. /**
  35660. * Gets or sets the speed ratio to use for all animations
  35661. */
  35662. get speedRatio(): number;
  35663. /**
  35664. * Gets or sets the speed ratio to use for all animations
  35665. */
  35666. set speedRatio(value: number);
  35667. /**
  35668. * Gets or sets if all animations should loop or not
  35669. */
  35670. get loopAnimation(): boolean;
  35671. set loopAnimation(value: boolean);
  35672. /**
  35673. * Gets the targeted animations for this animation group
  35674. */
  35675. get targetedAnimations(): Array<TargetedAnimation>;
  35676. /**
  35677. * returning the list of animatables controlled by this animation group.
  35678. */
  35679. get animatables(): Array<Animatable>;
  35680. /**
  35681. * Instantiates a new Animation Group.
  35682. * This helps managing several animations at once.
  35683. * @see http://doc.babylonjs.com/how_to/group
  35684. * @param name Defines the name of the group
  35685. * @param scene Defines the scene the group belongs to
  35686. */
  35687. constructor(
  35688. /** The name of the animation group */
  35689. name: string, scene?: Nullable<Scene>);
  35690. /**
  35691. * Add an animation (with its target) in the group
  35692. * @param animation defines the animation we want to add
  35693. * @param target defines the target of the animation
  35694. * @returns the TargetedAnimation object
  35695. */
  35696. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35697. /**
  35698. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35699. * It can add constant keys at begin or end
  35700. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35701. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35702. * @returns the animation group
  35703. */
  35704. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35705. private _animationLoopCount;
  35706. private _animationLoopFlags;
  35707. private _processLoop;
  35708. /**
  35709. * Start all animations on given targets
  35710. * @param loop defines if animations must loop
  35711. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35712. * @param from defines the from key (optional)
  35713. * @param to defines the to key (optional)
  35714. * @returns the current animation group
  35715. */
  35716. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35717. /**
  35718. * Pause all animations
  35719. * @returns the animation group
  35720. */
  35721. pause(): AnimationGroup;
  35722. /**
  35723. * Play all animations to initial state
  35724. * This function will start() the animations if they were not started or will restart() them if they were paused
  35725. * @param loop defines if animations must loop
  35726. * @returns the animation group
  35727. */
  35728. play(loop?: boolean): AnimationGroup;
  35729. /**
  35730. * Reset all animations to initial state
  35731. * @returns the animation group
  35732. */
  35733. reset(): AnimationGroup;
  35734. /**
  35735. * Restart animations from key 0
  35736. * @returns the animation group
  35737. */
  35738. restart(): AnimationGroup;
  35739. /**
  35740. * Stop all animations
  35741. * @returns the animation group
  35742. */
  35743. stop(): AnimationGroup;
  35744. /**
  35745. * Set animation weight for all animatables
  35746. * @param weight defines the weight to use
  35747. * @return the animationGroup
  35748. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35749. */
  35750. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35751. /**
  35752. * Synchronize and normalize all animatables with a source animatable
  35753. * @param root defines the root animatable to synchronize with
  35754. * @return the animationGroup
  35755. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35756. */
  35757. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35758. /**
  35759. * Goes to a specific frame in this animation group
  35760. * @param frame the frame number to go to
  35761. * @return the animationGroup
  35762. */
  35763. goToFrame(frame: number): AnimationGroup;
  35764. /**
  35765. * Dispose all associated resources
  35766. */
  35767. dispose(): void;
  35768. private _checkAnimationGroupEnded;
  35769. /**
  35770. * Clone the current animation group and returns a copy
  35771. * @param newName defines the name of the new group
  35772. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35773. * @returns the new aniamtion group
  35774. */
  35775. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35776. /**
  35777. * Serializes the animationGroup to an object
  35778. * @returns Serialized object
  35779. */
  35780. serialize(): any;
  35781. /**
  35782. * Returns a new AnimationGroup object parsed from the source provided.
  35783. * @param parsedAnimationGroup defines the source
  35784. * @param scene defines the scene that will receive the animationGroup
  35785. * @returns a new AnimationGroup
  35786. */
  35787. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35788. /**
  35789. * Returns the string "AnimationGroup"
  35790. * @returns "AnimationGroup"
  35791. */
  35792. getClassName(): string;
  35793. /**
  35794. * Creates a detailled string about the object
  35795. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35796. * @returns a string representing the object
  35797. */
  35798. toString(fullDetails?: boolean): string;
  35799. }
  35800. }
  35801. declare module "babylonjs/scene" {
  35802. import { Nullable } from "babylonjs/types";
  35803. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35804. import { Observable } from "babylonjs/Misc/observable";
  35805. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  35806. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  35807. import { Geometry } from "babylonjs/Meshes/geometry";
  35808. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35809. import { SubMesh } from "babylonjs/Meshes/subMesh";
  35810. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35811. import { Mesh } from "babylonjs/Meshes/mesh";
  35812. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35813. import { Bone } from "babylonjs/Bones/bone";
  35814. import { Skeleton } from "babylonjs/Bones/skeleton";
  35815. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35816. import { Camera } from "babylonjs/Cameras/camera";
  35817. import { AbstractScene } from "babylonjs/abstractScene";
  35818. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35819. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35820. import { Material } from "babylonjs/Materials/material";
  35821. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35822. import { Effect } from "babylonjs/Materials/effect";
  35823. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35824. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35825. import { Light } from "babylonjs/Lights/light";
  35826. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35827. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  35828. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  35829. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  35830. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35831. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  35832. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35833. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  35834. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  35835. import { Engine } from "babylonjs/Engines/engine";
  35836. import { Node } from "babylonjs/node";
  35837. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  35838. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35839. import { WebRequest } from "babylonjs/Misc/webRequest";
  35840. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  35841. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  35842. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35843. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  35844. import { Plane } from "babylonjs/Maths/math.plane";
  35845. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  35846. import { Ray } from "babylonjs/Culling/ray";
  35847. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  35848. import { Animation } from "babylonjs/Animations/animation";
  35849. import { Animatable } from "babylonjs/Animations/animatable";
  35850. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35851. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  35852. import { Collider } from "babylonjs/Collisions/collider";
  35853. /**
  35854. * Define an interface for all classes that will hold resources
  35855. */
  35856. export interface IDisposable {
  35857. /**
  35858. * Releases all held resources
  35859. */
  35860. dispose(): void;
  35861. }
  35862. /** Interface defining initialization parameters for Scene class */
  35863. export interface SceneOptions {
  35864. /**
  35865. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35866. * It will improve performance when the number of geometries becomes important.
  35867. */
  35868. useGeometryUniqueIdsMap?: boolean;
  35869. /**
  35870. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35871. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35872. */
  35873. useMaterialMeshMap?: boolean;
  35874. /**
  35875. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35876. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35877. */
  35878. useClonedMeshMap?: boolean;
  35879. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35880. virtual?: boolean;
  35881. }
  35882. /**
  35883. * Represents a scene to be rendered by the engine.
  35884. * @see http://doc.babylonjs.com/features/scene
  35885. */
  35886. export class Scene extends AbstractScene implements IAnimatable {
  35887. /** The fog is deactivated */
  35888. static readonly FOGMODE_NONE: number;
  35889. /** The fog density is following an exponential function */
  35890. static readonly FOGMODE_EXP: number;
  35891. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35892. static readonly FOGMODE_EXP2: number;
  35893. /** The fog density is following a linear function. */
  35894. static readonly FOGMODE_LINEAR: number;
  35895. /**
  35896. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35897. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35898. */
  35899. static MinDeltaTime: number;
  35900. /**
  35901. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35902. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35903. */
  35904. static MaxDeltaTime: number;
  35905. /**
  35906. * Factory used to create the default material.
  35907. * @param name The name of the material to create
  35908. * @param scene The scene to create the material for
  35909. * @returns The default material
  35910. */
  35911. static DefaultMaterialFactory(scene: Scene): Material;
  35912. /**
  35913. * Factory used to create the a collision coordinator.
  35914. * @returns The collision coordinator
  35915. */
  35916. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35917. /** @hidden */
  35918. _inputManager: InputManager;
  35919. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35920. cameraToUseForPointers: Nullable<Camera>;
  35921. /** @hidden */
  35922. readonly _isScene: boolean;
  35923. /**
  35924. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35925. */
  35926. autoClear: boolean;
  35927. /**
  35928. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35929. */
  35930. autoClearDepthAndStencil: boolean;
  35931. /**
  35932. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35933. */
  35934. clearColor: Color4;
  35935. /**
  35936. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35937. */
  35938. ambientColor: Color3;
  35939. /**
  35940. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35941. * It should only be one of the following (if not the default embedded one):
  35942. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35943. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35944. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35945. * The material properties need to be setup according to the type of texture in use.
  35946. */
  35947. environmentBRDFTexture: BaseTexture;
  35948. /** @hidden */
  35949. protected _environmentTexture: Nullable<BaseTexture>;
  35950. /**
  35951. * Texture used in all pbr material as the reflection texture.
  35952. * As in the majority of the scene they are the same (exception for multi room and so on),
  35953. * this is easier to reference from here than from all the materials.
  35954. */
  35955. get environmentTexture(): Nullable<BaseTexture>;
  35956. /**
  35957. * Texture used in all pbr material as the reflection texture.
  35958. * As in the majority of the scene they are the same (exception for multi room and so on),
  35959. * this is easier to set here than in all the materials.
  35960. */
  35961. set environmentTexture(value: Nullable<BaseTexture>);
  35962. /** @hidden */
  35963. protected _environmentIntensity: number;
  35964. /**
  35965. * Intensity of the environment in all pbr material.
  35966. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35967. * As in the majority of the scene they are the same (exception for multi room and so on),
  35968. * this is easier to reference from here than from all the materials.
  35969. */
  35970. get environmentIntensity(): number;
  35971. /**
  35972. * Intensity of the environment in all pbr material.
  35973. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35974. * As in the majority of the scene they are the same (exception for multi room and so on),
  35975. * this is easier to set here than in all the materials.
  35976. */
  35977. set environmentIntensity(value: number);
  35978. /** @hidden */
  35979. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35980. /**
  35981. * Default image processing configuration used either in the rendering
  35982. * Forward main pass or through the imageProcessingPostProcess if present.
  35983. * As in the majority of the scene they are the same (exception for multi camera),
  35984. * this is easier to reference from here than from all the materials and post process.
  35985. *
  35986. * No setter as we it is a shared configuration, you can set the values instead.
  35987. */
  35988. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35989. private _forceWireframe;
  35990. /**
  35991. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35992. */
  35993. set forceWireframe(value: boolean);
  35994. get forceWireframe(): boolean;
  35995. private _skipFrustumClipping;
  35996. /**
  35997. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35998. */
  35999. set skipFrustumClipping(value: boolean);
  36000. get skipFrustumClipping(): boolean;
  36001. private _forcePointsCloud;
  36002. /**
  36003. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36004. */
  36005. set forcePointsCloud(value: boolean);
  36006. get forcePointsCloud(): boolean;
  36007. /**
  36008. * Gets or sets the active clipplane 1
  36009. */
  36010. clipPlane: Nullable<Plane>;
  36011. /**
  36012. * Gets or sets the active clipplane 2
  36013. */
  36014. clipPlane2: Nullable<Plane>;
  36015. /**
  36016. * Gets or sets the active clipplane 3
  36017. */
  36018. clipPlane3: Nullable<Plane>;
  36019. /**
  36020. * Gets or sets the active clipplane 4
  36021. */
  36022. clipPlane4: Nullable<Plane>;
  36023. /**
  36024. * Gets or sets the active clipplane 5
  36025. */
  36026. clipPlane5: Nullable<Plane>;
  36027. /**
  36028. * Gets or sets the active clipplane 6
  36029. */
  36030. clipPlane6: Nullable<Plane>;
  36031. /**
  36032. * Gets or sets a boolean indicating if animations are enabled
  36033. */
  36034. animationsEnabled: boolean;
  36035. private _animationPropertiesOverride;
  36036. /**
  36037. * Gets or sets the animation properties override
  36038. */
  36039. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36040. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36041. /**
  36042. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36043. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36044. */
  36045. useConstantAnimationDeltaTime: boolean;
  36046. /**
  36047. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36048. * Please note that it requires to run a ray cast through the scene on every frame
  36049. */
  36050. constantlyUpdateMeshUnderPointer: boolean;
  36051. /**
  36052. * Defines the HTML cursor to use when hovering over interactive elements
  36053. */
  36054. hoverCursor: string;
  36055. /**
  36056. * Defines the HTML default cursor to use (empty by default)
  36057. */
  36058. defaultCursor: string;
  36059. /**
  36060. * Defines wether cursors are handled by the scene.
  36061. */
  36062. doNotHandleCursors: boolean;
  36063. /**
  36064. * This is used to call preventDefault() on pointer down
  36065. * in order to block unwanted artifacts like system double clicks
  36066. */
  36067. preventDefaultOnPointerDown: boolean;
  36068. /**
  36069. * This is used to call preventDefault() on pointer up
  36070. * in order to block unwanted artifacts like system double clicks
  36071. */
  36072. preventDefaultOnPointerUp: boolean;
  36073. /**
  36074. * Gets or sets user defined metadata
  36075. */
  36076. metadata: any;
  36077. /**
  36078. * For internal use only. Please do not use.
  36079. */
  36080. reservedDataStore: any;
  36081. /**
  36082. * Gets the name of the plugin used to load this scene (null by default)
  36083. */
  36084. loadingPluginName: string;
  36085. /**
  36086. * Use this array to add regular expressions used to disable offline support for specific urls
  36087. */
  36088. disableOfflineSupportExceptionRules: RegExp[];
  36089. /**
  36090. * An event triggered when the scene is disposed.
  36091. */
  36092. onDisposeObservable: Observable<Scene>;
  36093. private _onDisposeObserver;
  36094. /** Sets a function to be executed when this scene is disposed. */
  36095. set onDispose(callback: () => void);
  36096. /**
  36097. * An event triggered before rendering the scene (right after animations and physics)
  36098. */
  36099. onBeforeRenderObservable: Observable<Scene>;
  36100. private _onBeforeRenderObserver;
  36101. /** Sets a function to be executed before rendering this scene */
  36102. set beforeRender(callback: Nullable<() => void>);
  36103. /**
  36104. * An event triggered after rendering the scene
  36105. */
  36106. onAfterRenderObservable: Observable<Scene>;
  36107. /**
  36108. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36109. */
  36110. onAfterRenderCameraObservable: Observable<Camera>;
  36111. private _onAfterRenderObserver;
  36112. /** Sets a function to be executed after rendering this scene */
  36113. set afterRender(callback: Nullable<() => void>);
  36114. /**
  36115. * An event triggered before animating the scene
  36116. */
  36117. onBeforeAnimationsObservable: Observable<Scene>;
  36118. /**
  36119. * An event triggered after animations processing
  36120. */
  36121. onAfterAnimationsObservable: Observable<Scene>;
  36122. /**
  36123. * An event triggered before draw calls are ready to be sent
  36124. */
  36125. onBeforeDrawPhaseObservable: Observable<Scene>;
  36126. /**
  36127. * An event triggered after draw calls have been sent
  36128. */
  36129. onAfterDrawPhaseObservable: Observable<Scene>;
  36130. /**
  36131. * An event triggered when the scene is ready
  36132. */
  36133. onReadyObservable: Observable<Scene>;
  36134. /**
  36135. * An event triggered before rendering a camera
  36136. */
  36137. onBeforeCameraRenderObservable: Observable<Camera>;
  36138. private _onBeforeCameraRenderObserver;
  36139. /** Sets a function to be executed before rendering a camera*/
  36140. set beforeCameraRender(callback: () => void);
  36141. /**
  36142. * An event triggered after rendering a camera
  36143. */
  36144. onAfterCameraRenderObservable: Observable<Camera>;
  36145. private _onAfterCameraRenderObserver;
  36146. /** Sets a function to be executed after rendering a camera*/
  36147. set afterCameraRender(callback: () => void);
  36148. /**
  36149. * An event triggered when active meshes evaluation is about to start
  36150. */
  36151. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36152. /**
  36153. * An event triggered when active meshes evaluation is done
  36154. */
  36155. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36156. /**
  36157. * An event triggered when particles rendering is about to start
  36158. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36159. */
  36160. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36161. /**
  36162. * An event triggered when particles rendering is done
  36163. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36164. */
  36165. onAfterParticlesRenderingObservable: Observable<Scene>;
  36166. /**
  36167. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36168. */
  36169. onDataLoadedObservable: Observable<Scene>;
  36170. /**
  36171. * An event triggered when a camera is created
  36172. */
  36173. onNewCameraAddedObservable: Observable<Camera>;
  36174. /**
  36175. * An event triggered when a camera is removed
  36176. */
  36177. onCameraRemovedObservable: Observable<Camera>;
  36178. /**
  36179. * An event triggered when a light is created
  36180. */
  36181. onNewLightAddedObservable: Observable<Light>;
  36182. /**
  36183. * An event triggered when a light is removed
  36184. */
  36185. onLightRemovedObservable: Observable<Light>;
  36186. /**
  36187. * An event triggered when a geometry is created
  36188. */
  36189. onNewGeometryAddedObservable: Observable<Geometry>;
  36190. /**
  36191. * An event triggered when a geometry is removed
  36192. */
  36193. onGeometryRemovedObservable: Observable<Geometry>;
  36194. /**
  36195. * An event triggered when a transform node is created
  36196. */
  36197. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36198. /**
  36199. * An event triggered when a transform node is removed
  36200. */
  36201. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36202. /**
  36203. * An event triggered when a mesh is created
  36204. */
  36205. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36206. /**
  36207. * An event triggered when a mesh is removed
  36208. */
  36209. onMeshRemovedObservable: Observable<AbstractMesh>;
  36210. /**
  36211. * An event triggered when a skeleton is created
  36212. */
  36213. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36214. /**
  36215. * An event triggered when a skeleton is removed
  36216. */
  36217. onSkeletonRemovedObservable: Observable<Skeleton>;
  36218. /**
  36219. * An event triggered when a material is created
  36220. */
  36221. onNewMaterialAddedObservable: Observable<Material>;
  36222. /**
  36223. * An event triggered when a material is removed
  36224. */
  36225. onMaterialRemovedObservable: Observable<Material>;
  36226. /**
  36227. * An event triggered when a texture is created
  36228. */
  36229. onNewTextureAddedObservable: Observable<BaseTexture>;
  36230. /**
  36231. * An event triggered when a texture is removed
  36232. */
  36233. onTextureRemovedObservable: Observable<BaseTexture>;
  36234. /**
  36235. * An event triggered when render targets are about to be rendered
  36236. * Can happen multiple times per frame.
  36237. */
  36238. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36239. /**
  36240. * An event triggered when render targets were rendered.
  36241. * Can happen multiple times per frame.
  36242. */
  36243. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36244. /**
  36245. * An event triggered before calculating deterministic simulation step
  36246. */
  36247. onBeforeStepObservable: Observable<Scene>;
  36248. /**
  36249. * An event triggered after calculating deterministic simulation step
  36250. */
  36251. onAfterStepObservable: Observable<Scene>;
  36252. /**
  36253. * An event triggered when the activeCamera property is updated
  36254. */
  36255. onActiveCameraChanged: Observable<Scene>;
  36256. /**
  36257. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36258. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36259. * 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)
  36260. */
  36261. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36262. /**
  36263. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36264. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36265. * 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)
  36266. */
  36267. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36268. /**
  36269. * This Observable will when a mesh has been imported into the scene.
  36270. */
  36271. onMeshImportedObservable: Observable<AbstractMesh>;
  36272. /**
  36273. * This Observable will when an animation file has been imported into the scene.
  36274. */
  36275. onAnimationFileImportedObservable: Observable<Scene>;
  36276. /**
  36277. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36278. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36279. */
  36280. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36281. /** @hidden */
  36282. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36283. /**
  36284. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36285. */
  36286. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36287. /**
  36288. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36289. */
  36290. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36291. /**
  36292. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36293. */
  36294. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36295. /** Callback called when a pointer move is detected */
  36296. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36297. /** Callback called when a pointer down is detected */
  36298. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36299. /** Callback called when a pointer up is detected */
  36300. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36301. /** Callback called when a pointer pick is detected */
  36302. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36303. /**
  36304. * 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).
  36305. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36306. */
  36307. onPrePointerObservable: Observable<PointerInfoPre>;
  36308. /**
  36309. * Observable event triggered each time an input event is received from the rendering canvas
  36310. */
  36311. onPointerObservable: Observable<PointerInfo>;
  36312. /**
  36313. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36314. */
  36315. get unTranslatedPointer(): Vector2;
  36316. /**
  36317. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36318. */
  36319. static get DragMovementThreshold(): number;
  36320. static set DragMovementThreshold(value: number);
  36321. /**
  36322. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36323. */
  36324. static get LongPressDelay(): number;
  36325. static set LongPressDelay(value: number);
  36326. /**
  36327. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36328. */
  36329. static get DoubleClickDelay(): number;
  36330. static set DoubleClickDelay(value: number);
  36331. /** If you need to check double click without raising a single click at first click, enable this flag */
  36332. static get ExclusiveDoubleClickMode(): boolean;
  36333. static set ExclusiveDoubleClickMode(value: boolean);
  36334. /** @hidden */
  36335. _mirroredCameraPosition: Nullable<Vector3>;
  36336. /**
  36337. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36338. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36339. */
  36340. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36341. /**
  36342. * Observable event triggered each time an keyboard event is received from the hosting window
  36343. */
  36344. onKeyboardObservable: Observable<KeyboardInfo>;
  36345. private _useRightHandedSystem;
  36346. /**
  36347. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36348. */
  36349. set useRightHandedSystem(value: boolean);
  36350. get useRightHandedSystem(): boolean;
  36351. private _timeAccumulator;
  36352. private _currentStepId;
  36353. private _currentInternalStep;
  36354. /**
  36355. * Sets the step Id used by deterministic lock step
  36356. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36357. * @param newStepId defines the step Id
  36358. */
  36359. setStepId(newStepId: number): void;
  36360. /**
  36361. * Gets the step Id used by deterministic lock step
  36362. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36363. * @returns the step Id
  36364. */
  36365. getStepId(): number;
  36366. /**
  36367. * Gets the internal step used by deterministic lock step
  36368. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36369. * @returns the internal step
  36370. */
  36371. getInternalStep(): number;
  36372. private _fogEnabled;
  36373. /**
  36374. * Gets or sets a boolean indicating if fog is enabled on this scene
  36375. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36376. * (Default is true)
  36377. */
  36378. set fogEnabled(value: boolean);
  36379. get fogEnabled(): boolean;
  36380. private _fogMode;
  36381. /**
  36382. * Gets or sets the fog mode to use
  36383. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36384. * | mode | value |
  36385. * | --- | --- |
  36386. * | FOGMODE_NONE | 0 |
  36387. * | FOGMODE_EXP | 1 |
  36388. * | FOGMODE_EXP2 | 2 |
  36389. * | FOGMODE_LINEAR | 3 |
  36390. */
  36391. set fogMode(value: number);
  36392. get fogMode(): number;
  36393. /**
  36394. * Gets or sets the fog color to use
  36395. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36396. * (Default is Color3(0.2, 0.2, 0.3))
  36397. */
  36398. fogColor: Color3;
  36399. /**
  36400. * Gets or sets the fog density to use
  36401. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36402. * (Default is 0.1)
  36403. */
  36404. fogDensity: number;
  36405. /**
  36406. * Gets or sets the fog start distance to use
  36407. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36408. * (Default is 0)
  36409. */
  36410. fogStart: number;
  36411. /**
  36412. * Gets or sets the fog end distance to use
  36413. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36414. * (Default is 1000)
  36415. */
  36416. fogEnd: number;
  36417. private _shadowsEnabled;
  36418. /**
  36419. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36420. */
  36421. set shadowsEnabled(value: boolean);
  36422. get shadowsEnabled(): boolean;
  36423. private _lightsEnabled;
  36424. /**
  36425. * Gets or sets a boolean indicating if lights are enabled on this scene
  36426. */
  36427. set lightsEnabled(value: boolean);
  36428. get lightsEnabled(): boolean;
  36429. /** All of the active cameras added to this scene. */
  36430. activeCameras: Camera[];
  36431. /** @hidden */
  36432. _activeCamera: Nullable<Camera>;
  36433. /** Gets or sets the current active camera */
  36434. get activeCamera(): Nullable<Camera>;
  36435. set activeCamera(value: Nullable<Camera>);
  36436. private _defaultMaterial;
  36437. /** The default material used on meshes when no material is affected */
  36438. get defaultMaterial(): Material;
  36439. /** The default material used on meshes when no material is affected */
  36440. set defaultMaterial(value: Material);
  36441. private _texturesEnabled;
  36442. /**
  36443. * Gets or sets a boolean indicating if textures are enabled on this scene
  36444. */
  36445. set texturesEnabled(value: boolean);
  36446. get texturesEnabled(): boolean;
  36447. /**
  36448. * Gets or sets a boolean indicating if particles are enabled on this scene
  36449. */
  36450. particlesEnabled: boolean;
  36451. /**
  36452. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36453. */
  36454. spritesEnabled: boolean;
  36455. private _skeletonsEnabled;
  36456. /**
  36457. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36458. */
  36459. set skeletonsEnabled(value: boolean);
  36460. get skeletonsEnabled(): boolean;
  36461. /**
  36462. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36463. */
  36464. lensFlaresEnabled: boolean;
  36465. /**
  36466. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36467. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36468. */
  36469. collisionsEnabled: boolean;
  36470. private _collisionCoordinator;
  36471. /** @hidden */
  36472. get collisionCoordinator(): ICollisionCoordinator;
  36473. /**
  36474. * Defines the gravity applied to this scene (used only for collisions)
  36475. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36476. */
  36477. gravity: Vector3;
  36478. /**
  36479. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36480. */
  36481. postProcessesEnabled: boolean;
  36482. /**
  36483. * The list of postprocesses added to the scene
  36484. */
  36485. postProcesses: PostProcess[];
  36486. /**
  36487. * Gets the current postprocess manager
  36488. */
  36489. postProcessManager: PostProcessManager;
  36490. /**
  36491. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36492. */
  36493. renderTargetsEnabled: boolean;
  36494. /**
  36495. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36496. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36497. */
  36498. dumpNextRenderTargets: boolean;
  36499. /**
  36500. * The list of user defined render targets added to the scene
  36501. */
  36502. customRenderTargets: RenderTargetTexture[];
  36503. /**
  36504. * Defines if texture loading must be delayed
  36505. * If true, textures will only be loaded when they need to be rendered
  36506. */
  36507. useDelayedTextureLoading: boolean;
  36508. /**
  36509. * Gets the list of meshes imported to the scene through SceneLoader
  36510. */
  36511. importedMeshesFiles: String[];
  36512. /**
  36513. * Gets or sets a boolean indicating if probes are enabled on this scene
  36514. */
  36515. probesEnabled: boolean;
  36516. /**
  36517. * Gets or sets the current offline provider to use to store scene data
  36518. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36519. */
  36520. offlineProvider: IOfflineProvider;
  36521. /**
  36522. * Gets or sets the action manager associated with the scene
  36523. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36524. */
  36525. actionManager: AbstractActionManager;
  36526. private _meshesForIntersections;
  36527. /**
  36528. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36529. */
  36530. proceduralTexturesEnabled: boolean;
  36531. private _engine;
  36532. private _totalVertices;
  36533. /** @hidden */
  36534. _activeIndices: PerfCounter;
  36535. /** @hidden */
  36536. _activeParticles: PerfCounter;
  36537. /** @hidden */
  36538. _activeBones: PerfCounter;
  36539. private _animationRatio;
  36540. /** @hidden */
  36541. _animationTimeLast: number;
  36542. /** @hidden */
  36543. _animationTime: number;
  36544. /**
  36545. * Gets or sets a general scale for animation speed
  36546. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36547. */
  36548. animationTimeScale: number;
  36549. /** @hidden */
  36550. _cachedMaterial: Nullable<Material>;
  36551. /** @hidden */
  36552. _cachedEffect: Nullable<Effect>;
  36553. /** @hidden */
  36554. _cachedVisibility: Nullable<number>;
  36555. private _renderId;
  36556. private _frameId;
  36557. private _executeWhenReadyTimeoutId;
  36558. private _intermediateRendering;
  36559. private _viewUpdateFlag;
  36560. private _projectionUpdateFlag;
  36561. /** @hidden */
  36562. _toBeDisposed: Nullable<IDisposable>[];
  36563. private _activeRequests;
  36564. /** @hidden */
  36565. _pendingData: any[];
  36566. private _isDisposed;
  36567. /**
  36568. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36569. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36570. */
  36571. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36572. private _activeMeshes;
  36573. private _processedMaterials;
  36574. private _renderTargets;
  36575. /** @hidden */
  36576. _activeParticleSystems: SmartArray<IParticleSystem>;
  36577. private _activeSkeletons;
  36578. private _softwareSkinnedMeshes;
  36579. private _renderingManager;
  36580. /** @hidden */
  36581. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36582. private _transformMatrix;
  36583. private _sceneUbo;
  36584. /** @hidden */
  36585. _viewMatrix: Matrix;
  36586. private _projectionMatrix;
  36587. /** @hidden */
  36588. _forcedViewPosition: Nullable<Vector3>;
  36589. /** @hidden */
  36590. _frustumPlanes: Plane[];
  36591. /**
  36592. * Gets the list of frustum planes (built from the active camera)
  36593. */
  36594. get frustumPlanes(): Plane[];
  36595. /**
  36596. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36597. * This is useful if there are more lights that the maximum simulteanous authorized
  36598. */
  36599. requireLightSorting: boolean;
  36600. /** @hidden */
  36601. readonly useMaterialMeshMap: boolean;
  36602. /** @hidden */
  36603. readonly useClonedMeshMap: boolean;
  36604. private _externalData;
  36605. private _uid;
  36606. /**
  36607. * @hidden
  36608. * Backing store of defined scene components.
  36609. */
  36610. _components: ISceneComponent[];
  36611. /**
  36612. * @hidden
  36613. * Backing store of defined scene components.
  36614. */
  36615. _serializableComponents: ISceneSerializableComponent[];
  36616. /**
  36617. * List of components to register on the next registration step.
  36618. */
  36619. private _transientComponents;
  36620. /**
  36621. * Registers the transient components if needed.
  36622. */
  36623. private _registerTransientComponents;
  36624. /**
  36625. * @hidden
  36626. * Add a component to the scene.
  36627. * Note that the ccomponent could be registered on th next frame if this is called after
  36628. * the register component stage.
  36629. * @param component Defines the component to add to the scene
  36630. */
  36631. _addComponent(component: ISceneComponent): void;
  36632. /**
  36633. * @hidden
  36634. * Gets a component from the scene.
  36635. * @param name defines the name of the component to retrieve
  36636. * @returns the component or null if not present
  36637. */
  36638. _getComponent(name: string): Nullable<ISceneComponent>;
  36639. /**
  36640. * @hidden
  36641. * Defines the actions happening before camera updates.
  36642. */
  36643. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36644. /**
  36645. * @hidden
  36646. * Defines the actions happening before clear the canvas.
  36647. */
  36648. _beforeClearStage: Stage<SimpleStageAction>;
  36649. /**
  36650. * @hidden
  36651. * Defines the actions when collecting render targets for the frame.
  36652. */
  36653. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36654. /**
  36655. * @hidden
  36656. * Defines the actions happening for one camera in the frame.
  36657. */
  36658. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36659. /**
  36660. * @hidden
  36661. * Defines the actions happening during the per mesh ready checks.
  36662. */
  36663. _isReadyForMeshStage: Stage<MeshStageAction>;
  36664. /**
  36665. * @hidden
  36666. * Defines the actions happening before evaluate active mesh checks.
  36667. */
  36668. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36669. /**
  36670. * @hidden
  36671. * Defines the actions happening during the evaluate sub mesh checks.
  36672. */
  36673. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36674. /**
  36675. * @hidden
  36676. * Defines the actions happening during the active mesh stage.
  36677. */
  36678. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36679. /**
  36680. * @hidden
  36681. * Defines the actions happening during the per camera render target step.
  36682. */
  36683. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36684. /**
  36685. * @hidden
  36686. * Defines the actions happening just before the active camera is drawing.
  36687. */
  36688. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36689. /**
  36690. * @hidden
  36691. * Defines the actions happening just before a render target is drawing.
  36692. */
  36693. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36694. /**
  36695. * @hidden
  36696. * Defines the actions happening just before a rendering group is drawing.
  36697. */
  36698. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36699. /**
  36700. * @hidden
  36701. * Defines the actions happening just before a mesh is drawing.
  36702. */
  36703. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36704. /**
  36705. * @hidden
  36706. * Defines the actions happening just after a mesh has been drawn.
  36707. */
  36708. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36709. /**
  36710. * @hidden
  36711. * Defines the actions happening just after a rendering group has been drawn.
  36712. */
  36713. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36714. /**
  36715. * @hidden
  36716. * Defines the actions happening just after the active camera has been drawn.
  36717. */
  36718. _afterCameraDrawStage: Stage<CameraStageAction>;
  36719. /**
  36720. * @hidden
  36721. * Defines the actions happening just after a render target has been drawn.
  36722. */
  36723. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36724. /**
  36725. * @hidden
  36726. * Defines the actions happening just after rendering all cameras and computing intersections.
  36727. */
  36728. _afterRenderStage: Stage<SimpleStageAction>;
  36729. /**
  36730. * @hidden
  36731. * Defines the actions happening when a pointer move event happens.
  36732. */
  36733. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36734. /**
  36735. * @hidden
  36736. * Defines the actions happening when a pointer down event happens.
  36737. */
  36738. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36739. /**
  36740. * @hidden
  36741. * Defines the actions happening when a pointer up event happens.
  36742. */
  36743. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36744. /**
  36745. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36746. */
  36747. private geometriesByUniqueId;
  36748. /**
  36749. * Creates a new Scene
  36750. * @param engine defines the engine to use to render this scene
  36751. * @param options defines the scene options
  36752. */
  36753. constructor(engine: Engine, options?: SceneOptions);
  36754. /**
  36755. * Gets a string idenfifying the name of the class
  36756. * @returns "Scene" string
  36757. */
  36758. getClassName(): string;
  36759. private _defaultMeshCandidates;
  36760. /**
  36761. * @hidden
  36762. */
  36763. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36764. private _defaultSubMeshCandidates;
  36765. /**
  36766. * @hidden
  36767. */
  36768. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36769. /**
  36770. * Sets the default candidate providers for the scene.
  36771. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36772. * and getCollidingSubMeshCandidates to their default function
  36773. */
  36774. setDefaultCandidateProviders(): void;
  36775. /**
  36776. * Gets the mesh that is currently under the pointer
  36777. */
  36778. get meshUnderPointer(): Nullable<AbstractMesh>;
  36779. /**
  36780. * Gets or sets the current on-screen X position of the pointer
  36781. */
  36782. get pointerX(): number;
  36783. set pointerX(value: number);
  36784. /**
  36785. * Gets or sets the current on-screen Y position of the pointer
  36786. */
  36787. get pointerY(): number;
  36788. set pointerY(value: number);
  36789. /**
  36790. * Gets the cached material (ie. the latest rendered one)
  36791. * @returns the cached material
  36792. */
  36793. getCachedMaterial(): Nullable<Material>;
  36794. /**
  36795. * Gets the cached effect (ie. the latest rendered one)
  36796. * @returns the cached effect
  36797. */
  36798. getCachedEffect(): Nullable<Effect>;
  36799. /**
  36800. * Gets the cached visibility state (ie. the latest rendered one)
  36801. * @returns the cached visibility state
  36802. */
  36803. getCachedVisibility(): Nullable<number>;
  36804. /**
  36805. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36806. * @param material defines the current material
  36807. * @param effect defines the current effect
  36808. * @param visibility defines the current visibility state
  36809. * @returns true if one parameter is not cached
  36810. */
  36811. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36812. /**
  36813. * Gets the engine associated with the scene
  36814. * @returns an Engine
  36815. */
  36816. getEngine(): Engine;
  36817. /**
  36818. * Gets the total number of vertices rendered per frame
  36819. * @returns the total number of vertices rendered per frame
  36820. */
  36821. getTotalVertices(): number;
  36822. /**
  36823. * Gets the performance counter for total vertices
  36824. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36825. */
  36826. get totalVerticesPerfCounter(): PerfCounter;
  36827. /**
  36828. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36829. * @returns the total number of active indices rendered per frame
  36830. */
  36831. getActiveIndices(): number;
  36832. /**
  36833. * Gets the performance counter for active indices
  36834. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36835. */
  36836. get totalActiveIndicesPerfCounter(): PerfCounter;
  36837. /**
  36838. * Gets the total number of active particles rendered per frame
  36839. * @returns the total number of active particles rendered per frame
  36840. */
  36841. getActiveParticles(): number;
  36842. /**
  36843. * Gets the performance counter for active particles
  36844. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36845. */
  36846. get activeParticlesPerfCounter(): PerfCounter;
  36847. /**
  36848. * Gets the total number of active bones rendered per frame
  36849. * @returns the total number of active bones rendered per frame
  36850. */
  36851. getActiveBones(): number;
  36852. /**
  36853. * Gets the performance counter for active bones
  36854. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36855. */
  36856. get activeBonesPerfCounter(): PerfCounter;
  36857. /**
  36858. * Gets the array of active meshes
  36859. * @returns an array of AbstractMesh
  36860. */
  36861. getActiveMeshes(): SmartArray<AbstractMesh>;
  36862. /**
  36863. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36864. * @returns a number
  36865. */
  36866. getAnimationRatio(): number;
  36867. /**
  36868. * Gets an unique Id for the current render phase
  36869. * @returns a number
  36870. */
  36871. getRenderId(): number;
  36872. /**
  36873. * Gets an unique Id for the current frame
  36874. * @returns a number
  36875. */
  36876. getFrameId(): number;
  36877. /** Call this function if you want to manually increment the render Id*/
  36878. incrementRenderId(): void;
  36879. private _createUbo;
  36880. /**
  36881. * Use this method to simulate a pointer move on a mesh
  36882. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36883. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36884. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36885. * @returns the current scene
  36886. */
  36887. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36888. /**
  36889. * Use this method to simulate a pointer down on a mesh
  36890. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36891. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36892. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36893. * @returns the current scene
  36894. */
  36895. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36896. /**
  36897. * Use this method to simulate a pointer up on a mesh
  36898. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36899. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36900. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36901. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36902. * @returns the current scene
  36903. */
  36904. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36905. /**
  36906. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36907. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36908. * @returns true if the pointer was captured
  36909. */
  36910. isPointerCaptured(pointerId?: number): boolean;
  36911. /**
  36912. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36913. * @param attachUp defines if you want to attach events to pointerup
  36914. * @param attachDown defines if you want to attach events to pointerdown
  36915. * @param attachMove defines if you want to attach events to pointermove
  36916. */
  36917. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36918. /** Detaches all event handlers*/
  36919. detachControl(): void;
  36920. /**
  36921. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36922. * Delay loaded resources are not taking in account
  36923. * @return true if all required resources are ready
  36924. */
  36925. isReady(): boolean;
  36926. /** Resets all cached information relative to material (including effect and visibility) */
  36927. resetCachedMaterial(): void;
  36928. /**
  36929. * Registers a function to be called before every frame render
  36930. * @param func defines the function to register
  36931. */
  36932. registerBeforeRender(func: () => void): void;
  36933. /**
  36934. * Unregisters a function called before every frame render
  36935. * @param func defines the function to unregister
  36936. */
  36937. unregisterBeforeRender(func: () => void): void;
  36938. /**
  36939. * Registers a function to be called after every frame render
  36940. * @param func defines the function to register
  36941. */
  36942. registerAfterRender(func: () => void): void;
  36943. /**
  36944. * Unregisters a function called after every frame render
  36945. * @param func defines the function to unregister
  36946. */
  36947. unregisterAfterRender(func: () => void): void;
  36948. private _executeOnceBeforeRender;
  36949. /**
  36950. * The provided function will run before render once and will be disposed afterwards.
  36951. * A timeout delay can be provided so that the function will be executed in N ms.
  36952. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36953. * @param func The function to be executed.
  36954. * @param timeout optional delay in ms
  36955. */
  36956. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36957. /** @hidden */
  36958. _addPendingData(data: any): void;
  36959. /** @hidden */
  36960. _removePendingData(data: any): void;
  36961. /**
  36962. * Returns the number of items waiting to be loaded
  36963. * @returns the number of items waiting to be loaded
  36964. */
  36965. getWaitingItemsCount(): number;
  36966. /**
  36967. * Returns a boolean indicating if the scene is still loading data
  36968. */
  36969. get isLoading(): boolean;
  36970. /**
  36971. * Registers a function to be executed when the scene is ready
  36972. * @param {Function} func - the function to be executed
  36973. */
  36974. executeWhenReady(func: () => void): void;
  36975. /**
  36976. * Returns a promise that resolves when the scene is ready
  36977. * @returns A promise that resolves when the scene is ready
  36978. */
  36979. whenReadyAsync(): Promise<void>;
  36980. /** @hidden */
  36981. _checkIsReady(): void;
  36982. /**
  36983. * Gets all animatable attached to the scene
  36984. */
  36985. get animatables(): Animatable[];
  36986. /**
  36987. * Resets the last animation time frame.
  36988. * Useful to override when animations start running when loading a scene for the first time.
  36989. */
  36990. resetLastAnimationTimeFrame(): void;
  36991. /**
  36992. * Gets the current view matrix
  36993. * @returns a Matrix
  36994. */
  36995. getViewMatrix(): Matrix;
  36996. /**
  36997. * Gets the current projection matrix
  36998. * @returns a Matrix
  36999. */
  37000. getProjectionMatrix(): Matrix;
  37001. /**
  37002. * Gets the current transform matrix
  37003. * @returns a Matrix made of View * Projection
  37004. */
  37005. getTransformMatrix(): Matrix;
  37006. /**
  37007. * Sets the current transform matrix
  37008. * @param viewL defines the View matrix to use
  37009. * @param projectionL defines the Projection matrix to use
  37010. * @param viewR defines the right View matrix to use (if provided)
  37011. * @param projectionR defines the right Projection matrix to use (if provided)
  37012. */
  37013. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37014. /**
  37015. * Gets the uniform buffer used to store scene data
  37016. * @returns a UniformBuffer
  37017. */
  37018. getSceneUniformBuffer(): UniformBuffer;
  37019. /**
  37020. * Gets an unique (relatively to the current scene) Id
  37021. * @returns an unique number for the scene
  37022. */
  37023. getUniqueId(): number;
  37024. /**
  37025. * Add a mesh to the list of scene's meshes
  37026. * @param newMesh defines the mesh to add
  37027. * @param recursive if all child meshes should also be added to the scene
  37028. */
  37029. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37030. /**
  37031. * Remove a mesh for the list of scene's meshes
  37032. * @param toRemove defines the mesh to remove
  37033. * @param recursive if all child meshes should also be removed from the scene
  37034. * @returns the index where the mesh was in the mesh list
  37035. */
  37036. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37037. /**
  37038. * Add a transform node to the list of scene's transform nodes
  37039. * @param newTransformNode defines the transform node to add
  37040. */
  37041. addTransformNode(newTransformNode: TransformNode): void;
  37042. /**
  37043. * Remove a transform node for the list of scene's transform nodes
  37044. * @param toRemove defines the transform node to remove
  37045. * @returns the index where the transform node was in the transform node list
  37046. */
  37047. removeTransformNode(toRemove: TransformNode): number;
  37048. /**
  37049. * Remove a skeleton for the list of scene's skeletons
  37050. * @param toRemove defines the skeleton to remove
  37051. * @returns the index where the skeleton was in the skeleton list
  37052. */
  37053. removeSkeleton(toRemove: Skeleton): number;
  37054. /**
  37055. * Remove a morph target for the list of scene's morph targets
  37056. * @param toRemove defines the morph target to remove
  37057. * @returns the index where the morph target was in the morph target list
  37058. */
  37059. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37060. /**
  37061. * Remove a light for the list of scene's lights
  37062. * @param toRemove defines the light to remove
  37063. * @returns the index where the light was in the light list
  37064. */
  37065. removeLight(toRemove: Light): number;
  37066. /**
  37067. * Remove a camera for the list of scene's cameras
  37068. * @param toRemove defines the camera to remove
  37069. * @returns the index where the camera was in the camera list
  37070. */
  37071. removeCamera(toRemove: Camera): number;
  37072. /**
  37073. * Remove a particle system for the list of scene's particle systems
  37074. * @param toRemove defines the particle system to remove
  37075. * @returns the index where the particle system was in the particle system list
  37076. */
  37077. removeParticleSystem(toRemove: IParticleSystem): number;
  37078. /**
  37079. * Remove a animation for the list of scene's animations
  37080. * @param toRemove defines the animation to remove
  37081. * @returns the index where the animation was in the animation list
  37082. */
  37083. removeAnimation(toRemove: Animation): number;
  37084. /**
  37085. * Will stop the animation of the given target
  37086. * @param target - the target
  37087. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37088. * @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)
  37089. */
  37090. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37091. /**
  37092. * Removes the given animation group from this scene.
  37093. * @param toRemove The animation group to remove
  37094. * @returns The index of the removed animation group
  37095. */
  37096. removeAnimationGroup(toRemove: AnimationGroup): number;
  37097. /**
  37098. * Removes the given multi-material from this scene.
  37099. * @param toRemove The multi-material to remove
  37100. * @returns The index of the removed multi-material
  37101. */
  37102. removeMultiMaterial(toRemove: MultiMaterial): number;
  37103. /**
  37104. * Removes the given material from this scene.
  37105. * @param toRemove The material to remove
  37106. * @returns The index of the removed material
  37107. */
  37108. removeMaterial(toRemove: Material): number;
  37109. /**
  37110. * Removes the given action manager from this scene.
  37111. * @param toRemove The action manager to remove
  37112. * @returns The index of the removed action manager
  37113. */
  37114. removeActionManager(toRemove: AbstractActionManager): number;
  37115. /**
  37116. * Removes the given texture from this scene.
  37117. * @param toRemove The texture to remove
  37118. * @returns The index of the removed texture
  37119. */
  37120. removeTexture(toRemove: BaseTexture): number;
  37121. /**
  37122. * Adds the given light to this scene
  37123. * @param newLight The light to add
  37124. */
  37125. addLight(newLight: Light): void;
  37126. /**
  37127. * Sorts the list list based on light priorities
  37128. */
  37129. sortLightsByPriority(): void;
  37130. /**
  37131. * Adds the given camera to this scene
  37132. * @param newCamera The camera to add
  37133. */
  37134. addCamera(newCamera: Camera): void;
  37135. /**
  37136. * Adds the given skeleton to this scene
  37137. * @param newSkeleton The skeleton to add
  37138. */
  37139. addSkeleton(newSkeleton: Skeleton): void;
  37140. /**
  37141. * Adds the given particle system to this scene
  37142. * @param newParticleSystem The particle system to add
  37143. */
  37144. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37145. /**
  37146. * Adds the given animation to this scene
  37147. * @param newAnimation The animation to add
  37148. */
  37149. addAnimation(newAnimation: Animation): void;
  37150. /**
  37151. * Adds the given animation group to this scene.
  37152. * @param newAnimationGroup The animation group to add
  37153. */
  37154. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37155. /**
  37156. * Adds the given multi-material to this scene
  37157. * @param newMultiMaterial The multi-material to add
  37158. */
  37159. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37160. /**
  37161. * Adds the given material to this scene
  37162. * @param newMaterial The material to add
  37163. */
  37164. addMaterial(newMaterial: Material): void;
  37165. /**
  37166. * Adds the given morph target to this scene
  37167. * @param newMorphTargetManager The morph target to add
  37168. */
  37169. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37170. /**
  37171. * Adds the given geometry to this scene
  37172. * @param newGeometry The geometry to add
  37173. */
  37174. addGeometry(newGeometry: Geometry): void;
  37175. /**
  37176. * Adds the given action manager to this scene
  37177. * @param newActionManager The action manager to add
  37178. */
  37179. addActionManager(newActionManager: AbstractActionManager): void;
  37180. /**
  37181. * Adds the given texture to this scene.
  37182. * @param newTexture The texture to add
  37183. */
  37184. addTexture(newTexture: BaseTexture): void;
  37185. /**
  37186. * Switch active camera
  37187. * @param newCamera defines the new active camera
  37188. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37189. */
  37190. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37191. /**
  37192. * sets the active camera of the scene using its ID
  37193. * @param id defines the camera's ID
  37194. * @return the new active camera or null if none found.
  37195. */
  37196. setActiveCameraByID(id: string): Nullable<Camera>;
  37197. /**
  37198. * sets the active camera of the scene using its name
  37199. * @param name defines the camera's name
  37200. * @returns the new active camera or null if none found.
  37201. */
  37202. setActiveCameraByName(name: string): Nullable<Camera>;
  37203. /**
  37204. * get an animation group using its name
  37205. * @param name defines the material's name
  37206. * @return the animation group or null if none found.
  37207. */
  37208. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37209. /**
  37210. * Get a material using its unique id
  37211. * @param uniqueId defines the material's unique id
  37212. * @return the material or null if none found.
  37213. */
  37214. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37215. /**
  37216. * get a material using its id
  37217. * @param id defines the material's ID
  37218. * @return the material or null if none found.
  37219. */
  37220. getMaterialByID(id: string): Nullable<Material>;
  37221. /**
  37222. * Gets a the last added material using a given id
  37223. * @param id defines the material's ID
  37224. * @return the last material with the given id or null if none found.
  37225. */
  37226. getLastMaterialByID(id: string): Nullable<Material>;
  37227. /**
  37228. * Gets a material using its name
  37229. * @param name defines the material's name
  37230. * @return the material or null if none found.
  37231. */
  37232. getMaterialByName(name: string): Nullable<Material>;
  37233. /**
  37234. * Get a texture using its unique id
  37235. * @param uniqueId defines the texture's unique id
  37236. * @return the texture or null if none found.
  37237. */
  37238. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37239. /**
  37240. * Gets a camera using its id
  37241. * @param id defines the id to look for
  37242. * @returns the camera or null if not found
  37243. */
  37244. getCameraByID(id: string): Nullable<Camera>;
  37245. /**
  37246. * Gets a camera using its unique id
  37247. * @param uniqueId defines the unique id to look for
  37248. * @returns the camera or null if not found
  37249. */
  37250. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37251. /**
  37252. * Gets a camera using its name
  37253. * @param name defines the camera's name
  37254. * @return the camera or null if none found.
  37255. */
  37256. getCameraByName(name: string): Nullable<Camera>;
  37257. /**
  37258. * Gets a bone using its id
  37259. * @param id defines the bone's id
  37260. * @return the bone or null if not found
  37261. */
  37262. getBoneByID(id: string): Nullable<Bone>;
  37263. /**
  37264. * Gets a bone using its id
  37265. * @param name defines the bone's name
  37266. * @return the bone or null if not found
  37267. */
  37268. getBoneByName(name: string): Nullable<Bone>;
  37269. /**
  37270. * Gets a light node using its name
  37271. * @param name defines the the light's name
  37272. * @return the light or null if none found.
  37273. */
  37274. getLightByName(name: string): Nullable<Light>;
  37275. /**
  37276. * Gets a light node using its id
  37277. * @param id defines the light's id
  37278. * @return the light or null if none found.
  37279. */
  37280. getLightByID(id: string): Nullable<Light>;
  37281. /**
  37282. * Gets a light node using its scene-generated unique ID
  37283. * @param uniqueId defines the light's unique id
  37284. * @return the light or null if none found.
  37285. */
  37286. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37287. /**
  37288. * Gets a particle system by id
  37289. * @param id defines the particle system id
  37290. * @return the corresponding system or null if none found
  37291. */
  37292. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37293. /**
  37294. * Gets a geometry using its ID
  37295. * @param id defines the geometry's id
  37296. * @return the geometry or null if none found.
  37297. */
  37298. getGeometryByID(id: string): Nullable<Geometry>;
  37299. private _getGeometryByUniqueID;
  37300. /**
  37301. * Add a new geometry to this scene
  37302. * @param geometry defines the geometry to be added to the scene.
  37303. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37304. * @return a boolean defining if the geometry was added or not
  37305. */
  37306. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37307. /**
  37308. * Removes an existing geometry
  37309. * @param geometry defines the geometry to be removed from the scene
  37310. * @return a boolean defining if the geometry was removed or not
  37311. */
  37312. removeGeometry(geometry: Geometry): boolean;
  37313. /**
  37314. * Gets the list of geometries attached to the scene
  37315. * @returns an array of Geometry
  37316. */
  37317. getGeometries(): Geometry[];
  37318. /**
  37319. * Gets the first added mesh found of a given ID
  37320. * @param id defines the id to search for
  37321. * @return the mesh found or null if not found at all
  37322. */
  37323. getMeshByID(id: string): Nullable<AbstractMesh>;
  37324. /**
  37325. * Gets a list of meshes using their id
  37326. * @param id defines the id to search for
  37327. * @returns a list of meshes
  37328. */
  37329. getMeshesByID(id: string): Array<AbstractMesh>;
  37330. /**
  37331. * Gets the first added transform node found of a given ID
  37332. * @param id defines the id to search for
  37333. * @return the found transform node or null if not found at all.
  37334. */
  37335. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37336. /**
  37337. * Gets a transform node with its auto-generated unique id
  37338. * @param uniqueId efines the unique id to search for
  37339. * @return the found transform node or null if not found at all.
  37340. */
  37341. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37342. /**
  37343. * Gets a list of transform nodes using their id
  37344. * @param id defines the id to search for
  37345. * @returns a list of transform nodes
  37346. */
  37347. getTransformNodesByID(id: string): Array<TransformNode>;
  37348. /**
  37349. * Gets a mesh with its auto-generated unique id
  37350. * @param uniqueId defines the unique id to search for
  37351. * @return the found mesh or null if not found at all.
  37352. */
  37353. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37354. /**
  37355. * Gets a the last added mesh using a given id
  37356. * @param id defines the id to search for
  37357. * @return the found mesh or null if not found at all.
  37358. */
  37359. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37360. /**
  37361. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37362. * @param id defines the id to search for
  37363. * @return the found node or null if not found at all
  37364. */
  37365. getLastEntryByID(id: string): Nullable<Node>;
  37366. /**
  37367. * Gets a node (Mesh, Camera, Light) using a given id
  37368. * @param id defines the id to search for
  37369. * @return the found node or null if not found at all
  37370. */
  37371. getNodeByID(id: string): Nullable<Node>;
  37372. /**
  37373. * Gets a node (Mesh, Camera, Light) using a given name
  37374. * @param name defines the name to search for
  37375. * @return the found node or null if not found at all.
  37376. */
  37377. getNodeByName(name: string): Nullable<Node>;
  37378. /**
  37379. * Gets a mesh using a given name
  37380. * @param name defines the name to search for
  37381. * @return the found mesh or null if not found at all.
  37382. */
  37383. getMeshByName(name: string): Nullable<AbstractMesh>;
  37384. /**
  37385. * Gets a transform node using a given name
  37386. * @param name defines the name to search for
  37387. * @return the found transform node or null if not found at all.
  37388. */
  37389. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37390. /**
  37391. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37392. * @param id defines the id to search for
  37393. * @return the found skeleton or null if not found at all.
  37394. */
  37395. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37396. /**
  37397. * Gets a skeleton using a given auto generated unique id
  37398. * @param uniqueId defines the unique id to search for
  37399. * @return the found skeleton or null if not found at all.
  37400. */
  37401. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37402. /**
  37403. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37404. * @param id defines the id to search for
  37405. * @return the found skeleton or null if not found at all.
  37406. */
  37407. getSkeletonById(id: string): Nullable<Skeleton>;
  37408. /**
  37409. * Gets a skeleton using a given name
  37410. * @param name defines the name to search for
  37411. * @return the found skeleton or null if not found at all.
  37412. */
  37413. getSkeletonByName(name: string): Nullable<Skeleton>;
  37414. /**
  37415. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37416. * @param id defines the id to search for
  37417. * @return the found morph target manager or null if not found at all.
  37418. */
  37419. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37420. /**
  37421. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37422. * @param id defines the id to search for
  37423. * @return the found morph target or null if not found at all.
  37424. */
  37425. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37426. /**
  37427. * Gets a boolean indicating if the given mesh is active
  37428. * @param mesh defines the mesh to look for
  37429. * @returns true if the mesh is in the active list
  37430. */
  37431. isActiveMesh(mesh: AbstractMesh): boolean;
  37432. /**
  37433. * Return a unique id as a string which can serve as an identifier for the scene
  37434. */
  37435. get uid(): string;
  37436. /**
  37437. * Add an externaly attached data from its key.
  37438. * This method call will fail and return false, if such key already exists.
  37439. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37440. * @param key the unique key that identifies the data
  37441. * @param data the data object to associate to the key for this Engine instance
  37442. * @return true if no such key were already present and the data was added successfully, false otherwise
  37443. */
  37444. addExternalData<T>(key: string, data: T): boolean;
  37445. /**
  37446. * Get an externaly attached data from its key
  37447. * @param key the unique key that identifies the data
  37448. * @return the associated data, if present (can be null), or undefined if not present
  37449. */
  37450. getExternalData<T>(key: string): Nullable<T>;
  37451. /**
  37452. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37453. * @param key the unique key that identifies the data
  37454. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37455. * @return the associated data, can be null if the factory returned null.
  37456. */
  37457. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37458. /**
  37459. * Remove an externaly attached data from the Engine instance
  37460. * @param key the unique key that identifies the data
  37461. * @return true if the data was successfully removed, false if it doesn't exist
  37462. */
  37463. removeExternalData(key: string): boolean;
  37464. private _evaluateSubMesh;
  37465. /**
  37466. * Clear the processed materials smart array preventing retention point in material dispose.
  37467. */
  37468. freeProcessedMaterials(): void;
  37469. private _preventFreeActiveMeshesAndRenderingGroups;
  37470. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37471. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37472. * when disposing several meshes in a row or a hierarchy of meshes.
  37473. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37474. */
  37475. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37476. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37477. /**
  37478. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37479. */
  37480. freeActiveMeshes(): void;
  37481. /**
  37482. * Clear the info related to rendering groups preventing retention points during dispose.
  37483. */
  37484. freeRenderingGroups(): void;
  37485. /** @hidden */
  37486. _isInIntermediateRendering(): boolean;
  37487. /**
  37488. * Lambda returning the list of potentially active meshes.
  37489. */
  37490. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37491. /**
  37492. * Lambda returning the list of potentially active sub meshes.
  37493. */
  37494. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37495. /**
  37496. * Lambda returning the list of potentially intersecting sub meshes.
  37497. */
  37498. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37499. /**
  37500. * Lambda returning the list of potentially colliding sub meshes.
  37501. */
  37502. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37503. private _activeMeshesFrozen;
  37504. private _skipEvaluateActiveMeshesCompletely;
  37505. /**
  37506. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37507. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37508. * @returns the current scene
  37509. */
  37510. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37511. /**
  37512. * Use this function to restart evaluating active meshes on every frame
  37513. * @returns the current scene
  37514. */
  37515. unfreezeActiveMeshes(): Scene;
  37516. private _evaluateActiveMeshes;
  37517. private _activeMesh;
  37518. /**
  37519. * Update the transform matrix to update from the current active camera
  37520. * @param force defines a boolean used to force the update even if cache is up to date
  37521. */
  37522. updateTransformMatrix(force?: boolean): void;
  37523. private _bindFrameBuffer;
  37524. /** @hidden */
  37525. _allowPostProcessClearColor: boolean;
  37526. /** @hidden */
  37527. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37528. private _processSubCameras;
  37529. private _checkIntersections;
  37530. /** @hidden */
  37531. _advancePhysicsEngineStep(step: number): void;
  37532. /**
  37533. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37534. */
  37535. getDeterministicFrameTime: () => number;
  37536. /** @hidden */
  37537. _animate(): void;
  37538. /** Execute all animations (for a frame) */
  37539. animate(): void;
  37540. /**
  37541. * Render the scene
  37542. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37543. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37544. */
  37545. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37546. /**
  37547. * Freeze all materials
  37548. * A frozen material will not be updatable but should be faster to render
  37549. */
  37550. freezeMaterials(): void;
  37551. /**
  37552. * Unfreeze all materials
  37553. * A frozen material will not be updatable but should be faster to render
  37554. */
  37555. unfreezeMaterials(): void;
  37556. /**
  37557. * Releases all held ressources
  37558. */
  37559. dispose(): void;
  37560. /**
  37561. * Gets if the scene is already disposed
  37562. */
  37563. get isDisposed(): boolean;
  37564. /**
  37565. * Call this function to reduce memory footprint of the scene.
  37566. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37567. */
  37568. clearCachedVertexData(): void;
  37569. /**
  37570. * This function will remove the local cached buffer data from texture.
  37571. * It will save memory but will prevent the texture from being rebuilt
  37572. */
  37573. cleanCachedTextureBuffer(): void;
  37574. /**
  37575. * Get the world extend vectors with an optional filter
  37576. *
  37577. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37578. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37579. */
  37580. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37581. min: Vector3;
  37582. max: Vector3;
  37583. };
  37584. /**
  37585. * Creates a ray that can be used to pick in the scene
  37586. * @param x defines the x coordinate of the origin (on-screen)
  37587. * @param y defines the y coordinate of the origin (on-screen)
  37588. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37589. * @param camera defines the camera to use for the picking
  37590. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37591. * @returns a Ray
  37592. */
  37593. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37594. /**
  37595. * Creates a ray that can be used to pick in the scene
  37596. * @param x defines the x coordinate of the origin (on-screen)
  37597. * @param y defines the y coordinate of the origin (on-screen)
  37598. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37599. * @param result defines the ray where to store the picking ray
  37600. * @param camera defines the camera to use for the picking
  37601. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37602. * @returns the current scene
  37603. */
  37604. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37605. /**
  37606. * Creates a ray that can be used to pick in the scene
  37607. * @param x defines the x coordinate of the origin (on-screen)
  37608. * @param y defines the y coordinate of the origin (on-screen)
  37609. * @param camera defines the camera to use for the picking
  37610. * @returns a Ray
  37611. */
  37612. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37613. /**
  37614. * Creates a ray that can be used to pick in the scene
  37615. * @param x defines the x coordinate of the origin (on-screen)
  37616. * @param y defines the y coordinate of the origin (on-screen)
  37617. * @param result defines the ray where to store the picking ray
  37618. * @param camera defines the camera to use for the picking
  37619. * @returns the current scene
  37620. */
  37621. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37622. /** Launch a ray to try to pick a mesh in the scene
  37623. * @param x position on screen
  37624. * @param y position on screen
  37625. * @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
  37626. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37627. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37628. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37629. * @returns a PickingInfo
  37630. */
  37631. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37632. /** Use the given ray to pick a mesh in the scene
  37633. * @param ray The ray to use to pick meshes
  37634. * @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
  37635. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37636. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37637. * @returns a PickingInfo
  37638. */
  37639. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37640. /**
  37641. * Launch a ray to try to pick a mesh in the scene
  37642. * @param x X position on screen
  37643. * @param y Y position on screen
  37644. * @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
  37645. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37646. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37647. * @returns an array of PickingInfo
  37648. */
  37649. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37650. /**
  37651. * Launch a ray to try to pick a mesh in the scene
  37652. * @param ray Ray to use
  37653. * @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
  37654. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37655. * @returns an array of PickingInfo
  37656. */
  37657. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37658. /**
  37659. * Force the value of meshUnderPointer
  37660. * @param mesh defines the mesh to use
  37661. */
  37662. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37663. /**
  37664. * Gets the mesh under the pointer
  37665. * @returns a Mesh or null if no mesh is under the pointer
  37666. */
  37667. getPointerOverMesh(): Nullable<AbstractMesh>;
  37668. /** @hidden */
  37669. _rebuildGeometries(): void;
  37670. /** @hidden */
  37671. _rebuildTextures(): void;
  37672. private _getByTags;
  37673. /**
  37674. * Get a list of meshes by tags
  37675. * @param tagsQuery defines the tags query to use
  37676. * @param forEach defines a predicate used to filter results
  37677. * @returns an array of Mesh
  37678. */
  37679. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37680. /**
  37681. * Get a list of cameras by tags
  37682. * @param tagsQuery defines the tags query to use
  37683. * @param forEach defines a predicate used to filter results
  37684. * @returns an array of Camera
  37685. */
  37686. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37687. /**
  37688. * Get a list of lights by tags
  37689. * @param tagsQuery defines the tags query to use
  37690. * @param forEach defines a predicate used to filter results
  37691. * @returns an array of Light
  37692. */
  37693. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37694. /**
  37695. * Get a list of materials by tags
  37696. * @param tagsQuery defines the tags query to use
  37697. * @param forEach defines a predicate used to filter results
  37698. * @returns an array of Material
  37699. */
  37700. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37701. /**
  37702. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37703. * This allowed control for front to back rendering or reversly depending of the special needs.
  37704. *
  37705. * @param renderingGroupId The rendering group id corresponding to its index
  37706. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37707. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37708. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37709. */
  37710. 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;
  37711. /**
  37712. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37713. *
  37714. * @param renderingGroupId The rendering group id corresponding to its index
  37715. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37716. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37717. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37718. */
  37719. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37720. /**
  37721. * Gets the current auto clear configuration for one rendering group of the rendering
  37722. * manager.
  37723. * @param index the rendering group index to get the information for
  37724. * @returns The auto clear setup for the requested rendering group
  37725. */
  37726. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37727. private _blockMaterialDirtyMechanism;
  37728. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37729. get blockMaterialDirtyMechanism(): boolean;
  37730. set blockMaterialDirtyMechanism(value: boolean);
  37731. /**
  37732. * Will flag all materials as dirty to trigger new shader compilation
  37733. * @param flag defines the flag used to specify which material part must be marked as dirty
  37734. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37735. */
  37736. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37737. /** @hidden */
  37738. _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;
  37739. /** @hidden */
  37740. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37741. /** @hidden */
  37742. _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;
  37743. /** @hidden */
  37744. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37745. /** @hidden */
  37746. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37747. /** @hidden */
  37748. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37749. }
  37750. }
  37751. declare module "babylonjs/assetContainer" {
  37752. import { AbstractScene } from "babylonjs/abstractScene";
  37753. import { Scene } from "babylonjs/scene";
  37754. import { Mesh } from "babylonjs/Meshes/mesh";
  37755. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37756. import { Skeleton } from "babylonjs/Bones/skeleton";
  37757. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37758. import { Animatable } from "babylonjs/Animations/animatable";
  37759. import { Nullable } from "babylonjs/types";
  37760. import { Node } from "babylonjs/node";
  37761. /**
  37762. * Set of assets to keep when moving a scene into an asset container.
  37763. */
  37764. export class KeepAssets extends AbstractScene {
  37765. }
  37766. /**
  37767. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37768. */
  37769. export class InstantiatedEntries {
  37770. /**
  37771. * List of new root nodes (eg. nodes with no parent)
  37772. */
  37773. rootNodes: TransformNode[];
  37774. /**
  37775. * List of new skeletons
  37776. */
  37777. skeletons: Skeleton[];
  37778. /**
  37779. * List of new animation groups
  37780. */
  37781. animationGroups: AnimationGroup[];
  37782. }
  37783. /**
  37784. * Container with a set of assets that can be added or removed from a scene.
  37785. */
  37786. export class AssetContainer extends AbstractScene {
  37787. /**
  37788. * The scene the AssetContainer belongs to.
  37789. */
  37790. scene: Scene;
  37791. /**
  37792. * Instantiates an AssetContainer.
  37793. * @param scene The scene the AssetContainer belongs to.
  37794. */
  37795. constructor(scene: Scene);
  37796. /**
  37797. * Instantiate or clone all meshes and add the new ones to the scene.
  37798. * Skeletons and animation groups will all be cloned
  37799. * @param nameFunction defines an optional function used to get new names for clones
  37800. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37801. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37802. */
  37803. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37804. /**
  37805. * Adds all the assets from the container to the scene.
  37806. */
  37807. addAllToScene(): void;
  37808. /**
  37809. * Removes all the assets in the container from the scene
  37810. */
  37811. removeAllFromScene(): void;
  37812. /**
  37813. * Disposes all the assets in the container
  37814. */
  37815. dispose(): void;
  37816. private _moveAssets;
  37817. /**
  37818. * Removes all the assets contained in the scene and adds them to the container.
  37819. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37820. */
  37821. moveAllFromScene(keepAssets?: KeepAssets): void;
  37822. /**
  37823. * 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.
  37824. * @returns the root mesh
  37825. */
  37826. createRootMesh(): Mesh;
  37827. /**
  37828. * Merge animations from this asset container into a scene
  37829. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37830. * @param animatables set of animatables to retarget to a node from the scene
  37831. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37832. */
  37833. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37834. }
  37835. }
  37836. declare module "babylonjs/abstractScene" {
  37837. import { Scene } from "babylonjs/scene";
  37838. import { Nullable } from "babylonjs/types";
  37839. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37840. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37841. import { Geometry } from "babylonjs/Meshes/geometry";
  37842. import { Skeleton } from "babylonjs/Bones/skeleton";
  37843. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  37844. import { AssetContainer } from "babylonjs/assetContainer";
  37845. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  37846. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37847. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37848. import { Material } from "babylonjs/Materials/material";
  37849. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  37850. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37851. import { Camera } from "babylonjs/Cameras/camera";
  37852. import { Light } from "babylonjs/Lights/light";
  37853. import { Node } from "babylonjs/node";
  37854. import { Animation } from "babylonjs/Animations/animation";
  37855. /**
  37856. * Defines how the parser contract is defined.
  37857. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37858. */
  37859. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37860. /**
  37861. * Defines how the individual parser contract is defined.
  37862. * These parser can parse an individual asset
  37863. */
  37864. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37865. /**
  37866. * Base class of the scene acting as a container for the different elements composing a scene.
  37867. * This class is dynamically extended by the different components of the scene increasing
  37868. * flexibility and reducing coupling
  37869. */
  37870. export abstract class AbstractScene {
  37871. /**
  37872. * Stores the list of available parsers in the application.
  37873. */
  37874. private static _BabylonFileParsers;
  37875. /**
  37876. * Stores the list of available individual parsers in the application.
  37877. */
  37878. private static _IndividualBabylonFileParsers;
  37879. /**
  37880. * Adds a parser in the list of available ones
  37881. * @param name Defines the name of the parser
  37882. * @param parser Defines the parser to add
  37883. */
  37884. static AddParser(name: string, parser: BabylonFileParser): void;
  37885. /**
  37886. * Gets a general parser from the list of avaialble ones
  37887. * @param name Defines the name of the parser
  37888. * @returns the requested parser or null
  37889. */
  37890. static GetParser(name: string): Nullable<BabylonFileParser>;
  37891. /**
  37892. * Adds n individual parser in the list of available ones
  37893. * @param name Defines the name of the parser
  37894. * @param parser Defines the parser to add
  37895. */
  37896. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37897. /**
  37898. * Gets an individual parser from the list of avaialble ones
  37899. * @param name Defines the name of the parser
  37900. * @returns the requested parser or null
  37901. */
  37902. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37903. /**
  37904. * Parser json data and populate both a scene and its associated container object
  37905. * @param jsonData Defines the data to parse
  37906. * @param scene Defines the scene to parse the data for
  37907. * @param container Defines the container attached to the parsing sequence
  37908. * @param rootUrl Defines the root url of the data
  37909. */
  37910. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37911. /**
  37912. * Gets the list of root nodes (ie. nodes with no parent)
  37913. */
  37914. rootNodes: Node[];
  37915. /** All of the cameras added to this scene
  37916. * @see http://doc.babylonjs.com/babylon101/cameras
  37917. */
  37918. cameras: Camera[];
  37919. /**
  37920. * All of the lights added to this scene
  37921. * @see http://doc.babylonjs.com/babylon101/lights
  37922. */
  37923. lights: Light[];
  37924. /**
  37925. * All of the (abstract) meshes added to this scene
  37926. */
  37927. meshes: AbstractMesh[];
  37928. /**
  37929. * The list of skeletons added to the scene
  37930. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37931. */
  37932. skeletons: Skeleton[];
  37933. /**
  37934. * All of the particle systems added to this scene
  37935. * @see http://doc.babylonjs.com/babylon101/particles
  37936. */
  37937. particleSystems: IParticleSystem[];
  37938. /**
  37939. * Gets a list of Animations associated with the scene
  37940. */
  37941. animations: Animation[];
  37942. /**
  37943. * All of the animation groups added to this scene
  37944. * @see http://doc.babylonjs.com/how_to/group
  37945. */
  37946. animationGroups: AnimationGroup[];
  37947. /**
  37948. * All of the multi-materials added to this scene
  37949. * @see http://doc.babylonjs.com/how_to/multi_materials
  37950. */
  37951. multiMaterials: MultiMaterial[];
  37952. /**
  37953. * All of the materials added to this scene
  37954. * In the context of a Scene, it is not supposed to be modified manually.
  37955. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37956. * Note also that the order of the Material within the array is not significant and might change.
  37957. * @see http://doc.babylonjs.com/babylon101/materials
  37958. */
  37959. materials: Material[];
  37960. /**
  37961. * The list of morph target managers added to the scene
  37962. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37963. */
  37964. morphTargetManagers: MorphTargetManager[];
  37965. /**
  37966. * The list of geometries used in the scene.
  37967. */
  37968. geometries: Geometry[];
  37969. /**
  37970. * All of the tranform nodes added to this scene
  37971. * In the context of a Scene, it is not supposed to be modified manually.
  37972. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37973. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37974. * @see http://doc.babylonjs.com/how_to/transformnode
  37975. */
  37976. transformNodes: TransformNode[];
  37977. /**
  37978. * ActionManagers available on the scene.
  37979. */
  37980. actionManagers: AbstractActionManager[];
  37981. /**
  37982. * Textures to keep.
  37983. */
  37984. textures: BaseTexture[];
  37985. /**
  37986. * Environment texture for the scene
  37987. */
  37988. environmentTexture: Nullable<BaseTexture>;
  37989. /**
  37990. * @returns all meshes, lights, cameras, transformNodes and bones
  37991. */
  37992. getNodes(): Array<Node>;
  37993. }
  37994. }
  37995. declare module "babylonjs/Audio/sound" {
  37996. import { Observable } from "babylonjs/Misc/observable";
  37997. import { Vector3 } from "babylonjs/Maths/math.vector";
  37998. import { Nullable } from "babylonjs/types";
  37999. import { Scene } from "babylonjs/scene";
  38000. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38001. /**
  38002. * Interface used to define options for Sound class
  38003. */
  38004. export interface ISoundOptions {
  38005. /**
  38006. * Does the sound autoplay once loaded.
  38007. */
  38008. autoplay?: boolean;
  38009. /**
  38010. * Does the sound loop after it finishes playing once.
  38011. */
  38012. loop?: boolean;
  38013. /**
  38014. * Sound's volume
  38015. */
  38016. volume?: number;
  38017. /**
  38018. * Is it a spatial sound?
  38019. */
  38020. spatialSound?: boolean;
  38021. /**
  38022. * Maximum distance to hear that sound
  38023. */
  38024. maxDistance?: number;
  38025. /**
  38026. * Uses user defined attenuation function
  38027. */
  38028. useCustomAttenuation?: boolean;
  38029. /**
  38030. * Define the roll off factor of spatial sounds.
  38031. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38032. */
  38033. rolloffFactor?: number;
  38034. /**
  38035. * Define the reference distance the sound should be heard perfectly.
  38036. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38037. */
  38038. refDistance?: number;
  38039. /**
  38040. * Define the distance attenuation model the sound will follow.
  38041. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38042. */
  38043. distanceModel?: string;
  38044. /**
  38045. * Defines the playback speed (1 by default)
  38046. */
  38047. playbackRate?: number;
  38048. /**
  38049. * Defines if the sound is from a streaming source
  38050. */
  38051. streaming?: boolean;
  38052. /**
  38053. * Defines an optional length (in seconds) inside the sound file
  38054. */
  38055. length?: number;
  38056. /**
  38057. * Defines an optional offset (in seconds) inside the sound file
  38058. */
  38059. offset?: number;
  38060. /**
  38061. * If true, URLs will not be required to state the audio file codec to use.
  38062. */
  38063. skipCodecCheck?: boolean;
  38064. }
  38065. /**
  38066. * Defines a sound that can be played in the application.
  38067. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38068. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38069. */
  38070. export class Sound {
  38071. /**
  38072. * The name of the sound in the scene.
  38073. */
  38074. name: string;
  38075. /**
  38076. * Does the sound autoplay once loaded.
  38077. */
  38078. autoplay: boolean;
  38079. /**
  38080. * Does the sound loop after it finishes playing once.
  38081. */
  38082. loop: boolean;
  38083. /**
  38084. * Does the sound use a custom attenuation curve to simulate the falloff
  38085. * happening when the source gets further away from the camera.
  38086. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38087. */
  38088. useCustomAttenuation: boolean;
  38089. /**
  38090. * The sound track id this sound belongs to.
  38091. */
  38092. soundTrackId: number;
  38093. /**
  38094. * Is this sound currently played.
  38095. */
  38096. isPlaying: boolean;
  38097. /**
  38098. * Is this sound currently paused.
  38099. */
  38100. isPaused: boolean;
  38101. /**
  38102. * Does this sound enables spatial sound.
  38103. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38104. */
  38105. spatialSound: boolean;
  38106. /**
  38107. * Define the reference distance the sound should be heard perfectly.
  38108. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38109. */
  38110. refDistance: number;
  38111. /**
  38112. * Define the roll off factor of spatial sounds.
  38113. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38114. */
  38115. rolloffFactor: number;
  38116. /**
  38117. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38118. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38119. */
  38120. maxDistance: number;
  38121. /**
  38122. * Define the distance attenuation model the sound will follow.
  38123. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38124. */
  38125. distanceModel: string;
  38126. /**
  38127. * @hidden
  38128. * Back Compat
  38129. **/
  38130. onended: () => any;
  38131. /**
  38132. * Observable event when the current playing sound finishes.
  38133. */
  38134. onEndedObservable: Observable<Sound>;
  38135. private _panningModel;
  38136. private _playbackRate;
  38137. private _streaming;
  38138. private _startTime;
  38139. private _startOffset;
  38140. private _position;
  38141. /** @hidden */
  38142. _positionInEmitterSpace: boolean;
  38143. private _localDirection;
  38144. private _volume;
  38145. private _isReadyToPlay;
  38146. private _isDirectional;
  38147. private _readyToPlayCallback;
  38148. private _audioBuffer;
  38149. private _soundSource;
  38150. private _streamingSource;
  38151. private _soundPanner;
  38152. private _soundGain;
  38153. private _inputAudioNode;
  38154. private _outputAudioNode;
  38155. private _coneInnerAngle;
  38156. private _coneOuterAngle;
  38157. private _coneOuterGain;
  38158. private _scene;
  38159. private _connectedTransformNode;
  38160. private _customAttenuationFunction;
  38161. private _registerFunc;
  38162. private _isOutputConnected;
  38163. private _htmlAudioElement;
  38164. private _urlType;
  38165. private _length?;
  38166. private _offset?;
  38167. /** @hidden */
  38168. static _SceneComponentInitialization: (scene: Scene) => void;
  38169. /**
  38170. * Create a sound and attach it to a scene
  38171. * @param name Name of your sound
  38172. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38173. * @param scene defines the scene the sound belongs to
  38174. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38175. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38176. */
  38177. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38178. /**
  38179. * Release the sound and its associated resources
  38180. */
  38181. dispose(): void;
  38182. /**
  38183. * Gets if the sounds is ready to be played or not.
  38184. * @returns true if ready, otherwise false
  38185. */
  38186. isReady(): boolean;
  38187. private _soundLoaded;
  38188. /**
  38189. * Sets the data of the sound from an audiobuffer
  38190. * @param audioBuffer The audioBuffer containing the data
  38191. */
  38192. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38193. /**
  38194. * Updates the current sounds options such as maxdistance, loop...
  38195. * @param options A JSON object containing values named as the object properties
  38196. */
  38197. updateOptions(options: ISoundOptions): void;
  38198. private _createSpatialParameters;
  38199. private _updateSpatialParameters;
  38200. /**
  38201. * Switch the panning model to HRTF:
  38202. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38203. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38204. */
  38205. switchPanningModelToHRTF(): void;
  38206. /**
  38207. * Switch the panning model to Equal Power:
  38208. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38209. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38210. */
  38211. switchPanningModelToEqualPower(): void;
  38212. private _switchPanningModel;
  38213. /**
  38214. * Connect this sound to a sound track audio node like gain...
  38215. * @param soundTrackAudioNode the sound track audio node to connect to
  38216. */
  38217. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38218. /**
  38219. * Transform this sound into a directional source
  38220. * @param coneInnerAngle Size of the inner cone in degree
  38221. * @param coneOuterAngle Size of the outer cone in degree
  38222. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38223. */
  38224. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38225. /**
  38226. * Gets or sets the inner angle for the directional cone.
  38227. */
  38228. get directionalConeInnerAngle(): number;
  38229. /**
  38230. * Gets or sets the inner angle for the directional cone.
  38231. */
  38232. set directionalConeInnerAngle(value: number);
  38233. /**
  38234. * Gets or sets the outer angle for the directional cone.
  38235. */
  38236. get directionalConeOuterAngle(): number;
  38237. /**
  38238. * Gets or sets the outer angle for the directional cone.
  38239. */
  38240. set directionalConeOuterAngle(value: number);
  38241. /**
  38242. * Sets the position of the emitter if spatial sound is enabled
  38243. * @param newPosition Defines the new posisiton
  38244. */
  38245. setPosition(newPosition: Vector3): void;
  38246. /**
  38247. * Sets the local direction of the emitter if spatial sound is enabled
  38248. * @param newLocalDirection Defines the new local direction
  38249. */
  38250. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38251. private _updateDirection;
  38252. /** @hidden */
  38253. updateDistanceFromListener(): void;
  38254. /**
  38255. * Sets a new custom attenuation function for the sound.
  38256. * @param callback Defines the function used for the attenuation
  38257. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38258. */
  38259. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38260. /**
  38261. * Play the sound
  38262. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38263. * @param offset (optional) Start the sound at a specific time in seconds
  38264. * @param length (optional) Sound duration (in seconds)
  38265. */
  38266. play(time?: number, offset?: number, length?: number): void;
  38267. private _onended;
  38268. /**
  38269. * Stop the sound
  38270. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38271. */
  38272. stop(time?: number): void;
  38273. /**
  38274. * Put the sound in pause
  38275. */
  38276. pause(): void;
  38277. /**
  38278. * Sets a dedicated volume for this sounds
  38279. * @param newVolume Define the new volume of the sound
  38280. * @param time Define time for gradual change to new volume
  38281. */
  38282. setVolume(newVolume: number, time?: number): void;
  38283. /**
  38284. * Set the sound play back rate
  38285. * @param newPlaybackRate Define the playback rate the sound should be played at
  38286. */
  38287. setPlaybackRate(newPlaybackRate: number): void;
  38288. /**
  38289. * Gets the volume of the sound.
  38290. * @returns the volume of the sound
  38291. */
  38292. getVolume(): number;
  38293. /**
  38294. * Attach the sound to a dedicated mesh
  38295. * @param transformNode The transform node to connect the sound with
  38296. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38297. */
  38298. attachToMesh(transformNode: TransformNode): void;
  38299. /**
  38300. * Detach the sound from the previously attached mesh
  38301. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38302. */
  38303. detachFromMesh(): void;
  38304. private _onRegisterAfterWorldMatrixUpdate;
  38305. /**
  38306. * Clone the current sound in the scene.
  38307. * @returns the new sound clone
  38308. */
  38309. clone(): Nullable<Sound>;
  38310. /**
  38311. * Gets the current underlying audio buffer containing the data
  38312. * @returns the audio buffer
  38313. */
  38314. getAudioBuffer(): Nullable<AudioBuffer>;
  38315. /**
  38316. * Serializes the Sound in a JSON representation
  38317. * @returns the JSON representation of the sound
  38318. */
  38319. serialize(): any;
  38320. /**
  38321. * Parse a JSON representation of a sound to innstantiate in a given scene
  38322. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38323. * @param scene Define the scene the new parsed sound should be created in
  38324. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38325. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38326. * @returns the newly parsed sound
  38327. */
  38328. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38329. }
  38330. }
  38331. declare module "babylonjs/Actions/directAudioActions" {
  38332. import { Action } from "babylonjs/Actions/action";
  38333. import { Condition } from "babylonjs/Actions/condition";
  38334. import { Sound } from "babylonjs/Audio/sound";
  38335. /**
  38336. * This defines an action helpful to play a defined sound on a triggered action.
  38337. */
  38338. export class PlaySoundAction extends Action {
  38339. private _sound;
  38340. /**
  38341. * Instantiate the action
  38342. * @param triggerOptions defines the trigger options
  38343. * @param sound defines the sound to play
  38344. * @param condition defines the trigger related conditions
  38345. */
  38346. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38347. /** @hidden */
  38348. _prepare(): void;
  38349. /**
  38350. * Execute the action and play the sound.
  38351. */
  38352. execute(): void;
  38353. /**
  38354. * Serializes the actions and its related information.
  38355. * @param parent defines the object to serialize in
  38356. * @returns the serialized object
  38357. */
  38358. serialize(parent: any): any;
  38359. }
  38360. /**
  38361. * This defines an action helpful to stop a defined sound on a triggered action.
  38362. */
  38363. export class StopSoundAction extends Action {
  38364. private _sound;
  38365. /**
  38366. * Instantiate the action
  38367. * @param triggerOptions defines the trigger options
  38368. * @param sound defines the sound to stop
  38369. * @param condition defines the trigger related conditions
  38370. */
  38371. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38372. /** @hidden */
  38373. _prepare(): void;
  38374. /**
  38375. * Execute the action and stop the sound.
  38376. */
  38377. execute(): void;
  38378. /**
  38379. * Serializes the actions and its related information.
  38380. * @param parent defines the object to serialize in
  38381. * @returns the serialized object
  38382. */
  38383. serialize(parent: any): any;
  38384. }
  38385. }
  38386. declare module "babylonjs/Actions/interpolateValueAction" {
  38387. import { Action } from "babylonjs/Actions/action";
  38388. import { Condition } from "babylonjs/Actions/condition";
  38389. import { Observable } from "babylonjs/Misc/observable";
  38390. /**
  38391. * This defines an action responsible to change the value of a property
  38392. * by interpolating between its current value and the newly set one once triggered.
  38393. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38394. */
  38395. export class InterpolateValueAction extends Action {
  38396. /**
  38397. * Defines the path of the property where the value should be interpolated
  38398. */
  38399. propertyPath: string;
  38400. /**
  38401. * Defines the target value at the end of the interpolation.
  38402. */
  38403. value: any;
  38404. /**
  38405. * Defines the time it will take for the property to interpolate to the value.
  38406. */
  38407. duration: number;
  38408. /**
  38409. * Defines if the other scene animations should be stopped when the action has been triggered
  38410. */
  38411. stopOtherAnimations?: boolean;
  38412. /**
  38413. * Defines a callback raised once the interpolation animation has been done.
  38414. */
  38415. onInterpolationDone?: () => void;
  38416. /**
  38417. * Observable triggered once the interpolation animation has been done.
  38418. */
  38419. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38420. private _target;
  38421. private _effectiveTarget;
  38422. private _property;
  38423. /**
  38424. * Instantiate the action
  38425. * @param triggerOptions defines the trigger options
  38426. * @param target defines the object containing the value to interpolate
  38427. * @param propertyPath defines the path to the property in the target object
  38428. * @param value defines the target value at the end of the interpolation
  38429. * @param duration deines the time it will take for the property to interpolate to the value.
  38430. * @param condition defines the trigger related conditions
  38431. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38432. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38433. */
  38434. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38435. /** @hidden */
  38436. _prepare(): void;
  38437. /**
  38438. * Execute the action starts the value interpolation.
  38439. */
  38440. execute(): void;
  38441. /**
  38442. * Serializes the actions and its related information.
  38443. * @param parent defines the object to serialize in
  38444. * @returns the serialized object
  38445. */
  38446. serialize(parent: any): any;
  38447. }
  38448. }
  38449. declare module "babylonjs/Actions/index" {
  38450. export * from "babylonjs/Actions/abstractActionManager";
  38451. export * from "babylonjs/Actions/action";
  38452. export * from "babylonjs/Actions/actionEvent";
  38453. export * from "babylonjs/Actions/actionManager";
  38454. export * from "babylonjs/Actions/condition";
  38455. export * from "babylonjs/Actions/directActions";
  38456. export * from "babylonjs/Actions/directAudioActions";
  38457. export * from "babylonjs/Actions/interpolateValueAction";
  38458. }
  38459. declare module "babylonjs/Animations/index" {
  38460. export * from "babylonjs/Animations/animatable";
  38461. export * from "babylonjs/Animations/animation";
  38462. export * from "babylonjs/Animations/animationGroup";
  38463. export * from "babylonjs/Animations/animationPropertiesOverride";
  38464. export * from "babylonjs/Animations/easing";
  38465. export * from "babylonjs/Animations/runtimeAnimation";
  38466. export * from "babylonjs/Animations/animationEvent";
  38467. export * from "babylonjs/Animations/animationGroup";
  38468. export * from "babylonjs/Animations/animationKey";
  38469. export * from "babylonjs/Animations/animationRange";
  38470. export * from "babylonjs/Animations/animatable.interface";
  38471. }
  38472. declare module "babylonjs/Audio/soundTrack" {
  38473. import { Sound } from "babylonjs/Audio/sound";
  38474. import { Analyser } from "babylonjs/Audio/analyser";
  38475. import { Scene } from "babylonjs/scene";
  38476. /**
  38477. * Options allowed during the creation of a sound track.
  38478. */
  38479. export interface ISoundTrackOptions {
  38480. /**
  38481. * The volume the sound track should take during creation
  38482. */
  38483. volume?: number;
  38484. /**
  38485. * Define if the sound track is the main sound track of the scene
  38486. */
  38487. mainTrack?: boolean;
  38488. }
  38489. /**
  38490. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38491. * It will be also used in a future release to apply effects on a specific track.
  38492. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38493. */
  38494. export class SoundTrack {
  38495. /**
  38496. * The unique identifier of the sound track in the scene.
  38497. */
  38498. id: number;
  38499. /**
  38500. * The list of sounds included in the sound track.
  38501. */
  38502. soundCollection: Array<Sound>;
  38503. private _outputAudioNode;
  38504. private _scene;
  38505. private _connectedAnalyser;
  38506. private _options;
  38507. private _isInitialized;
  38508. /**
  38509. * Creates a new sound track.
  38510. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38511. * @param scene Define the scene the sound track belongs to
  38512. * @param options
  38513. */
  38514. constructor(scene: Scene, options?: ISoundTrackOptions);
  38515. private _initializeSoundTrackAudioGraph;
  38516. /**
  38517. * Release the sound track and its associated resources
  38518. */
  38519. dispose(): void;
  38520. /**
  38521. * Adds a sound to this sound track
  38522. * @param sound define the cound to add
  38523. * @ignoreNaming
  38524. */
  38525. AddSound(sound: Sound): void;
  38526. /**
  38527. * Removes a sound to this sound track
  38528. * @param sound define the cound to remove
  38529. * @ignoreNaming
  38530. */
  38531. RemoveSound(sound: Sound): void;
  38532. /**
  38533. * Set a global volume for the full sound track.
  38534. * @param newVolume Define the new volume of the sound track
  38535. */
  38536. setVolume(newVolume: number): void;
  38537. /**
  38538. * Switch the panning model to HRTF:
  38539. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38540. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38541. */
  38542. switchPanningModelToHRTF(): void;
  38543. /**
  38544. * Switch the panning model to Equal Power:
  38545. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38546. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38547. */
  38548. switchPanningModelToEqualPower(): void;
  38549. /**
  38550. * Connect the sound track to an audio analyser allowing some amazing
  38551. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38552. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38553. * @param analyser The analyser to connect to the engine
  38554. */
  38555. connectToAnalyser(analyser: Analyser): void;
  38556. }
  38557. }
  38558. declare module "babylonjs/Audio/audioSceneComponent" {
  38559. import { Sound } from "babylonjs/Audio/sound";
  38560. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38561. import { Nullable } from "babylonjs/types";
  38562. import { Vector3 } from "babylonjs/Maths/math.vector";
  38563. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38564. import { Scene } from "babylonjs/scene";
  38565. import { AbstractScene } from "babylonjs/abstractScene";
  38566. import "babylonjs/Audio/audioEngine";
  38567. module "babylonjs/abstractScene" {
  38568. interface AbstractScene {
  38569. /**
  38570. * The list of sounds used in the scene.
  38571. */
  38572. sounds: Nullable<Array<Sound>>;
  38573. }
  38574. }
  38575. module "babylonjs/scene" {
  38576. interface Scene {
  38577. /**
  38578. * @hidden
  38579. * Backing field
  38580. */
  38581. _mainSoundTrack: SoundTrack;
  38582. /**
  38583. * The main sound track played by the scene.
  38584. * It cotains your primary collection of sounds.
  38585. */
  38586. mainSoundTrack: SoundTrack;
  38587. /**
  38588. * The list of sound tracks added to the scene
  38589. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38590. */
  38591. soundTracks: Nullable<Array<SoundTrack>>;
  38592. /**
  38593. * Gets a sound using a given name
  38594. * @param name defines the name to search for
  38595. * @return the found sound or null if not found at all.
  38596. */
  38597. getSoundByName(name: string): Nullable<Sound>;
  38598. /**
  38599. * Gets or sets if audio support is enabled
  38600. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38601. */
  38602. audioEnabled: boolean;
  38603. /**
  38604. * Gets or sets if audio will be output to headphones
  38605. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38606. */
  38607. headphone: boolean;
  38608. /**
  38609. * Gets or sets custom audio listener position provider
  38610. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38611. */
  38612. audioListenerPositionProvider: Nullable<() => Vector3>;
  38613. /**
  38614. * Gets or sets a refresh rate when using 3D audio positioning
  38615. */
  38616. audioPositioningRefreshRate: number;
  38617. }
  38618. }
  38619. /**
  38620. * Defines the sound scene component responsible to manage any sounds
  38621. * in a given scene.
  38622. */
  38623. export class AudioSceneComponent implements ISceneSerializableComponent {
  38624. /**
  38625. * The component name helpfull to identify the component in the list of scene components.
  38626. */
  38627. readonly name: string;
  38628. /**
  38629. * The scene the component belongs to.
  38630. */
  38631. scene: Scene;
  38632. private _audioEnabled;
  38633. /**
  38634. * Gets whether audio is enabled or not.
  38635. * Please use related enable/disable method to switch state.
  38636. */
  38637. get audioEnabled(): boolean;
  38638. private _headphone;
  38639. /**
  38640. * Gets whether audio is outputing to headphone or not.
  38641. * Please use the according Switch methods to change output.
  38642. */
  38643. get headphone(): boolean;
  38644. /**
  38645. * Gets or sets a refresh rate when using 3D audio positioning
  38646. */
  38647. audioPositioningRefreshRate: number;
  38648. private _audioListenerPositionProvider;
  38649. /**
  38650. * Gets the current audio listener position provider
  38651. */
  38652. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38653. /**
  38654. * Sets a custom listener position for all sounds in the scene
  38655. * By default, this is the position of the first active camera
  38656. */
  38657. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38658. /**
  38659. * Creates a new instance of the component for the given scene
  38660. * @param scene Defines the scene to register the component in
  38661. */
  38662. constructor(scene: Scene);
  38663. /**
  38664. * Registers the component in a given scene
  38665. */
  38666. register(): void;
  38667. /**
  38668. * Rebuilds the elements related to this component in case of
  38669. * context lost for instance.
  38670. */
  38671. rebuild(): void;
  38672. /**
  38673. * Serializes the component data to the specified json object
  38674. * @param serializationObject The object to serialize to
  38675. */
  38676. serialize(serializationObject: any): void;
  38677. /**
  38678. * Adds all the elements from the container to the scene
  38679. * @param container the container holding the elements
  38680. */
  38681. addFromContainer(container: AbstractScene): void;
  38682. /**
  38683. * Removes all the elements in the container from the scene
  38684. * @param container contains the elements to remove
  38685. * @param dispose if the removed element should be disposed (default: false)
  38686. */
  38687. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38688. /**
  38689. * Disposes the component and the associated ressources.
  38690. */
  38691. dispose(): void;
  38692. /**
  38693. * Disables audio in the associated scene.
  38694. */
  38695. disableAudio(): void;
  38696. /**
  38697. * Enables audio in the associated scene.
  38698. */
  38699. enableAudio(): void;
  38700. /**
  38701. * Switch audio to headphone output.
  38702. */
  38703. switchAudioModeForHeadphones(): void;
  38704. /**
  38705. * Switch audio to normal speakers.
  38706. */
  38707. switchAudioModeForNormalSpeakers(): void;
  38708. private _cachedCameraDirection;
  38709. private _cachedCameraPosition;
  38710. private _lastCheck;
  38711. private _afterRender;
  38712. }
  38713. }
  38714. declare module "babylonjs/Audio/weightedsound" {
  38715. import { Sound } from "babylonjs/Audio/sound";
  38716. /**
  38717. * Wraps one or more Sound objects and selects one with random weight for playback.
  38718. */
  38719. export class WeightedSound {
  38720. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38721. loop: boolean;
  38722. private _coneInnerAngle;
  38723. private _coneOuterAngle;
  38724. private _volume;
  38725. /** A Sound is currently playing. */
  38726. isPlaying: boolean;
  38727. /** A Sound is currently paused. */
  38728. isPaused: boolean;
  38729. private _sounds;
  38730. private _weights;
  38731. private _currentIndex?;
  38732. /**
  38733. * Creates a new WeightedSound from the list of sounds given.
  38734. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38735. * @param sounds Array of Sounds that will be selected from.
  38736. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38737. */
  38738. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38739. /**
  38740. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38741. */
  38742. get directionalConeInnerAngle(): number;
  38743. /**
  38744. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38745. */
  38746. set directionalConeInnerAngle(value: number);
  38747. /**
  38748. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38749. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38750. */
  38751. get directionalConeOuterAngle(): number;
  38752. /**
  38753. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38754. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38755. */
  38756. set directionalConeOuterAngle(value: number);
  38757. /**
  38758. * Playback volume.
  38759. */
  38760. get volume(): number;
  38761. /**
  38762. * Playback volume.
  38763. */
  38764. set volume(value: number);
  38765. private _onended;
  38766. /**
  38767. * Suspend playback
  38768. */
  38769. pause(): void;
  38770. /**
  38771. * Stop playback
  38772. */
  38773. stop(): void;
  38774. /**
  38775. * Start playback.
  38776. * @param startOffset Position the clip head at a specific time in seconds.
  38777. */
  38778. play(startOffset?: number): void;
  38779. }
  38780. }
  38781. declare module "babylonjs/Audio/index" {
  38782. export * from "babylonjs/Audio/analyser";
  38783. export * from "babylonjs/Audio/audioEngine";
  38784. export * from "babylonjs/Audio/audioSceneComponent";
  38785. export * from "babylonjs/Audio/sound";
  38786. export * from "babylonjs/Audio/soundTrack";
  38787. export * from "babylonjs/Audio/weightedsound";
  38788. }
  38789. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  38790. import { Behavior } from "babylonjs/Behaviors/behavior";
  38791. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38792. import { BackEase } from "babylonjs/Animations/easing";
  38793. /**
  38794. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38795. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38796. */
  38797. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38798. /**
  38799. * Gets the name of the behavior.
  38800. */
  38801. get name(): string;
  38802. /**
  38803. * The easing function used by animations
  38804. */
  38805. static EasingFunction: BackEase;
  38806. /**
  38807. * The easing mode used by animations
  38808. */
  38809. static EasingMode: number;
  38810. /**
  38811. * The duration of the animation, in milliseconds
  38812. */
  38813. transitionDuration: number;
  38814. /**
  38815. * Length of the distance animated by the transition when lower radius is reached
  38816. */
  38817. lowerRadiusTransitionRange: number;
  38818. /**
  38819. * Length of the distance animated by the transition when upper radius is reached
  38820. */
  38821. upperRadiusTransitionRange: number;
  38822. private _autoTransitionRange;
  38823. /**
  38824. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38825. */
  38826. get autoTransitionRange(): boolean;
  38827. /**
  38828. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38829. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38830. */
  38831. set autoTransitionRange(value: boolean);
  38832. private _attachedCamera;
  38833. private _onAfterCheckInputsObserver;
  38834. private _onMeshTargetChangedObserver;
  38835. /**
  38836. * Initializes the behavior.
  38837. */
  38838. init(): void;
  38839. /**
  38840. * Attaches the behavior to its arc rotate camera.
  38841. * @param camera Defines the camera to attach the behavior to
  38842. */
  38843. attach(camera: ArcRotateCamera): void;
  38844. /**
  38845. * Detaches the behavior from its current arc rotate camera.
  38846. */
  38847. detach(): void;
  38848. private _radiusIsAnimating;
  38849. private _radiusBounceTransition;
  38850. private _animatables;
  38851. private _cachedWheelPrecision;
  38852. /**
  38853. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38854. * @param radiusLimit The limit to check against.
  38855. * @return Bool to indicate if at limit.
  38856. */
  38857. private _isRadiusAtLimit;
  38858. /**
  38859. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38860. * @param radiusDelta The delta by which to animate to. Can be negative.
  38861. */
  38862. private _applyBoundRadiusAnimation;
  38863. /**
  38864. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38865. */
  38866. protected _clearAnimationLocks(): void;
  38867. /**
  38868. * Stops and removes all animations that have been applied to the camera
  38869. */
  38870. stopAllAnimations(): void;
  38871. }
  38872. }
  38873. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  38874. import { Behavior } from "babylonjs/Behaviors/behavior";
  38875. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38876. import { ExponentialEase } from "babylonjs/Animations/easing";
  38877. import { Nullable } from "babylonjs/types";
  38878. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38879. import { Vector3 } from "babylonjs/Maths/math.vector";
  38880. /**
  38881. * 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.
  38882. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38883. */
  38884. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38885. /**
  38886. * Gets the name of the behavior.
  38887. */
  38888. get name(): string;
  38889. private _mode;
  38890. private _radiusScale;
  38891. private _positionScale;
  38892. private _defaultElevation;
  38893. private _elevationReturnTime;
  38894. private _elevationReturnWaitTime;
  38895. private _zoomStopsAnimation;
  38896. private _framingTime;
  38897. /**
  38898. * The easing function used by animations
  38899. */
  38900. static EasingFunction: ExponentialEase;
  38901. /**
  38902. * The easing mode used by animations
  38903. */
  38904. static EasingMode: number;
  38905. /**
  38906. * Sets the current mode used by the behavior
  38907. */
  38908. set mode(mode: number);
  38909. /**
  38910. * Gets current mode used by the behavior.
  38911. */
  38912. get mode(): number;
  38913. /**
  38914. * Sets the scale applied to the radius (1 by default)
  38915. */
  38916. set radiusScale(radius: number);
  38917. /**
  38918. * Gets the scale applied to the radius
  38919. */
  38920. get radiusScale(): number;
  38921. /**
  38922. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38923. */
  38924. set positionScale(scale: number);
  38925. /**
  38926. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38927. */
  38928. get positionScale(): number;
  38929. /**
  38930. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38931. * behaviour is triggered, in radians.
  38932. */
  38933. set defaultElevation(elevation: number);
  38934. /**
  38935. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38936. * behaviour is triggered, in radians.
  38937. */
  38938. get defaultElevation(): number;
  38939. /**
  38940. * Sets the time (in milliseconds) taken to return to the default beta position.
  38941. * Negative value indicates camera should not return to default.
  38942. */
  38943. set elevationReturnTime(speed: number);
  38944. /**
  38945. * Gets the time (in milliseconds) taken to return to the default beta position.
  38946. * Negative value indicates camera should not return to default.
  38947. */
  38948. get elevationReturnTime(): number;
  38949. /**
  38950. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38951. */
  38952. set elevationReturnWaitTime(time: number);
  38953. /**
  38954. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38955. */
  38956. get elevationReturnWaitTime(): number;
  38957. /**
  38958. * Sets the flag that indicates if user zooming should stop animation.
  38959. */
  38960. set zoomStopsAnimation(flag: boolean);
  38961. /**
  38962. * Gets the flag that indicates if user zooming should stop animation.
  38963. */
  38964. get zoomStopsAnimation(): boolean;
  38965. /**
  38966. * Sets the transition time when framing the mesh, in milliseconds
  38967. */
  38968. set framingTime(time: number);
  38969. /**
  38970. * Gets the transition time when framing the mesh, in milliseconds
  38971. */
  38972. get framingTime(): number;
  38973. /**
  38974. * Define if the behavior should automatically change the configured
  38975. * camera limits and sensibilities.
  38976. */
  38977. autoCorrectCameraLimitsAndSensibility: boolean;
  38978. private _onPrePointerObservableObserver;
  38979. private _onAfterCheckInputsObserver;
  38980. private _onMeshTargetChangedObserver;
  38981. private _attachedCamera;
  38982. private _isPointerDown;
  38983. private _lastInteractionTime;
  38984. /**
  38985. * Initializes the behavior.
  38986. */
  38987. init(): void;
  38988. /**
  38989. * Attaches the behavior to its arc rotate camera.
  38990. * @param camera Defines the camera to attach the behavior to
  38991. */
  38992. attach(camera: ArcRotateCamera): void;
  38993. /**
  38994. * Detaches the behavior from its current arc rotate camera.
  38995. */
  38996. detach(): void;
  38997. private _animatables;
  38998. private _betaIsAnimating;
  38999. private _betaTransition;
  39000. private _radiusTransition;
  39001. private _vectorTransition;
  39002. /**
  39003. * Targets the given mesh and updates zoom level accordingly.
  39004. * @param mesh The mesh to target.
  39005. * @param radius Optional. If a cached radius position already exists, overrides default.
  39006. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39007. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39008. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39009. */
  39010. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39011. /**
  39012. * Targets the given mesh with its children and updates zoom level accordingly.
  39013. * @param mesh The mesh to target.
  39014. * @param radius Optional. If a cached radius position already exists, overrides default.
  39015. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39016. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39017. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39018. */
  39019. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39020. /**
  39021. * Targets the given meshes with their children and updates zoom level accordingly.
  39022. * @param meshes The mesh to target.
  39023. * @param radius Optional. If a cached radius position already exists, overrides default.
  39024. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39025. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39026. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39027. */
  39028. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39029. /**
  39030. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39031. * @param minimumWorld Determines the smaller position of the bounding box extend
  39032. * @param maximumWorld Determines the bigger position of the bounding box extend
  39033. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39034. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39035. */
  39036. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39037. /**
  39038. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39039. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39040. * frustum width.
  39041. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39042. * to fully enclose the mesh in the viewing frustum.
  39043. */
  39044. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39045. /**
  39046. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39047. * is automatically returned to its default position (expected to be above ground plane).
  39048. */
  39049. private _maintainCameraAboveGround;
  39050. /**
  39051. * Returns the frustum slope based on the canvas ratio and camera FOV
  39052. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39053. */
  39054. private _getFrustumSlope;
  39055. /**
  39056. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39057. */
  39058. private _clearAnimationLocks;
  39059. /**
  39060. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39061. */
  39062. private _applyUserInteraction;
  39063. /**
  39064. * Stops and removes all animations that have been applied to the camera
  39065. */
  39066. stopAllAnimations(): void;
  39067. /**
  39068. * Gets a value indicating if the user is moving the camera
  39069. */
  39070. get isUserIsMoving(): boolean;
  39071. /**
  39072. * The camera can move all the way towards the mesh.
  39073. */
  39074. static IgnoreBoundsSizeMode: number;
  39075. /**
  39076. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39077. */
  39078. static FitFrustumSidesMode: number;
  39079. }
  39080. }
  39081. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39082. import { Nullable } from "babylonjs/types";
  39083. import { Camera } from "babylonjs/Cameras/camera";
  39084. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39085. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39086. /**
  39087. * Base class for Camera Pointer Inputs.
  39088. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39089. * for example usage.
  39090. */
  39091. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39092. /**
  39093. * Defines the camera the input is attached to.
  39094. */
  39095. abstract camera: Camera;
  39096. /**
  39097. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39098. */
  39099. protected _altKey: boolean;
  39100. protected _ctrlKey: boolean;
  39101. protected _metaKey: boolean;
  39102. protected _shiftKey: boolean;
  39103. /**
  39104. * Which mouse buttons were pressed at time of last mouse event.
  39105. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39106. */
  39107. protected _buttonsPressed: number;
  39108. /**
  39109. * Defines the buttons associated with the input to handle camera move.
  39110. */
  39111. buttons: number[];
  39112. /**
  39113. * Attach the input controls to a specific dom element to get the input from.
  39114. * @param element Defines the element the controls should be listened from
  39115. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39116. */
  39117. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39118. /**
  39119. * Detach the current controls from the specified dom element.
  39120. * @param element Defines the element to stop listening the inputs from
  39121. */
  39122. detachControl(element: Nullable<HTMLElement>): void;
  39123. /**
  39124. * Gets the class name of the current input.
  39125. * @returns the class name
  39126. */
  39127. getClassName(): string;
  39128. /**
  39129. * Get the friendly name associated with the input class.
  39130. * @returns the input friendly name
  39131. */
  39132. getSimpleName(): string;
  39133. /**
  39134. * Called on pointer POINTERDOUBLETAP event.
  39135. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39136. */
  39137. protected onDoubleTap(type: string): void;
  39138. /**
  39139. * Called on pointer POINTERMOVE event if only a single touch is active.
  39140. * Override this method to provide functionality.
  39141. */
  39142. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39143. /**
  39144. * Called on pointer POINTERMOVE event if multiple touches are active.
  39145. * Override this method to provide functionality.
  39146. */
  39147. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39148. /**
  39149. * Called on JS contextmenu event.
  39150. * Override this method to provide functionality.
  39151. */
  39152. protected onContextMenu(evt: PointerEvent): void;
  39153. /**
  39154. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39155. * press.
  39156. * Override this method to provide functionality.
  39157. */
  39158. protected onButtonDown(evt: PointerEvent): void;
  39159. /**
  39160. * Called each time a new POINTERUP event occurs. Ie, for each button
  39161. * release.
  39162. * Override this method to provide functionality.
  39163. */
  39164. protected onButtonUp(evt: PointerEvent): void;
  39165. /**
  39166. * Called when window becomes inactive.
  39167. * Override this method to provide functionality.
  39168. */
  39169. protected onLostFocus(): void;
  39170. private _pointerInput;
  39171. private _observer;
  39172. private _onLostFocus;
  39173. private pointA;
  39174. private pointB;
  39175. }
  39176. }
  39177. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39178. import { Nullable } from "babylonjs/types";
  39179. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39180. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39181. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39182. /**
  39183. * Manage the pointers inputs to control an arc rotate camera.
  39184. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39185. */
  39186. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39187. /**
  39188. * Defines the camera the input is attached to.
  39189. */
  39190. camera: ArcRotateCamera;
  39191. /**
  39192. * Gets the class name of the current input.
  39193. * @returns the class name
  39194. */
  39195. getClassName(): string;
  39196. /**
  39197. * Defines the buttons associated with the input to handle camera move.
  39198. */
  39199. buttons: number[];
  39200. /**
  39201. * Defines the pointer angular sensibility along the X axis or how fast is
  39202. * the camera rotating.
  39203. */
  39204. angularSensibilityX: number;
  39205. /**
  39206. * Defines the pointer angular sensibility along the Y axis or how fast is
  39207. * the camera rotating.
  39208. */
  39209. angularSensibilityY: number;
  39210. /**
  39211. * Defines the pointer pinch precision or how fast is the camera zooming.
  39212. */
  39213. pinchPrecision: number;
  39214. /**
  39215. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39216. * from 0.
  39217. * It defines the percentage of current camera.radius to use as delta when
  39218. * pinch zoom is used.
  39219. */
  39220. pinchDeltaPercentage: number;
  39221. /**
  39222. * Defines the pointer panning sensibility or how fast is the camera moving.
  39223. */
  39224. panningSensibility: number;
  39225. /**
  39226. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39227. */
  39228. multiTouchPanning: boolean;
  39229. /**
  39230. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39231. * zoom (pinch) through multitouch.
  39232. */
  39233. multiTouchPanAndZoom: boolean;
  39234. /**
  39235. * Revers pinch action direction.
  39236. */
  39237. pinchInwards: boolean;
  39238. private _isPanClick;
  39239. private _twoFingerActivityCount;
  39240. private _isPinching;
  39241. /**
  39242. * Called on pointer POINTERMOVE event if only a single touch is active.
  39243. */
  39244. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39245. /**
  39246. * Called on pointer POINTERDOUBLETAP event.
  39247. */
  39248. protected onDoubleTap(type: string): void;
  39249. /**
  39250. * Called on pointer POINTERMOVE event if multiple touches are active.
  39251. */
  39252. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39253. /**
  39254. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39255. * press.
  39256. */
  39257. protected onButtonDown(evt: PointerEvent): void;
  39258. /**
  39259. * Called each time a new POINTERUP event occurs. Ie, for each button
  39260. * release.
  39261. */
  39262. protected onButtonUp(evt: PointerEvent): void;
  39263. /**
  39264. * Called when window becomes inactive.
  39265. */
  39266. protected onLostFocus(): void;
  39267. }
  39268. }
  39269. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39270. import { Nullable } from "babylonjs/types";
  39271. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39272. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39273. /**
  39274. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39275. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39276. */
  39277. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39278. /**
  39279. * Defines the camera the input is attached to.
  39280. */
  39281. camera: ArcRotateCamera;
  39282. /**
  39283. * Defines the list of key codes associated with the up action (increase alpha)
  39284. */
  39285. keysUp: number[];
  39286. /**
  39287. * Defines the list of key codes associated with the down action (decrease alpha)
  39288. */
  39289. keysDown: number[];
  39290. /**
  39291. * Defines the list of key codes associated with the left action (increase beta)
  39292. */
  39293. keysLeft: number[];
  39294. /**
  39295. * Defines the list of key codes associated with the right action (decrease beta)
  39296. */
  39297. keysRight: number[];
  39298. /**
  39299. * Defines the list of key codes associated with the reset action.
  39300. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39301. */
  39302. keysReset: number[];
  39303. /**
  39304. * Defines the panning sensibility of the inputs.
  39305. * (How fast is the camera paning)
  39306. */
  39307. panningSensibility: number;
  39308. /**
  39309. * Defines the zooming sensibility of the inputs.
  39310. * (How fast is the camera zooming)
  39311. */
  39312. zoomingSensibility: number;
  39313. /**
  39314. * Defines wether maintaining the alt key down switch the movement mode from
  39315. * orientation to zoom.
  39316. */
  39317. useAltToZoom: boolean;
  39318. /**
  39319. * Rotation speed of the camera
  39320. */
  39321. angularSpeed: number;
  39322. private _keys;
  39323. private _ctrlPressed;
  39324. private _altPressed;
  39325. private _onCanvasBlurObserver;
  39326. private _onKeyboardObserver;
  39327. private _engine;
  39328. private _scene;
  39329. /**
  39330. * Attach the input controls to a specific dom element to get the input from.
  39331. * @param element Defines the element the controls should be listened from
  39332. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39333. */
  39334. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39335. /**
  39336. * Detach the current controls from the specified dom element.
  39337. * @param element Defines the element to stop listening the inputs from
  39338. */
  39339. detachControl(element: Nullable<HTMLElement>): void;
  39340. /**
  39341. * Update the current camera state depending on the inputs that have been used this frame.
  39342. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39343. */
  39344. checkInputs(): void;
  39345. /**
  39346. * Gets the class name of the current intput.
  39347. * @returns the class name
  39348. */
  39349. getClassName(): string;
  39350. /**
  39351. * Get the friendly name associated with the input class.
  39352. * @returns the input friendly name
  39353. */
  39354. getSimpleName(): string;
  39355. }
  39356. }
  39357. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39358. import { Nullable } from "babylonjs/types";
  39359. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39360. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39361. /**
  39362. * Manage the mouse wheel inputs to control an arc rotate camera.
  39363. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39364. */
  39365. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39366. /**
  39367. * Defines the camera the input is attached to.
  39368. */
  39369. camera: ArcRotateCamera;
  39370. /**
  39371. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39372. */
  39373. wheelPrecision: number;
  39374. /**
  39375. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39376. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39377. */
  39378. wheelDeltaPercentage: number;
  39379. private _wheel;
  39380. private _observer;
  39381. private computeDeltaFromMouseWheelLegacyEvent;
  39382. /**
  39383. * Attach the input controls to a specific dom element to get the input from.
  39384. * @param element Defines the element the controls should be listened from
  39385. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39386. */
  39387. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39388. /**
  39389. * Detach the current controls from the specified dom element.
  39390. * @param element Defines the element to stop listening the inputs from
  39391. */
  39392. detachControl(element: Nullable<HTMLElement>): void;
  39393. /**
  39394. * Gets the class name of the current intput.
  39395. * @returns the class name
  39396. */
  39397. getClassName(): string;
  39398. /**
  39399. * Get the friendly name associated with the input class.
  39400. * @returns the input friendly name
  39401. */
  39402. getSimpleName(): string;
  39403. }
  39404. }
  39405. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39406. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39407. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39408. /**
  39409. * Default Inputs manager for the ArcRotateCamera.
  39410. * It groups all the default supported inputs for ease of use.
  39411. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39412. */
  39413. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39414. /**
  39415. * Instantiates a new ArcRotateCameraInputsManager.
  39416. * @param camera Defines the camera the inputs belong to
  39417. */
  39418. constructor(camera: ArcRotateCamera);
  39419. /**
  39420. * Add mouse wheel input support to the input manager.
  39421. * @returns the current input manager
  39422. */
  39423. addMouseWheel(): ArcRotateCameraInputsManager;
  39424. /**
  39425. * Add pointers input support to the input manager.
  39426. * @returns the current input manager
  39427. */
  39428. addPointers(): ArcRotateCameraInputsManager;
  39429. /**
  39430. * Add keyboard input support to the input manager.
  39431. * @returns the current input manager
  39432. */
  39433. addKeyboard(): ArcRotateCameraInputsManager;
  39434. }
  39435. }
  39436. declare module "babylonjs/Cameras/arcRotateCamera" {
  39437. import { Observable } from "babylonjs/Misc/observable";
  39438. import { Nullable } from "babylonjs/types";
  39439. import { Scene } from "babylonjs/scene";
  39440. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39442. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39443. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39444. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39445. import { Camera } from "babylonjs/Cameras/camera";
  39446. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39447. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39448. import { Collider } from "babylonjs/Collisions/collider";
  39449. /**
  39450. * This represents an orbital type of camera.
  39451. *
  39452. * 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.
  39453. * 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.
  39454. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39455. */
  39456. export class ArcRotateCamera extends TargetCamera {
  39457. /**
  39458. * Defines the rotation angle of the camera along the longitudinal axis.
  39459. */
  39460. alpha: number;
  39461. /**
  39462. * Defines the rotation angle of the camera along the latitudinal axis.
  39463. */
  39464. beta: number;
  39465. /**
  39466. * Defines the radius of the camera from it s target point.
  39467. */
  39468. radius: number;
  39469. protected _target: Vector3;
  39470. protected _targetHost: Nullable<AbstractMesh>;
  39471. /**
  39472. * Defines the target point of the camera.
  39473. * The camera looks towards it form the radius distance.
  39474. */
  39475. get target(): Vector3;
  39476. set target(value: Vector3);
  39477. /**
  39478. * Define the current local position of the camera in the scene
  39479. */
  39480. get position(): Vector3;
  39481. set position(newPosition: Vector3);
  39482. protected _upVector: Vector3;
  39483. protected _upToYMatrix: Matrix;
  39484. protected _YToUpMatrix: Matrix;
  39485. /**
  39486. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39487. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39488. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39489. */
  39490. set upVector(vec: Vector3);
  39491. get upVector(): Vector3;
  39492. /**
  39493. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39494. */
  39495. setMatUp(): void;
  39496. /**
  39497. * Current inertia value on the longitudinal axis.
  39498. * The bigger this number the longer it will take for the camera to stop.
  39499. */
  39500. inertialAlphaOffset: number;
  39501. /**
  39502. * Current inertia value on the latitudinal axis.
  39503. * The bigger this number the longer it will take for the camera to stop.
  39504. */
  39505. inertialBetaOffset: number;
  39506. /**
  39507. * Current inertia value on the radius axis.
  39508. * The bigger this number the longer it will take for the camera to stop.
  39509. */
  39510. inertialRadiusOffset: number;
  39511. /**
  39512. * Minimum allowed angle on the longitudinal axis.
  39513. * This can help limiting how the Camera is able to move in the scene.
  39514. */
  39515. lowerAlphaLimit: Nullable<number>;
  39516. /**
  39517. * Maximum allowed angle on the longitudinal axis.
  39518. * This can help limiting how the Camera is able to move in the scene.
  39519. */
  39520. upperAlphaLimit: Nullable<number>;
  39521. /**
  39522. * Minimum allowed angle on the latitudinal axis.
  39523. * This can help limiting how the Camera is able to move in the scene.
  39524. */
  39525. lowerBetaLimit: number;
  39526. /**
  39527. * Maximum allowed angle on the latitudinal axis.
  39528. * This can help limiting how the Camera is able to move in the scene.
  39529. */
  39530. upperBetaLimit: number;
  39531. /**
  39532. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39533. * This can help limiting how the Camera is able to move in the scene.
  39534. */
  39535. lowerRadiusLimit: Nullable<number>;
  39536. /**
  39537. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39538. * This can help limiting how the Camera is able to move in the scene.
  39539. */
  39540. upperRadiusLimit: Nullable<number>;
  39541. /**
  39542. * Defines the current inertia value used during panning of the camera along the X axis.
  39543. */
  39544. inertialPanningX: number;
  39545. /**
  39546. * Defines the current inertia value used during panning of the camera along the Y axis.
  39547. */
  39548. inertialPanningY: number;
  39549. /**
  39550. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39551. * Basically if your fingers moves away from more than this distance you will be considered
  39552. * in pinch mode.
  39553. */
  39554. pinchToPanMaxDistance: number;
  39555. /**
  39556. * Defines the maximum distance the camera can pan.
  39557. * This could help keeping the cammera always in your scene.
  39558. */
  39559. panningDistanceLimit: Nullable<number>;
  39560. /**
  39561. * Defines the target of the camera before paning.
  39562. */
  39563. panningOriginTarget: Vector3;
  39564. /**
  39565. * Defines the value of the inertia used during panning.
  39566. * 0 would mean stop inertia and one would mean no decelleration at all.
  39567. */
  39568. panningInertia: number;
  39569. /**
  39570. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39571. */
  39572. get angularSensibilityX(): number;
  39573. set angularSensibilityX(value: number);
  39574. /**
  39575. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39576. */
  39577. get angularSensibilityY(): number;
  39578. set angularSensibilityY(value: number);
  39579. /**
  39580. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39581. */
  39582. get pinchPrecision(): number;
  39583. set pinchPrecision(value: number);
  39584. /**
  39585. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39586. * It will be used instead of pinchDeltaPrecision if different from 0.
  39587. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39588. */
  39589. get pinchDeltaPercentage(): number;
  39590. set pinchDeltaPercentage(value: number);
  39591. /**
  39592. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39593. */
  39594. get panningSensibility(): number;
  39595. set panningSensibility(value: number);
  39596. /**
  39597. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39598. */
  39599. get keysUp(): number[];
  39600. set keysUp(value: number[]);
  39601. /**
  39602. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39603. */
  39604. get keysDown(): number[];
  39605. set keysDown(value: number[]);
  39606. /**
  39607. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39608. */
  39609. get keysLeft(): number[];
  39610. set keysLeft(value: number[]);
  39611. /**
  39612. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39613. */
  39614. get keysRight(): number[];
  39615. set keysRight(value: number[]);
  39616. /**
  39617. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39618. */
  39619. get wheelPrecision(): number;
  39620. set wheelPrecision(value: number);
  39621. /**
  39622. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39623. * It will be used instead of pinchDeltaPrecision if different from 0.
  39624. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39625. */
  39626. get wheelDeltaPercentage(): number;
  39627. set wheelDeltaPercentage(value: number);
  39628. /**
  39629. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39630. */
  39631. zoomOnFactor: number;
  39632. /**
  39633. * Defines a screen offset for the camera position.
  39634. */
  39635. targetScreenOffset: Vector2;
  39636. /**
  39637. * Allows the camera to be completely reversed.
  39638. * If false the camera can not arrive upside down.
  39639. */
  39640. allowUpsideDown: boolean;
  39641. /**
  39642. * Define if double tap/click is used to restore the previously saved state of the camera.
  39643. */
  39644. useInputToRestoreState: boolean;
  39645. /** @hidden */
  39646. _viewMatrix: Matrix;
  39647. /** @hidden */
  39648. _useCtrlForPanning: boolean;
  39649. /** @hidden */
  39650. _panningMouseButton: number;
  39651. /**
  39652. * Defines the input associated to the camera.
  39653. */
  39654. inputs: ArcRotateCameraInputsManager;
  39655. /** @hidden */
  39656. _reset: () => void;
  39657. /**
  39658. * Defines the allowed panning axis.
  39659. */
  39660. panningAxis: Vector3;
  39661. protected _localDirection: Vector3;
  39662. protected _transformedDirection: Vector3;
  39663. private _bouncingBehavior;
  39664. /**
  39665. * Gets the bouncing behavior of the camera if it has been enabled.
  39666. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39667. */
  39668. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39669. /**
  39670. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39671. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39672. */
  39673. get useBouncingBehavior(): boolean;
  39674. set useBouncingBehavior(value: boolean);
  39675. private _framingBehavior;
  39676. /**
  39677. * Gets the framing behavior of the camera if it has been enabled.
  39678. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39679. */
  39680. get framingBehavior(): Nullable<FramingBehavior>;
  39681. /**
  39682. * Defines if the framing behavior of the camera is enabled on the camera.
  39683. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39684. */
  39685. get useFramingBehavior(): boolean;
  39686. set useFramingBehavior(value: boolean);
  39687. private _autoRotationBehavior;
  39688. /**
  39689. * Gets the auto rotation behavior of the camera if it has been enabled.
  39690. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39691. */
  39692. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39693. /**
  39694. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39695. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39696. */
  39697. get useAutoRotationBehavior(): boolean;
  39698. set useAutoRotationBehavior(value: boolean);
  39699. /**
  39700. * Observable triggered when the mesh target has been changed on the camera.
  39701. */
  39702. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39703. /**
  39704. * Event raised when the camera is colliding with a mesh.
  39705. */
  39706. onCollide: (collidedMesh: AbstractMesh) => void;
  39707. /**
  39708. * Defines whether the camera should check collision with the objects oh the scene.
  39709. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39710. */
  39711. checkCollisions: boolean;
  39712. /**
  39713. * Defines the collision radius of the camera.
  39714. * This simulates a sphere around the camera.
  39715. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39716. */
  39717. collisionRadius: Vector3;
  39718. protected _collider: Collider;
  39719. protected _previousPosition: Vector3;
  39720. protected _collisionVelocity: Vector3;
  39721. protected _newPosition: Vector3;
  39722. protected _previousAlpha: number;
  39723. protected _previousBeta: number;
  39724. protected _previousRadius: number;
  39725. protected _collisionTriggered: boolean;
  39726. protected _targetBoundingCenter: Nullable<Vector3>;
  39727. private _computationVector;
  39728. /**
  39729. * Instantiates a new ArcRotateCamera in a given scene
  39730. * @param name Defines the name of the camera
  39731. * @param alpha Defines the camera rotation along the logitudinal axis
  39732. * @param beta Defines the camera rotation along the latitudinal axis
  39733. * @param radius Defines the camera distance from its target
  39734. * @param target Defines the camera target
  39735. * @param scene Defines the scene the camera belongs to
  39736. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39737. */
  39738. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39739. /** @hidden */
  39740. _initCache(): void;
  39741. /** @hidden */
  39742. _updateCache(ignoreParentClass?: boolean): void;
  39743. protected _getTargetPosition(): Vector3;
  39744. private _storedAlpha;
  39745. private _storedBeta;
  39746. private _storedRadius;
  39747. private _storedTarget;
  39748. private _storedTargetScreenOffset;
  39749. /**
  39750. * Stores the current state of the camera (alpha, beta, radius and target)
  39751. * @returns the camera itself
  39752. */
  39753. storeState(): Camera;
  39754. /**
  39755. * @hidden
  39756. * Restored camera state. You must call storeState() first
  39757. */
  39758. _restoreStateValues(): boolean;
  39759. /** @hidden */
  39760. _isSynchronizedViewMatrix(): boolean;
  39761. /**
  39762. * Attached controls to the current camera.
  39763. * @param element Defines the element the controls should be listened from
  39764. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39765. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39766. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39767. */
  39768. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39769. /**
  39770. * Detach the current controls from the camera.
  39771. * The camera will stop reacting to inputs.
  39772. * @param element Defines the element to stop listening the inputs from
  39773. */
  39774. detachControl(element: HTMLElement): void;
  39775. /** @hidden */
  39776. _checkInputs(): void;
  39777. protected _checkLimits(): void;
  39778. /**
  39779. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39780. */
  39781. rebuildAnglesAndRadius(): void;
  39782. /**
  39783. * Use a position to define the current camera related information like alpha, beta and radius
  39784. * @param position Defines the position to set the camera at
  39785. */
  39786. setPosition(position: Vector3): void;
  39787. /**
  39788. * Defines the target the camera should look at.
  39789. * This will automatically adapt alpha beta and radius to fit within the new target.
  39790. * @param target Defines the new target as a Vector or a mesh
  39791. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  39792. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39793. */
  39794. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39795. /** @hidden */
  39796. _getViewMatrix(): Matrix;
  39797. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39798. /**
  39799. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39800. * @param meshes Defines the mesh to zoom on
  39801. * @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)
  39802. */
  39803. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39804. /**
  39805. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39806. * The target will be changed but the radius
  39807. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39808. * @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)
  39809. */
  39810. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39811. min: Vector3;
  39812. max: Vector3;
  39813. distance: number;
  39814. }, doNotUpdateMaxZ?: boolean): void;
  39815. /**
  39816. * @override
  39817. * Override Camera.createRigCamera
  39818. */
  39819. createRigCamera(name: string, cameraIndex: number): Camera;
  39820. /**
  39821. * @hidden
  39822. * @override
  39823. * Override Camera._updateRigCameras
  39824. */
  39825. _updateRigCameras(): void;
  39826. /**
  39827. * Destroy the camera and release the current resources hold by it.
  39828. */
  39829. dispose(): void;
  39830. /**
  39831. * Gets the current object class name.
  39832. * @return the class name
  39833. */
  39834. getClassName(): string;
  39835. }
  39836. }
  39837. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  39838. import { Behavior } from "babylonjs/Behaviors/behavior";
  39839. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39840. /**
  39841. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39842. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39843. */
  39844. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39845. /**
  39846. * Gets the name of the behavior.
  39847. */
  39848. get name(): string;
  39849. private _zoomStopsAnimation;
  39850. private _idleRotationSpeed;
  39851. private _idleRotationWaitTime;
  39852. private _idleRotationSpinupTime;
  39853. /**
  39854. * Sets the flag that indicates if user zooming should stop animation.
  39855. */
  39856. set zoomStopsAnimation(flag: boolean);
  39857. /**
  39858. * Gets the flag that indicates if user zooming should stop animation.
  39859. */
  39860. get zoomStopsAnimation(): boolean;
  39861. /**
  39862. * Sets the default speed at which the camera rotates around the model.
  39863. */
  39864. set idleRotationSpeed(speed: number);
  39865. /**
  39866. * Gets the default speed at which the camera rotates around the model.
  39867. */
  39868. get idleRotationSpeed(): number;
  39869. /**
  39870. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39871. */
  39872. set idleRotationWaitTime(time: number);
  39873. /**
  39874. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39875. */
  39876. get idleRotationWaitTime(): number;
  39877. /**
  39878. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39879. */
  39880. set idleRotationSpinupTime(time: number);
  39881. /**
  39882. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39883. */
  39884. get idleRotationSpinupTime(): number;
  39885. /**
  39886. * Gets a value indicating if the camera is currently rotating because of this behavior
  39887. */
  39888. get rotationInProgress(): boolean;
  39889. private _onPrePointerObservableObserver;
  39890. private _onAfterCheckInputsObserver;
  39891. private _attachedCamera;
  39892. private _isPointerDown;
  39893. private _lastFrameTime;
  39894. private _lastInteractionTime;
  39895. private _cameraRotationSpeed;
  39896. /**
  39897. * Initializes the behavior.
  39898. */
  39899. init(): void;
  39900. /**
  39901. * Attaches the behavior to its arc rotate camera.
  39902. * @param camera Defines the camera to attach the behavior to
  39903. */
  39904. attach(camera: ArcRotateCamera): void;
  39905. /**
  39906. * Detaches the behavior from its current arc rotate camera.
  39907. */
  39908. detach(): void;
  39909. /**
  39910. * Returns true if user is scrolling.
  39911. * @return true if user is scrolling.
  39912. */
  39913. private _userIsZooming;
  39914. private _lastFrameRadius;
  39915. private _shouldAnimationStopForInteraction;
  39916. /**
  39917. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39918. */
  39919. private _applyUserInteraction;
  39920. private _userIsMoving;
  39921. }
  39922. }
  39923. declare module "babylonjs/Behaviors/Cameras/index" {
  39924. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39925. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39926. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  39927. }
  39928. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  39929. import { Mesh } from "babylonjs/Meshes/mesh";
  39930. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39931. import { Behavior } from "babylonjs/Behaviors/behavior";
  39932. /**
  39933. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39934. */
  39935. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39936. private ui;
  39937. /**
  39938. * The name of the behavior
  39939. */
  39940. name: string;
  39941. /**
  39942. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39943. */
  39944. distanceAwayFromFace: number;
  39945. /**
  39946. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39947. */
  39948. distanceAwayFromBottomOfFace: number;
  39949. private _faceVectors;
  39950. private _target;
  39951. private _scene;
  39952. private _onRenderObserver;
  39953. private _tmpMatrix;
  39954. private _tmpVector;
  39955. /**
  39956. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39957. * @param ui The transform node that should be attched to the mesh
  39958. */
  39959. constructor(ui: TransformNode);
  39960. /**
  39961. * Initializes the behavior
  39962. */
  39963. init(): void;
  39964. private _closestFace;
  39965. private _zeroVector;
  39966. private _lookAtTmpMatrix;
  39967. private _lookAtToRef;
  39968. /**
  39969. * Attaches the AttachToBoxBehavior to the passed in mesh
  39970. * @param target The mesh that the specified node will be attached to
  39971. */
  39972. attach(target: Mesh): void;
  39973. /**
  39974. * Detaches the behavior from the mesh
  39975. */
  39976. detach(): void;
  39977. }
  39978. }
  39979. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  39980. import { Behavior } from "babylonjs/Behaviors/behavior";
  39981. import { Mesh } from "babylonjs/Meshes/mesh";
  39982. /**
  39983. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39984. */
  39985. export class FadeInOutBehavior implements Behavior<Mesh> {
  39986. /**
  39987. * Time in milliseconds to delay before fading in (Default: 0)
  39988. */
  39989. delay: number;
  39990. /**
  39991. * Time in milliseconds for the mesh to fade in (Default: 300)
  39992. */
  39993. fadeInTime: number;
  39994. private _millisecondsPerFrame;
  39995. private _hovered;
  39996. private _hoverValue;
  39997. private _ownerNode;
  39998. /**
  39999. * Instatiates the FadeInOutBehavior
  40000. */
  40001. constructor();
  40002. /**
  40003. * The name of the behavior
  40004. */
  40005. get name(): string;
  40006. /**
  40007. * Initializes the behavior
  40008. */
  40009. init(): void;
  40010. /**
  40011. * Attaches the fade behavior on the passed in mesh
  40012. * @param ownerNode The mesh that will be faded in/out once attached
  40013. */
  40014. attach(ownerNode: Mesh): void;
  40015. /**
  40016. * Detaches the behavior from the mesh
  40017. */
  40018. detach(): void;
  40019. /**
  40020. * Triggers the mesh to begin fading in or out
  40021. * @param value if the object should fade in or out (true to fade in)
  40022. */
  40023. fadeIn(value: boolean): void;
  40024. private _update;
  40025. private _setAllVisibility;
  40026. }
  40027. }
  40028. declare module "babylonjs/Misc/pivotTools" {
  40029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40030. /**
  40031. * Class containing a set of static utilities functions for managing Pivots
  40032. * @hidden
  40033. */
  40034. export class PivotTools {
  40035. private static _PivotCached;
  40036. private static _OldPivotPoint;
  40037. private static _PivotTranslation;
  40038. private static _PivotTmpVector;
  40039. /** @hidden */
  40040. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40041. /** @hidden */
  40042. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40043. }
  40044. }
  40045. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40046. import { Scene } from "babylonjs/scene";
  40047. import { Vector4 } from "babylonjs/Maths/math.vector";
  40048. import { Mesh } from "babylonjs/Meshes/mesh";
  40049. import { Nullable } from "babylonjs/types";
  40050. import { Plane } from "babylonjs/Maths/math.plane";
  40051. /**
  40052. * Class containing static functions to help procedurally build meshes
  40053. */
  40054. export class PlaneBuilder {
  40055. /**
  40056. * Creates a plane mesh
  40057. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40058. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40059. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40060. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40061. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40063. * @param name defines the name of the mesh
  40064. * @param options defines the options used to create the mesh
  40065. * @param scene defines the hosting scene
  40066. * @returns the plane mesh
  40067. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40068. */
  40069. static CreatePlane(name: string, options: {
  40070. size?: number;
  40071. width?: number;
  40072. height?: number;
  40073. sideOrientation?: number;
  40074. frontUVs?: Vector4;
  40075. backUVs?: Vector4;
  40076. updatable?: boolean;
  40077. sourcePlane?: Plane;
  40078. }, scene?: Nullable<Scene>): Mesh;
  40079. }
  40080. }
  40081. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40082. import { Behavior } from "babylonjs/Behaviors/behavior";
  40083. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40084. import { Observable } from "babylonjs/Misc/observable";
  40085. import { Vector3 } from "babylonjs/Maths/math.vector";
  40086. import { Ray } from "babylonjs/Culling/ray";
  40087. import "babylonjs/Meshes/Builders/planeBuilder";
  40088. /**
  40089. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40090. */
  40091. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40092. private static _AnyMouseID;
  40093. /**
  40094. * Abstract mesh the behavior is set on
  40095. */
  40096. attachedNode: AbstractMesh;
  40097. private _dragPlane;
  40098. private _scene;
  40099. private _pointerObserver;
  40100. private _beforeRenderObserver;
  40101. private static _planeScene;
  40102. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40103. /**
  40104. * 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)
  40105. */
  40106. maxDragAngle: number;
  40107. /**
  40108. * @hidden
  40109. */
  40110. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40111. /**
  40112. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40113. */
  40114. currentDraggingPointerID: number;
  40115. /**
  40116. * The last position where the pointer hit the drag plane in world space
  40117. */
  40118. lastDragPosition: Vector3;
  40119. /**
  40120. * If the behavior is currently in a dragging state
  40121. */
  40122. dragging: boolean;
  40123. /**
  40124. * 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)
  40125. */
  40126. dragDeltaRatio: number;
  40127. /**
  40128. * If the drag plane orientation should be updated during the dragging (Default: true)
  40129. */
  40130. updateDragPlane: boolean;
  40131. private _debugMode;
  40132. private _moving;
  40133. /**
  40134. * Fires each time the attached mesh is dragged with the pointer
  40135. * * delta between last drag position and current drag position in world space
  40136. * * dragDistance along the drag axis
  40137. * * dragPlaneNormal normal of the current drag plane used during the drag
  40138. * * dragPlanePoint in world space where the drag intersects the drag plane
  40139. */
  40140. onDragObservable: Observable<{
  40141. delta: Vector3;
  40142. dragPlanePoint: Vector3;
  40143. dragPlaneNormal: Vector3;
  40144. dragDistance: number;
  40145. pointerId: number;
  40146. }>;
  40147. /**
  40148. * Fires each time a drag begins (eg. mouse down on mesh)
  40149. */
  40150. onDragStartObservable: Observable<{
  40151. dragPlanePoint: Vector3;
  40152. pointerId: number;
  40153. }>;
  40154. /**
  40155. * Fires each time a drag ends (eg. mouse release after drag)
  40156. */
  40157. onDragEndObservable: Observable<{
  40158. dragPlanePoint: Vector3;
  40159. pointerId: number;
  40160. }>;
  40161. /**
  40162. * If the attached mesh should be moved when dragged
  40163. */
  40164. moveAttached: boolean;
  40165. /**
  40166. * If the drag behavior will react to drag events (Default: true)
  40167. */
  40168. enabled: boolean;
  40169. /**
  40170. * If pointer events should start and release the drag (Default: true)
  40171. */
  40172. startAndReleaseDragOnPointerEvents: boolean;
  40173. /**
  40174. * If camera controls should be detached during the drag
  40175. */
  40176. detachCameraControls: boolean;
  40177. /**
  40178. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40179. */
  40180. useObjectOrienationForDragging: boolean;
  40181. private _options;
  40182. /**
  40183. * Gets the options used by the behavior
  40184. */
  40185. get options(): {
  40186. dragAxis?: Vector3;
  40187. dragPlaneNormal?: Vector3;
  40188. };
  40189. /**
  40190. * Sets the options used by the behavior
  40191. */
  40192. set options(options: {
  40193. dragAxis?: Vector3;
  40194. dragPlaneNormal?: Vector3;
  40195. });
  40196. /**
  40197. * Creates a pointer drag behavior that can be attached to a mesh
  40198. * @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)
  40199. */
  40200. constructor(options?: {
  40201. dragAxis?: Vector3;
  40202. dragPlaneNormal?: Vector3;
  40203. });
  40204. /**
  40205. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40206. */
  40207. validateDrag: (targetPosition: Vector3) => boolean;
  40208. /**
  40209. * The name of the behavior
  40210. */
  40211. get name(): string;
  40212. /**
  40213. * Initializes the behavior
  40214. */
  40215. init(): void;
  40216. private _tmpVector;
  40217. private _alternatePickedPoint;
  40218. private _worldDragAxis;
  40219. private _targetPosition;
  40220. private _attachedElement;
  40221. /**
  40222. * Attaches the drag behavior the passed in mesh
  40223. * @param ownerNode The mesh that will be dragged around once attached
  40224. * @param predicate Predicate to use for pick filtering
  40225. */
  40226. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40227. /**
  40228. * Force relase the drag action by code.
  40229. */
  40230. releaseDrag(): void;
  40231. private _startDragRay;
  40232. private _lastPointerRay;
  40233. /**
  40234. * Simulates the start of a pointer drag event on the behavior
  40235. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40236. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40237. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40238. */
  40239. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40240. private _startDrag;
  40241. private _dragDelta;
  40242. private _moveDrag;
  40243. private _pickWithRayOnDragPlane;
  40244. private _pointA;
  40245. private _pointB;
  40246. private _pointC;
  40247. private _lineA;
  40248. private _lineB;
  40249. private _localAxis;
  40250. private _lookAt;
  40251. private _updateDragPlanePosition;
  40252. /**
  40253. * Detaches the behavior from the mesh
  40254. */
  40255. detach(): void;
  40256. }
  40257. }
  40258. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40259. import { Mesh } from "babylonjs/Meshes/mesh";
  40260. import { Behavior } from "babylonjs/Behaviors/behavior";
  40261. /**
  40262. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40263. */
  40264. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40265. private _dragBehaviorA;
  40266. private _dragBehaviorB;
  40267. private _startDistance;
  40268. private _initialScale;
  40269. private _targetScale;
  40270. private _ownerNode;
  40271. private _sceneRenderObserver;
  40272. /**
  40273. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40274. */
  40275. constructor();
  40276. /**
  40277. * The name of the behavior
  40278. */
  40279. get name(): string;
  40280. /**
  40281. * Initializes the behavior
  40282. */
  40283. init(): void;
  40284. private _getCurrentDistance;
  40285. /**
  40286. * Attaches the scale behavior the passed in mesh
  40287. * @param ownerNode The mesh that will be scaled around once attached
  40288. */
  40289. attach(ownerNode: Mesh): void;
  40290. /**
  40291. * Detaches the behavior from the mesh
  40292. */
  40293. detach(): void;
  40294. }
  40295. }
  40296. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40297. import { Behavior } from "babylonjs/Behaviors/behavior";
  40298. import { Mesh } from "babylonjs/Meshes/mesh";
  40299. import { Observable } from "babylonjs/Misc/observable";
  40300. /**
  40301. * 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
  40302. */
  40303. export class SixDofDragBehavior implements Behavior<Mesh> {
  40304. private static _virtualScene;
  40305. private _ownerNode;
  40306. private _sceneRenderObserver;
  40307. private _scene;
  40308. private _targetPosition;
  40309. private _virtualOriginMesh;
  40310. private _virtualDragMesh;
  40311. private _pointerObserver;
  40312. private _moving;
  40313. private _startingOrientation;
  40314. /**
  40315. * 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)
  40316. */
  40317. private zDragFactor;
  40318. /**
  40319. * If the object should rotate to face the drag origin
  40320. */
  40321. rotateDraggedObject: boolean;
  40322. /**
  40323. * If the behavior is currently in a dragging state
  40324. */
  40325. dragging: boolean;
  40326. /**
  40327. * 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)
  40328. */
  40329. dragDeltaRatio: number;
  40330. /**
  40331. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40332. */
  40333. currentDraggingPointerID: number;
  40334. /**
  40335. * If camera controls should be detached during the drag
  40336. */
  40337. detachCameraControls: boolean;
  40338. /**
  40339. * Fires each time a drag starts
  40340. */
  40341. onDragStartObservable: Observable<{}>;
  40342. /**
  40343. * Fires each time a drag ends (eg. mouse release after drag)
  40344. */
  40345. onDragEndObservable: Observable<{}>;
  40346. /**
  40347. * 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
  40348. */
  40349. constructor();
  40350. /**
  40351. * The name of the behavior
  40352. */
  40353. get name(): string;
  40354. /**
  40355. * Initializes the behavior
  40356. */
  40357. init(): void;
  40358. /**
  40359. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40360. */
  40361. private get _pointerCamera();
  40362. /**
  40363. * Attaches the scale behavior the passed in mesh
  40364. * @param ownerNode The mesh that will be scaled around once attached
  40365. */
  40366. attach(ownerNode: Mesh): void;
  40367. /**
  40368. * Detaches the behavior from the mesh
  40369. */
  40370. detach(): void;
  40371. }
  40372. }
  40373. declare module "babylonjs/Behaviors/Meshes/index" {
  40374. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40375. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40376. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40377. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40378. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40379. }
  40380. declare module "babylonjs/Behaviors/index" {
  40381. export * from "babylonjs/Behaviors/behavior";
  40382. export * from "babylonjs/Behaviors/Cameras/index";
  40383. export * from "babylonjs/Behaviors/Meshes/index";
  40384. }
  40385. declare module "babylonjs/Bones/boneIKController" {
  40386. import { Bone } from "babylonjs/Bones/bone";
  40387. import { Vector3 } from "babylonjs/Maths/math.vector";
  40388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40389. import { Nullable } from "babylonjs/types";
  40390. /**
  40391. * Class used to apply inverse kinematics to bones
  40392. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40393. */
  40394. export class BoneIKController {
  40395. private static _tmpVecs;
  40396. private static _tmpQuat;
  40397. private static _tmpMats;
  40398. /**
  40399. * Gets or sets the target mesh
  40400. */
  40401. targetMesh: AbstractMesh;
  40402. /** Gets or sets the mesh used as pole */
  40403. poleTargetMesh: AbstractMesh;
  40404. /**
  40405. * Gets or sets the bone used as pole
  40406. */
  40407. poleTargetBone: Nullable<Bone>;
  40408. /**
  40409. * Gets or sets the target position
  40410. */
  40411. targetPosition: Vector3;
  40412. /**
  40413. * Gets or sets the pole target position
  40414. */
  40415. poleTargetPosition: Vector3;
  40416. /**
  40417. * Gets or sets the pole target local offset
  40418. */
  40419. poleTargetLocalOffset: Vector3;
  40420. /**
  40421. * Gets or sets the pole angle
  40422. */
  40423. poleAngle: number;
  40424. /**
  40425. * Gets or sets the mesh associated with the controller
  40426. */
  40427. mesh: AbstractMesh;
  40428. /**
  40429. * 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)
  40430. */
  40431. slerpAmount: number;
  40432. private _bone1Quat;
  40433. private _bone1Mat;
  40434. private _bone2Ang;
  40435. private _bone1;
  40436. private _bone2;
  40437. private _bone1Length;
  40438. private _bone2Length;
  40439. private _maxAngle;
  40440. private _maxReach;
  40441. private _rightHandedSystem;
  40442. private _bendAxis;
  40443. private _slerping;
  40444. private _adjustRoll;
  40445. /**
  40446. * Gets or sets maximum allowed angle
  40447. */
  40448. get maxAngle(): number;
  40449. set maxAngle(value: number);
  40450. /**
  40451. * Creates a new BoneIKController
  40452. * @param mesh defines the mesh to control
  40453. * @param bone defines the bone to control
  40454. * @param options defines options to set up the controller
  40455. */
  40456. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40457. targetMesh?: AbstractMesh;
  40458. poleTargetMesh?: AbstractMesh;
  40459. poleTargetBone?: Bone;
  40460. poleTargetLocalOffset?: Vector3;
  40461. poleAngle?: number;
  40462. bendAxis?: Vector3;
  40463. maxAngle?: number;
  40464. slerpAmount?: number;
  40465. });
  40466. private _setMaxAngle;
  40467. /**
  40468. * Force the controller to update the bones
  40469. */
  40470. update(): void;
  40471. }
  40472. }
  40473. declare module "babylonjs/Bones/boneLookController" {
  40474. import { Vector3 } from "babylonjs/Maths/math.vector";
  40475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40476. import { Bone } from "babylonjs/Bones/bone";
  40477. import { Space } from "babylonjs/Maths/math.axis";
  40478. /**
  40479. * Class used to make a bone look toward a point in space
  40480. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40481. */
  40482. export class BoneLookController {
  40483. private static _tmpVecs;
  40484. private static _tmpQuat;
  40485. private static _tmpMats;
  40486. /**
  40487. * The target Vector3 that the bone will look at
  40488. */
  40489. target: Vector3;
  40490. /**
  40491. * The mesh that the bone is attached to
  40492. */
  40493. mesh: AbstractMesh;
  40494. /**
  40495. * The bone that will be looking to the target
  40496. */
  40497. bone: Bone;
  40498. /**
  40499. * The up axis of the coordinate system that is used when the bone is rotated
  40500. */
  40501. upAxis: Vector3;
  40502. /**
  40503. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40504. */
  40505. upAxisSpace: Space;
  40506. /**
  40507. * Used to make an adjustment to the yaw of the bone
  40508. */
  40509. adjustYaw: number;
  40510. /**
  40511. * Used to make an adjustment to the pitch of the bone
  40512. */
  40513. adjustPitch: number;
  40514. /**
  40515. * Used to make an adjustment to the roll of the bone
  40516. */
  40517. adjustRoll: number;
  40518. /**
  40519. * 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)
  40520. */
  40521. slerpAmount: number;
  40522. private _minYaw;
  40523. private _maxYaw;
  40524. private _minPitch;
  40525. private _maxPitch;
  40526. private _minYawSin;
  40527. private _minYawCos;
  40528. private _maxYawSin;
  40529. private _maxYawCos;
  40530. private _midYawConstraint;
  40531. private _minPitchTan;
  40532. private _maxPitchTan;
  40533. private _boneQuat;
  40534. private _slerping;
  40535. private _transformYawPitch;
  40536. private _transformYawPitchInv;
  40537. private _firstFrameSkipped;
  40538. private _yawRange;
  40539. private _fowardAxis;
  40540. /**
  40541. * Gets or sets the minimum yaw angle that the bone can look to
  40542. */
  40543. get minYaw(): number;
  40544. set minYaw(value: number);
  40545. /**
  40546. * Gets or sets the maximum yaw angle that the bone can look to
  40547. */
  40548. get maxYaw(): number;
  40549. set maxYaw(value: number);
  40550. /**
  40551. * Gets or sets the minimum pitch angle that the bone can look to
  40552. */
  40553. get minPitch(): number;
  40554. set minPitch(value: number);
  40555. /**
  40556. * Gets or sets the maximum pitch angle that the bone can look to
  40557. */
  40558. get maxPitch(): number;
  40559. set maxPitch(value: number);
  40560. /**
  40561. * Create a BoneLookController
  40562. * @param mesh the mesh that the bone belongs to
  40563. * @param bone the bone that will be looking to the target
  40564. * @param target the target Vector3 to look at
  40565. * @param options optional settings:
  40566. * * maxYaw: the maximum angle the bone will yaw to
  40567. * * minYaw: the minimum angle the bone will yaw to
  40568. * * maxPitch: the maximum angle the bone will pitch to
  40569. * * minPitch: the minimum angle the bone will yaw to
  40570. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40571. * * upAxis: the up axis of the coordinate system
  40572. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40573. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40574. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40575. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40576. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40577. * * adjustRoll: used to make an adjustment to the roll of the bone
  40578. **/
  40579. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40580. maxYaw?: number;
  40581. minYaw?: number;
  40582. maxPitch?: number;
  40583. minPitch?: number;
  40584. slerpAmount?: number;
  40585. upAxis?: Vector3;
  40586. upAxisSpace?: Space;
  40587. yawAxis?: Vector3;
  40588. pitchAxis?: Vector3;
  40589. adjustYaw?: number;
  40590. adjustPitch?: number;
  40591. adjustRoll?: number;
  40592. });
  40593. /**
  40594. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40595. */
  40596. update(): void;
  40597. private _getAngleDiff;
  40598. private _getAngleBetween;
  40599. private _isAngleBetween;
  40600. }
  40601. }
  40602. declare module "babylonjs/Bones/index" {
  40603. export * from "babylonjs/Bones/bone";
  40604. export * from "babylonjs/Bones/boneIKController";
  40605. export * from "babylonjs/Bones/boneLookController";
  40606. export * from "babylonjs/Bones/skeleton";
  40607. }
  40608. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40609. import { Nullable } from "babylonjs/types";
  40610. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40611. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40612. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40613. /**
  40614. * Manage the gamepad inputs to control an arc rotate camera.
  40615. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40616. */
  40617. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40618. /**
  40619. * Defines the camera the input is attached to.
  40620. */
  40621. camera: ArcRotateCamera;
  40622. /**
  40623. * Defines the gamepad the input is gathering event from.
  40624. */
  40625. gamepad: Nullable<Gamepad>;
  40626. /**
  40627. * Defines the gamepad rotation sensiblity.
  40628. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40629. */
  40630. gamepadRotationSensibility: number;
  40631. /**
  40632. * Defines the gamepad move sensiblity.
  40633. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40634. */
  40635. gamepadMoveSensibility: number;
  40636. private _yAxisScale;
  40637. /**
  40638. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40639. */
  40640. get invertYAxis(): boolean;
  40641. set invertYAxis(value: boolean);
  40642. private _onGamepadConnectedObserver;
  40643. private _onGamepadDisconnectedObserver;
  40644. /**
  40645. * Attach the input controls to a specific dom element to get the input from.
  40646. * @param element Defines the element the controls should be listened from
  40647. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40648. */
  40649. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40650. /**
  40651. * Detach the current controls from the specified dom element.
  40652. * @param element Defines the element to stop listening the inputs from
  40653. */
  40654. detachControl(element: Nullable<HTMLElement>): void;
  40655. /**
  40656. * Update the current camera state depending on the inputs that have been used this frame.
  40657. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40658. */
  40659. checkInputs(): void;
  40660. /**
  40661. * Gets the class name of the current intput.
  40662. * @returns the class name
  40663. */
  40664. getClassName(): string;
  40665. /**
  40666. * Get the friendly name associated with the input class.
  40667. * @returns the input friendly name
  40668. */
  40669. getSimpleName(): string;
  40670. }
  40671. }
  40672. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40673. import { Nullable } from "babylonjs/types";
  40674. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40675. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40676. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40677. interface ArcRotateCameraInputsManager {
  40678. /**
  40679. * Add orientation input support to the input manager.
  40680. * @returns the current input manager
  40681. */
  40682. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40683. }
  40684. }
  40685. /**
  40686. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40687. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40688. */
  40689. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40690. /**
  40691. * Defines the camera the input is attached to.
  40692. */
  40693. camera: ArcRotateCamera;
  40694. /**
  40695. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40696. */
  40697. alphaCorrection: number;
  40698. /**
  40699. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40700. */
  40701. gammaCorrection: number;
  40702. private _alpha;
  40703. private _gamma;
  40704. private _dirty;
  40705. private _deviceOrientationHandler;
  40706. /**
  40707. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40708. */
  40709. constructor();
  40710. /**
  40711. * Attach the input controls to a specific dom element to get the input from.
  40712. * @param element Defines the element the controls should be listened from
  40713. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40714. */
  40715. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40716. /** @hidden */
  40717. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40718. /**
  40719. * Update the current camera state depending on the inputs that have been used this frame.
  40720. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40721. */
  40722. checkInputs(): void;
  40723. /**
  40724. * Detach the current controls from the specified dom element.
  40725. * @param element Defines the element to stop listening the inputs from
  40726. */
  40727. detachControl(element: Nullable<HTMLElement>): void;
  40728. /**
  40729. * Gets the class name of the current intput.
  40730. * @returns the class name
  40731. */
  40732. getClassName(): string;
  40733. /**
  40734. * Get the friendly name associated with the input class.
  40735. * @returns the input friendly name
  40736. */
  40737. getSimpleName(): string;
  40738. }
  40739. }
  40740. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  40741. import { Nullable } from "babylonjs/types";
  40742. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40743. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40744. /**
  40745. * Listen to mouse events to control the camera.
  40746. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40747. */
  40748. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40749. /**
  40750. * Defines the camera the input is attached to.
  40751. */
  40752. camera: FlyCamera;
  40753. /**
  40754. * Defines if touch is enabled. (Default is true.)
  40755. */
  40756. touchEnabled: boolean;
  40757. /**
  40758. * Defines the buttons associated with the input to handle camera rotation.
  40759. */
  40760. buttons: number[];
  40761. /**
  40762. * Assign buttons for Yaw control.
  40763. */
  40764. buttonsYaw: number[];
  40765. /**
  40766. * Assign buttons for Pitch control.
  40767. */
  40768. buttonsPitch: number[];
  40769. /**
  40770. * Assign buttons for Roll control.
  40771. */
  40772. buttonsRoll: number[];
  40773. /**
  40774. * Detect if any button is being pressed while mouse is moved.
  40775. * -1 = Mouse locked.
  40776. * 0 = Left button.
  40777. * 1 = Middle Button.
  40778. * 2 = Right Button.
  40779. */
  40780. activeButton: number;
  40781. /**
  40782. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40783. * Higher values reduce its sensitivity.
  40784. */
  40785. angularSensibility: number;
  40786. private _mousemoveCallback;
  40787. private _observer;
  40788. private _rollObserver;
  40789. private previousPosition;
  40790. private noPreventDefault;
  40791. private element;
  40792. /**
  40793. * Listen to mouse events to control the camera.
  40794. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40795. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40796. */
  40797. constructor(touchEnabled?: boolean);
  40798. /**
  40799. * Attach the mouse control to the HTML DOM element.
  40800. * @param element Defines the element that listens to the input events.
  40801. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40802. */
  40803. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40804. /**
  40805. * Detach the current controls from the specified dom element.
  40806. * @param element Defines the element to stop listening the inputs from
  40807. */
  40808. detachControl(element: Nullable<HTMLElement>): void;
  40809. /**
  40810. * Gets the class name of the current input.
  40811. * @returns the class name.
  40812. */
  40813. getClassName(): string;
  40814. /**
  40815. * Get the friendly name associated with the input class.
  40816. * @returns the input's friendly name.
  40817. */
  40818. getSimpleName(): string;
  40819. private _pointerInput;
  40820. private _onMouseMove;
  40821. /**
  40822. * Rotate camera by mouse offset.
  40823. */
  40824. private rotateCamera;
  40825. }
  40826. }
  40827. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  40828. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40829. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40830. /**
  40831. * Default Inputs manager for the FlyCamera.
  40832. * It groups all the default supported inputs for ease of use.
  40833. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40834. */
  40835. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40836. /**
  40837. * Instantiates a new FlyCameraInputsManager.
  40838. * @param camera Defines the camera the inputs belong to.
  40839. */
  40840. constructor(camera: FlyCamera);
  40841. /**
  40842. * Add keyboard input support to the input manager.
  40843. * @returns the new FlyCameraKeyboardMoveInput().
  40844. */
  40845. addKeyboard(): FlyCameraInputsManager;
  40846. /**
  40847. * Add mouse input support to the input manager.
  40848. * @param touchEnabled Enable touch screen support.
  40849. * @returns the new FlyCameraMouseInput().
  40850. */
  40851. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40852. }
  40853. }
  40854. declare module "babylonjs/Cameras/flyCamera" {
  40855. import { Scene } from "babylonjs/scene";
  40856. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  40857. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40858. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40859. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  40860. /**
  40861. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40862. * such as in a 3D Space Shooter or a Flight Simulator.
  40863. */
  40864. export class FlyCamera extends TargetCamera {
  40865. /**
  40866. * Define the collision ellipsoid of the camera.
  40867. * This is helpful for simulating a camera body, like a player's body.
  40868. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40869. */
  40870. ellipsoid: Vector3;
  40871. /**
  40872. * Define an offset for the position of the ellipsoid around the camera.
  40873. * This can be helpful if the camera is attached away from the player's body center,
  40874. * such as at its head.
  40875. */
  40876. ellipsoidOffset: Vector3;
  40877. /**
  40878. * Enable or disable collisions of the camera with the rest of the scene objects.
  40879. */
  40880. checkCollisions: boolean;
  40881. /**
  40882. * Enable or disable gravity on the camera.
  40883. */
  40884. applyGravity: boolean;
  40885. /**
  40886. * Define the current direction the camera is moving to.
  40887. */
  40888. cameraDirection: Vector3;
  40889. /**
  40890. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40891. * This overrides and empties cameraRotation.
  40892. */
  40893. rotationQuaternion: Quaternion;
  40894. /**
  40895. * Track Roll to maintain the wanted Rolling when looking around.
  40896. */
  40897. _trackRoll: number;
  40898. /**
  40899. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40900. */
  40901. rollCorrect: number;
  40902. /**
  40903. * Mimic a banked turn, Rolling the camera when Yawing.
  40904. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40905. */
  40906. bankedTurn: boolean;
  40907. /**
  40908. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40909. */
  40910. bankedTurnLimit: number;
  40911. /**
  40912. * Value of 0 disables the banked Roll.
  40913. * Value of 1 is equal to the Yaw angle in radians.
  40914. */
  40915. bankedTurnMultiplier: number;
  40916. /**
  40917. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40918. */
  40919. inputs: FlyCameraInputsManager;
  40920. /**
  40921. * Gets the input sensibility for mouse input.
  40922. * Higher values reduce sensitivity.
  40923. */
  40924. get angularSensibility(): number;
  40925. /**
  40926. * Sets the input sensibility for a mouse input.
  40927. * Higher values reduce sensitivity.
  40928. */
  40929. set angularSensibility(value: number);
  40930. /**
  40931. * Get the keys for camera movement forward.
  40932. */
  40933. get keysForward(): number[];
  40934. /**
  40935. * Set the keys for camera movement forward.
  40936. */
  40937. set keysForward(value: number[]);
  40938. /**
  40939. * Get the keys for camera movement backward.
  40940. */
  40941. get keysBackward(): number[];
  40942. set keysBackward(value: number[]);
  40943. /**
  40944. * Get the keys for camera movement up.
  40945. */
  40946. get keysUp(): number[];
  40947. /**
  40948. * Set the keys for camera movement up.
  40949. */
  40950. set keysUp(value: number[]);
  40951. /**
  40952. * Get the keys for camera movement down.
  40953. */
  40954. get keysDown(): number[];
  40955. /**
  40956. * Set the keys for camera movement down.
  40957. */
  40958. set keysDown(value: number[]);
  40959. /**
  40960. * Get the keys for camera movement left.
  40961. */
  40962. get keysLeft(): number[];
  40963. /**
  40964. * Set the keys for camera movement left.
  40965. */
  40966. set keysLeft(value: number[]);
  40967. /**
  40968. * Set the keys for camera movement right.
  40969. */
  40970. get keysRight(): number[];
  40971. /**
  40972. * Set the keys for camera movement right.
  40973. */
  40974. set keysRight(value: number[]);
  40975. /**
  40976. * Event raised when the camera collides with a mesh in the scene.
  40977. */
  40978. onCollide: (collidedMesh: AbstractMesh) => void;
  40979. private _collider;
  40980. private _needMoveForGravity;
  40981. private _oldPosition;
  40982. private _diffPosition;
  40983. private _newPosition;
  40984. /** @hidden */
  40985. _localDirection: Vector3;
  40986. /** @hidden */
  40987. _transformedDirection: Vector3;
  40988. /**
  40989. * Instantiates a FlyCamera.
  40990. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40991. * such as in a 3D Space Shooter or a Flight Simulator.
  40992. * @param name Define the name of the camera in the scene.
  40993. * @param position Define the starting position of the camera in the scene.
  40994. * @param scene Define the scene the camera belongs to.
  40995. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40996. */
  40997. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40998. /**
  40999. * Attach a control to the HTML DOM element.
  41000. * @param element Defines the element that listens to the input events.
  41001. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41002. */
  41003. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41004. /**
  41005. * Detach a control from the HTML DOM element.
  41006. * The camera will stop reacting to that input.
  41007. * @param element Defines the element that listens to the input events.
  41008. */
  41009. detachControl(element: HTMLElement): void;
  41010. private _collisionMask;
  41011. /**
  41012. * Get the mask that the camera ignores in collision events.
  41013. */
  41014. get collisionMask(): number;
  41015. /**
  41016. * Set the mask that the camera ignores in collision events.
  41017. */
  41018. set collisionMask(mask: number);
  41019. /** @hidden */
  41020. _collideWithWorld(displacement: Vector3): void;
  41021. /** @hidden */
  41022. private _onCollisionPositionChange;
  41023. /** @hidden */
  41024. _checkInputs(): void;
  41025. /** @hidden */
  41026. _decideIfNeedsToMove(): boolean;
  41027. /** @hidden */
  41028. _updatePosition(): void;
  41029. /**
  41030. * Restore the Roll to its target value at the rate specified.
  41031. * @param rate - Higher means slower restoring.
  41032. * @hidden
  41033. */
  41034. restoreRoll(rate: number): void;
  41035. /**
  41036. * Destroy the camera and release the current resources held by it.
  41037. */
  41038. dispose(): void;
  41039. /**
  41040. * Get the current object class name.
  41041. * @returns the class name.
  41042. */
  41043. getClassName(): string;
  41044. }
  41045. }
  41046. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41047. import { Nullable } from "babylonjs/types";
  41048. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41049. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41050. /**
  41051. * Listen to keyboard events to control the camera.
  41052. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41053. */
  41054. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41055. /**
  41056. * Defines the camera the input is attached to.
  41057. */
  41058. camera: FlyCamera;
  41059. /**
  41060. * The list of keyboard keys used to control the forward move of the camera.
  41061. */
  41062. keysForward: number[];
  41063. /**
  41064. * The list of keyboard keys used to control the backward move of the camera.
  41065. */
  41066. keysBackward: number[];
  41067. /**
  41068. * The list of keyboard keys used to control the forward move of the camera.
  41069. */
  41070. keysUp: number[];
  41071. /**
  41072. * The list of keyboard keys used to control the backward move of the camera.
  41073. */
  41074. keysDown: number[];
  41075. /**
  41076. * The list of keyboard keys used to control the right strafe move of the camera.
  41077. */
  41078. keysRight: number[];
  41079. /**
  41080. * The list of keyboard keys used to control the left strafe move of the camera.
  41081. */
  41082. keysLeft: number[];
  41083. private _keys;
  41084. private _onCanvasBlurObserver;
  41085. private _onKeyboardObserver;
  41086. private _engine;
  41087. private _scene;
  41088. /**
  41089. * Attach the input controls to a specific dom element to get the input from.
  41090. * @param element Defines the element the controls should be listened from
  41091. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41092. */
  41093. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41094. /**
  41095. * Detach the current controls from the specified dom element.
  41096. * @param element Defines the element to stop listening the inputs from
  41097. */
  41098. detachControl(element: Nullable<HTMLElement>): void;
  41099. /**
  41100. * Gets the class name of the current intput.
  41101. * @returns the class name
  41102. */
  41103. getClassName(): string;
  41104. /** @hidden */
  41105. _onLostFocus(e: FocusEvent): void;
  41106. /**
  41107. * Get the friendly name associated with the input class.
  41108. * @returns the input friendly name
  41109. */
  41110. getSimpleName(): string;
  41111. /**
  41112. * Update the current camera state depending on the inputs that have been used this frame.
  41113. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41114. */
  41115. checkInputs(): void;
  41116. }
  41117. }
  41118. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41119. import { Nullable } from "babylonjs/types";
  41120. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41121. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41122. /**
  41123. * Manage the mouse wheel inputs to control a follow camera.
  41124. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41125. */
  41126. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41127. /**
  41128. * Defines the camera the input is attached to.
  41129. */
  41130. camera: FollowCamera;
  41131. /**
  41132. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41133. */
  41134. axisControlRadius: boolean;
  41135. /**
  41136. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41137. */
  41138. axisControlHeight: boolean;
  41139. /**
  41140. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41141. */
  41142. axisControlRotation: boolean;
  41143. /**
  41144. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41145. * relation to mouseWheel events.
  41146. */
  41147. wheelPrecision: number;
  41148. /**
  41149. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41150. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41151. */
  41152. wheelDeltaPercentage: number;
  41153. private _wheel;
  41154. private _observer;
  41155. /**
  41156. * Attach the input controls to a specific dom element to get the input from.
  41157. * @param element Defines the element the controls should be listened from
  41158. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41159. */
  41160. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41161. /**
  41162. * Detach the current controls from the specified dom element.
  41163. * @param element Defines the element to stop listening the inputs from
  41164. */
  41165. detachControl(element: Nullable<HTMLElement>): void;
  41166. /**
  41167. * Gets the class name of the current intput.
  41168. * @returns the class name
  41169. */
  41170. getClassName(): string;
  41171. /**
  41172. * Get the friendly name associated with the input class.
  41173. * @returns the input friendly name
  41174. */
  41175. getSimpleName(): string;
  41176. }
  41177. }
  41178. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41179. import { Nullable } from "babylonjs/types";
  41180. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41181. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41182. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41183. /**
  41184. * Manage the pointers inputs to control an follow camera.
  41185. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41186. */
  41187. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41188. /**
  41189. * Defines the camera the input is attached to.
  41190. */
  41191. camera: FollowCamera;
  41192. /**
  41193. * Gets the class name of the current input.
  41194. * @returns the class name
  41195. */
  41196. getClassName(): string;
  41197. /**
  41198. * Defines the pointer angular sensibility along the X axis or how fast is
  41199. * the camera rotating.
  41200. * A negative number will reverse the axis direction.
  41201. */
  41202. angularSensibilityX: number;
  41203. /**
  41204. * Defines the pointer angular sensibility along the Y axis or how fast is
  41205. * the camera rotating.
  41206. * A negative number will reverse the axis direction.
  41207. */
  41208. angularSensibilityY: number;
  41209. /**
  41210. * Defines the pointer pinch precision or how fast is the camera zooming.
  41211. * A negative number will reverse the axis direction.
  41212. */
  41213. pinchPrecision: number;
  41214. /**
  41215. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41216. * from 0.
  41217. * It defines the percentage of current camera.radius to use as delta when
  41218. * pinch zoom is used.
  41219. */
  41220. pinchDeltaPercentage: number;
  41221. /**
  41222. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41223. */
  41224. axisXControlRadius: boolean;
  41225. /**
  41226. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41227. */
  41228. axisXControlHeight: boolean;
  41229. /**
  41230. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41231. */
  41232. axisXControlRotation: boolean;
  41233. /**
  41234. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41235. */
  41236. axisYControlRadius: boolean;
  41237. /**
  41238. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41239. */
  41240. axisYControlHeight: boolean;
  41241. /**
  41242. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41243. */
  41244. axisYControlRotation: boolean;
  41245. /**
  41246. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41247. */
  41248. axisPinchControlRadius: boolean;
  41249. /**
  41250. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41251. */
  41252. axisPinchControlHeight: boolean;
  41253. /**
  41254. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41255. */
  41256. axisPinchControlRotation: boolean;
  41257. /**
  41258. * Log error messages if basic misconfiguration has occurred.
  41259. */
  41260. warningEnable: boolean;
  41261. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41262. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41263. private _warningCounter;
  41264. private _warning;
  41265. }
  41266. }
  41267. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41268. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41269. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41270. /**
  41271. * Default Inputs manager for the FollowCamera.
  41272. * It groups all the default supported inputs for ease of use.
  41273. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41274. */
  41275. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41276. /**
  41277. * Instantiates a new FollowCameraInputsManager.
  41278. * @param camera Defines the camera the inputs belong to
  41279. */
  41280. constructor(camera: FollowCamera);
  41281. /**
  41282. * Add keyboard input support to the input manager.
  41283. * @returns the current input manager
  41284. */
  41285. addKeyboard(): FollowCameraInputsManager;
  41286. /**
  41287. * Add mouse wheel input support to the input manager.
  41288. * @returns the current input manager
  41289. */
  41290. addMouseWheel(): FollowCameraInputsManager;
  41291. /**
  41292. * Add pointers input support to the input manager.
  41293. * @returns the current input manager
  41294. */
  41295. addPointers(): FollowCameraInputsManager;
  41296. /**
  41297. * Add orientation input support to the input manager.
  41298. * @returns the current input manager
  41299. */
  41300. addVRDeviceOrientation(): FollowCameraInputsManager;
  41301. }
  41302. }
  41303. declare module "babylonjs/Cameras/followCamera" {
  41304. import { Nullable } from "babylonjs/types";
  41305. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41306. import { Scene } from "babylonjs/scene";
  41307. import { Vector3 } from "babylonjs/Maths/math.vector";
  41308. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41309. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41310. /**
  41311. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41312. * an arc rotate version arcFollowCamera are available.
  41313. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41314. */
  41315. export class FollowCamera extends TargetCamera {
  41316. /**
  41317. * Distance the follow camera should follow an object at
  41318. */
  41319. radius: number;
  41320. /**
  41321. * Minimum allowed distance of the camera to the axis of rotation
  41322. * (The camera can not get closer).
  41323. * This can help limiting how the Camera is able to move in the scene.
  41324. */
  41325. lowerRadiusLimit: Nullable<number>;
  41326. /**
  41327. * Maximum allowed distance of the camera to the axis of rotation
  41328. * (The camera can not get further).
  41329. * This can help limiting how the Camera is able to move in the scene.
  41330. */
  41331. upperRadiusLimit: Nullable<number>;
  41332. /**
  41333. * Define a rotation offset between the camera and the object it follows
  41334. */
  41335. rotationOffset: number;
  41336. /**
  41337. * Minimum allowed angle to camera position relative to target object.
  41338. * This can help limiting how the Camera is able to move in the scene.
  41339. */
  41340. lowerRotationOffsetLimit: Nullable<number>;
  41341. /**
  41342. * Maximum allowed angle to camera position relative to target object.
  41343. * This can help limiting how the Camera is able to move in the scene.
  41344. */
  41345. upperRotationOffsetLimit: Nullable<number>;
  41346. /**
  41347. * Define a height offset between the camera and the object it follows.
  41348. * It can help following an object from the top (like a car chaing a plane)
  41349. */
  41350. heightOffset: number;
  41351. /**
  41352. * Minimum allowed height of camera position relative to target object.
  41353. * This can help limiting how the Camera is able to move in the scene.
  41354. */
  41355. lowerHeightOffsetLimit: Nullable<number>;
  41356. /**
  41357. * Maximum allowed height of camera position relative to target object.
  41358. * This can help limiting how the Camera is able to move in the scene.
  41359. */
  41360. upperHeightOffsetLimit: Nullable<number>;
  41361. /**
  41362. * Define how fast the camera can accelerate to follow it s target.
  41363. */
  41364. cameraAcceleration: number;
  41365. /**
  41366. * Define the speed limit of the camera following an object.
  41367. */
  41368. maxCameraSpeed: number;
  41369. /**
  41370. * Define the target of the camera.
  41371. */
  41372. lockedTarget: Nullable<AbstractMesh>;
  41373. /**
  41374. * Defines the input associated with the camera.
  41375. */
  41376. inputs: FollowCameraInputsManager;
  41377. /**
  41378. * Instantiates the follow camera.
  41379. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41380. * @param name Define the name of the camera in the scene
  41381. * @param position Define the position of the camera
  41382. * @param scene Define the scene the camera belong to
  41383. * @param lockedTarget Define the target of the camera
  41384. */
  41385. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41386. private _follow;
  41387. /**
  41388. * Attached controls to the current camera.
  41389. * @param element Defines the element the controls should be listened from
  41390. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41391. */
  41392. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41393. /**
  41394. * Detach the current controls from the camera.
  41395. * The camera will stop reacting to inputs.
  41396. * @param element Defines the element to stop listening the inputs from
  41397. */
  41398. detachControl(element: HTMLElement): void;
  41399. /** @hidden */
  41400. _checkInputs(): void;
  41401. private _checkLimits;
  41402. /**
  41403. * Gets the camera class name.
  41404. * @returns the class name
  41405. */
  41406. getClassName(): string;
  41407. }
  41408. /**
  41409. * Arc Rotate version of the follow camera.
  41410. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41411. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41412. */
  41413. export class ArcFollowCamera extends TargetCamera {
  41414. /** The longitudinal angle of the camera */
  41415. alpha: number;
  41416. /** The latitudinal angle of the camera */
  41417. beta: number;
  41418. /** The radius of the camera from its target */
  41419. radius: number;
  41420. /** Define the camera target (the messh it should follow) */
  41421. target: Nullable<AbstractMesh>;
  41422. private _cartesianCoordinates;
  41423. /**
  41424. * Instantiates a new ArcFollowCamera
  41425. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41426. * @param name Define the name of the camera
  41427. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41428. * @param beta Define the rotation angle of the camera around the elevation axis
  41429. * @param radius Define the radius of the camera from its target point
  41430. * @param target Define the target of the camera
  41431. * @param scene Define the scene the camera belongs to
  41432. */
  41433. constructor(name: string,
  41434. /** The longitudinal angle of the camera */
  41435. alpha: number,
  41436. /** The latitudinal angle of the camera */
  41437. beta: number,
  41438. /** The radius of the camera from its target */
  41439. radius: number,
  41440. /** Define the camera target (the messh it should follow) */
  41441. target: Nullable<AbstractMesh>, scene: Scene);
  41442. private _follow;
  41443. /** @hidden */
  41444. _checkInputs(): void;
  41445. /**
  41446. * Returns the class name of the object.
  41447. * It is mostly used internally for serialization purposes.
  41448. */
  41449. getClassName(): string;
  41450. }
  41451. }
  41452. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41453. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41454. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41455. import { Nullable } from "babylonjs/types";
  41456. /**
  41457. * Manage the keyboard inputs to control the movement of a follow camera.
  41458. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41459. */
  41460. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41461. /**
  41462. * Defines the camera the input is attached to.
  41463. */
  41464. camera: FollowCamera;
  41465. /**
  41466. * Defines the list of key codes associated with the up action (increase heightOffset)
  41467. */
  41468. keysHeightOffsetIncr: number[];
  41469. /**
  41470. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41471. */
  41472. keysHeightOffsetDecr: number[];
  41473. /**
  41474. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41475. */
  41476. keysHeightOffsetModifierAlt: boolean;
  41477. /**
  41478. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41479. */
  41480. keysHeightOffsetModifierCtrl: boolean;
  41481. /**
  41482. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41483. */
  41484. keysHeightOffsetModifierShift: boolean;
  41485. /**
  41486. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41487. */
  41488. keysRotationOffsetIncr: number[];
  41489. /**
  41490. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41491. */
  41492. keysRotationOffsetDecr: number[];
  41493. /**
  41494. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41495. */
  41496. keysRotationOffsetModifierAlt: boolean;
  41497. /**
  41498. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41499. */
  41500. keysRotationOffsetModifierCtrl: boolean;
  41501. /**
  41502. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41503. */
  41504. keysRotationOffsetModifierShift: boolean;
  41505. /**
  41506. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41507. */
  41508. keysRadiusIncr: number[];
  41509. /**
  41510. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41511. */
  41512. keysRadiusDecr: number[];
  41513. /**
  41514. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41515. */
  41516. keysRadiusModifierAlt: boolean;
  41517. /**
  41518. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41519. */
  41520. keysRadiusModifierCtrl: boolean;
  41521. /**
  41522. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41523. */
  41524. keysRadiusModifierShift: boolean;
  41525. /**
  41526. * Defines the rate of change of heightOffset.
  41527. */
  41528. heightSensibility: number;
  41529. /**
  41530. * Defines the rate of change of rotationOffset.
  41531. */
  41532. rotationSensibility: number;
  41533. /**
  41534. * Defines the rate of change of radius.
  41535. */
  41536. radiusSensibility: number;
  41537. private _keys;
  41538. private _ctrlPressed;
  41539. private _altPressed;
  41540. private _shiftPressed;
  41541. private _onCanvasBlurObserver;
  41542. private _onKeyboardObserver;
  41543. private _engine;
  41544. private _scene;
  41545. /**
  41546. * Attach the input controls to a specific dom element to get the input from.
  41547. * @param element Defines the element the controls should be listened from
  41548. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41549. */
  41550. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41551. /**
  41552. * Detach the current controls from the specified dom element.
  41553. * @param element Defines the element to stop listening the inputs from
  41554. */
  41555. detachControl(element: Nullable<HTMLElement>): void;
  41556. /**
  41557. * Update the current camera state depending on the inputs that have been used this frame.
  41558. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41559. */
  41560. checkInputs(): void;
  41561. /**
  41562. * Gets the class name of the current input.
  41563. * @returns the class name
  41564. */
  41565. getClassName(): string;
  41566. /**
  41567. * Get the friendly name associated with the input class.
  41568. * @returns the input friendly name
  41569. */
  41570. getSimpleName(): string;
  41571. /**
  41572. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41573. * allow modification of the heightOffset value.
  41574. */
  41575. private _modifierHeightOffset;
  41576. /**
  41577. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41578. * allow modification of the rotationOffset value.
  41579. */
  41580. private _modifierRotationOffset;
  41581. /**
  41582. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41583. * allow modification of the radius value.
  41584. */
  41585. private _modifierRadius;
  41586. }
  41587. }
  41588. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41589. import { Nullable } from "babylonjs/types";
  41590. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41591. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41592. import { Observable } from "babylonjs/Misc/observable";
  41593. module "babylonjs/Cameras/freeCameraInputsManager" {
  41594. interface FreeCameraInputsManager {
  41595. /**
  41596. * @hidden
  41597. */
  41598. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41599. /**
  41600. * Add orientation input support to the input manager.
  41601. * @returns the current input manager
  41602. */
  41603. addDeviceOrientation(): FreeCameraInputsManager;
  41604. }
  41605. }
  41606. /**
  41607. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41608. * Screen rotation is taken into account.
  41609. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41610. */
  41611. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41612. private _camera;
  41613. private _screenOrientationAngle;
  41614. private _constantTranform;
  41615. private _screenQuaternion;
  41616. private _alpha;
  41617. private _beta;
  41618. private _gamma;
  41619. /**
  41620. * Can be used to detect if a device orientation sensor is available on a device
  41621. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41622. * @returns a promise that will resolve on orientation change
  41623. */
  41624. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41625. /**
  41626. * @hidden
  41627. */
  41628. _onDeviceOrientationChangedObservable: Observable<void>;
  41629. /**
  41630. * Instantiates a new input
  41631. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41632. */
  41633. constructor();
  41634. /**
  41635. * Define the camera controlled by the input.
  41636. */
  41637. get camera(): FreeCamera;
  41638. set camera(camera: FreeCamera);
  41639. /**
  41640. * Attach the input controls to a specific dom element to get the input from.
  41641. * @param element Defines the element the controls should be listened from
  41642. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41643. */
  41644. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41645. private _orientationChanged;
  41646. private _deviceOrientation;
  41647. /**
  41648. * Detach the current controls from the specified dom element.
  41649. * @param element Defines the element to stop listening the inputs from
  41650. */
  41651. detachControl(element: Nullable<HTMLElement>): void;
  41652. /**
  41653. * Update the current camera state depending on the inputs that have been used this frame.
  41654. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41655. */
  41656. checkInputs(): void;
  41657. /**
  41658. * Gets the class name of the current intput.
  41659. * @returns the class name
  41660. */
  41661. getClassName(): string;
  41662. /**
  41663. * Get the friendly name associated with the input class.
  41664. * @returns the input friendly name
  41665. */
  41666. getSimpleName(): string;
  41667. }
  41668. }
  41669. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41670. import { Nullable } from "babylonjs/types";
  41671. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41672. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41673. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41674. /**
  41675. * Manage the gamepad inputs to control a free camera.
  41676. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41677. */
  41678. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41679. /**
  41680. * Define the camera the input is attached to.
  41681. */
  41682. camera: FreeCamera;
  41683. /**
  41684. * Define the Gamepad controlling the input
  41685. */
  41686. gamepad: Nullable<Gamepad>;
  41687. /**
  41688. * Defines the gamepad rotation sensiblity.
  41689. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41690. */
  41691. gamepadAngularSensibility: number;
  41692. /**
  41693. * Defines the gamepad move sensiblity.
  41694. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41695. */
  41696. gamepadMoveSensibility: number;
  41697. private _yAxisScale;
  41698. /**
  41699. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41700. */
  41701. get invertYAxis(): boolean;
  41702. set invertYAxis(value: boolean);
  41703. private _onGamepadConnectedObserver;
  41704. private _onGamepadDisconnectedObserver;
  41705. private _cameraTransform;
  41706. private _deltaTransform;
  41707. private _vector3;
  41708. private _vector2;
  41709. /**
  41710. * Attach the input controls to a specific dom element to get the input from.
  41711. * @param element Defines the element the controls should be listened from
  41712. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41713. */
  41714. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41715. /**
  41716. * Detach the current controls from the specified dom element.
  41717. * @param element Defines the element to stop listening the inputs from
  41718. */
  41719. detachControl(element: Nullable<HTMLElement>): void;
  41720. /**
  41721. * Update the current camera state depending on the inputs that have been used this frame.
  41722. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41723. */
  41724. checkInputs(): void;
  41725. /**
  41726. * Gets the class name of the current intput.
  41727. * @returns the class name
  41728. */
  41729. getClassName(): string;
  41730. /**
  41731. * Get the friendly name associated with the input class.
  41732. * @returns the input friendly name
  41733. */
  41734. getSimpleName(): string;
  41735. }
  41736. }
  41737. declare module "babylonjs/Misc/virtualJoystick" {
  41738. import { Nullable } from "babylonjs/types";
  41739. import { Vector3 } from "babylonjs/Maths/math.vector";
  41740. /**
  41741. * Defines the potential axis of a Joystick
  41742. */
  41743. export enum JoystickAxis {
  41744. /** X axis */
  41745. X = 0,
  41746. /** Y axis */
  41747. Y = 1,
  41748. /** Z axis */
  41749. Z = 2
  41750. }
  41751. /**
  41752. * Class used to define virtual joystick (used in touch mode)
  41753. */
  41754. export class VirtualJoystick {
  41755. /**
  41756. * Gets or sets a boolean indicating that left and right values must be inverted
  41757. */
  41758. reverseLeftRight: boolean;
  41759. /**
  41760. * Gets or sets a boolean indicating that up and down values must be inverted
  41761. */
  41762. reverseUpDown: boolean;
  41763. /**
  41764. * Gets the offset value for the position (ie. the change of the position value)
  41765. */
  41766. deltaPosition: Vector3;
  41767. /**
  41768. * Gets a boolean indicating if the virtual joystick was pressed
  41769. */
  41770. pressed: boolean;
  41771. /**
  41772. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41773. */
  41774. static Canvas: Nullable<HTMLCanvasElement>;
  41775. private static _globalJoystickIndex;
  41776. private static vjCanvasContext;
  41777. private static vjCanvasWidth;
  41778. private static vjCanvasHeight;
  41779. private static halfWidth;
  41780. private _action;
  41781. private _axisTargetedByLeftAndRight;
  41782. private _axisTargetedByUpAndDown;
  41783. private _joystickSensibility;
  41784. private _inversedSensibility;
  41785. private _joystickPointerID;
  41786. private _joystickColor;
  41787. private _joystickPointerPos;
  41788. private _joystickPreviousPointerPos;
  41789. private _joystickPointerStartPos;
  41790. private _deltaJoystickVector;
  41791. private _leftJoystick;
  41792. private _touches;
  41793. private _onPointerDownHandlerRef;
  41794. private _onPointerMoveHandlerRef;
  41795. private _onPointerUpHandlerRef;
  41796. private _onResize;
  41797. /**
  41798. * Creates a new virtual joystick
  41799. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41800. */
  41801. constructor(leftJoystick?: boolean);
  41802. /**
  41803. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41804. * @param newJoystickSensibility defines the new sensibility
  41805. */
  41806. setJoystickSensibility(newJoystickSensibility: number): void;
  41807. private _onPointerDown;
  41808. private _onPointerMove;
  41809. private _onPointerUp;
  41810. /**
  41811. * Change the color of the virtual joystick
  41812. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41813. */
  41814. setJoystickColor(newColor: string): void;
  41815. /**
  41816. * Defines a callback to call when the joystick is touched
  41817. * @param action defines the callback
  41818. */
  41819. setActionOnTouch(action: () => any): void;
  41820. /**
  41821. * Defines which axis you'd like to control for left & right
  41822. * @param axis defines the axis to use
  41823. */
  41824. setAxisForLeftRight(axis: JoystickAxis): void;
  41825. /**
  41826. * Defines which axis you'd like to control for up & down
  41827. * @param axis defines the axis to use
  41828. */
  41829. setAxisForUpDown(axis: JoystickAxis): void;
  41830. private _drawVirtualJoystick;
  41831. /**
  41832. * Release internal HTML canvas
  41833. */
  41834. releaseCanvas(): void;
  41835. }
  41836. }
  41837. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  41838. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  41839. import { Nullable } from "babylonjs/types";
  41840. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41841. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41842. module "babylonjs/Cameras/freeCameraInputsManager" {
  41843. interface FreeCameraInputsManager {
  41844. /**
  41845. * Add virtual joystick input support to the input manager.
  41846. * @returns the current input manager
  41847. */
  41848. addVirtualJoystick(): FreeCameraInputsManager;
  41849. }
  41850. }
  41851. /**
  41852. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41853. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41854. */
  41855. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41856. /**
  41857. * Defines the camera the input is attached to.
  41858. */
  41859. camera: FreeCamera;
  41860. private _leftjoystick;
  41861. private _rightjoystick;
  41862. /**
  41863. * Gets the left stick of the virtual joystick.
  41864. * @returns The virtual Joystick
  41865. */
  41866. getLeftJoystick(): VirtualJoystick;
  41867. /**
  41868. * Gets the right stick of the virtual joystick.
  41869. * @returns The virtual Joystick
  41870. */
  41871. getRightJoystick(): VirtualJoystick;
  41872. /**
  41873. * Update the current camera state depending on the inputs that have been used this frame.
  41874. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41875. */
  41876. checkInputs(): void;
  41877. /**
  41878. * Attach the input controls to a specific dom element to get the input from.
  41879. * @param element Defines the element the controls should be listened from
  41880. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41881. */
  41882. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41883. /**
  41884. * Detach the current controls from the specified dom element.
  41885. * @param element Defines the element to stop listening the inputs from
  41886. */
  41887. detachControl(element: Nullable<HTMLElement>): void;
  41888. /**
  41889. * Gets the class name of the current intput.
  41890. * @returns the class name
  41891. */
  41892. getClassName(): string;
  41893. /**
  41894. * Get the friendly name associated with the input class.
  41895. * @returns the input friendly name
  41896. */
  41897. getSimpleName(): string;
  41898. }
  41899. }
  41900. declare module "babylonjs/Cameras/Inputs/index" {
  41901. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  41902. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  41903. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  41904. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  41905. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41906. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  41907. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  41908. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  41909. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  41910. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  41911. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41912. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  41913. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  41914. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  41915. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  41916. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41917. }
  41918. declare module "babylonjs/Cameras/touchCamera" {
  41919. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41920. import { Scene } from "babylonjs/scene";
  41921. import { Vector3 } from "babylonjs/Maths/math.vector";
  41922. /**
  41923. * This represents a FPS type of camera controlled by touch.
  41924. * This is like a universal camera minus the Gamepad controls.
  41925. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41926. */
  41927. export class TouchCamera extends FreeCamera {
  41928. /**
  41929. * Defines the touch sensibility for rotation.
  41930. * The higher the faster.
  41931. */
  41932. get touchAngularSensibility(): number;
  41933. set touchAngularSensibility(value: number);
  41934. /**
  41935. * Defines the touch sensibility for move.
  41936. * The higher the faster.
  41937. */
  41938. get touchMoveSensibility(): number;
  41939. set touchMoveSensibility(value: number);
  41940. /**
  41941. * Instantiates a new touch camera.
  41942. * This represents a FPS type of camera controlled by touch.
  41943. * This is like a universal camera minus the Gamepad controls.
  41944. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41945. * @param name Define the name of the camera in the scene
  41946. * @param position Define the start position of the camera in the scene
  41947. * @param scene Define the scene the camera belongs to
  41948. */
  41949. constructor(name: string, position: Vector3, scene: Scene);
  41950. /**
  41951. * Gets the current object class name.
  41952. * @return the class name
  41953. */
  41954. getClassName(): string;
  41955. /** @hidden */
  41956. _setupInputs(): void;
  41957. }
  41958. }
  41959. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  41960. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41961. import { Scene } from "babylonjs/scene";
  41962. import { Vector3 } from "babylonjs/Maths/math.vector";
  41963. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41964. import { Axis } from "babylonjs/Maths/math.axis";
  41965. /**
  41966. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41967. * being tilted forward or back and left or right.
  41968. */
  41969. export class DeviceOrientationCamera extends FreeCamera {
  41970. private _initialQuaternion;
  41971. private _quaternionCache;
  41972. private _tmpDragQuaternion;
  41973. private _disablePointerInputWhenUsingDeviceOrientation;
  41974. /**
  41975. * Creates a new device orientation camera
  41976. * @param name The name of the camera
  41977. * @param position The start position camera
  41978. * @param scene The scene the camera belongs to
  41979. */
  41980. constructor(name: string, position: Vector3, scene: Scene);
  41981. /**
  41982. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41983. */
  41984. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41985. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41986. private _dragFactor;
  41987. /**
  41988. * Enabled turning on the y axis when the orientation sensor is active
  41989. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41990. */
  41991. enableHorizontalDragging(dragFactor?: number): void;
  41992. /**
  41993. * Gets the current instance class name ("DeviceOrientationCamera").
  41994. * This helps avoiding instanceof at run time.
  41995. * @returns the class name
  41996. */
  41997. getClassName(): string;
  41998. /**
  41999. * @hidden
  42000. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42001. */
  42002. _checkInputs(): void;
  42003. /**
  42004. * Reset the camera to its default orientation on the specified axis only.
  42005. * @param axis The axis to reset
  42006. */
  42007. resetToCurrentRotation(axis?: Axis): void;
  42008. }
  42009. }
  42010. declare module "babylonjs/Gamepads/xboxGamepad" {
  42011. import { Observable } from "babylonjs/Misc/observable";
  42012. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42013. /**
  42014. * Defines supported buttons for XBox360 compatible gamepads
  42015. */
  42016. export enum Xbox360Button {
  42017. /** A */
  42018. A = 0,
  42019. /** B */
  42020. B = 1,
  42021. /** X */
  42022. X = 2,
  42023. /** Y */
  42024. Y = 3,
  42025. /** Start */
  42026. Start = 4,
  42027. /** Back */
  42028. Back = 5,
  42029. /** Left button */
  42030. LB = 6,
  42031. /** Right button */
  42032. RB = 7,
  42033. /** Left stick */
  42034. LeftStick = 8,
  42035. /** Right stick */
  42036. RightStick = 9
  42037. }
  42038. /** Defines values for XBox360 DPad */
  42039. export enum Xbox360Dpad {
  42040. /** Up */
  42041. Up = 0,
  42042. /** Down */
  42043. Down = 1,
  42044. /** Left */
  42045. Left = 2,
  42046. /** Right */
  42047. Right = 3
  42048. }
  42049. /**
  42050. * Defines a XBox360 gamepad
  42051. */
  42052. export class Xbox360Pad extends Gamepad {
  42053. private _leftTrigger;
  42054. private _rightTrigger;
  42055. private _onlefttriggerchanged;
  42056. private _onrighttriggerchanged;
  42057. private _onbuttondown;
  42058. private _onbuttonup;
  42059. private _ondpaddown;
  42060. private _ondpadup;
  42061. /** Observable raised when a button is pressed */
  42062. onButtonDownObservable: Observable<Xbox360Button>;
  42063. /** Observable raised when a button is released */
  42064. onButtonUpObservable: Observable<Xbox360Button>;
  42065. /** Observable raised when a pad is pressed */
  42066. onPadDownObservable: Observable<Xbox360Dpad>;
  42067. /** Observable raised when a pad is released */
  42068. onPadUpObservable: Observable<Xbox360Dpad>;
  42069. private _buttonA;
  42070. private _buttonB;
  42071. private _buttonX;
  42072. private _buttonY;
  42073. private _buttonBack;
  42074. private _buttonStart;
  42075. private _buttonLB;
  42076. private _buttonRB;
  42077. private _buttonLeftStick;
  42078. private _buttonRightStick;
  42079. private _dPadUp;
  42080. private _dPadDown;
  42081. private _dPadLeft;
  42082. private _dPadRight;
  42083. private _isXboxOnePad;
  42084. /**
  42085. * Creates a new XBox360 gamepad object
  42086. * @param id defines the id of this gamepad
  42087. * @param index defines its index
  42088. * @param gamepad defines the internal HTML gamepad object
  42089. * @param xboxOne defines if it is a XBox One gamepad
  42090. */
  42091. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42092. /**
  42093. * Defines the callback to call when left trigger is pressed
  42094. * @param callback defines the callback to use
  42095. */
  42096. onlefttriggerchanged(callback: (value: number) => void): void;
  42097. /**
  42098. * Defines the callback to call when right trigger is pressed
  42099. * @param callback defines the callback to use
  42100. */
  42101. onrighttriggerchanged(callback: (value: number) => void): void;
  42102. /**
  42103. * Gets the left trigger value
  42104. */
  42105. get leftTrigger(): number;
  42106. /**
  42107. * Sets the left trigger value
  42108. */
  42109. set leftTrigger(newValue: number);
  42110. /**
  42111. * Gets the right trigger value
  42112. */
  42113. get rightTrigger(): number;
  42114. /**
  42115. * Sets the right trigger value
  42116. */
  42117. set rightTrigger(newValue: number);
  42118. /**
  42119. * Defines the callback to call when a button is pressed
  42120. * @param callback defines the callback to use
  42121. */
  42122. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42123. /**
  42124. * Defines the callback to call when a button is released
  42125. * @param callback defines the callback to use
  42126. */
  42127. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42128. /**
  42129. * Defines the callback to call when a pad is pressed
  42130. * @param callback defines the callback to use
  42131. */
  42132. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42133. /**
  42134. * Defines the callback to call when a pad is released
  42135. * @param callback defines the callback to use
  42136. */
  42137. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42138. private _setButtonValue;
  42139. private _setDPadValue;
  42140. /**
  42141. * Gets the value of the `A` button
  42142. */
  42143. get buttonA(): number;
  42144. /**
  42145. * Sets the value of the `A` button
  42146. */
  42147. set buttonA(value: number);
  42148. /**
  42149. * Gets the value of the `B` button
  42150. */
  42151. get buttonB(): number;
  42152. /**
  42153. * Sets the value of the `B` button
  42154. */
  42155. set buttonB(value: number);
  42156. /**
  42157. * Gets the value of the `X` button
  42158. */
  42159. get buttonX(): number;
  42160. /**
  42161. * Sets the value of the `X` button
  42162. */
  42163. set buttonX(value: number);
  42164. /**
  42165. * Gets the value of the `Y` button
  42166. */
  42167. get buttonY(): number;
  42168. /**
  42169. * Sets the value of the `Y` button
  42170. */
  42171. set buttonY(value: number);
  42172. /**
  42173. * Gets the value of the `Start` button
  42174. */
  42175. get buttonStart(): number;
  42176. /**
  42177. * Sets the value of the `Start` button
  42178. */
  42179. set buttonStart(value: number);
  42180. /**
  42181. * Gets the value of the `Back` button
  42182. */
  42183. get buttonBack(): number;
  42184. /**
  42185. * Sets the value of the `Back` button
  42186. */
  42187. set buttonBack(value: number);
  42188. /**
  42189. * Gets the value of the `Left` button
  42190. */
  42191. get buttonLB(): number;
  42192. /**
  42193. * Sets the value of the `Left` button
  42194. */
  42195. set buttonLB(value: number);
  42196. /**
  42197. * Gets the value of the `Right` button
  42198. */
  42199. get buttonRB(): number;
  42200. /**
  42201. * Sets the value of the `Right` button
  42202. */
  42203. set buttonRB(value: number);
  42204. /**
  42205. * Gets the value of the Left joystick
  42206. */
  42207. get buttonLeftStick(): number;
  42208. /**
  42209. * Sets the value of the Left joystick
  42210. */
  42211. set buttonLeftStick(value: number);
  42212. /**
  42213. * Gets the value of the Right joystick
  42214. */
  42215. get buttonRightStick(): number;
  42216. /**
  42217. * Sets the value of the Right joystick
  42218. */
  42219. set buttonRightStick(value: number);
  42220. /**
  42221. * Gets the value of D-pad up
  42222. */
  42223. get dPadUp(): number;
  42224. /**
  42225. * Sets the value of D-pad up
  42226. */
  42227. set dPadUp(value: number);
  42228. /**
  42229. * Gets the value of D-pad down
  42230. */
  42231. get dPadDown(): number;
  42232. /**
  42233. * Sets the value of D-pad down
  42234. */
  42235. set dPadDown(value: number);
  42236. /**
  42237. * Gets the value of D-pad left
  42238. */
  42239. get dPadLeft(): number;
  42240. /**
  42241. * Sets the value of D-pad left
  42242. */
  42243. set dPadLeft(value: number);
  42244. /**
  42245. * Gets the value of D-pad right
  42246. */
  42247. get dPadRight(): number;
  42248. /**
  42249. * Sets the value of D-pad right
  42250. */
  42251. set dPadRight(value: number);
  42252. /**
  42253. * Force the gamepad to synchronize with device values
  42254. */
  42255. update(): void;
  42256. /**
  42257. * Disposes the gamepad
  42258. */
  42259. dispose(): void;
  42260. }
  42261. }
  42262. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42263. import { Observable } from "babylonjs/Misc/observable";
  42264. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42265. /**
  42266. * Defines supported buttons for DualShock compatible gamepads
  42267. */
  42268. export enum DualShockButton {
  42269. /** Cross */
  42270. Cross = 0,
  42271. /** Circle */
  42272. Circle = 1,
  42273. /** Square */
  42274. Square = 2,
  42275. /** Triangle */
  42276. Triangle = 3,
  42277. /** Options */
  42278. Options = 4,
  42279. /** Share */
  42280. Share = 5,
  42281. /** L1 */
  42282. L1 = 6,
  42283. /** R1 */
  42284. R1 = 7,
  42285. /** Left stick */
  42286. LeftStick = 8,
  42287. /** Right stick */
  42288. RightStick = 9
  42289. }
  42290. /** Defines values for DualShock DPad */
  42291. export enum DualShockDpad {
  42292. /** Up */
  42293. Up = 0,
  42294. /** Down */
  42295. Down = 1,
  42296. /** Left */
  42297. Left = 2,
  42298. /** Right */
  42299. Right = 3
  42300. }
  42301. /**
  42302. * Defines a DualShock gamepad
  42303. */
  42304. export class DualShockPad extends Gamepad {
  42305. private _leftTrigger;
  42306. private _rightTrigger;
  42307. private _onlefttriggerchanged;
  42308. private _onrighttriggerchanged;
  42309. private _onbuttondown;
  42310. private _onbuttonup;
  42311. private _ondpaddown;
  42312. private _ondpadup;
  42313. /** Observable raised when a button is pressed */
  42314. onButtonDownObservable: Observable<DualShockButton>;
  42315. /** Observable raised when a button is released */
  42316. onButtonUpObservable: Observable<DualShockButton>;
  42317. /** Observable raised when a pad is pressed */
  42318. onPadDownObservable: Observable<DualShockDpad>;
  42319. /** Observable raised when a pad is released */
  42320. onPadUpObservable: Observable<DualShockDpad>;
  42321. private _buttonCross;
  42322. private _buttonCircle;
  42323. private _buttonSquare;
  42324. private _buttonTriangle;
  42325. private _buttonShare;
  42326. private _buttonOptions;
  42327. private _buttonL1;
  42328. private _buttonR1;
  42329. private _buttonLeftStick;
  42330. private _buttonRightStick;
  42331. private _dPadUp;
  42332. private _dPadDown;
  42333. private _dPadLeft;
  42334. private _dPadRight;
  42335. /**
  42336. * Creates a new DualShock gamepad object
  42337. * @param id defines the id of this gamepad
  42338. * @param index defines its index
  42339. * @param gamepad defines the internal HTML gamepad object
  42340. */
  42341. constructor(id: string, index: number, gamepad: any);
  42342. /**
  42343. * Defines the callback to call when left trigger is pressed
  42344. * @param callback defines the callback to use
  42345. */
  42346. onlefttriggerchanged(callback: (value: number) => void): void;
  42347. /**
  42348. * Defines the callback to call when right trigger is pressed
  42349. * @param callback defines the callback to use
  42350. */
  42351. onrighttriggerchanged(callback: (value: number) => void): void;
  42352. /**
  42353. * Gets the left trigger value
  42354. */
  42355. get leftTrigger(): number;
  42356. /**
  42357. * Sets the left trigger value
  42358. */
  42359. set leftTrigger(newValue: number);
  42360. /**
  42361. * Gets the right trigger value
  42362. */
  42363. get rightTrigger(): number;
  42364. /**
  42365. * Sets the right trigger value
  42366. */
  42367. set rightTrigger(newValue: number);
  42368. /**
  42369. * Defines the callback to call when a button is pressed
  42370. * @param callback defines the callback to use
  42371. */
  42372. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42373. /**
  42374. * Defines the callback to call when a button is released
  42375. * @param callback defines the callback to use
  42376. */
  42377. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42378. /**
  42379. * Defines the callback to call when a pad is pressed
  42380. * @param callback defines the callback to use
  42381. */
  42382. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42383. /**
  42384. * Defines the callback to call when a pad is released
  42385. * @param callback defines the callback to use
  42386. */
  42387. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42388. private _setButtonValue;
  42389. private _setDPadValue;
  42390. /**
  42391. * Gets the value of the `Cross` button
  42392. */
  42393. get buttonCross(): number;
  42394. /**
  42395. * Sets the value of the `Cross` button
  42396. */
  42397. set buttonCross(value: number);
  42398. /**
  42399. * Gets the value of the `Circle` button
  42400. */
  42401. get buttonCircle(): number;
  42402. /**
  42403. * Sets the value of the `Circle` button
  42404. */
  42405. set buttonCircle(value: number);
  42406. /**
  42407. * Gets the value of the `Square` button
  42408. */
  42409. get buttonSquare(): number;
  42410. /**
  42411. * Sets the value of the `Square` button
  42412. */
  42413. set buttonSquare(value: number);
  42414. /**
  42415. * Gets the value of the `Triangle` button
  42416. */
  42417. get buttonTriangle(): number;
  42418. /**
  42419. * Sets the value of the `Triangle` button
  42420. */
  42421. set buttonTriangle(value: number);
  42422. /**
  42423. * Gets the value of the `Options` button
  42424. */
  42425. get buttonOptions(): number;
  42426. /**
  42427. * Sets the value of the `Options` button
  42428. */
  42429. set buttonOptions(value: number);
  42430. /**
  42431. * Gets the value of the `Share` button
  42432. */
  42433. get buttonShare(): number;
  42434. /**
  42435. * Sets the value of the `Share` button
  42436. */
  42437. set buttonShare(value: number);
  42438. /**
  42439. * Gets the value of the `L1` button
  42440. */
  42441. get buttonL1(): number;
  42442. /**
  42443. * Sets the value of the `L1` button
  42444. */
  42445. set buttonL1(value: number);
  42446. /**
  42447. * Gets the value of the `R1` button
  42448. */
  42449. get buttonR1(): number;
  42450. /**
  42451. * Sets the value of the `R1` button
  42452. */
  42453. set buttonR1(value: number);
  42454. /**
  42455. * Gets the value of the Left joystick
  42456. */
  42457. get buttonLeftStick(): number;
  42458. /**
  42459. * Sets the value of the Left joystick
  42460. */
  42461. set buttonLeftStick(value: number);
  42462. /**
  42463. * Gets the value of the Right joystick
  42464. */
  42465. get buttonRightStick(): number;
  42466. /**
  42467. * Sets the value of the Right joystick
  42468. */
  42469. set buttonRightStick(value: number);
  42470. /**
  42471. * Gets the value of D-pad up
  42472. */
  42473. get dPadUp(): number;
  42474. /**
  42475. * Sets the value of D-pad up
  42476. */
  42477. set dPadUp(value: number);
  42478. /**
  42479. * Gets the value of D-pad down
  42480. */
  42481. get dPadDown(): number;
  42482. /**
  42483. * Sets the value of D-pad down
  42484. */
  42485. set dPadDown(value: number);
  42486. /**
  42487. * Gets the value of D-pad left
  42488. */
  42489. get dPadLeft(): number;
  42490. /**
  42491. * Sets the value of D-pad left
  42492. */
  42493. set dPadLeft(value: number);
  42494. /**
  42495. * Gets the value of D-pad right
  42496. */
  42497. get dPadRight(): number;
  42498. /**
  42499. * Sets the value of D-pad right
  42500. */
  42501. set dPadRight(value: number);
  42502. /**
  42503. * Force the gamepad to synchronize with device values
  42504. */
  42505. update(): void;
  42506. /**
  42507. * Disposes the gamepad
  42508. */
  42509. dispose(): void;
  42510. }
  42511. }
  42512. declare module "babylonjs/Gamepads/gamepadManager" {
  42513. import { Observable } from "babylonjs/Misc/observable";
  42514. import { Nullable } from "babylonjs/types";
  42515. import { Scene } from "babylonjs/scene";
  42516. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42517. /**
  42518. * Manager for handling gamepads
  42519. */
  42520. export class GamepadManager {
  42521. private _scene?;
  42522. private _babylonGamepads;
  42523. private _oneGamepadConnected;
  42524. /** @hidden */
  42525. _isMonitoring: boolean;
  42526. private _gamepadEventSupported;
  42527. private _gamepadSupport?;
  42528. /**
  42529. * observable to be triggered when the gamepad controller has been connected
  42530. */
  42531. onGamepadConnectedObservable: Observable<Gamepad>;
  42532. /**
  42533. * observable to be triggered when the gamepad controller has been disconnected
  42534. */
  42535. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42536. private _onGamepadConnectedEvent;
  42537. private _onGamepadDisconnectedEvent;
  42538. /**
  42539. * Initializes the gamepad manager
  42540. * @param _scene BabylonJS scene
  42541. */
  42542. constructor(_scene?: Scene | undefined);
  42543. /**
  42544. * The gamepads in the game pad manager
  42545. */
  42546. get gamepads(): Gamepad[];
  42547. /**
  42548. * Get the gamepad controllers based on type
  42549. * @param type The type of gamepad controller
  42550. * @returns Nullable gamepad
  42551. */
  42552. getGamepadByType(type?: number): Nullable<Gamepad>;
  42553. /**
  42554. * Disposes the gamepad manager
  42555. */
  42556. dispose(): void;
  42557. private _addNewGamepad;
  42558. private _startMonitoringGamepads;
  42559. private _stopMonitoringGamepads;
  42560. /** @hidden */
  42561. _checkGamepadsStatus(): void;
  42562. private _updateGamepadObjects;
  42563. }
  42564. }
  42565. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42566. import { Nullable } from "babylonjs/types";
  42567. import { Scene } from "babylonjs/scene";
  42568. import { ISceneComponent } from "babylonjs/sceneComponent";
  42569. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42570. module "babylonjs/scene" {
  42571. interface Scene {
  42572. /** @hidden */
  42573. _gamepadManager: Nullable<GamepadManager>;
  42574. /**
  42575. * Gets the gamepad manager associated with the scene
  42576. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42577. */
  42578. gamepadManager: GamepadManager;
  42579. }
  42580. }
  42581. module "babylonjs/Cameras/freeCameraInputsManager" {
  42582. /**
  42583. * Interface representing a free camera inputs manager
  42584. */
  42585. interface FreeCameraInputsManager {
  42586. /**
  42587. * Adds gamepad input support to the FreeCameraInputsManager.
  42588. * @returns the FreeCameraInputsManager
  42589. */
  42590. addGamepad(): FreeCameraInputsManager;
  42591. }
  42592. }
  42593. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42594. /**
  42595. * Interface representing an arc rotate camera inputs manager
  42596. */
  42597. interface ArcRotateCameraInputsManager {
  42598. /**
  42599. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42600. * @returns the camera inputs manager
  42601. */
  42602. addGamepad(): ArcRotateCameraInputsManager;
  42603. }
  42604. }
  42605. /**
  42606. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42607. */
  42608. export class GamepadSystemSceneComponent implements ISceneComponent {
  42609. /**
  42610. * The component name helpfull to identify the component in the list of scene components.
  42611. */
  42612. readonly name: string;
  42613. /**
  42614. * The scene the component belongs to.
  42615. */
  42616. scene: Scene;
  42617. /**
  42618. * Creates a new instance of the component for the given scene
  42619. * @param scene Defines the scene to register the component in
  42620. */
  42621. constructor(scene: Scene);
  42622. /**
  42623. * Registers the component in a given scene
  42624. */
  42625. register(): void;
  42626. /**
  42627. * Rebuilds the elements related to this component in case of
  42628. * context lost for instance.
  42629. */
  42630. rebuild(): void;
  42631. /**
  42632. * Disposes the component and the associated ressources
  42633. */
  42634. dispose(): void;
  42635. private _beforeCameraUpdate;
  42636. }
  42637. }
  42638. declare module "babylonjs/Cameras/universalCamera" {
  42639. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42640. import { Scene } from "babylonjs/scene";
  42641. import { Vector3 } from "babylonjs/Maths/math.vector";
  42642. import "babylonjs/Gamepads/gamepadSceneComponent";
  42643. /**
  42644. * 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,
  42645. * which still works and will still be found in many Playgrounds.
  42646. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42647. */
  42648. export class UniversalCamera extends TouchCamera {
  42649. /**
  42650. * Defines the gamepad rotation sensiblity.
  42651. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42652. */
  42653. get gamepadAngularSensibility(): number;
  42654. set gamepadAngularSensibility(value: number);
  42655. /**
  42656. * Defines the gamepad move sensiblity.
  42657. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42658. */
  42659. get gamepadMoveSensibility(): number;
  42660. set gamepadMoveSensibility(value: number);
  42661. /**
  42662. * 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,
  42663. * which still works and will still be found in many Playgrounds.
  42664. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42665. * @param name Define the name of the camera in the scene
  42666. * @param position Define the start position of the camera in the scene
  42667. * @param scene Define the scene the camera belongs to
  42668. */
  42669. constructor(name: string, position: Vector3, scene: Scene);
  42670. /**
  42671. * Gets the current object class name.
  42672. * @return the class name
  42673. */
  42674. getClassName(): string;
  42675. }
  42676. }
  42677. declare module "babylonjs/Cameras/gamepadCamera" {
  42678. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42679. import { Scene } from "babylonjs/scene";
  42680. import { Vector3 } from "babylonjs/Maths/math.vector";
  42681. /**
  42682. * This represents a FPS type of camera. This is only here for back compat purpose.
  42683. * Please use the UniversalCamera instead as both are identical.
  42684. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42685. */
  42686. export class GamepadCamera extends UniversalCamera {
  42687. /**
  42688. * Instantiates a new Gamepad Camera
  42689. * This represents a FPS type of camera. This is only here for back compat purpose.
  42690. * Please use the UniversalCamera instead as both are identical.
  42691. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42692. * @param name Define the name of the camera in the scene
  42693. * @param position Define the start position of the camera in the scene
  42694. * @param scene Define the scene the camera belongs to
  42695. */
  42696. constructor(name: string, position: Vector3, scene: Scene);
  42697. /**
  42698. * Gets the current object class name.
  42699. * @return the class name
  42700. */
  42701. getClassName(): string;
  42702. }
  42703. }
  42704. declare module "babylonjs/Shaders/pass.fragment" {
  42705. /** @hidden */
  42706. export var passPixelShader: {
  42707. name: string;
  42708. shader: string;
  42709. };
  42710. }
  42711. declare module "babylonjs/Shaders/passCube.fragment" {
  42712. /** @hidden */
  42713. export var passCubePixelShader: {
  42714. name: string;
  42715. shader: string;
  42716. };
  42717. }
  42718. declare module "babylonjs/PostProcesses/passPostProcess" {
  42719. import { Nullable } from "babylonjs/types";
  42720. import { Camera } from "babylonjs/Cameras/camera";
  42721. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42722. import { Engine } from "babylonjs/Engines/engine";
  42723. import "babylonjs/Shaders/pass.fragment";
  42724. import "babylonjs/Shaders/passCube.fragment";
  42725. /**
  42726. * PassPostProcess which produces an output the same as it's input
  42727. */
  42728. export class PassPostProcess extends PostProcess {
  42729. /**
  42730. * Creates the PassPostProcess
  42731. * @param name The name of the effect.
  42732. * @param options The required width/height ratio to downsize to before computing the render pass.
  42733. * @param camera The camera to apply the render pass to.
  42734. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42735. * @param engine The engine which the post process will be applied. (default: current engine)
  42736. * @param reusable If the post process can be reused on the same frame. (default: false)
  42737. * @param textureType The type of texture to be used when performing the post processing.
  42738. * @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)
  42739. */
  42740. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42741. }
  42742. /**
  42743. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42744. */
  42745. export class PassCubePostProcess extends PostProcess {
  42746. private _face;
  42747. /**
  42748. * Gets or sets the cube face to display.
  42749. * * 0 is +X
  42750. * * 1 is -X
  42751. * * 2 is +Y
  42752. * * 3 is -Y
  42753. * * 4 is +Z
  42754. * * 5 is -Z
  42755. */
  42756. get face(): number;
  42757. set face(value: number);
  42758. /**
  42759. * Creates the PassCubePostProcess
  42760. * @param name The name of the effect.
  42761. * @param options The required width/height ratio to downsize to before computing the render pass.
  42762. * @param camera The camera to apply the render pass to.
  42763. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42764. * @param engine The engine which the post process will be applied. (default: current engine)
  42765. * @param reusable If the post process can be reused on the same frame. (default: false)
  42766. * @param textureType The type of texture to be used when performing the post processing.
  42767. * @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)
  42768. */
  42769. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42770. }
  42771. }
  42772. declare module "babylonjs/Shaders/anaglyph.fragment" {
  42773. /** @hidden */
  42774. export var anaglyphPixelShader: {
  42775. name: string;
  42776. shader: string;
  42777. };
  42778. }
  42779. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  42780. import { Engine } from "babylonjs/Engines/engine";
  42781. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42782. import { Camera } from "babylonjs/Cameras/camera";
  42783. import "babylonjs/Shaders/anaglyph.fragment";
  42784. /**
  42785. * Postprocess used to generate anaglyphic rendering
  42786. */
  42787. export class AnaglyphPostProcess extends PostProcess {
  42788. private _passedProcess;
  42789. /**
  42790. * Creates a new AnaglyphPostProcess
  42791. * @param name defines postprocess name
  42792. * @param options defines creation options or target ratio scale
  42793. * @param rigCameras defines cameras using this postprocess
  42794. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42795. * @param engine defines hosting engine
  42796. * @param reusable defines if the postprocess will be reused multiple times per frame
  42797. */
  42798. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42799. }
  42800. }
  42801. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  42802. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  42803. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42804. import { Scene } from "babylonjs/scene";
  42805. import { Vector3 } from "babylonjs/Maths/math.vector";
  42806. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42807. /**
  42808. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42809. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42810. */
  42811. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42812. /**
  42813. * Creates a new AnaglyphArcRotateCamera
  42814. * @param name defines camera name
  42815. * @param alpha defines alpha angle (in radians)
  42816. * @param beta defines beta angle (in radians)
  42817. * @param radius defines radius
  42818. * @param target defines camera target
  42819. * @param interaxialDistance defines distance between each color axis
  42820. * @param scene defines the hosting scene
  42821. */
  42822. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42823. /**
  42824. * Gets camera class name
  42825. * @returns AnaglyphArcRotateCamera
  42826. */
  42827. getClassName(): string;
  42828. }
  42829. }
  42830. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  42831. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42832. import { Scene } from "babylonjs/scene";
  42833. import { Vector3 } from "babylonjs/Maths/math.vector";
  42834. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42835. /**
  42836. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42837. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42838. */
  42839. export class AnaglyphFreeCamera extends FreeCamera {
  42840. /**
  42841. * Creates a new AnaglyphFreeCamera
  42842. * @param name defines camera name
  42843. * @param position defines initial position
  42844. * @param interaxialDistance defines distance between each color axis
  42845. * @param scene defines the hosting scene
  42846. */
  42847. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42848. /**
  42849. * Gets camera class name
  42850. * @returns AnaglyphFreeCamera
  42851. */
  42852. getClassName(): string;
  42853. }
  42854. }
  42855. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  42856. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42857. import { Scene } from "babylonjs/scene";
  42858. import { Vector3 } from "babylonjs/Maths/math.vector";
  42859. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42860. /**
  42861. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42862. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42863. */
  42864. export class AnaglyphGamepadCamera extends GamepadCamera {
  42865. /**
  42866. * Creates a new AnaglyphGamepadCamera
  42867. * @param name defines camera name
  42868. * @param position defines initial position
  42869. * @param interaxialDistance defines distance between each color axis
  42870. * @param scene defines the hosting scene
  42871. */
  42872. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42873. /**
  42874. * Gets camera class name
  42875. * @returns AnaglyphGamepadCamera
  42876. */
  42877. getClassName(): string;
  42878. }
  42879. }
  42880. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  42881. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42882. import { Scene } from "babylonjs/scene";
  42883. import { Vector3 } from "babylonjs/Maths/math.vector";
  42884. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42885. /**
  42886. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42887. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42888. */
  42889. export class AnaglyphUniversalCamera extends UniversalCamera {
  42890. /**
  42891. * Creates a new AnaglyphUniversalCamera
  42892. * @param name defines camera name
  42893. * @param position defines initial position
  42894. * @param interaxialDistance defines distance between each color axis
  42895. * @param scene defines the hosting scene
  42896. */
  42897. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42898. /**
  42899. * Gets camera class name
  42900. * @returns AnaglyphUniversalCamera
  42901. */
  42902. getClassName(): string;
  42903. }
  42904. }
  42905. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  42906. /** @hidden */
  42907. export var stereoscopicInterlacePixelShader: {
  42908. name: string;
  42909. shader: string;
  42910. };
  42911. }
  42912. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  42913. import { Camera } from "babylonjs/Cameras/camera";
  42914. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42915. import { Engine } from "babylonjs/Engines/engine";
  42916. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  42917. /**
  42918. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42919. */
  42920. export class StereoscopicInterlacePostProcess extends PostProcess {
  42921. private _stepSize;
  42922. private _passedProcess;
  42923. /**
  42924. * Initializes a StereoscopicInterlacePostProcess
  42925. * @param name The name of the effect.
  42926. * @param rigCameras The rig cameras to be appled to the post process
  42927. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42928. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42929. * @param engine The engine which the post process will be applied. (default: current engine)
  42930. * @param reusable If the post process can be reused on the same frame. (default: false)
  42931. */
  42932. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42933. }
  42934. }
  42935. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  42936. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  42937. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42938. import { Scene } from "babylonjs/scene";
  42939. import { Vector3 } from "babylonjs/Maths/math.vector";
  42940. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42941. /**
  42942. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42943. * @see http://doc.babylonjs.com/features/cameras
  42944. */
  42945. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42946. /**
  42947. * Creates a new StereoscopicArcRotateCamera
  42948. * @param name defines camera name
  42949. * @param alpha defines alpha angle (in radians)
  42950. * @param beta defines beta angle (in radians)
  42951. * @param radius defines radius
  42952. * @param target defines camera target
  42953. * @param interaxialDistance defines distance between each color axis
  42954. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42955. * @param scene defines the hosting scene
  42956. */
  42957. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42958. /**
  42959. * Gets camera class name
  42960. * @returns StereoscopicArcRotateCamera
  42961. */
  42962. getClassName(): string;
  42963. }
  42964. }
  42965. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  42966. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42967. import { Scene } from "babylonjs/scene";
  42968. import { Vector3 } from "babylonjs/Maths/math.vector";
  42969. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42970. /**
  42971. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42972. * @see http://doc.babylonjs.com/features/cameras
  42973. */
  42974. export class StereoscopicFreeCamera extends FreeCamera {
  42975. /**
  42976. * Creates a new StereoscopicFreeCamera
  42977. * @param name defines camera name
  42978. * @param position defines initial position
  42979. * @param interaxialDistance defines distance between each color axis
  42980. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42981. * @param scene defines the hosting scene
  42982. */
  42983. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42984. /**
  42985. * Gets camera class name
  42986. * @returns StereoscopicFreeCamera
  42987. */
  42988. getClassName(): string;
  42989. }
  42990. }
  42991. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  42992. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42993. import { Scene } from "babylonjs/scene";
  42994. import { Vector3 } from "babylonjs/Maths/math.vector";
  42995. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42996. /**
  42997. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42998. * @see http://doc.babylonjs.com/features/cameras
  42999. */
  43000. export class StereoscopicGamepadCamera extends GamepadCamera {
  43001. /**
  43002. * Creates a new StereoscopicGamepadCamera
  43003. * @param name defines camera name
  43004. * @param position defines initial position
  43005. * @param interaxialDistance defines distance between each color axis
  43006. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43007. * @param scene defines the hosting scene
  43008. */
  43009. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43010. /**
  43011. * Gets camera class name
  43012. * @returns StereoscopicGamepadCamera
  43013. */
  43014. getClassName(): string;
  43015. }
  43016. }
  43017. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43018. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43019. import { Scene } from "babylonjs/scene";
  43020. import { Vector3 } from "babylonjs/Maths/math.vector";
  43021. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43022. /**
  43023. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43024. * @see http://doc.babylonjs.com/features/cameras
  43025. */
  43026. export class StereoscopicUniversalCamera extends UniversalCamera {
  43027. /**
  43028. * Creates a new StereoscopicUniversalCamera
  43029. * @param name defines camera name
  43030. * @param position defines initial position
  43031. * @param interaxialDistance defines distance between each color axis
  43032. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43033. * @param scene defines the hosting scene
  43034. */
  43035. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43036. /**
  43037. * Gets camera class name
  43038. * @returns StereoscopicUniversalCamera
  43039. */
  43040. getClassName(): string;
  43041. }
  43042. }
  43043. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43044. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43045. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43046. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43047. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43048. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43049. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43050. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43051. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43052. }
  43053. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43054. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43055. import { Scene } from "babylonjs/scene";
  43056. import { Vector3 } from "babylonjs/Maths/math.vector";
  43057. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43058. /**
  43059. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43060. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43061. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43062. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43063. */
  43064. export class VirtualJoysticksCamera extends FreeCamera {
  43065. /**
  43066. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43067. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43068. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43069. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43070. * @param name Define the name of the camera in the scene
  43071. * @param position Define the start position of the camera in the scene
  43072. * @param scene Define the scene the camera belongs to
  43073. */
  43074. constructor(name: string, position: Vector3, scene: Scene);
  43075. /**
  43076. * Gets the current object class name.
  43077. * @return the class name
  43078. */
  43079. getClassName(): string;
  43080. }
  43081. }
  43082. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43083. import { Matrix } from "babylonjs/Maths/math.vector";
  43084. /**
  43085. * This represents all the required metrics to create a VR camera.
  43086. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43087. */
  43088. export class VRCameraMetrics {
  43089. /**
  43090. * Define the horizontal resolution off the screen.
  43091. */
  43092. hResolution: number;
  43093. /**
  43094. * Define the vertical resolution off the screen.
  43095. */
  43096. vResolution: number;
  43097. /**
  43098. * Define the horizontal screen size.
  43099. */
  43100. hScreenSize: number;
  43101. /**
  43102. * Define the vertical screen size.
  43103. */
  43104. vScreenSize: number;
  43105. /**
  43106. * Define the vertical screen center position.
  43107. */
  43108. vScreenCenter: number;
  43109. /**
  43110. * Define the distance of the eyes to the screen.
  43111. */
  43112. eyeToScreenDistance: number;
  43113. /**
  43114. * Define the distance between both lenses
  43115. */
  43116. lensSeparationDistance: number;
  43117. /**
  43118. * Define the distance between both viewer's eyes.
  43119. */
  43120. interpupillaryDistance: number;
  43121. /**
  43122. * Define the distortion factor of the VR postprocess.
  43123. * Please, touch with care.
  43124. */
  43125. distortionK: number[];
  43126. /**
  43127. * Define the chromatic aberration correction factors for the VR post process.
  43128. */
  43129. chromaAbCorrection: number[];
  43130. /**
  43131. * Define the scale factor of the post process.
  43132. * The smaller the better but the slower.
  43133. */
  43134. postProcessScaleFactor: number;
  43135. /**
  43136. * Define an offset for the lens center.
  43137. */
  43138. lensCenterOffset: number;
  43139. /**
  43140. * Define if the current vr camera should compensate the distortion of the lense or not.
  43141. */
  43142. compensateDistortion: boolean;
  43143. /**
  43144. * Defines if multiview should be enabled when rendering (Default: false)
  43145. */
  43146. multiviewEnabled: boolean;
  43147. /**
  43148. * Gets the rendering aspect ratio based on the provided resolutions.
  43149. */
  43150. get aspectRatio(): number;
  43151. /**
  43152. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43153. */
  43154. get aspectRatioFov(): number;
  43155. /**
  43156. * @hidden
  43157. */
  43158. get leftHMatrix(): Matrix;
  43159. /**
  43160. * @hidden
  43161. */
  43162. get rightHMatrix(): Matrix;
  43163. /**
  43164. * @hidden
  43165. */
  43166. get leftPreViewMatrix(): Matrix;
  43167. /**
  43168. * @hidden
  43169. */
  43170. get rightPreViewMatrix(): Matrix;
  43171. /**
  43172. * Get the default VRMetrics based on the most generic setup.
  43173. * @returns the default vr metrics
  43174. */
  43175. static GetDefault(): VRCameraMetrics;
  43176. }
  43177. }
  43178. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43179. /** @hidden */
  43180. export var vrDistortionCorrectionPixelShader: {
  43181. name: string;
  43182. shader: string;
  43183. };
  43184. }
  43185. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43186. import { Camera } from "babylonjs/Cameras/camera";
  43187. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43188. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43189. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43190. /**
  43191. * VRDistortionCorrectionPostProcess used for mobile VR
  43192. */
  43193. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43194. private _isRightEye;
  43195. private _distortionFactors;
  43196. private _postProcessScaleFactor;
  43197. private _lensCenterOffset;
  43198. private _scaleIn;
  43199. private _scaleFactor;
  43200. private _lensCenter;
  43201. /**
  43202. * Initializes the VRDistortionCorrectionPostProcess
  43203. * @param name The name of the effect.
  43204. * @param camera The camera to apply the render pass to.
  43205. * @param isRightEye If this is for the right eye distortion
  43206. * @param vrMetrics All the required metrics for the VR camera
  43207. */
  43208. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43209. }
  43210. }
  43211. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43212. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43213. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43214. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43215. import { Scene } from "babylonjs/scene";
  43216. import { Vector3 } from "babylonjs/Maths/math.vector";
  43217. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43218. import "babylonjs/Cameras/RigModes/vrRigMode";
  43219. /**
  43220. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43221. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43222. */
  43223. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43224. /**
  43225. * Creates a new VRDeviceOrientationArcRotateCamera
  43226. * @param name defines camera name
  43227. * @param alpha defines the camera rotation along the logitudinal axis
  43228. * @param beta defines the camera rotation along the latitudinal axis
  43229. * @param radius defines the camera distance from its target
  43230. * @param target defines the camera target
  43231. * @param scene defines the scene the camera belongs to
  43232. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43233. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43234. */
  43235. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43236. /**
  43237. * Gets camera class name
  43238. * @returns VRDeviceOrientationArcRotateCamera
  43239. */
  43240. getClassName(): string;
  43241. }
  43242. }
  43243. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43244. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43245. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43246. import { Scene } from "babylonjs/scene";
  43247. import { Vector3 } from "babylonjs/Maths/math.vector";
  43248. import "babylonjs/Cameras/RigModes/vrRigMode";
  43249. /**
  43250. * Camera used to simulate VR rendering (based on FreeCamera)
  43251. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43252. */
  43253. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43254. /**
  43255. * Creates a new VRDeviceOrientationFreeCamera
  43256. * @param name defines camera name
  43257. * @param position defines the start position of the camera
  43258. * @param scene defines the scene the camera belongs to
  43259. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43260. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43261. */
  43262. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43263. /**
  43264. * Gets camera class name
  43265. * @returns VRDeviceOrientationFreeCamera
  43266. */
  43267. getClassName(): string;
  43268. }
  43269. }
  43270. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43271. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43272. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43273. import { Scene } from "babylonjs/scene";
  43274. import { Vector3 } from "babylonjs/Maths/math.vector";
  43275. import "babylonjs/Gamepads/gamepadSceneComponent";
  43276. /**
  43277. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43278. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43279. */
  43280. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43281. /**
  43282. * Creates a new VRDeviceOrientationGamepadCamera
  43283. * @param name defines camera name
  43284. * @param position defines the start position of the camera
  43285. * @param scene defines the scene the camera belongs to
  43286. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43287. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43288. */
  43289. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43290. /**
  43291. * Gets camera class name
  43292. * @returns VRDeviceOrientationGamepadCamera
  43293. */
  43294. getClassName(): string;
  43295. }
  43296. }
  43297. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43298. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43299. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43300. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43301. /** @hidden */
  43302. export var imageProcessingPixelShader: {
  43303. name: string;
  43304. shader: string;
  43305. };
  43306. }
  43307. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43308. import { Nullable } from "babylonjs/types";
  43309. import { Color4 } from "babylonjs/Maths/math.color";
  43310. import { Camera } from "babylonjs/Cameras/camera";
  43311. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43312. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43313. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43314. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43315. import { Engine } from "babylonjs/Engines/engine";
  43316. import "babylonjs/Shaders/imageProcessing.fragment";
  43317. import "babylonjs/Shaders/postprocess.vertex";
  43318. /**
  43319. * ImageProcessingPostProcess
  43320. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43321. */
  43322. export class ImageProcessingPostProcess extends PostProcess {
  43323. /**
  43324. * Default configuration related to image processing available in the PBR Material.
  43325. */
  43326. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43327. /**
  43328. * Gets the image processing configuration used either in this material.
  43329. */
  43330. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43331. /**
  43332. * Sets the Default image processing configuration used either in the this material.
  43333. *
  43334. * If sets to null, the scene one is in use.
  43335. */
  43336. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43337. /**
  43338. * Keep track of the image processing observer to allow dispose and replace.
  43339. */
  43340. private _imageProcessingObserver;
  43341. /**
  43342. * Attaches a new image processing configuration to the PBR Material.
  43343. * @param configuration
  43344. */
  43345. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43346. /**
  43347. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43348. */
  43349. get colorCurves(): Nullable<ColorCurves>;
  43350. /**
  43351. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43352. */
  43353. set colorCurves(value: Nullable<ColorCurves>);
  43354. /**
  43355. * Gets wether the color curves effect is enabled.
  43356. */
  43357. get colorCurvesEnabled(): boolean;
  43358. /**
  43359. * Sets wether the color curves effect is enabled.
  43360. */
  43361. set colorCurvesEnabled(value: boolean);
  43362. /**
  43363. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43364. */
  43365. get colorGradingTexture(): Nullable<BaseTexture>;
  43366. /**
  43367. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43368. */
  43369. set colorGradingTexture(value: Nullable<BaseTexture>);
  43370. /**
  43371. * Gets wether the color grading effect is enabled.
  43372. */
  43373. get colorGradingEnabled(): boolean;
  43374. /**
  43375. * Gets wether the color grading effect is enabled.
  43376. */
  43377. set colorGradingEnabled(value: boolean);
  43378. /**
  43379. * Gets exposure used in the effect.
  43380. */
  43381. get exposure(): number;
  43382. /**
  43383. * Sets exposure used in the effect.
  43384. */
  43385. set exposure(value: number);
  43386. /**
  43387. * Gets wether tonemapping is enabled or not.
  43388. */
  43389. get toneMappingEnabled(): boolean;
  43390. /**
  43391. * Sets wether tonemapping is enabled or not
  43392. */
  43393. set toneMappingEnabled(value: boolean);
  43394. /**
  43395. * Gets the type of tone mapping effect.
  43396. */
  43397. get toneMappingType(): number;
  43398. /**
  43399. * Sets the type of tone mapping effect.
  43400. */
  43401. set toneMappingType(value: number);
  43402. /**
  43403. * Gets contrast used in the effect.
  43404. */
  43405. get contrast(): number;
  43406. /**
  43407. * Sets contrast used in the effect.
  43408. */
  43409. set contrast(value: number);
  43410. /**
  43411. * Gets Vignette stretch size.
  43412. */
  43413. get vignetteStretch(): number;
  43414. /**
  43415. * Sets Vignette stretch size.
  43416. */
  43417. set vignetteStretch(value: number);
  43418. /**
  43419. * Gets Vignette centre X Offset.
  43420. */
  43421. get vignetteCentreX(): number;
  43422. /**
  43423. * Sets Vignette centre X Offset.
  43424. */
  43425. set vignetteCentreX(value: number);
  43426. /**
  43427. * Gets Vignette centre Y Offset.
  43428. */
  43429. get vignetteCentreY(): number;
  43430. /**
  43431. * Sets Vignette centre Y Offset.
  43432. */
  43433. set vignetteCentreY(value: number);
  43434. /**
  43435. * Gets Vignette weight or intensity of the vignette effect.
  43436. */
  43437. get vignetteWeight(): number;
  43438. /**
  43439. * Sets Vignette weight or intensity of the vignette effect.
  43440. */
  43441. set vignetteWeight(value: number);
  43442. /**
  43443. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43444. * if vignetteEnabled is set to true.
  43445. */
  43446. get vignetteColor(): Color4;
  43447. /**
  43448. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43449. * if vignetteEnabled is set to true.
  43450. */
  43451. set vignetteColor(value: Color4);
  43452. /**
  43453. * Gets Camera field of view used by the Vignette effect.
  43454. */
  43455. get vignetteCameraFov(): number;
  43456. /**
  43457. * Sets Camera field of view used by the Vignette effect.
  43458. */
  43459. set vignetteCameraFov(value: number);
  43460. /**
  43461. * Gets the vignette blend mode allowing different kind of effect.
  43462. */
  43463. get vignetteBlendMode(): number;
  43464. /**
  43465. * Sets the vignette blend mode allowing different kind of effect.
  43466. */
  43467. set vignetteBlendMode(value: number);
  43468. /**
  43469. * Gets wether the vignette effect is enabled.
  43470. */
  43471. get vignetteEnabled(): boolean;
  43472. /**
  43473. * Sets wether the vignette effect is enabled.
  43474. */
  43475. set vignetteEnabled(value: boolean);
  43476. private _fromLinearSpace;
  43477. /**
  43478. * Gets wether the input of the processing is in Gamma or Linear Space.
  43479. */
  43480. get fromLinearSpace(): boolean;
  43481. /**
  43482. * Sets wether the input of the processing is in Gamma or Linear Space.
  43483. */
  43484. set fromLinearSpace(value: boolean);
  43485. /**
  43486. * Defines cache preventing GC.
  43487. */
  43488. private _defines;
  43489. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43490. /**
  43491. * "ImageProcessingPostProcess"
  43492. * @returns "ImageProcessingPostProcess"
  43493. */
  43494. getClassName(): string;
  43495. protected _updateParameters(): void;
  43496. dispose(camera?: Camera): void;
  43497. }
  43498. }
  43499. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43500. import { Scene } from "babylonjs/scene";
  43501. import { Color3 } from "babylonjs/Maths/math.color";
  43502. import { Mesh } from "babylonjs/Meshes/mesh";
  43503. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43504. import { Nullable } from "babylonjs/types";
  43505. /**
  43506. * Class containing static functions to help procedurally build meshes
  43507. */
  43508. export class GroundBuilder {
  43509. /**
  43510. * Creates a ground mesh
  43511. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43512. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43514. * @param name defines the name of the mesh
  43515. * @param options defines the options used to create the mesh
  43516. * @param scene defines the hosting scene
  43517. * @returns the ground mesh
  43518. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43519. */
  43520. static CreateGround(name: string, options: {
  43521. width?: number;
  43522. height?: number;
  43523. subdivisions?: number;
  43524. subdivisionsX?: number;
  43525. subdivisionsY?: number;
  43526. updatable?: boolean;
  43527. }, scene: any): Mesh;
  43528. /**
  43529. * Creates a tiled ground mesh
  43530. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43531. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43532. * * 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
  43533. * * 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
  43534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43535. * @param name defines the name of the mesh
  43536. * @param options defines the options used to create the mesh
  43537. * @param scene defines the hosting scene
  43538. * @returns the tiled ground mesh
  43539. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43540. */
  43541. static CreateTiledGround(name: string, options: {
  43542. xmin: number;
  43543. zmin: number;
  43544. xmax: number;
  43545. zmax: number;
  43546. subdivisions?: {
  43547. w: number;
  43548. h: number;
  43549. };
  43550. precision?: {
  43551. w: number;
  43552. h: number;
  43553. };
  43554. updatable?: boolean;
  43555. }, scene?: Nullable<Scene>): Mesh;
  43556. /**
  43557. * Creates a ground mesh from a height map
  43558. * * The parameter `url` sets the URL of the height map image resource.
  43559. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43560. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43561. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43562. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43563. * * 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.
  43564. * * 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).
  43565. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43567. * @param name defines the name of the mesh
  43568. * @param url defines the url to the height map
  43569. * @param options defines the options used to create the mesh
  43570. * @param scene defines the hosting scene
  43571. * @returns the ground mesh
  43572. * @see https://doc.babylonjs.com/babylon101/height_map
  43573. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43574. */
  43575. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43576. width?: number;
  43577. height?: number;
  43578. subdivisions?: number;
  43579. minHeight?: number;
  43580. maxHeight?: number;
  43581. colorFilter?: Color3;
  43582. alphaFilter?: number;
  43583. updatable?: boolean;
  43584. onReady?: (mesh: GroundMesh) => void;
  43585. }, scene?: Nullable<Scene>): GroundMesh;
  43586. }
  43587. }
  43588. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43589. import { Vector4 } from "babylonjs/Maths/math.vector";
  43590. import { Mesh } from "babylonjs/Meshes/mesh";
  43591. /**
  43592. * Class containing static functions to help procedurally build meshes
  43593. */
  43594. export class TorusBuilder {
  43595. /**
  43596. * Creates a torus mesh
  43597. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43598. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43599. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43600. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43601. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43603. * @param name defines the name of the mesh
  43604. * @param options defines the options used to create the mesh
  43605. * @param scene defines the hosting scene
  43606. * @returns the torus mesh
  43607. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43608. */
  43609. static CreateTorus(name: string, options: {
  43610. diameter?: number;
  43611. thickness?: number;
  43612. tessellation?: number;
  43613. updatable?: boolean;
  43614. sideOrientation?: number;
  43615. frontUVs?: Vector4;
  43616. backUVs?: Vector4;
  43617. }, scene: any): Mesh;
  43618. }
  43619. }
  43620. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43621. import { Vector4 } from "babylonjs/Maths/math.vector";
  43622. import { Color4 } from "babylonjs/Maths/math.color";
  43623. import { Mesh } from "babylonjs/Meshes/mesh";
  43624. /**
  43625. * Class containing static functions to help procedurally build meshes
  43626. */
  43627. export class CylinderBuilder {
  43628. /**
  43629. * Creates a cylinder or a cone mesh
  43630. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43631. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43632. * * 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.
  43633. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43634. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43635. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43636. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43637. * * 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).
  43638. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43639. * * 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).
  43640. * * 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
  43641. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43642. * * 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
  43643. * * 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.
  43644. * * If `enclose` is false, a ring surface is one element.
  43645. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43646. * * 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
  43647. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43648. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43650. * @param name defines the name of the mesh
  43651. * @param options defines the options used to create the mesh
  43652. * @param scene defines the hosting scene
  43653. * @returns the cylinder mesh
  43654. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43655. */
  43656. static CreateCylinder(name: string, options: {
  43657. height?: number;
  43658. diameterTop?: number;
  43659. diameterBottom?: number;
  43660. diameter?: number;
  43661. tessellation?: number;
  43662. subdivisions?: number;
  43663. arc?: number;
  43664. faceColors?: Color4[];
  43665. faceUV?: Vector4[];
  43666. updatable?: boolean;
  43667. hasRings?: boolean;
  43668. enclose?: boolean;
  43669. cap?: number;
  43670. sideOrientation?: number;
  43671. frontUVs?: Vector4;
  43672. backUVs?: Vector4;
  43673. }, scene: any): Mesh;
  43674. }
  43675. }
  43676. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43677. import { Nullable } from "babylonjs/types";
  43678. import { IDisposable } from "babylonjs/scene";
  43679. /**
  43680. * States of the webXR experience
  43681. */
  43682. export enum WebXRState {
  43683. /**
  43684. * Transitioning to being in XR mode
  43685. */
  43686. ENTERING_XR = 0,
  43687. /**
  43688. * Transitioning to non XR mode
  43689. */
  43690. EXITING_XR = 1,
  43691. /**
  43692. * In XR mode and presenting
  43693. */
  43694. IN_XR = 2,
  43695. /**
  43696. * Not entered XR mode
  43697. */
  43698. NOT_IN_XR = 3
  43699. }
  43700. /**
  43701. * Abstraction of the XR render target
  43702. */
  43703. export interface WebXRRenderTarget extends IDisposable {
  43704. /**
  43705. * xrpresent context of the canvas which can be used to display/mirror xr content
  43706. */
  43707. canvasContext: WebGLRenderingContext;
  43708. /**
  43709. * xr layer for the canvas
  43710. */
  43711. xrLayer: Nullable<XRWebGLLayer>;
  43712. /**
  43713. * Initializes the xr layer for the session
  43714. * @param xrSession xr session
  43715. * @returns a promise that will resolve once the XR Layer has been created
  43716. */
  43717. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43718. }
  43719. }
  43720. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43721. import { Nullable } from "babylonjs/types";
  43722. import { Observable } from "babylonjs/Misc/observable";
  43723. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43724. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43725. /**
  43726. * COnfiguration object for WebXR output canvas
  43727. */
  43728. export class WebXRManagedOutputCanvasOptions {
  43729. /**
  43730. * Options for this XR Layer output
  43731. */
  43732. canvasOptions: XRWebGLLayerOptions;
  43733. /**
  43734. * CSS styling for a newly created canvas (if not provided)
  43735. */
  43736. newCanvasCssStyle?: string;
  43737. /**
  43738. * Get the default values of the configuration object
  43739. * @returns default values of this configuration object
  43740. */
  43741. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43742. }
  43743. /**
  43744. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43745. */
  43746. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43747. private configuration;
  43748. private _engine;
  43749. private _canvas;
  43750. /**
  43751. * xrpresent context of the canvas which can be used to display/mirror xr content
  43752. */
  43753. canvasContext: WebGLRenderingContext;
  43754. /**
  43755. * xr layer for the canvas
  43756. */
  43757. xrLayer: Nullable<XRWebGLLayer>;
  43758. /**
  43759. * Initializes the xr layer for the session
  43760. * @param xrSession xr session
  43761. * @returns a promise that will resolve once the XR Layer has been created
  43762. */
  43763. initializeXRLayerAsync(xrSession: any): any;
  43764. /**
  43765. * Initializes the canvas to be added/removed upon entering/exiting xr
  43766. * @param engine the Babylon engine
  43767. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43768. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43769. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  43770. */
  43771. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  43772. /**
  43773. * Disposes of the object
  43774. */
  43775. dispose(): void;
  43776. private _setManagedOutputCanvas;
  43777. private _addCanvas;
  43778. private _removeCanvas;
  43779. }
  43780. }
  43781. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43782. import { Observable } from "babylonjs/Misc/observable";
  43783. import { Nullable } from "babylonjs/types";
  43784. import { IDisposable, Scene } from "babylonjs/scene";
  43785. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43786. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43787. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43788. /**
  43789. * Manages an XRSession to work with Babylon's engine
  43790. * @see https://doc.babylonjs.com/how_to/webxr
  43791. */
  43792. export class WebXRSessionManager implements IDisposable {
  43793. /** The scene which the session should be created for */
  43794. scene: Scene;
  43795. /**
  43796. * Fires every time a new xrFrame arrives which can be used to update the camera
  43797. */
  43798. onXRFrameObservable: Observable<XRFrame>;
  43799. /**
  43800. * Fires when the xr session is ended either by the device or manually done
  43801. */
  43802. onXRSessionEnded: Observable<any>;
  43803. /**
  43804. * Fires when the xr session is ended either by the device or manually done
  43805. */
  43806. onXRSessionInit: Observable<XRSession>;
  43807. /**
  43808. * Underlying xr session
  43809. */
  43810. session: XRSession;
  43811. /**
  43812. * Type of reference space used when creating the session
  43813. */
  43814. referenceSpace: XRReferenceSpace;
  43815. /**
  43816. * Current XR frame
  43817. */
  43818. currentFrame: Nullable<XRFrame>;
  43819. /** WebXR timestamp updated every frame */
  43820. currentTimestamp: number;
  43821. private _xrNavigator;
  43822. private baseLayer;
  43823. private _rttProvider;
  43824. private _sessionEnded;
  43825. /**
  43826. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43827. * @param scene The scene which the session should be created for
  43828. */
  43829. constructor(
  43830. /** The scene which the session should be created for */
  43831. scene: Scene);
  43832. /**
  43833. * Initializes the manager
  43834. * After initialization enterXR can be called to start an XR session
  43835. * @returns Promise which resolves after it is initialized
  43836. */
  43837. initializeAsync(): Promise<void>;
  43838. /**
  43839. * Initializes an xr session
  43840. * @param xrSessionMode mode to initialize
  43841. * @param optionalFeatures defines optional values to pass to the session builder
  43842. * @returns a promise which will resolve once the session has been initialized
  43843. */
  43844. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  43845. /**
  43846. * Sets the reference space on the xr session
  43847. * @param referenceSpace space to set
  43848. * @returns a promise that will resolve once the reference space has been set
  43849. */
  43850. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43851. /**
  43852. * Updates the render state of the session
  43853. * @param state state to set
  43854. * @returns a promise that resolves once the render state has been updated
  43855. */
  43856. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43857. /**
  43858. * Starts rendering to the xr layer
  43859. * @returns a promise that will resolve once rendering has started
  43860. */
  43861. startRenderingToXRAsync(): Promise<void>;
  43862. /**
  43863. * Gets the correct render target texture to be rendered this frame for this eye
  43864. * @param eye the eye for which to get the render target
  43865. * @returns the render target for the specified eye
  43866. */
  43867. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43868. /**
  43869. * Stops the xrSession and restores the renderloop
  43870. * @returns Promise which resolves after it exits XR
  43871. */
  43872. exitXRAsync(): Promise<void>;
  43873. /**
  43874. * Checks if a session would be supported for the creation options specified
  43875. * @param sessionMode session mode to check if supported eg. immersive-vr
  43876. * @returns true if supported
  43877. */
  43878. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43879. /**
  43880. * Creates a WebXRRenderTarget object for the XR session
  43881. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43882. * @param options optional options to provide when creating a new render target
  43883. * @returns a WebXR render target to which the session can render
  43884. */
  43885. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43886. /**
  43887. * @hidden
  43888. * Converts the render layer of xrSession to a render target
  43889. * @param session session to create render target for
  43890. * @param scene scene the new render target should be created for
  43891. * @param baseLayer the webgl layer to create the render target for
  43892. */
  43893. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43894. /**
  43895. * Disposes of the session manager
  43896. */
  43897. dispose(): void;
  43898. /**
  43899. * Gets a promise returning true when fullfiled if the given session mode is supported
  43900. * @param sessionMode defines the session to test
  43901. * @returns a promise
  43902. */
  43903. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43904. }
  43905. }
  43906. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43907. import { Scene } from "babylonjs/scene";
  43908. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43909. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43910. /**
  43911. * WebXR Camera which holds the views for the xrSession
  43912. * @see https://doc.babylonjs.com/how_to/webxr
  43913. */
  43914. export class WebXRCamera extends FreeCamera {
  43915. /**
  43916. * Is the camera in debug mode. Used when using an emulator
  43917. */
  43918. debugMode: boolean;
  43919. /**
  43920. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43921. * @param name the name of the camera
  43922. * @param scene the scene to add the camera to
  43923. */
  43924. constructor(name: string, scene: Scene);
  43925. private _updateNumberOfRigCameras;
  43926. /** @hidden */
  43927. _updateForDualEyeDebugging(): void;
  43928. /**
  43929. * Updates the cameras position from the current pose information of the XR session
  43930. * @param xrSessionManager the session containing pose information
  43931. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43932. */
  43933. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43934. }
  43935. }
  43936. declare module "babylonjs/Cameras/XR/webXRFeaturesManager" {
  43937. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43938. import { IDisposable } from "babylonjs/scene";
  43939. /**
  43940. * Defining the interface required for a (webxr) feature
  43941. */
  43942. export interface IWebXRFeature extends IDisposable {
  43943. /**
  43944. * Attach the feature to the session
  43945. * Will usually be called by the features manager
  43946. *
  43947. * @returns true if successful.
  43948. */
  43949. attach(): boolean;
  43950. /**
  43951. * Detach the feature from the session
  43952. * Will usually be called by the features manager
  43953. *
  43954. * @returns true if successful.
  43955. */
  43956. detach(): boolean;
  43957. }
  43958. /**
  43959. * Defining the constructor of a feature. Used to register the modules.
  43960. */
  43961. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43962. /**
  43963. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43964. * It is mainly used in AR sessions.
  43965. *
  43966. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43967. */
  43968. export class WebXRFeaturesManager implements IDisposable {
  43969. private _xrSessionManager;
  43970. private static readonly _AvailableFeatures;
  43971. /**
  43972. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43973. * Mainly used internally.
  43974. *
  43975. * @param featureName the name of the feature to register
  43976. * @param constructorFunction the function used to construct the module
  43977. * @param version the (babylon) version of the module
  43978. * @param stable is that a stable version of this module
  43979. */
  43980. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43981. /**
  43982. * Returns a constructor of a specific feature.
  43983. *
  43984. * @param featureName the name of the feature to construct
  43985. * @param version the version of the feature to load
  43986. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43987. * @param options optional options provided to the module.
  43988. * @returns a function that, when called, will return a new instance of this feature
  43989. */
  43990. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43991. /**
  43992. * Return the latest unstable version of this feature
  43993. * @param featureName the name of the feature to search
  43994. * @returns the version number. if not found will return -1
  43995. */
  43996. static GetLatestVersionOfFeature(featureName: string): number;
  43997. /**
  43998. * Return the latest stable version of this feature
  43999. * @param featureName the name of the feature to search
  44000. * @returns the version number. if not found will return -1
  44001. */
  44002. static GetStableVersionOfFeature(featureName: string): number;
  44003. /**
  44004. * Can be used to return the list of features currently registered
  44005. *
  44006. * @returns an Array of available features
  44007. */
  44008. static GetAvailableFeatures(): string[];
  44009. /**
  44010. * Gets the versions available for a specific feature
  44011. * @param featureName the name of the feature
  44012. * @returns an array with the available versions
  44013. */
  44014. static GetAvailableVersions(featureName: string): string[];
  44015. private _features;
  44016. /**
  44017. * constructs a new features manages.
  44018. *
  44019. * @param _xrSessionManager an instance of WebXRSessionManager
  44020. */
  44021. constructor(_xrSessionManager: WebXRSessionManager);
  44022. /**
  44023. * 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.
  44024. *
  44025. * @param featureName the name of the feature to load or the class of the feature
  44026. * @param version optional version to load. if not provided the latest version will be enabled
  44027. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44028. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44029. * @returns a new constructed feature or throws an error if feature not found.
  44030. */
  44031. enableFeature(featureName: string | {
  44032. Name: string;
  44033. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44034. /**
  44035. * Used to disable an already-enabled feature
  44036. * @param featureName the feature to disable
  44037. * @returns true if disable was successful
  44038. */
  44039. disableFeature(featureName: string | {
  44040. Name: string;
  44041. }): boolean;
  44042. /**
  44043. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44044. * Can be used during a session to start a feature
  44045. * @param featureName the name of feature to attach
  44046. */
  44047. attachFeature(featureName: string): void;
  44048. /**
  44049. * Can be used inside a session or when the session ends to detach a specific feature
  44050. * @param featureName the name of the feature to detach
  44051. */
  44052. detachFeature(featureName: string): void;
  44053. /**
  44054. * Get the list of enabled features
  44055. * @returns an array of enabled features
  44056. */
  44057. getEnabledFeatures(): string[];
  44058. /**
  44059. * get the implementation of an enabled feature.
  44060. * @param featureName the name of the feature to load
  44061. * @returns the feature class, if found
  44062. */
  44063. getEnabledFeature(featureName: string): IWebXRFeature;
  44064. /**
  44065. * dispose this features manager
  44066. */
  44067. dispose(): void;
  44068. }
  44069. }
  44070. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  44071. import { Observable } from "babylonjs/Misc/observable";
  44072. import { IDisposable, Scene } from "babylonjs/scene";
  44073. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  44074. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44075. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  44076. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  44077. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44078. import { WebXRFeaturesManager } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  44079. /**
  44080. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  44081. * @see https://doc.babylonjs.com/how_to/webxr
  44082. */
  44083. export class WebXRExperienceHelper implements IDisposable {
  44084. private scene;
  44085. /**
  44086. * 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
  44087. */
  44088. container: AbstractMesh;
  44089. /**
  44090. * Camera used to render xr content
  44091. */
  44092. camera: WebXRCamera;
  44093. /**
  44094. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44095. */
  44096. state: WebXRState;
  44097. private _setState;
  44098. private static _TmpVector;
  44099. /**
  44100. * Fires when the state of the experience helper has changed
  44101. */
  44102. onStateChangedObservable: Observable<WebXRState>;
  44103. /** Session manager used to keep track of xr session */
  44104. sessionManager: WebXRSessionManager;
  44105. /** A features manager for this xr session */
  44106. featuresManager: WebXRFeaturesManager;
  44107. private _nonVRCamera;
  44108. private _originalSceneAutoClear;
  44109. private _supported;
  44110. /**
  44111. * Creates the experience helper
  44112. * @param scene the scene to attach the experience helper to
  44113. * @returns a promise for the experience helper
  44114. */
  44115. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44116. /**
  44117. * Creates a WebXRExperienceHelper
  44118. * @param scene The scene the helper should be created in
  44119. */
  44120. private constructor();
  44121. /**
  44122. * Exits XR mode and returns the scene to its original state
  44123. * @returns promise that resolves after xr mode has exited
  44124. */
  44125. exitXRAsync(): Promise<void>;
  44126. /**
  44127. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44128. * @param sessionMode options for the XR session
  44129. * @param referenceSpaceType frame of reference of the XR session
  44130. * @param renderTarget the output canvas that will be used to enter XR mode
  44131. * @returns promise that resolves after xr mode has entered
  44132. */
  44133. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44134. /**
  44135. * Updates the global position of the camera by moving the camera's container
  44136. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  44137. * @param position The desired global position of the camera
  44138. */
  44139. setPositionOfCameraUsingContainer(position: Vector3): void;
  44140. /**
  44141. * Rotates the xr camera by rotating the camera's container around the camera's position
  44142. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  44143. * @param rotation the desired quaternion rotation to apply to the camera
  44144. */
  44145. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  44146. /**
  44147. * Disposes of the experience helper
  44148. */
  44149. dispose(): void;
  44150. }
  44151. }
  44152. declare module "babylonjs/Cameras/XR/webXRController" {
  44153. import { Nullable } from "babylonjs/types";
  44154. import { Observable } from "babylonjs/Misc/observable";
  44155. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44156. import { Ray } from "babylonjs/Culling/ray";
  44157. import { Scene } from "babylonjs/scene";
  44158. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44159. /**
  44160. * Represents an XR input
  44161. */
  44162. export class WebXRController {
  44163. private scene;
  44164. /** The underlying input source for the controller */
  44165. inputSource: XRInputSource;
  44166. private parentContainer;
  44167. /**
  44168. * 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
  44169. */
  44170. grip?: AbstractMesh;
  44171. /**
  44172. * Pointer which can be used to select objects or attach a visible laser to
  44173. */
  44174. pointer: AbstractMesh;
  44175. private _gamepadMode;
  44176. /**
  44177. * If available, this is the gamepad object related to this controller.
  44178. * Using this object it is possible to get click events and trackpad changes of the
  44179. * webxr controller that is currently being used.
  44180. */
  44181. gamepadController?: WebVRController;
  44182. /**
  44183. * Event that fires when the controller is removed/disposed
  44184. */
  44185. onDisposeObservable: Observable<{}>;
  44186. private _tmpQuaternion;
  44187. private _tmpVector;
  44188. /**
  44189. * Creates the controller
  44190. * @see https://doc.babylonjs.com/how_to/webxr
  44191. * @param scene the scene which the controller should be associated to
  44192. * @param inputSource the underlying input source for the controller
  44193. * @param parentContainer parent that the controller meshes should be children of
  44194. */
  44195. constructor(scene: Scene,
  44196. /** The underlying input source for the controller */
  44197. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  44198. /**
  44199. * Updates the controller pose based on the given XRFrame
  44200. * @param xrFrame xr frame to update the pose with
  44201. * @param referenceSpace reference space to use
  44202. */
  44203. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44204. /**
  44205. * Gets a world space ray coming from the controller
  44206. * @param result the resulting ray
  44207. */
  44208. getWorldPointerRayToRef(result: Ray): void;
  44209. /**
  44210. * Get the scene associated with this controller
  44211. * @returns the scene object
  44212. */
  44213. getScene(): Scene;
  44214. /**
  44215. * Disposes of the object
  44216. */
  44217. dispose(): void;
  44218. }
  44219. }
  44220. declare module "babylonjs/Cameras/XR/webXRInput" {
  44221. import { Observable } from "babylonjs/Misc/observable";
  44222. import { IDisposable } from "babylonjs/scene";
  44223. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44224. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  44225. /**
  44226. * XR input used to track XR inputs such as controllers/rays
  44227. */
  44228. export class WebXRInput implements IDisposable {
  44229. /**
  44230. * Base experience the input listens to
  44231. */
  44232. baseExperience: WebXRExperienceHelper;
  44233. /**
  44234. * XR controllers being tracked
  44235. */
  44236. controllers: Array<WebXRController>;
  44237. private _frameObserver;
  44238. private _stateObserver;
  44239. /**
  44240. * Event when a controller has been connected/added
  44241. */
  44242. onControllerAddedObservable: Observable<WebXRController>;
  44243. /**
  44244. * Event when a controller has been removed/disconnected
  44245. */
  44246. onControllerRemovedObservable: Observable<WebXRController>;
  44247. /**
  44248. * Initializes the WebXRInput
  44249. * @param baseExperience experience helper which the input should be created for
  44250. */
  44251. constructor(
  44252. /**
  44253. * Base experience the input listens to
  44254. */
  44255. baseExperience: WebXRExperienceHelper);
  44256. private _onInputSourcesChange;
  44257. private _addAndRemoveControllers;
  44258. /**
  44259. * Disposes of the object
  44260. */
  44261. dispose(): void;
  44262. }
  44263. }
  44264. declare module "babylonjs/Loading/sceneLoader" {
  44265. import { Observable } from "babylonjs/Misc/observable";
  44266. import { Nullable } from "babylonjs/types";
  44267. import { Scene } from "babylonjs/scene";
  44268. import { Engine } from "babylonjs/Engines/engine";
  44269. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44270. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44271. import { AssetContainer } from "babylonjs/assetContainer";
  44272. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44273. import { Skeleton } from "babylonjs/Bones/skeleton";
  44274. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44275. import { WebRequest } from "babylonjs/Misc/webRequest";
  44276. /**
  44277. * Class used to represent data loading progression
  44278. */
  44279. export class SceneLoaderProgressEvent {
  44280. /** defines if data length to load can be evaluated */
  44281. readonly lengthComputable: boolean;
  44282. /** defines the loaded data length */
  44283. readonly loaded: number;
  44284. /** defines the data length to load */
  44285. readonly total: number;
  44286. /**
  44287. * Create a new progress event
  44288. * @param lengthComputable defines if data length to load can be evaluated
  44289. * @param loaded defines the loaded data length
  44290. * @param total defines the data length to load
  44291. */
  44292. constructor(
  44293. /** defines if data length to load can be evaluated */
  44294. lengthComputable: boolean,
  44295. /** defines the loaded data length */
  44296. loaded: number,
  44297. /** defines the data length to load */
  44298. total: number);
  44299. /**
  44300. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44301. * @param event defines the source event
  44302. * @returns a new SceneLoaderProgressEvent
  44303. */
  44304. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44305. }
  44306. /**
  44307. * Interface used by SceneLoader plugins to define supported file extensions
  44308. */
  44309. export interface ISceneLoaderPluginExtensions {
  44310. /**
  44311. * Defines the list of supported extensions
  44312. */
  44313. [extension: string]: {
  44314. isBinary: boolean;
  44315. };
  44316. }
  44317. /**
  44318. * Interface used by SceneLoader plugin factory
  44319. */
  44320. export interface ISceneLoaderPluginFactory {
  44321. /**
  44322. * Defines the name of the factory
  44323. */
  44324. name: string;
  44325. /**
  44326. * Function called to create a new plugin
  44327. * @return the new plugin
  44328. */
  44329. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44330. /**
  44331. * The callback that returns true if the data can be directly loaded.
  44332. * @param data string containing the file data
  44333. * @returns if the data can be loaded directly
  44334. */
  44335. canDirectLoad?(data: string): boolean;
  44336. }
  44337. /**
  44338. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44339. */
  44340. export interface ISceneLoaderPluginBase {
  44341. /**
  44342. * The friendly name of this plugin.
  44343. */
  44344. name: string;
  44345. /**
  44346. * The file extensions supported by this plugin.
  44347. */
  44348. extensions: string | ISceneLoaderPluginExtensions;
  44349. /**
  44350. * The callback called when loading from a url.
  44351. * @param scene scene loading this url
  44352. * @param url url to load
  44353. * @param onSuccess callback called when the file successfully loads
  44354. * @param onProgress callback called while file is loading (if the server supports this mode)
  44355. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44356. * @param onError callback called when the file fails to load
  44357. * @returns a file request object
  44358. */
  44359. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44360. /**
  44361. * The callback called when loading from a file object.
  44362. * @param scene scene loading this file
  44363. * @param file defines the file to load
  44364. * @param onSuccess defines the callback to call when data is loaded
  44365. * @param onProgress defines the callback to call during loading process
  44366. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44367. * @param onError defines the callback to call when an error occurs
  44368. * @returns a file request object
  44369. */
  44370. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44371. /**
  44372. * The callback that returns true if the data can be directly loaded.
  44373. * @param data string containing the file data
  44374. * @returns if the data can be loaded directly
  44375. */
  44376. canDirectLoad?(data: string): boolean;
  44377. /**
  44378. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44379. * @param scene scene loading this data
  44380. * @param data string containing the data
  44381. * @returns data to pass to the plugin
  44382. */
  44383. directLoad?(scene: Scene, data: string): any;
  44384. /**
  44385. * The callback that allows custom handling of the root url based on the response url.
  44386. * @param rootUrl the original root url
  44387. * @param responseURL the response url if available
  44388. * @returns the new root url
  44389. */
  44390. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44391. }
  44392. /**
  44393. * Interface used to define a SceneLoader plugin
  44394. */
  44395. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44396. /**
  44397. * Import meshes into a scene.
  44398. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44399. * @param scene The scene to import into
  44400. * @param data The data to import
  44401. * @param rootUrl The root url for scene and resources
  44402. * @param meshes The meshes array to import into
  44403. * @param particleSystems The particle systems array to import into
  44404. * @param skeletons The skeletons array to import into
  44405. * @param onError The callback when import fails
  44406. * @returns True if successful or false otherwise
  44407. */
  44408. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44409. /**
  44410. * Load into a scene.
  44411. * @param scene The scene to load into
  44412. * @param data The data to import
  44413. * @param rootUrl The root url for scene and resources
  44414. * @param onError The callback when import fails
  44415. * @returns True if successful or false otherwise
  44416. */
  44417. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44418. /**
  44419. * Load into an asset container.
  44420. * @param scene The scene to load into
  44421. * @param data The data to import
  44422. * @param rootUrl The root url for scene and resources
  44423. * @param onError The callback when import fails
  44424. * @returns The loaded asset container
  44425. */
  44426. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44427. }
  44428. /**
  44429. * Interface used to define an async SceneLoader plugin
  44430. */
  44431. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44432. /**
  44433. * Import meshes into a scene.
  44434. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44435. * @param scene The scene to import into
  44436. * @param data The data to import
  44437. * @param rootUrl The root url for scene and resources
  44438. * @param onProgress The callback when the load progresses
  44439. * @param fileName Defines the name of the file to load
  44440. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44441. */
  44442. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44443. meshes: AbstractMesh[];
  44444. particleSystems: IParticleSystem[];
  44445. skeletons: Skeleton[];
  44446. animationGroups: AnimationGroup[];
  44447. }>;
  44448. /**
  44449. * Load into a scene.
  44450. * @param scene The scene to load into
  44451. * @param data The data to import
  44452. * @param rootUrl The root url for scene and resources
  44453. * @param onProgress The callback when the load progresses
  44454. * @param fileName Defines the name of the file to load
  44455. * @returns Nothing
  44456. */
  44457. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44458. /**
  44459. * Load into an asset container.
  44460. * @param scene The scene to load into
  44461. * @param data The data to import
  44462. * @param rootUrl The root url for scene and resources
  44463. * @param onProgress The callback when the load progresses
  44464. * @param fileName Defines the name of the file to load
  44465. * @returns The loaded asset container
  44466. */
  44467. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44468. }
  44469. /**
  44470. * Mode that determines how to handle old animation groups before loading new ones.
  44471. */
  44472. export enum SceneLoaderAnimationGroupLoadingMode {
  44473. /**
  44474. * Reset all old animations to initial state then dispose them.
  44475. */
  44476. Clean = 0,
  44477. /**
  44478. * Stop all old animations.
  44479. */
  44480. Stop = 1,
  44481. /**
  44482. * Restart old animations from first frame.
  44483. */
  44484. Sync = 2,
  44485. /**
  44486. * Old animations remains untouched.
  44487. */
  44488. NoSync = 3
  44489. }
  44490. /**
  44491. * Class used to load scene from various file formats using registered plugins
  44492. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44493. */
  44494. export class SceneLoader {
  44495. /**
  44496. * No logging while loading
  44497. */
  44498. static readonly NO_LOGGING: number;
  44499. /**
  44500. * Minimal logging while loading
  44501. */
  44502. static readonly MINIMAL_LOGGING: number;
  44503. /**
  44504. * Summary logging while loading
  44505. */
  44506. static readonly SUMMARY_LOGGING: number;
  44507. /**
  44508. * Detailled logging while loading
  44509. */
  44510. static readonly DETAILED_LOGGING: number;
  44511. /**
  44512. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44513. */
  44514. static get ForceFullSceneLoadingForIncremental(): boolean;
  44515. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44516. /**
  44517. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44518. */
  44519. static get ShowLoadingScreen(): boolean;
  44520. static set ShowLoadingScreen(value: boolean);
  44521. /**
  44522. * Defines the current logging level (while loading the scene)
  44523. * @ignorenaming
  44524. */
  44525. static get loggingLevel(): number;
  44526. static set loggingLevel(value: number);
  44527. /**
  44528. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44529. */
  44530. static get CleanBoneMatrixWeights(): boolean;
  44531. static set CleanBoneMatrixWeights(value: boolean);
  44532. /**
  44533. * Event raised when a plugin is used to load a scene
  44534. */
  44535. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44536. private static _registeredPlugins;
  44537. private static _getDefaultPlugin;
  44538. private static _getPluginForExtension;
  44539. private static _getPluginForDirectLoad;
  44540. private static _getPluginForFilename;
  44541. private static _getDirectLoad;
  44542. private static _loadData;
  44543. private static _getFileInfo;
  44544. /**
  44545. * Gets a plugin that can load the given extension
  44546. * @param extension defines the extension to load
  44547. * @returns a plugin or null if none works
  44548. */
  44549. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44550. /**
  44551. * Gets a boolean indicating that the given extension can be loaded
  44552. * @param extension defines the extension to load
  44553. * @returns true if the extension is supported
  44554. */
  44555. static IsPluginForExtensionAvailable(extension: string): boolean;
  44556. /**
  44557. * Adds a new plugin to the list of registered plugins
  44558. * @param plugin defines the plugin to add
  44559. */
  44560. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44561. /**
  44562. * Import meshes into a scene
  44563. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44564. * @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)
  44565. * @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)
  44566. * @param scene the instance of BABYLON.Scene to append to
  44567. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44568. * @param onProgress a callback with a progress event for each file being loaded
  44569. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44570. * @param pluginExtension the extension used to determine the plugin
  44571. * @returns The loaded plugin
  44572. */
  44573. 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>;
  44574. /**
  44575. * Import meshes into a scene
  44576. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44577. * @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)
  44578. * @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)
  44579. * @param scene the instance of BABYLON.Scene to append to
  44580. * @param onProgress a callback with a progress event for each file being loaded
  44581. * @param pluginExtension the extension used to determine the plugin
  44582. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44583. */
  44584. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44585. meshes: AbstractMesh[];
  44586. particleSystems: IParticleSystem[];
  44587. skeletons: Skeleton[];
  44588. animationGroups: AnimationGroup[];
  44589. }>;
  44590. /**
  44591. * Load a scene
  44592. * @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)
  44593. * @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)
  44594. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44595. * @param onSuccess a callback with the scene when import succeeds
  44596. * @param onProgress a callback with a progress event for each file being loaded
  44597. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44598. * @param pluginExtension the extension used to determine the plugin
  44599. * @returns The loaded plugin
  44600. */
  44601. 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>;
  44602. /**
  44603. * Load a scene
  44604. * @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)
  44605. * @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)
  44606. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44607. * @param onProgress a callback with a progress event for each file being loaded
  44608. * @param pluginExtension the extension used to determine the plugin
  44609. * @returns The loaded scene
  44610. */
  44611. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44612. /**
  44613. * Append a scene
  44614. * @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)
  44615. * @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)
  44616. * @param scene is the instance of BABYLON.Scene to append to
  44617. * @param onSuccess a callback with the scene when import succeeds
  44618. * @param onProgress a callback with a progress event for each file being loaded
  44619. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44620. * @param pluginExtension the extension used to determine the plugin
  44621. * @returns The loaded plugin
  44622. */
  44623. 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>;
  44624. /**
  44625. * Append a scene
  44626. * @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)
  44627. * @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)
  44628. * @param scene is the instance of BABYLON.Scene to append to
  44629. * @param onProgress a callback with a progress event for each file being loaded
  44630. * @param pluginExtension the extension used to determine the plugin
  44631. * @returns The given scene
  44632. */
  44633. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44634. /**
  44635. * Load a scene into an asset container
  44636. * @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)
  44637. * @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)
  44638. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44639. * @param onSuccess a callback with the scene when import succeeds
  44640. * @param onProgress a callback with a progress event for each file being loaded
  44641. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44642. * @param pluginExtension the extension used to determine the plugin
  44643. * @returns The loaded plugin
  44644. */
  44645. 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>;
  44646. /**
  44647. * Load a scene into an asset container
  44648. * @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)
  44649. * @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)
  44650. * @param scene is the instance of Scene to append to
  44651. * @param onProgress a callback with a progress event for each file being loaded
  44652. * @param pluginExtension the extension used to determine the plugin
  44653. * @returns The loaded asset container
  44654. */
  44655. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44656. /**
  44657. * Import animations from a file into a scene
  44658. * @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)
  44659. * @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)
  44660. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44661. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44662. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44663. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44664. * @param onSuccess a callback with the scene when import succeeds
  44665. * @param onProgress a callback with a progress event for each file being loaded
  44666. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44667. */
  44668. 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;
  44669. /**
  44670. * Import animations from a file into a scene
  44671. * @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)
  44672. * @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)
  44673. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44674. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44675. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44676. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44677. * @param onSuccess a callback with the scene when import succeeds
  44678. * @param onProgress a callback with a progress event for each file being loaded
  44679. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44680. * @returns the updated scene with imported animations
  44681. */
  44682. 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>;
  44683. }
  44684. }
  44685. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44686. import { Scene } from "babylonjs/scene";
  44687. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44688. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44689. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44690. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44691. /**
  44692. * Generic Controller
  44693. */
  44694. export class GenericController extends WebVRController {
  44695. /**
  44696. * Base Url for the controller model.
  44697. */
  44698. static readonly MODEL_BASE_URL: string;
  44699. /**
  44700. * File name for the controller model.
  44701. */
  44702. static readonly MODEL_FILENAME: string;
  44703. /**
  44704. * Creates a new GenericController from a gamepad
  44705. * @param vrGamepad the gamepad that the controller should be created from
  44706. */
  44707. constructor(vrGamepad: any);
  44708. /**
  44709. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44710. * @param scene scene in which to add meshes
  44711. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44712. */
  44713. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44714. /**
  44715. * Called once for each button that changed state since the last frame
  44716. * @param buttonIdx Which button index changed
  44717. * @param state New state of the button
  44718. * @param changes Which properties on the state changed since last frame
  44719. */
  44720. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44721. }
  44722. }
  44723. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44724. import { Observable } from "babylonjs/Misc/observable";
  44725. import { Scene } from "babylonjs/scene";
  44726. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44727. import { Ray } from "babylonjs/Culling/ray";
  44728. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44729. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44730. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44731. /**
  44732. * Defines the WindowsMotionController object that the state of the windows motion controller
  44733. */
  44734. export class WindowsMotionController extends WebVRController {
  44735. /**
  44736. * The base url used to load the left and right controller models
  44737. */
  44738. static MODEL_BASE_URL: string;
  44739. /**
  44740. * The name of the left controller model file
  44741. */
  44742. static MODEL_LEFT_FILENAME: string;
  44743. /**
  44744. * The name of the right controller model file
  44745. */
  44746. static MODEL_RIGHT_FILENAME: string;
  44747. /**
  44748. * The controller name prefix for this controller type
  44749. */
  44750. static readonly GAMEPAD_ID_PREFIX: string;
  44751. /**
  44752. * The controller id pattern for this controller type
  44753. */
  44754. private static readonly GAMEPAD_ID_PATTERN;
  44755. private _loadedMeshInfo;
  44756. protected readonly _mapping: {
  44757. buttons: string[];
  44758. buttonMeshNames: {
  44759. 'trigger': string;
  44760. 'menu': string;
  44761. 'grip': string;
  44762. 'thumbstick': string;
  44763. 'trackpad': string;
  44764. };
  44765. buttonObservableNames: {
  44766. 'trigger': string;
  44767. 'menu': string;
  44768. 'grip': string;
  44769. 'thumbstick': string;
  44770. 'trackpad': string;
  44771. };
  44772. axisMeshNames: string[];
  44773. pointingPoseMeshName: string;
  44774. };
  44775. /**
  44776. * Fired when the trackpad on this controller is clicked
  44777. */
  44778. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44779. /**
  44780. * Fired when the trackpad on this controller is modified
  44781. */
  44782. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44783. /**
  44784. * The current x and y values of this controller's trackpad
  44785. */
  44786. trackpad: StickValues;
  44787. /**
  44788. * Creates a new WindowsMotionController from a gamepad
  44789. * @param vrGamepad the gamepad that the controller should be created from
  44790. */
  44791. constructor(vrGamepad: any);
  44792. /**
  44793. * Fired when the trigger on this controller is modified
  44794. */
  44795. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44796. /**
  44797. * Fired when the menu button on this controller is modified
  44798. */
  44799. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44800. /**
  44801. * Fired when the grip button on this controller is modified
  44802. */
  44803. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44804. /**
  44805. * Fired when the thumbstick button on this controller is modified
  44806. */
  44807. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44808. /**
  44809. * Fired when the touchpad button on this controller is modified
  44810. */
  44811. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44812. /**
  44813. * Fired when the touchpad values on this controller are modified
  44814. */
  44815. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  44816. protected _updateTrackpad(): void;
  44817. /**
  44818. * Called once per frame by the engine.
  44819. */
  44820. update(): void;
  44821. /**
  44822. * Called once for each button that changed state since the last frame
  44823. * @param buttonIdx Which button index changed
  44824. * @param state New state of the button
  44825. * @param changes Which properties on the state changed since last frame
  44826. */
  44827. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44828. /**
  44829. * Moves the buttons on the controller mesh based on their current state
  44830. * @param buttonName the name of the button to move
  44831. * @param buttonValue the value of the button which determines the buttons new position
  44832. */
  44833. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44834. /**
  44835. * Moves the axis on the controller mesh based on its current state
  44836. * @param axis the index of the axis
  44837. * @param axisValue the value of the axis which determines the meshes new position
  44838. * @hidden
  44839. */
  44840. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44841. /**
  44842. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44843. * @param scene scene in which to add meshes
  44844. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44845. */
  44846. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44847. /**
  44848. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44849. * can be transformed by button presses and axes values, based on this._mapping.
  44850. *
  44851. * @param scene scene in which the meshes exist
  44852. * @param meshes list of meshes that make up the controller model to process
  44853. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44854. */
  44855. private processModel;
  44856. private createMeshInfo;
  44857. /**
  44858. * Gets the ray of the controller in the direction the controller is pointing
  44859. * @param length the length the resulting ray should be
  44860. * @returns a ray in the direction the controller is pointing
  44861. */
  44862. getForwardRay(length?: number): Ray;
  44863. /**
  44864. * Disposes of the controller
  44865. */
  44866. dispose(): void;
  44867. }
  44868. /**
  44869. * This class represents a new windows motion controller in XR.
  44870. */
  44871. export class XRWindowsMotionController extends WindowsMotionController {
  44872. /**
  44873. * Changing the original WIndowsMotionController mapping to fir the new mapping
  44874. */
  44875. protected readonly _mapping: {
  44876. buttons: string[];
  44877. buttonMeshNames: {
  44878. 'trigger': string;
  44879. 'menu': string;
  44880. 'grip': string;
  44881. 'thumbstick': string;
  44882. 'trackpad': string;
  44883. };
  44884. buttonObservableNames: {
  44885. 'trigger': string;
  44886. 'menu': string;
  44887. 'grip': string;
  44888. 'thumbstick': string;
  44889. 'trackpad': string;
  44890. };
  44891. axisMeshNames: string[];
  44892. pointingPoseMeshName: string;
  44893. };
  44894. /**
  44895. * Construct a new XR-Based windows motion controller
  44896. *
  44897. * @param gamepadInfo the gamepad object from the browser
  44898. */
  44899. constructor(gamepadInfo: any);
  44900. /**
  44901. * holds the thumbstick values (X,Y)
  44902. */
  44903. thumbstickValues: StickValues;
  44904. /**
  44905. * Fired when the thumbstick on this controller is clicked
  44906. */
  44907. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  44908. /**
  44909. * Fired when the thumbstick on this controller is modified
  44910. */
  44911. onThumbstickValuesChangedObservable: Observable<StickValues>;
  44912. /**
  44913. * Fired when the touchpad button on this controller is modified
  44914. */
  44915. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44916. /**
  44917. * Fired when the touchpad values on this controller are modified
  44918. */
  44919. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44920. /**
  44921. * Fired when the thumbstick button on this controller is modified
  44922. * here to prevent breaking changes
  44923. */
  44924. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44925. /**
  44926. * updating the thumbstick(!) and not the trackpad.
  44927. * This is named this way due to the difference between WebVR and XR and to avoid
  44928. * changing the parent class.
  44929. */
  44930. protected _updateTrackpad(): void;
  44931. /**
  44932. * Disposes the class with joy
  44933. */
  44934. dispose(): void;
  44935. }
  44936. }
  44937. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44938. import { Observable } from "babylonjs/Misc/observable";
  44939. import { Scene } from "babylonjs/scene";
  44940. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44941. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44942. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44943. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44944. /**
  44945. * Oculus Touch Controller
  44946. */
  44947. export class OculusTouchController extends WebVRController {
  44948. /**
  44949. * Base Url for the controller model.
  44950. */
  44951. static MODEL_BASE_URL: string;
  44952. /**
  44953. * File name for the left controller model.
  44954. */
  44955. static MODEL_LEFT_FILENAME: string;
  44956. /**
  44957. * File name for the right controller model.
  44958. */
  44959. static MODEL_RIGHT_FILENAME: string;
  44960. /**
  44961. * Base Url for the Quest controller model.
  44962. */
  44963. static QUEST_MODEL_BASE_URL: string;
  44964. /**
  44965. * @hidden
  44966. * If the controllers are running on a device that needs the updated Quest controller models
  44967. */
  44968. static _IsQuest: boolean;
  44969. /**
  44970. * Fired when the secondary trigger on this controller is modified
  44971. */
  44972. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44973. /**
  44974. * Fired when the thumb rest on this controller is modified
  44975. */
  44976. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44977. /**
  44978. * Creates a new OculusTouchController from a gamepad
  44979. * @param vrGamepad the gamepad that the controller should be created from
  44980. */
  44981. constructor(vrGamepad: any);
  44982. /**
  44983. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44984. * @param scene scene in which to add meshes
  44985. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44986. */
  44987. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44988. /**
  44989. * Fired when the A button on this controller is modified
  44990. */
  44991. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44992. /**
  44993. * Fired when the B button on this controller is modified
  44994. */
  44995. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44996. /**
  44997. * Fired when the X button on this controller is modified
  44998. */
  44999. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  45000. /**
  45001. * Fired when the Y button on this controller is modified
  45002. */
  45003. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  45004. /**
  45005. * Called once for each button that changed state since the last frame
  45006. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  45007. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  45008. * 2) secondary trigger (same)
  45009. * 3) A (right) X (left), touch, pressed = value
  45010. * 4) B / Y
  45011. * 5) thumb rest
  45012. * @param buttonIdx Which button index changed
  45013. * @param state New state of the button
  45014. * @param changes Which properties on the state changed since last frame
  45015. */
  45016. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45017. }
  45018. }
  45019. declare module "babylonjs/Gamepads/Controllers/viveController" {
  45020. import { Scene } from "babylonjs/scene";
  45021. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45022. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45023. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45024. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45025. import { Observable } from "babylonjs/Misc/observable";
  45026. /**
  45027. * Vive Controller
  45028. */
  45029. export class ViveController extends WebVRController {
  45030. /**
  45031. * Base Url for the controller model.
  45032. */
  45033. static MODEL_BASE_URL: string;
  45034. /**
  45035. * File name for the controller model.
  45036. */
  45037. static MODEL_FILENAME: string;
  45038. /**
  45039. * Creates a new ViveController from a gamepad
  45040. * @param vrGamepad the gamepad that the controller should be created from
  45041. */
  45042. constructor(vrGamepad: any);
  45043. /**
  45044. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45045. * @param scene scene in which to add meshes
  45046. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45047. */
  45048. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45049. /**
  45050. * Fired when the left button on this controller is modified
  45051. */
  45052. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  45053. /**
  45054. * Fired when the right button on this controller is modified
  45055. */
  45056. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  45057. /**
  45058. * Fired when the menu button on this controller is modified
  45059. */
  45060. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  45061. /**
  45062. * Called once for each button that changed state since the last frame
  45063. * Vive mapping:
  45064. * 0: touchpad
  45065. * 1: trigger
  45066. * 2: left AND right buttons
  45067. * 3: menu button
  45068. * @param buttonIdx Which button index changed
  45069. * @param state New state of the button
  45070. * @param changes Which properties on the state changed since last frame
  45071. */
  45072. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45073. }
  45074. }
  45075. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  45076. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45077. import { Observable } from "babylonjs/Misc/observable";
  45078. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  45079. /**
  45080. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  45081. */
  45082. export class WebXRControllerModelLoader {
  45083. /**
  45084. * an observable that triggers when a new model (the mesh itself) was initialized.
  45085. * To know when the mesh was loaded use the controller's own modelLoaded() method
  45086. */
  45087. onControllerModelLoaded: Observable<WebXRController>;
  45088. /**
  45089. * Creates the WebXRControllerModelLoader
  45090. * @param input xr input that creates the controllers
  45091. */
  45092. constructor(input: WebXRInput);
  45093. }
  45094. }
  45095. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  45096. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45097. /**
  45098. * Handles pointer input automatically for the pointer of XR controllers
  45099. */
  45100. export class WebXRControllerPointerSelection {
  45101. private static _idCounter;
  45102. private _tmpRay;
  45103. /**
  45104. * Creates a WebXRControllerPointerSelection
  45105. * @param input input manager to setup pointer selection
  45106. */
  45107. constructor(input: WebXRInput);
  45108. private _convertNormalToDirectionOfRay;
  45109. private _updatePointerDistance;
  45110. }
  45111. }
  45112. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  45113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45114. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45115. /**
  45116. * Enables teleportation
  45117. */
  45118. export class WebXRControllerTeleportation {
  45119. private _teleportationFillColor;
  45120. private _teleportationBorderColor;
  45121. private _tmpRay;
  45122. private _tmpVector;
  45123. /**
  45124. * when set to true (default) teleportation will wait for thumbstick changes.
  45125. * When set to false teleportation will be disabled.
  45126. *
  45127. * If set to false while teleporting results can be unexpected.
  45128. */
  45129. enabled: boolean;
  45130. /**
  45131. * Creates a WebXRControllerTeleportation
  45132. * @param input input manager to add teleportation to
  45133. * @param floorMeshes floormeshes which can be teleported to
  45134. */
  45135. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  45136. }
  45137. }
  45138. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  45139. import { Nullable } from "babylonjs/types";
  45140. import { Observable } from "babylonjs/Misc/observable";
  45141. import { IDisposable, Scene } from "babylonjs/scene";
  45142. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45143. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  45144. /**
  45145. * Button which can be used to enter a different mode of XR
  45146. */
  45147. export class WebXREnterExitUIButton {
  45148. /** button element */
  45149. element: HTMLElement;
  45150. /** XR initialization options for the button */
  45151. sessionMode: XRSessionMode;
  45152. /** Reference space type */
  45153. referenceSpaceType: XRReferenceSpaceType;
  45154. /**
  45155. * Creates a WebXREnterExitUIButton
  45156. * @param element button element
  45157. * @param sessionMode XR initialization session mode
  45158. * @param referenceSpaceType the type of reference space to be used
  45159. */
  45160. constructor(
  45161. /** button element */
  45162. element: HTMLElement,
  45163. /** XR initialization options for the button */
  45164. sessionMode: XRSessionMode,
  45165. /** Reference space type */
  45166. referenceSpaceType: XRReferenceSpaceType);
  45167. /**
  45168. * Overwritable function which can be used to update the button's visuals when the state changes
  45169. * @param activeButton the current active button in the UI
  45170. */
  45171. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45172. }
  45173. /**
  45174. * Options to create the webXR UI
  45175. */
  45176. export class WebXREnterExitUIOptions {
  45177. /**
  45178. * Context to enter xr with
  45179. */
  45180. renderTarget?: Nullable<WebXRRenderTarget>;
  45181. /**
  45182. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45183. */
  45184. customButtons?: Array<WebXREnterExitUIButton>;
  45185. /**
  45186. * A session mode to use when creating the default button.
  45187. * Default is immersive-vr
  45188. */
  45189. sessionMode?: XRSessionMode;
  45190. /**
  45191. * A reference space type to use when creating the default button.
  45192. * Default is local-floor
  45193. */
  45194. referenceSpaceType?: XRReferenceSpaceType;
  45195. }
  45196. /**
  45197. * UI to allow the user to enter/exit XR mode
  45198. */
  45199. export class WebXREnterExitUI implements IDisposable {
  45200. private scene;
  45201. /** version of the options passed to this UI */
  45202. options: WebXREnterExitUIOptions;
  45203. private _overlay;
  45204. private _buttons;
  45205. private _activeButton;
  45206. /**
  45207. * Fired every time the active button is changed.
  45208. *
  45209. * When xr is entered via a button that launches xr that button will be the callback parameter
  45210. *
  45211. * When exiting xr the callback parameter will be null)
  45212. */
  45213. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45214. /**
  45215. * Creates UI to allow the user to enter/exit XR mode
  45216. * @param scene the scene to add the ui to
  45217. * @param helper the xr experience helper to enter/exit xr with
  45218. * @param options options to configure the UI
  45219. * @returns the created ui
  45220. */
  45221. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45222. /**
  45223. *
  45224. * @param scene babylon scene object to use
  45225. * @param options (read-only) version of the options passed to this UI
  45226. */
  45227. private constructor();
  45228. private _updateButtons;
  45229. /**
  45230. * Disposes of the object
  45231. */
  45232. dispose(): void;
  45233. }
  45234. }
  45235. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  45236. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45237. import { Scene } from "babylonjs/scene";
  45238. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45239. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  45240. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  45241. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  45242. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  45243. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/Cameras/XR/webXREnterExitUI";
  45244. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45245. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  45246. /**
  45247. * Options for the default xr helper
  45248. */
  45249. export class WebXRDefaultExperienceOptions {
  45250. /**
  45251. * Floor meshes that should be used for teleporting
  45252. */
  45253. floorMeshes: Array<AbstractMesh>;
  45254. /**
  45255. * Enable or disable default UI to enter XR
  45256. */
  45257. disableDefaultUI?: boolean;
  45258. /**
  45259. * optional configuration for the output canvas
  45260. */
  45261. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45262. /**
  45263. * optional UI options. This can be used among other to change session mode and reference space type
  45264. */
  45265. uiOptions?: WebXREnterExitUIOptions;
  45266. }
  45267. /**
  45268. * Default experience which provides a similar setup to the previous webVRExperience
  45269. */
  45270. export class WebXRDefaultExperience {
  45271. /**
  45272. * Base experience
  45273. */
  45274. baseExperience: WebXRExperienceHelper;
  45275. /**
  45276. * Input experience extension
  45277. */
  45278. input: WebXRInput;
  45279. /**
  45280. * Loads the controller models
  45281. */
  45282. controllerModelLoader: WebXRControllerModelLoader;
  45283. /**
  45284. * Enables laser pointer and selection
  45285. */
  45286. pointerSelection: WebXRControllerPointerSelection;
  45287. /**
  45288. * Enables teleportation
  45289. */
  45290. teleportation: WebXRControllerTeleportation;
  45291. /**
  45292. * Enables ui for entering/exiting xr
  45293. */
  45294. enterExitUI: WebXREnterExitUI;
  45295. /**
  45296. * Default target xr should render to
  45297. */
  45298. renderTarget: WebXRRenderTarget;
  45299. /**
  45300. * Creates the default xr experience
  45301. * @param scene scene
  45302. * @param options options for basic configuration
  45303. * @returns resulting WebXRDefaultExperience
  45304. */
  45305. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45306. private constructor();
  45307. /**
  45308. * DIsposes of the experience helper
  45309. */
  45310. dispose(): void;
  45311. }
  45312. }
  45313. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  45314. import { Observable } from "babylonjs/Misc/observable";
  45315. import { Nullable } from "babylonjs/types";
  45316. import { Camera } from "babylonjs/Cameras/camera";
  45317. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  45318. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  45319. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  45320. import { Scene } from "babylonjs/scene";
  45321. import { Vector3 } from "babylonjs/Maths/math.vector";
  45322. import { Color3 } from "babylonjs/Maths/math.color";
  45323. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45324. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45325. import { Mesh } from "babylonjs/Meshes/mesh";
  45326. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  45327. import { EasingFunction } from "babylonjs/Animations/easing";
  45328. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  45329. import "babylonjs/Meshes/Builders/groundBuilder";
  45330. import "babylonjs/Meshes/Builders/torusBuilder";
  45331. import "babylonjs/Meshes/Builders/cylinderBuilder";
  45332. import "babylonjs/Gamepads/gamepadSceneComponent";
  45333. import "babylonjs/Animations/animatable";
  45334. import { WebXRDefaultExperience } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  45335. /**
  45336. * Options to modify the vr teleportation behavior.
  45337. */
  45338. export interface VRTeleportationOptions {
  45339. /**
  45340. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45341. */
  45342. floorMeshName?: string;
  45343. /**
  45344. * A list of meshes to be used as the teleportation floor. (default: empty)
  45345. */
  45346. floorMeshes?: Mesh[];
  45347. /**
  45348. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45349. */
  45350. teleportationMode?: number;
  45351. /**
  45352. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45353. */
  45354. teleportationTime?: number;
  45355. /**
  45356. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45357. */
  45358. teleportationSpeed?: number;
  45359. /**
  45360. * The easing function used in the animation or null for Linear. (default CircleEase)
  45361. */
  45362. easingFunction?: EasingFunction;
  45363. }
  45364. /**
  45365. * Options to modify the vr experience helper's behavior.
  45366. */
  45367. export interface VRExperienceHelperOptions extends WebVROptions {
  45368. /**
  45369. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45370. */
  45371. createDeviceOrientationCamera?: boolean;
  45372. /**
  45373. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45374. */
  45375. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45376. /**
  45377. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45378. */
  45379. laserToggle?: boolean;
  45380. /**
  45381. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45382. */
  45383. floorMeshes?: Mesh[];
  45384. /**
  45385. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45386. */
  45387. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45388. /**
  45389. * Defines if WebXR should be used instead of WebVR (if available)
  45390. */
  45391. useXR?: boolean;
  45392. }
  45393. /**
  45394. * Event containing information after VR has been entered
  45395. */
  45396. export class OnAfterEnteringVRObservableEvent {
  45397. /**
  45398. * If entering vr was successful
  45399. */
  45400. success: boolean;
  45401. }
  45402. /**
  45403. * Helps to quickly add VR support to an existing scene.
  45404. * See http://doc.babylonjs.com/how_to/webvr_helper
  45405. */
  45406. export class VRExperienceHelper {
  45407. /** Options to modify the vr experience helper's behavior. */
  45408. webVROptions: VRExperienceHelperOptions;
  45409. private _scene;
  45410. private _position;
  45411. private _btnVR;
  45412. private _btnVRDisplayed;
  45413. private _webVRsupported;
  45414. private _webVRready;
  45415. private _webVRrequesting;
  45416. private _webVRpresenting;
  45417. private _hasEnteredVR;
  45418. private _fullscreenVRpresenting;
  45419. private _inputElement;
  45420. private _webVRCamera;
  45421. private _vrDeviceOrientationCamera;
  45422. private _deviceOrientationCamera;
  45423. private _existingCamera;
  45424. private _onKeyDown;
  45425. private _onVrDisplayPresentChange;
  45426. private _onVRDisplayChanged;
  45427. private _onVRRequestPresentStart;
  45428. private _onVRRequestPresentComplete;
  45429. /**
  45430. * 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)
  45431. */
  45432. enableGazeEvenWhenNoPointerLock: boolean;
  45433. /**
  45434. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45435. */
  45436. exitVROnDoubleTap: boolean;
  45437. /**
  45438. * Observable raised right before entering VR.
  45439. */
  45440. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45441. /**
  45442. * Observable raised when entering VR has completed.
  45443. */
  45444. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45445. /**
  45446. * Observable raised when exiting VR.
  45447. */
  45448. onExitingVRObservable: Observable<VRExperienceHelper>;
  45449. /**
  45450. * Observable raised when controller mesh is loaded.
  45451. */
  45452. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45453. /** Return this.onEnteringVRObservable
  45454. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45455. */
  45456. get onEnteringVR(): Observable<VRExperienceHelper>;
  45457. /** Return this.onExitingVRObservable
  45458. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45459. */
  45460. get onExitingVR(): Observable<VRExperienceHelper>;
  45461. /** Return this.onControllerMeshLoadedObservable
  45462. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45463. */
  45464. get onControllerMeshLoaded(): Observable<WebVRController>;
  45465. private _rayLength;
  45466. private _useCustomVRButton;
  45467. private _teleportationRequested;
  45468. private _teleportActive;
  45469. private _floorMeshName;
  45470. private _floorMeshesCollection;
  45471. private _teleportationMode;
  45472. private _teleportationTime;
  45473. private _teleportationSpeed;
  45474. private _teleportationEasing;
  45475. private _rotationAllowed;
  45476. private _teleportBackwardsVector;
  45477. private _teleportationTarget;
  45478. private _isDefaultTeleportationTarget;
  45479. private _postProcessMove;
  45480. private _teleportationFillColor;
  45481. private _teleportationBorderColor;
  45482. private _rotationAngle;
  45483. private _haloCenter;
  45484. private _cameraGazer;
  45485. private _padSensibilityUp;
  45486. private _padSensibilityDown;
  45487. private _leftController;
  45488. private _rightController;
  45489. private _gazeColor;
  45490. private _laserColor;
  45491. private _pickedLaserColor;
  45492. private _pickedGazeColor;
  45493. /**
  45494. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45495. */
  45496. onNewMeshSelected: Observable<AbstractMesh>;
  45497. /**
  45498. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45499. * This observable will provide the mesh and the controller used to select the mesh
  45500. */
  45501. onMeshSelectedWithController: Observable<{
  45502. mesh: AbstractMesh;
  45503. controller: WebVRController;
  45504. }>;
  45505. /**
  45506. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45507. */
  45508. onNewMeshPicked: Observable<PickingInfo>;
  45509. private _circleEase;
  45510. /**
  45511. * Observable raised before camera teleportation
  45512. */
  45513. onBeforeCameraTeleport: Observable<Vector3>;
  45514. /**
  45515. * Observable raised after camera teleportation
  45516. */
  45517. onAfterCameraTeleport: Observable<Vector3>;
  45518. /**
  45519. * Observable raised when current selected mesh gets unselected
  45520. */
  45521. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45522. private _raySelectionPredicate;
  45523. /**
  45524. * To be optionaly changed by user to define custom ray selection
  45525. */
  45526. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45527. /**
  45528. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45529. */
  45530. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45531. /**
  45532. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45533. */
  45534. teleportationEnabled: boolean;
  45535. private _defaultHeight;
  45536. private _teleportationInitialized;
  45537. private _interactionsEnabled;
  45538. private _interactionsRequested;
  45539. private _displayGaze;
  45540. private _displayLaserPointer;
  45541. /**
  45542. * The mesh used to display where the user is going to teleport.
  45543. */
  45544. get teleportationTarget(): Mesh;
  45545. /**
  45546. * Sets the mesh to be used to display where the user is going to teleport.
  45547. */
  45548. set teleportationTarget(value: Mesh);
  45549. /**
  45550. * 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
  45551. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45552. * See http://doc.babylonjs.com/resources/baking_transformations
  45553. */
  45554. get gazeTrackerMesh(): Mesh;
  45555. set gazeTrackerMesh(value: Mesh);
  45556. /**
  45557. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45558. */
  45559. updateGazeTrackerScale: boolean;
  45560. /**
  45561. * If the gaze trackers color should be updated when selecting meshes
  45562. */
  45563. updateGazeTrackerColor: boolean;
  45564. /**
  45565. * If the controller laser color should be updated when selecting meshes
  45566. */
  45567. updateControllerLaserColor: boolean;
  45568. /**
  45569. * The gaze tracking mesh corresponding to the left controller
  45570. */
  45571. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45572. /**
  45573. * The gaze tracking mesh corresponding to the right controller
  45574. */
  45575. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45576. /**
  45577. * If the ray of the gaze should be displayed.
  45578. */
  45579. get displayGaze(): boolean;
  45580. /**
  45581. * Sets if the ray of the gaze should be displayed.
  45582. */
  45583. set displayGaze(value: boolean);
  45584. /**
  45585. * If the ray of the LaserPointer should be displayed.
  45586. */
  45587. get displayLaserPointer(): boolean;
  45588. /**
  45589. * Sets if the ray of the LaserPointer should be displayed.
  45590. */
  45591. set displayLaserPointer(value: boolean);
  45592. /**
  45593. * The deviceOrientationCamera used as the camera when not in VR.
  45594. */
  45595. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45596. /**
  45597. * Based on the current WebVR support, returns the current VR camera used.
  45598. */
  45599. get currentVRCamera(): Nullable<Camera>;
  45600. /**
  45601. * The webVRCamera which is used when in VR.
  45602. */
  45603. get webVRCamera(): WebVRFreeCamera;
  45604. /**
  45605. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45606. */
  45607. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45608. /**
  45609. * The html button that is used to trigger entering into VR.
  45610. */
  45611. get vrButton(): Nullable<HTMLButtonElement>;
  45612. private get _teleportationRequestInitiated();
  45613. /**
  45614. * Defines wether or not Pointer lock should be requested when switching to
  45615. * full screen.
  45616. */
  45617. requestPointerLockOnFullScreen: boolean;
  45618. /**
  45619. * If asking to force XR, this will be populated with the default xr experience
  45620. */
  45621. xr: WebXRDefaultExperience;
  45622. /**
  45623. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45624. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45625. */
  45626. xrTestDone: boolean;
  45627. /**
  45628. * Instantiates a VRExperienceHelper.
  45629. * Helps to quickly add VR support to an existing scene.
  45630. * @param scene The scene the VRExperienceHelper belongs to.
  45631. * @param webVROptions Options to modify the vr experience helper's behavior.
  45632. */
  45633. constructor(scene: Scene,
  45634. /** Options to modify the vr experience helper's behavior. */
  45635. webVROptions?: VRExperienceHelperOptions);
  45636. private completeVRInit;
  45637. private _onDefaultMeshLoaded;
  45638. private _onResize;
  45639. private _onFullscreenChange;
  45640. /**
  45641. * Gets a value indicating if we are currently in VR mode.
  45642. */
  45643. get isInVRMode(): boolean;
  45644. private onVrDisplayPresentChange;
  45645. private onVRDisplayChanged;
  45646. private moveButtonToBottomRight;
  45647. private displayVRButton;
  45648. private updateButtonVisibility;
  45649. private _cachedAngularSensibility;
  45650. /**
  45651. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45652. * Otherwise, will use the fullscreen API.
  45653. */
  45654. enterVR(): void;
  45655. /**
  45656. * Attempt to exit VR, or fullscreen.
  45657. */
  45658. exitVR(): void;
  45659. /**
  45660. * The position of the vr experience helper.
  45661. */
  45662. get position(): Vector3;
  45663. /**
  45664. * Sets the position of the vr experience helper.
  45665. */
  45666. set position(value: Vector3);
  45667. /**
  45668. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45669. */
  45670. enableInteractions(): void;
  45671. private get _noControllerIsActive();
  45672. private beforeRender;
  45673. private _isTeleportationFloor;
  45674. /**
  45675. * Adds a floor mesh to be used for teleportation.
  45676. * @param floorMesh the mesh to be used for teleportation.
  45677. */
  45678. addFloorMesh(floorMesh: Mesh): void;
  45679. /**
  45680. * Removes a floor mesh from being used for teleportation.
  45681. * @param floorMesh the mesh to be removed.
  45682. */
  45683. removeFloorMesh(floorMesh: Mesh): void;
  45684. /**
  45685. * Enables interactions and teleportation using the VR controllers and gaze.
  45686. * @param vrTeleportationOptions options to modify teleportation behavior.
  45687. */
  45688. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45689. private _onNewGamepadConnected;
  45690. private _tryEnableInteractionOnController;
  45691. private _onNewGamepadDisconnected;
  45692. private _enableInteractionOnController;
  45693. private _checkTeleportWithRay;
  45694. private _checkRotate;
  45695. private _checkTeleportBackwards;
  45696. private _enableTeleportationOnController;
  45697. private _createTeleportationCircles;
  45698. private _displayTeleportationTarget;
  45699. private _hideTeleportationTarget;
  45700. private _rotateCamera;
  45701. private _moveTeleportationSelectorTo;
  45702. private _workingVector;
  45703. private _workingQuaternion;
  45704. private _workingMatrix;
  45705. /**
  45706. * Time Constant Teleportation Mode
  45707. */
  45708. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45709. /**
  45710. * Speed Constant Teleportation Mode
  45711. */
  45712. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45713. /**
  45714. * Teleports the users feet to the desired location
  45715. * @param location The location where the user's feet should be placed
  45716. */
  45717. teleportCamera(location: Vector3): void;
  45718. private _convertNormalToDirectionOfRay;
  45719. private _castRayAndSelectObject;
  45720. private _notifySelectedMeshUnselected;
  45721. /**
  45722. * Permanently set new colors for the laser pointer
  45723. * @param color the new laser color
  45724. * @param pickedColor the new laser color when picked mesh detected
  45725. */
  45726. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45727. /**
  45728. * Permanently set new colors for the gaze pointer
  45729. * @param color the new gaze color
  45730. * @param pickedColor the new gaze color when picked mesh detected
  45731. */
  45732. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45733. /**
  45734. * Sets the color of the laser ray from the vr controllers.
  45735. * @param color new color for the ray.
  45736. */
  45737. changeLaserColor(color: Color3): void;
  45738. /**
  45739. * Sets the color of the ray from the vr headsets gaze.
  45740. * @param color new color for the ray.
  45741. */
  45742. changeGazeColor(color: Color3): void;
  45743. /**
  45744. * Exits VR and disposes of the vr experience helper
  45745. */
  45746. dispose(): void;
  45747. /**
  45748. * Gets the name of the VRExperienceHelper class
  45749. * @returns "VRExperienceHelper"
  45750. */
  45751. getClassName(): string;
  45752. }
  45753. }
  45754. declare module "babylonjs/Cameras/VR/index" {
  45755. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  45756. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  45757. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  45758. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  45759. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  45760. export * from "babylonjs/Cameras/VR/webVRCamera";
  45761. }
  45762. declare module "babylonjs/Cameras/XR/features/WebXRHitTestLegacy" {
  45763. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45764. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45765. import { Observable } from "babylonjs/Misc/observable";
  45766. import { Matrix } from "babylonjs/Maths/math.vector";
  45767. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45768. /**
  45769. * Options used for hit testing
  45770. */
  45771. export interface IWebXRHitTestOptions {
  45772. /**
  45773. * Only test when user interacted with the scene. Default - hit test every frame
  45774. */
  45775. testOnPointerDownOnly?: boolean;
  45776. /**
  45777. * The node to use to transform the local results to world coordinates
  45778. */
  45779. worldParentNode?: TransformNode;
  45780. }
  45781. /**
  45782. * Interface defining the babylon result of raycasting/hit-test
  45783. */
  45784. export interface IWebXRHitResult {
  45785. /**
  45786. * The native hit test result
  45787. */
  45788. xrHitResult: XRHitResult;
  45789. /**
  45790. * Transformation matrix that can be applied to a node that will put it in the hit point location
  45791. */
  45792. transformationMatrix: Matrix;
  45793. }
  45794. /**
  45795. * The currently-working hit-test module.
  45796. * Hit test (or raycasting) is used to interact with the real world.
  45797. * For further information read here - https://github.com/immersive-web/hit-test
  45798. */
  45799. export class WebXRHitTestLegacy implements IWebXRFeature {
  45800. private _xrSessionManager;
  45801. /**
  45802. * options to use when constructing this feature
  45803. */
  45804. readonly options: IWebXRHitTestOptions;
  45805. /**
  45806. * The module's name
  45807. */
  45808. static readonly Name: string;
  45809. /**
  45810. * The (Babylon) version of this module.
  45811. * This is an integer representing the implementation version.
  45812. * This number does not correspond to the webxr specs version
  45813. */
  45814. static readonly Version: number;
  45815. /**
  45816. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  45817. * @param event the (select) event to use to select with
  45818. * @param referenceSpace the reference space to use for this hit test
  45819. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  45820. */
  45821. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  45822. /**
  45823. * execute a hit test with an XR Ray
  45824. *
  45825. * @param xrSession a native xrSession that will execute this hit test
  45826. * @param xrRay the ray (position and direction) to use for raycasting
  45827. * @param referenceSpace native XR reference space to use for the hit-test
  45828. * @param filter filter function that will filter the results
  45829. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  45830. */
  45831. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  45832. /**
  45833. * Triggered when new babylon (transformed) hit test results are available
  45834. */
  45835. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  45836. /**
  45837. * Creates a new instance of the (legacy version) hit test feature
  45838. * @param _xrSessionManager an instance of WebXRSessionManager
  45839. * @param options options to use when constructing this feature
  45840. */
  45841. constructor(_xrSessionManager: WebXRSessionManager,
  45842. /**
  45843. * options to use when constructing this feature
  45844. */
  45845. options?: IWebXRHitTestOptions);
  45846. private _onSelectEnabled;
  45847. private _xrFrameObserver;
  45848. private _attached;
  45849. /**
  45850. * Populated with the last native XR Hit Results
  45851. */
  45852. lastNativeXRHitResults: XRHitResult[];
  45853. /**
  45854. * attach this feature
  45855. * Will usually be called by the features manager
  45856. *
  45857. * @returns true if successful.
  45858. */
  45859. attach(): boolean;
  45860. /**
  45861. * detach this feature.
  45862. * Will usually be called by the features manager
  45863. *
  45864. * @returns true if successful.
  45865. */
  45866. detach(): boolean;
  45867. private _onHitTestResults;
  45868. private _onSelect;
  45869. /**
  45870. * Dispose this feature and all of the resources attached
  45871. */
  45872. dispose(): void;
  45873. }
  45874. }
  45875. declare module "babylonjs/Cameras/XR/features/WebXRPlaneDetector" {
  45876. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45877. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45878. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45879. import { Observable } from "babylonjs/Misc/observable";
  45880. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  45881. /**
  45882. * Options used in the plane detector module
  45883. */
  45884. export interface IWebXRPlaneDetectorOptions {
  45885. /**
  45886. * The node to use to transform the local results to world coordinates
  45887. */
  45888. worldParentNode?: TransformNode;
  45889. }
  45890. /**
  45891. * A babylon interface for a webxr plane.
  45892. * A Plane is actually a polygon, built from N points in space
  45893. */
  45894. export interface IWebXRPlane {
  45895. /**
  45896. * a babylon-assigned ID for this polygon
  45897. */
  45898. id: number;
  45899. /**
  45900. * the native xr-plane object
  45901. */
  45902. xrPlane: XRPlane;
  45903. /**
  45904. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  45905. */
  45906. polygonDefinition: Array<Vector3>;
  45907. /**
  45908. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  45909. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  45910. */
  45911. transformationMatrix: Matrix;
  45912. }
  45913. /**
  45914. * The plane detector is used to detect planes in the real world when in AR
  45915. * For more information see https://github.com/immersive-web/real-world-geometry/
  45916. */
  45917. export class WebXRPlaneDetector implements IWebXRFeature {
  45918. private _xrSessionManager;
  45919. private _options;
  45920. /**
  45921. * The module's name
  45922. */
  45923. static readonly Name: string;
  45924. /**
  45925. * The (Babylon) version of this module.
  45926. * This is an integer representing the implementation version.
  45927. * This number does not correspond to the webxr specs version
  45928. */
  45929. static readonly Version: number;
  45930. /**
  45931. * Observers registered here will be executed when a new plane was added to the session
  45932. */
  45933. onPlaneAddedObservable: Observable<IWebXRPlane>;
  45934. /**
  45935. * Observers registered here will be executed when a plane is no longer detected in the session
  45936. */
  45937. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  45938. /**
  45939. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  45940. * This can execute N times every frame
  45941. */
  45942. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  45943. private _enabled;
  45944. private _attached;
  45945. private _detectedPlanes;
  45946. private _lastFrameDetected;
  45947. private _observerTracked;
  45948. /**
  45949. * construct a new Plane Detector
  45950. * @param _xrSessionManager an instance of xr Session manager
  45951. * @param _options configuration to use when constructing this feature
  45952. */
  45953. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  45954. /**
  45955. * attach this feature
  45956. * Will usually be called by the features manager
  45957. *
  45958. * @returns true if successful.
  45959. */
  45960. attach(): boolean;
  45961. /**
  45962. * detach this feature.
  45963. * Will usually be called by the features manager
  45964. *
  45965. * @returns true if successful.
  45966. */
  45967. detach(): boolean;
  45968. /**
  45969. * Dispose this feature and all of the resources attached
  45970. */
  45971. dispose(): void;
  45972. private _updatePlaneWithXRPlane;
  45973. /**
  45974. * avoiding using Array.find for global support.
  45975. * @param xrPlane the plane to find in the array
  45976. */
  45977. private findIndexInPlaneArray;
  45978. }
  45979. }
  45980. declare module "babylonjs/Cameras/XR/features/WebXRAnchorSystem" {
  45981. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45982. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45983. import { Observable } from "babylonjs/Misc/observable";
  45984. import { Matrix } from "babylonjs/Maths/math.vector";
  45985. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45986. import { WebXRPlaneDetector } from "babylonjs/Cameras/XR/features/WebXRPlaneDetector";
  45987. import { WebXRHitTestLegacy } from "babylonjs/Cameras/XR/features/WebXRHitTestLegacy";
  45988. /**
  45989. * Configuration options of the anchor system
  45990. */
  45991. export interface IWebXRAnchorSystemOptions {
  45992. /**
  45993. * a node that will be used to convert local to world coordinates
  45994. */
  45995. worldParentNode?: TransformNode;
  45996. /**
  45997. * should the anchor system use plane detection.
  45998. * If set to true, the plane-detection feature should be set using setPlaneDetector
  45999. */
  46000. usePlaneDetection?: boolean;
  46001. /**
  46002. * Should a new anchor be added every time a select event is triggered
  46003. */
  46004. addAnchorOnSelect?: boolean;
  46005. }
  46006. /**
  46007. * A babylon container for an XR Anchor
  46008. */
  46009. export interface IWebXRAnchor {
  46010. /**
  46011. * A babylon-assigned ID for this anchor
  46012. */
  46013. id: number;
  46014. /**
  46015. * The native anchor object
  46016. */
  46017. xrAnchor: XRAnchor;
  46018. /**
  46019. * Transformation matrix to apply to an object attached to this anchor
  46020. */
  46021. transformationMatrix: Matrix;
  46022. }
  46023. /**
  46024. * An implementation of the anchor system of WebXR.
  46025. * Note that the current documented implementation is not available in any browser. Future implementations
  46026. * will use the frame to create an anchor and not the session or a detected plane
  46027. * For further information see https://github.com/immersive-web/anchors/
  46028. */
  46029. export class WebXRAnchorSystem implements IWebXRFeature {
  46030. private _xrSessionManager;
  46031. private _options;
  46032. /**
  46033. * The module's name
  46034. */
  46035. static readonly Name: string;
  46036. /**
  46037. * The (Babylon) version of this module.
  46038. * This is an integer representing the implementation version.
  46039. * This number does not correspond to the webxr specs version
  46040. */
  46041. static readonly Version: number;
  46042. /**
  46043. * Observers registered here will be executed when a new anchor was added to the session
  46044. */
  46045. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  46046. /**
  46047. * Observers registered here will be executed when an existing anchor updates
  46048. * This can execute N times every frame
  46049. */
  46050. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  46051. /**
  46052. * Observers registered here will be executed when an anchor was removed from the session
  46053. */
  46054. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  46055. private _planeDetector;
  46056. private _hitTestModule;
  46057. private _enabled;
  46058. private _attached;
  46059. private _trackedAnchors;
  46060. private _lastFrameDetected;
  46061. private _observerTracked;
  46062. /**
  46063. * constructs a new anchor system
  46064. * @param _xrSessionManager an instance of WebXRSessionManager
  46065. * @param _options configuration object for this feature
  46066. */
  46067. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  46068. /**
  46069. * set the plane detector to use in order to create anchors from frames
  46070. * @param planeDetector the plane-detector module to use
  46071. * @param enable enable plane-anchors. default is true
  46072. */
  46073. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  46074. /**
  46075. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  46076. * @param hitTestModule the hit-test module to use.
  46077. */
  46078. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  46079. /**
  46080. * attach this feature
  46081. * Will usually be called by the features manager
  46082. *
  46083. * @returns true if successful.
  46084. */
  46085. attach(): boolean;
  46086. /**
  46087. * detach this feature.
  46088. * Will usually be called by the features manager
  46089. *
  46090. * @returns true if successful.
  46091. */
  46092. detach(): boolean;
  46093. /**
  46094. * Dispose this feature and all of the resources attached
  46095. */
  46096. dispose(): void;
  46097. private _onSelect;
  46098. /**
  46099. * Add anchor at a specific XR point.
  46100. *
  46101. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  46102. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  46103. * @returns a promise the fulfills when the anchor was created
  46104. */
  46105. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  46106. private _updateAnchorWithXRFrame;
  46107. /**
  46108. * avoiding using Array.find for global support.
  46109. * @param xrAnchor the plane to find in the array
  46110. */
  46111. private _findIndexInAnchorArray;
  46112. }
  46113. }
  46114. declare module "babylonjs/Cameras/XR/features/WebXRBackgroundRemover" {
  46115. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46116. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46118. import { Observable } from "babylonjs/Misc/observable";
  46119. /**
  46120. * Options interface for the background remover plugin
  46121. */
  46122. export interface IWebXRBackgroundRemoverOptions {
  46123. /**
  46124. * don't disable the environment helper
  46125. */
  46126. ignoreEnvironmentHelper?: boolean;
  46127. /**
  46128. * flags to configure the removal of the environment helper.
  46129. * If not set, the entire background will be removed. If set, flags should be set as well.
  46130. */
  46131. environmentHelperRemovalFlags?: {
  46132. /**
  46133. * Should the skybox be removed (default false)
  46134. */
  46135. skyBox?: boolean;
  46136. /**
  46137. * Should the ground be removed (default false)
  46138. */
  46139. ground?: boolean;
  46140. };
  46141. /**
  46142. * Further background meshes to disable when entering AR
  46143. */
  46144. backgroundMeshes?: AbstractMesh[];
  46145. }
  46146. /**
  46147. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  46148. */
  46149. export class WebXRBackgroundRemover implements IWebXRFeature {
  46150. private _xrSessionManager;
  46151. /**
  46152. * read-only options to be used in this module
  46153. */
  46154. readonly options: IWebXRBackgroundRemoverOptions;
  46155. /**
  46156. * The module's name
  46157. */
  46158. static readonly Name: string;
  46159. /**
  46160. * The (Babylon) version of this module.
  46161. * This is an integer representing the implementation version.
  46162. * This number does not correspond to the webxr specs version
  46163. */
  46164. static readonly Version: number;
  46165. /**
  46166. * registered observers will be triggered when the background state changes
  46167. */
  46168. onBackgroundStateChangedObservable: Observable<boolean>;
  46169. /**
  46170. * constructs a new background remover module
  46171. * @param _xrSessionManager the session manager for this module
  46172. * @param options read-only options to be used in this module
  46173. */
  46174. constructor(_xrSessionManager: WebXRSessionManager,
  46175. /**
  46176. * read-only options to be used in this module
  46177. */
  46178. options?: IWebXRBackgroundRemoverOptions);
  46179. /**
  46180. * attach this feature
  46181. * Will usually be called by the features manager
  46182. *
  46183. * @returns true if successful.
  46184. */
  46185. attach(): boolean;
  46186. /**
  46187. * detach this feature.
  46188. * Will usually be called by the features manager
  46189. *
  46190. * @returns true if successful.
  46191. */
  46192. detach(): boolean;
  46193. private _setBackgroundState;
  46194. /**
  46195. * Dispose this feature and all of the resources attached
  46196. */
  46197. dispose(): void;
  46198. }
  46199. }
  46200. declare module "babylonjs/Cameras/XR/features/index" {
  46201. export * from "babylonjs/Cameras/XR/features/WebXRHitTestLegacy";
  46202. export * from "babylonjs/Cameras/XR/features/WebXRAnchorSystem";
  46203. export * from "babylonjs/Cameras/XR/features/WebXRPlaneDetector";
  46204. export * from "babylonjs/Cameras/XR/features/WebXRBackgroundRemover";
  46205. }
  46206. declare module "babylonjs/Cameras/XR/index" {
  46207. export * from "babylonjs/Cameras/XR/webXRCamera";
  46208. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  46209. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  46210. export * from "babylonjs/Cameras/XR/webXRInput";
  46211. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  46212. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  46213. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  46214. export * from "babylonjs/Cameras/XR/webXRController";
  46215. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  46216. export * from "babylonjs/Cameras/XR/webXRTypes";
  46217. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  46218. export * from "babylonjs/Cameras/XR/webXRDefaultExperience";
  46219. export * from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46220. export * from "babylonjs/Cameras/XR/features/index";
  46221. }
  46222. declare module "babylonjs/Cameras/RigModes/index" {
  46223. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46224. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46225. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  46226. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  46227. }
  46228. declare module "babylonjs/Cameras/index" {
  46229. export * from "babylonjs/Cameras/Inputs/index";
  46230. export * from "babylonjs/Cameras/cameraInputsManager";
  46231. export * from "babylonjs/Cameras/camera";
  46232. export * from "babylonjs/Cameras/targetCamera";
  46233. export * from "babylonjs/Cameras/freeCamera";
  46234. export * from "babylonjs/Cameras/freeCameraInputsManager";
  46235. export * from "babylonjs/Cameras/touchCamera";
  46236. export * from "babylonjs/Cameras/arcRotateCamera";
  46237. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  46238. export * from "babylonjs/Cameras/deviceOrientationCamera";
  46239. export * from "babylonjs/Cameras/flyCamera";
  46240. export * from "babylonjs/Cameras/flyCameraInputsManager";
  46241. export * from "babylonjs/Cameras/followCamera";
  46242. export * from "babylonjs/Cameras/followCameraInputsManager";
  46243. export * from "babylonjs/Cameras/gamepadCamera";
  46244. export * from "babylonjs/Cameras/Stereoscopic/index";
  46245. export * from "babylonjs/Cameras/universalCamera";
  46246. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  46247. export * from "babylonjs/Cameras/VR/index";
  46248. export * from "babylonjs/Cameras/XR/index";
  46249. export * from "babylonjs/Cameras/RigModes/index";
  46250. }
  46251. declare module "babylonjs/Collisions/index" {
  46252. export * from "babylonjs/Collisions/collider";
  46253. export * from "babylonjs/Collisions/collisionCoordinator";
  46254. export * from "babylonjs/Collisions/pickingInfo";
  46255. export * from "babylonjs/Collisions/intersectionInfo";
  46256. export * from "babylonjs/Collisions/meshCollisionData";
  46257. }
  46258. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  46259. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  46260. import { Vector3 } from "babylonjs/Maths/math.vector";
  46261. import { Ray } from "babylonjs/Culling/ray";
  46262. import { Plane } from "babylonjs/Maths/math.plane";
  46263. /**
  46264. * Contains an array of blocks representing the octree
  46265. */
  46266. export interface IOctreeContainer<T> {
  46267. /**
  46268. * Blocks within the octree
  46269. */
  46270. blocks: Array<OctreeBlock<T>>;
  46271. }
  46272. /**
  46273. * Class used to store a cell in an octree
  46274. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46275. */
  46276. export class OctreeBlock<T> {
  46277. /**
  46278. * Gets the content of the current block
  46279. */
  46280. entries: T[];
  46281. /**
  46282. * Gets the list of block children
  46283. */
  46284. blocks: Array<OctreeBlock<T>>;
  46285. private _depth;
  46286. private _maxDepth;
  46287. private _capacity;
  46288. private _minPoint;
  46289. private _maxPoint;
  46290. private _boundingVectors;
  46291. private _creationFunc;
  46292. /**
  46293. * Creates a new block
  46294. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  46295. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  46296. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46297. * @param depth defines the current depth of this block in the octree
  46298. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  46299. * @param creationFunc defines a callback to call when an element is added to the block
  46300. */
  46301. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  46302. /**
  46303. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46304. */
  46305. get capacity(): number;
  46306. /**
  46307. * Gets the minimum vector (in world space) of the block's bounding box
  46308. */
  46309. get minPoint(): Vector3;
  46310. /**
  46311. * Gets the maximum vector (in world space) of the block's bounding box
  46312. */
  46313. get maxPoint(): Vector3;
  46314. /**
  46315. * Add a new element to this block
  46316. * @param entry defines the element to add
  46317. */
  46318. addEntry(entry: T): void;
  46319. /**
  46320. * Remove an element from this block
  46321. * @param entry defines the element to remove
  46322. */
  46323. removeEntry(entry: T): void;
  46324. /**
  46325. * Add an array of elements to this block
  46326. * @param entries defines the array of elements to add
  46327. */
  46328. addEntries(entries: T[]): void;
  46329. /**
  46330. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  46331. * @param frustumPlanes defines the frustum planes to test
  46332. * @param selection defines the array to store current content if selection is positive
  46333. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46334. */
  46335. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46336. /**
  46337. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  46338. * @param sphereCenter defines the bounding sphere center
  46339. * @param sphereRadius defines the bounding sphere radius
  46340. * @param selection defines the array to store current content if selection is positive
  46341. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46342. */
  46343. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46344. /**
  46345. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  46346. * @param ray defines the ray to test with
  46347. * @param selection defines the array to store current content if selection is positive
  46348. */
  46349. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  46350. /**
  46351. * Subdivide the content into child blocks (this block will then be empty)
  46352. */
  46353. createInnerBlocks(): void;
  46354. /**
  46355. * @hidden
  46356. */
  46357. 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;
  46358. }
  46359. }
  46360. declare module "babylonjs/Culling/Octrees/octree" {
  46361. import { SmartArray } from "babylonjs/Misc/smartArray";
  46362. import { Vector3 } from "babylonjs/Maths/math.vector";
  46363. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46364. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46365. import { Ray } from "babylonjs/Culling/ray";
  46366. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  46367. import { Plane } from "babylonjs/Maths/math.plane";
  46368. /**
  46369. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  46370. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46371. */
  46372. export class Octree<T> {
  46373. /** 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.) */
  46374. maxDepth: number;
  46375. /**
  46376. * Blocks within the octree containing objects
  46377. */
  46378. blocks: Array<OctreeBlock<T>>;
  46379. /**
  46380. * Content stored in the octree
  46381. */
  46382. dynamicContent: T[];
  46383. private _maxBlockCapacity;
  46384. private _selectionContent;
  46385. private _creationFunc;
  46386. /**
  46387. * Creates a octree
  46388. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46389. * @param creationFunc function to be used to instatiate the octree
  46390. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  46391. * @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.)
  46392. */
  46393. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  46394. /** 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.) */
  46395. maxDepth?: number);
  46396. /**
  46397. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  46398. * @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);
  46399. * @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);
  46400. * @param entries meshes to be added to the octree blocks
  46401. */
  46402. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  46403. /**
  46404. * Adds a mesh to the octree
  46405. * @param entry Mesh to add to the octree
  46406. */
  46407. addMesh(entry: T): void;
  46408. /**
  46409. * Remove an element from the octree
  46410. * @param entry defines the element to remove
  46411. */
  46412. removeMesh(entry: T): void;
  46413. /**
  46414. * Selects an array of meshes within the frustum
  46415. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  46416. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  46417. * @returns array of meshes within the frustum
  46418. */
  46419. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  46420. /**
  46421. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  46422. * @param sphereCenter defines the bounding sphere center
  46423. * @param sphereRadius defines the bounding sphere radius
  46424. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46425. * @returns an array of objects that intersect the sphere
  46426. */
  46427. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  46428. /**
  46429. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  46430. * @param ray defines the ray to test with
  46431. * @returns array of intersected objects
  46432. */
  46433. intersectsRay(ray: Ray): SmartArray<T>;
  46434. /**
  46435. * Adds a mesh into the octree block if it intersects the block
  46436. */
  46437. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  46438. /**
  46439. * Adds a submesh into the octree block if it intersects the block
  46440. */
  46441. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  46442. }
  46443. }
  46444. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  46445. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  46446. import { Scene } from "babylonjs/scene";
  46447. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46449. import { Ray } from "babylonjs/Culling/ray";
  46450. import { Octree } from "babylonjs/Culling/Octrees/octree";
  46451. import { Collider } from "babylonjs/Collisions/collider";
  46452. module "babylonjs/scene" {
  46453. interface Scene {
  46454. /**
  46455. * @hidden
  46456. * Backing Filed
  46457. */
  46458. _selectionOctree: Octree<AbstractMesh>;
  46459. /**
  46460. * Gets the octree used to boost mesh selection (picking)
  46461. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46462. */
  46463. selectionOctree: Octree<AbstractMesh>;
  46464. /**
  46465. * Creates or updates the octree used to boost selection (picking)
  46466. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46467. * @param maxCapacity defines the maximum capacity per leaf
  46468. * @param maxDepth defines the maximum depth of the octree
  46469. * @returns an octree of AbstractMesh
  46470. */
  46471. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46472. }
  46473. }
  46474. module "babylonjs/Meshes/abstractMesh" {
  46475. interface AbstractMesh {
  46476. /**
  46477. * @hidden
  46478. * Backing Field
  46479. */
  46480. _submeshesOctree: Octree<SubMesh>;
  46481. /**
  46482. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46483. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46484. * @param maxCapacity defines the maximum size of each block (64 by default)
  46485. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46486. * @returns the new octree
  46487. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46488. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46489. */
  46490. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46491. }
  46492. }
  46493. /**
  46494. * Defines the octree scene component responsible to manage any octrees
  46495. * in a given scene.
  46496. */
  46497. export class OctreeSceneComponent {
  46498. /**
  46499. * The component name help to identify the component in the list of scene components.
  46500. */
  46501. readonly name: string;
  46502. /**
  46503. * The scene the component belongs to.
  46504. */
  46505. scene: Scene;
  46506. /**
  46507. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46508. */
  46509. readonly checksIsEnabled: boolean;
  46510. /**
  46511. * Creates a new instance of the component for the given scene
  46512. * @param scene Defines the scene to register the component in
  46513. */
  46514. constructor(scene: Scene);
  46515. /**
  46516. * Registers the component in a given scene
  46517. */
  46518. register(): void;
  46519. /**
  46520. * Return the list of active meshes
  46521. * @returns the list of active meshes
  46522. */
  46523. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46524. /**
  46525. * Return the list of active sub meshes
  46526. * @param mesh The mesh to get the candidates sub meshes from
  46527. * @returns the list of active sub meshes
  46528. */
  46529. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46530. private _tempRay;
  46531. /**
  46532. * Return the list of sub meshes intersecting with a given local ray
  46533. * @param mesh defines the mesh to find the submesh for
  46534. * @param localRay defines the ray in local space
  46535. * @returns the list of intersecting sub meshes
  46536. */
  46537. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46538. /**
  46539. * Return the list of sub meshes colliding with a collider
  46540. * @param mesh defines the mesh to find the submesh for
  46541. * @param collider defines the collider to evaluate the collision against
  46542. * @returns the list of colliding sub meshes
  46543. */
  46544. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46545. /**
  46546. * Rebuilds the elements related to this component in case of
  46547. * context lost for instance.
  46548. */
  46549. rebuild(): void;
  46550. /**
  46551. * Disposes the component and the associated ressources.
  46552. */
  46553. dispose(): void;
  46554. }
  46555. }
  46556. declare module "babylonjs/Culling/Octrees/index" {
  46557. export * from "babylonjs/Culling/Octrees/octree";
  46558. export * from "babylonjs/Culling/Octrees/octreeBlock";
  46559. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  46560. }
  46561. declare module "babylonjs/Culling/index" {
  46562. export * from "babylonjs/Culling/boundingBox";
  46563. export * from "babylonjs/Culling/boundingInfo";
  46564. export * from "babylonjs/Culling/boundingSphere";
  46565. export * from "babylonjs/Culling/Octrees/index";
  46566. export * from "babylonjs/Culling/ray";
  46567. }
  46568. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  46569. import { IDisposable, Scene } from "babylonjs/scene";
  46570. import { Nullable } from "babylonjs/types";
  46571. import { Observable } from "babylonjs/Misc/observable";
  46572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46573. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  46574. import { Camera } from "babylonjs/Cameras/camera";
  46575. /**
  46576. * Renders a layer on top of an existing scene
  46577. */
  46578. export class UtilityLayerRenderer implements IDisposable {
  46579. /** the original scene that will be rendered on top of */
  46580. originalScene: Scene;
  46581. private _pointerCaptures;
  46582. private _lastPointerEvents;
  46583. private static _DefaultUtilityLayer;
  46584. private static _DefaultKeepDepthUtilityLayer;
  46585. private _sharedGizmoLight;
  46586. private _renderCamera;
  46587. /**
  46588. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  46589. * @returns the camera that is used when rendering the utility layer
  46590. */
  46591. getRenderCamera(): Nullable<Camera>;
  46592. /**
  46593. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  46594. * @param cam the camera that should be used when rendering the utility layer
  46595. */
  46596. setRenderCamera(cam: Nullable<Camera>): void;
  46597. /**
  46598. * @hidden
  46599. * Light which used by gizmos to get light shading
  46600. */
  46601. _getSharedGizmoLight(): HemisphericLight;
  46602. /**
  46603. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  46604. */
  46605. pickUtilitySceneFirst: boolean;
  46606. /**
  46607. * 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)
  46608. */
  46609. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  46610. /**
  46611. * 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)
  46612. */
  46613. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  46614. /**
  46615. * The scene that is rendered on top of the original scene
  46616. */
  46617. utilityLayerScene: Scene;
  46618. /**
  46619. * If the utility layer should automatically be rendered on top of existing scene
  46620. */
  46621. shouldRender: boolean;
  46622. /**
  46623. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  46624. */
  46625. onlyCheckPointerDownEvents: boolean;
  46626. /**
  46627. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  46628. */
  46629. processAllEvents: boolean;
  46630. /**
  46631. * Observable raised when the pointer move from the utility layer scene to the main scene
  46632. */
  46633. onPointerOutObservable: Observable<number>;
  46634. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  46635. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  46636. private _afterRenderObserver;
  46637. private _sceneDisposeObserver;
  46638. private _originalPointerObserver;
  46639. /**
  46640. * Instantiates a UtilityLayerRenderer
  46641. * @param originalScene the original scene that will be rendered on top of
  46642. * @param handleEvents boolean indicating if the utility layer should handle events
  46643. */
  46644. constructor(
  46645. /** the original scene that will be rendered on top of */
  46646. originalScene: Scene, handleEvents?: boolean);
  46647. private _notifyObservers;
  46648. /**
  46649. * Renders the utility layers scene on top of the original scene
  46650. */
  46651. render(): void;
  46652. /**
  46653. * Disposes of the renderer
  46654. */
  46655. dispose(): void;
  46656. private _updateCamera;
  46657. }
  46658. }
  46659. declare module "babylonjs/Gizmos/gizmo" {
  46660. import { Nullable } from "babylonjs/types";
  46661. import { IDisposable } from "babylonjs/scene";
  46662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46663. import { Mesh } from "babylonjs/Meshes/mesh";
  46664. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46665. /**
  46666. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46667. */
  46668. export class Gizmo implements IDisposable {
  46669. /** The utility layer the gizmo will be added to */
  46670. gizmoLayer: UtilityLayerRenderer;
  46671. /**
  46672. * The root mesh of the gizmo
  46673. */
  46674. _rootMesh: Mesh;
  46675. private _attachedMesh;
  46676. /**
  46677. * Ratio for the scale of the gizmo (Default: 1)
  46678. */
  46679. scaleRatio: number;
  46680. /**
  46681. * If a custom mesh has been set (Default: false)
  46682. */
  46683. protected _customMeshSet: boolean;
  46684. /**
  46685. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46686. * * When set, interactions will be enabled
  46687. */
  46688. get attachedMesh(): Nullable<AbstractMesh>;
  46689. set attachedMesh(value: Nullable<AbstractMesh>);
  46690. /**
  46691. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46692. * @param mesh The mesh to replace the default mesh of the gizmo
  46693. */
  46694. setCustomMesh(mesh: Mesh): void;
  46695. /**
  46696. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46697. */
  46698. updateGizmoRotationToMatchAttachedMesh: boolean;
  46699. /**
  46700. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46701. */
  46702. updateGizmoPositionToMatchAttachedMesh: boolean;
  46703. /**
  46704. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46705. */
  46706. updateScale: boolean;
  46707. protected _interactionsEnabled: boolean;
  46708. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46709. private _beforeRenderObserver;
  46710. private _tempVector;
  46711. /**
  46712. * Creates a gizmo
  46713. * @param gizmoLayer The utility layer the gizmo will be added to
  46714. */
  46715. constructor(
  46716. /** The utility layer the gizmo will be added to */
  46717. gizmoLayer?: UtilityLayerRenderer);
  46718. /**
  46719. * Updates the gizmo to match the attached mesh's position/rotation
  46720. */
  46721. protected _update(): void;
  46722. /**
  46723. * Disposes of the gizmo
  46724. */
  46725. dispose(): void;
  46726. }
  46727. }
  46728. declare module "babylonjs/Gizmos/planeDragGizmo" {
  46729. import { Observable } from "babylonjs/Misc/observable";
  46730. import { Nullable } from "babylonjs/types";
  46731. import { Vector3 } from "babylonjs/Maths/math.vector";
  46732. import { Color3 } from "babylonjs/Maths/math.color";
  46733. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46734. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46735. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46736. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46737. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46738. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46739. import { Scene } from "babylonjs/scene";
  46740. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46741. /**
  46742. * Single plane drag gizmo
  46743. */
  46744. export class PlaneDragGizmo extends Gizmo {
  46745. /**
  46746. * Drag behavior responsible for the gizmos dragging interactions
  46747. */
  46748. dragBehavior: PointerDragBehavior;
  46749. private _pointerObserver;
  46750. /**
  46751. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46752. */
  46753. snapDistance: number;
  46754. /**
  46755. * Event that fires each time the gizmo snaps to a new location.
  46756. * * snapDistance is the the change in distance
  46757. */
  46758. onSnapObservable: Observable<{
  46759. snapDistance: number;
  46760. }>;
  46761. private _plane;
  46762. private _coloredMaterial;
  46763. private _hoverMaterial;
  46764. private _isEnabled;
  46765. private _parent;
  46766. /** @hidden */
  46767. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46768. /** @hidden */
  46769. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46770. /**
  46771. * Creates a PlaneDragGizmo
  46772. * @param gizmoLayer The utility layer the gizmo will be added to
  46773. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46774. * @param color The color of the gizmo
  46775. */
  46776. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46777. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46778. /**
  46779. * If the gizmo is enabled
  46780. */
  46781. set isEnabled(value: boolean);
  46782. get isEnabled(): boolean;
  46783. /**
  46784. * Disposes of the gizmo
  46785. */
  46786. dispose(): void;
  46787. }
  46788. }
  46789. declare module "babylonjs/Gizmos/positionGizmo" {
  46790. import { Observable } from "babylonjs/Misc/observable";
  46791. import { Nullable } from "babylonjs/types";
  46792. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46793. import { Mesh } from "babylonjs/Meshes/mesh";
  46794. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46795. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  46796. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  46797. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46798. /**
  46799. * Gizmo that enables dragging a mesh along 3 axis
  46800. */
  46801. export class PositionGizmo extends Gizmo {
  46802. /**
  46803. * Internal gizmo used for interactions on the x axis
  46804. */
  46805. xGizmo: AxisDragGizmo;
  46806. /**
  46807. * Internal gizmo used for interactions on the y axis
  46808. */
  46809. yGizmo: AxisDragGizmo;
  46810. /**
  46811. * Internal gizmo used for interactions on the z axis
  46812. */
  46813. zGizmo: AxisDragGizmo;
  46814. /**
  46815. * Internal gizmo used for interactions on the yz plane
  46816. */
  46817. xPlaneGizmo: PlaneDragGizmo;
  46818. /**
  46819. * Internal gizmo used for interactions on the xz plane
  46820. */
  46821. yPlaneGizmo: PlaneDragGizmo;
  46822. /**
  46823. * Internal gizmo used for interactions on the xy plane
  46824. */
  46825. zPlaneGizmo: PlaneDragGizmo;
  46826. /**
  46827. * private variables
  46828. */
  46829. private _meshAttached;
  46830. private _updateGizmoRotationToMatchAttachedMesh;
  46831. private _snapDistance;
  46832. private _scaleRatio;
  46833. /** Fires an event when any of it's sub gizmos are dragged */
  46834. onDragStartObservable: Observable<unknown>;
  46835. /** Fires an event when any of it's sub gizmos are released from dragging */
  46836. onDragEndObservable: Observable<unknown>;
  46837. /**
  46838. * If set to true, planar drag is enabled
  46839. */
  46840. private _planarGizmoEnabled;
  46841. get attachedMesh(): Nullable<AbstractMesh>;
  46842. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46843. /**
  46844. * Creates a PositionGizmo
  46845. * @param gizmoLayer The utility layer the gizmo will be added to
  46846. */
  46847. constructor(gizmoLayer?: UtilityLayerRenderer);
  46848. /**
  46849. * If the planar drag gizmo is enabled
  46850. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46851. */
  46852. set planarGizmoEnabled(value: boolean);
  46853. get planarGizmoEnabled(): boolean;
  46854. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46855. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46856. /**
  46857. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46858. */
  46859. set snapDistance(value: number);
  46860. get snapDistance(): number;
  46861. /**
  46862. * Ratio for the scale of the gizmo (Default: 1)
  46863. */
  46864. set scaleRatio(value: number);
  46865. get scaleRatio(): number;
  46866. /**
  46867. * Disposes of the gizmo
  46868. */
  46869. dispose(): void;
  46870. /**
  46871. * CustomMeshes are not supported by this gizmo
  46872. * @param mesh The mesh to replace the default mesh of the gizmo
  46873. */
  46874. setCustomMesh(mesh: Mesh): void;
  46875. }
  46876. }
  46877. declare module "babylonjs/Gizmos/axisDragGizmo" {
  46878. import { Observable } from "babylonjs/Misc/observable";
  46879. import { Nullable } from "babylonjs/types";
  46880. import { Vector3 } from "babylonjs/Maths/math.vector";
  46881. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46882. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46883. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46884. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46885. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46886. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46887. import { Scene } from "babylonjs/scene";
  46888. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46889. import { Color3 } from "babylonjs/Maths/math.color";
  46890. /**
  46891. * Single axis drag gizmo
  46892. */
  46893. export class AxisDragGizmo extends Gizmo {
  46894. /**
  46895. * Drag behavior responsible for the gizmos dragging interactions
  46896. */
  46897. dragBehavior: PointerDragBehavior;
  46898. private _pointerObserver;
  46899. /**
  46900. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46901. */
  46902. snapDistance: number;
  46903. /**
  46904. * Event that fires each time the gizmo snaps to a new location.
  46905. * * snapDistance is the the change in distance
  46906. */
  46907. onSnapObservable: Observable<{
  46908. snapDistance: number;
  46909. }>;
  46910. private _isEnabled;
  46911. private _parent;
  46912. private _arrow;
  46913. private _coloredMaterial;
  46914. private _hoverMaterial;
  46915. /** @hidden */
  46916. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46917. /** @hidden */
  46918. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46919. /**
  46920. * Creates an AxisDragGizmo
  46921. * @param gizmoLayer The utility layer the gizmo will be added to
  46922. * @param dragAxis The axis which the gizmo will be able to drag on
  46923. * @param color The color of the gizmo
  46924. */
  46925. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46926. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46927. /**
  46928. * If the gizmo is enabled
  46929. */
  46930. set isEnabled(value: boolean);
  46931. get isEnabled(): boolean;
  46932. /**
  46933. * Disposes of the gizmo
  46934. */
  46935. dispose(): void;
  46936. }
  46937. }
  46938. declare module "babylonjs/Debug/axesViewer" {
  46939. import { Vector3 } from "babylonjs/Maths/math.vector";
  46940. import { Nullable } from "babylonjs/types";
  46941. import { Scene } from "babylonjs/scene";
  46942. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46943. /**
  46944. * The Axes viewer will show 3 axes in a specific point in space
  46945. */
  46946. export class AxesViewer {
  46947. private _xAxis;
  46948. private _yAxis;
  46949. private _zAxis;
  46950. private _scaleLinesFactor;
  46951. private _instanced;
  46952. /**
  46953. * Gets the hosting scene
  46954. */
  46955. scene: Scene;
  46956. /**
  46957. * Gets or sets a number used to scale line length
  46958. */
  46959. scaleLines: number;
  46960. /** Gets the node hierarchy used to render x-axis */
  46961. get xAxis(): TransformNode;
  46962. /** Gets the node hierarchy used to render y-axis */
  46963. get yAxis(): TransformNode;
  46964. /** Gets the node hierarchy used to render z-axis */
  46965. get zAxis(): TransformNode;
  46966. /**
  46967. * Creates a new AxesViewer
  46968. * @param scene defines the hosting scene
  46969. * @param scaleLines defines a number used to scale line length (1 by default)
  46970. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46971. * @param xAxis defines the node hierarchy used to render the x-axis
  46972. * @param yAxis defines the node hierarchy used to render the y-axis
  46973. * @param zAxis defines the node hierarchy used to render the z-axis
  46974. */
  46975. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46976. /**
  46977. * Force the viewer to update
  46978. * @param position defines the position of the viewer
  46979. * @param xaxis defines the x axis of the viewer
  46980. * @param yaxis defines the y axis of the viewer
  46981. * @param zaxis defines the z axis of the viewer
  46982. */
  46983. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46984. /**
  46985. * Creates an instance of this axes viewer.
  46986. * @returns a new axes viewer with instanced meshes
  46987. */
  46988. createInstance(): AxesViewer;
  46989. /** Releases resources */
  46990. dispose(): void;
  46991. private static _SetRenderingGroupId;
  46992. }
  46993. }
  46994. declare module "babylonjs/Debug/boneAxesViewer" {
  46995. import { Nullable } from "babylonjs/types";
  46996. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  46997. import { Vector3 } from "babylonjs/Maths/math.vector";
  46998. import { Mesh } from "babylonjs/Meshes/mesh";
  46999. import { Bone } from "babylonjs/Bones/bone";
  47000. import { Scene } from "babylonjs/scene";
  47001. /**
  47002. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47003. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47004. */
  47005. export class BoneAxesViewer extends AxesViewer {
  47006. /**
  47007. * Gets or sets the target mesh where to display the axes viewer
  47008. */
  47009. mesh: Nullable<Mesh>;
  47010. /**
  47011. * Gets or sets the target bone where to display the axes viewer
  47012. */
  47013. bone: Nullable<Bone>;
  47014. /** Gets current position */
  47015. pos: Vector3;
  47016. /** Gets direction of X axis */
  47017. xaxis: Vector3;
  47018. /** Gets direction of Y axis */
  47019. yaxis: Vector3;
  47020. /** Gets direction of Z axis */
  47021. zaxis: Vector3;
  47022. /**
  47023. * Creates a new BoneAxesViewer
  47024. * @param scene defines the hosting scene
  47025. * @param bone defines the target bone
  47026. * @param mesh defines the target mesh
  47027. * @param scaleLines defines a scaling factor for line length (1 by default)
  47028. */
  47029. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47030. /**
  47031. * Force the viewer to update
  47032. */
  47033. update(): void;
  47034. /** Releases resources */
  47035. dispose(): void;
  47036. }
  47037. }
  47038. declare module "babylonjs/Debug/debugLayer" {
  47039. import { Scene } from "babylonjs/scene";
  47040. /**
  47041. * Interface used to define scene explorer extensibility option
  47042. */
  47043. export interface IExplorerExtensibilityOption {
  47044. /**
  47045. * Define the option label
  47046. */
  47047. label: string;
  47048. /**
  47049. * Defines the action to execute on click
  47050. */
  47051. action: (entity: any) => void;
  47052. }
  47053. /**
  47054. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  47055. */
  47056. export interface IExplorerExtensibilityGroup {
  47057. /**
  47058. * Defines a predicate to test if a given type mut be extended
  47059. */
  47060. predicate: (entity: any) => boolean;
  47061. /**
  47062. * Gets the list of options added to a type
  47063. */
  47064. entries: IExplorerExtensibilityOption[];
  47065. }
  47066. /**
  47067. * Interface used to define the options to use to create the Inspector
  47068. */
  47069. export interface IInspectorOptions {
  47070. /**
  47071. * Display in overlay mode (default: false)
  47072. */
  47073. overlay?: boolean;
  47074. /**
  47075. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47076. */
  47077. globalRoot?: HTMLElement;
  47078. /**
  47079. * Display the Scene explorer
  47080. */
  47081. showExplorer?: boolean;
  47082. /**
  47083. * Display the property inspector
  47084. */
  47085. showInspector?: boolean;
  47086. /**
  47087. * Display in embed mode (both panes on the right)
  47088. */
  47089. embedMode?: boolean;
  47090. /**
  47091. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  47092. */
  47093. handleResize?: boolean;
  47094. /**
  47095. * Allow the panes to popup (default: true)
  47096. */
  47097. enablePopup?: boolean;
  47098. /**
  47099. * Allow the panes to be closed by users (default: true)
  47100. */
  47101. enableClose?: boolean;
  47102. /**
  47103. * Optional list of extensibility entries
  47104. */
  47105. explorerExtensibility?: IExplorerExtensibilityGroup[];
  47106. /**
  47107. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  47108. */
  47109. inspectorURL?: string;
  47110. /**
  47111. * Optional initial tab (default to DebugLayerTab.Properties)
  47112. */
  47113. initialTab?: DebugLayerTab;
  47114. }
  47115. module "babylonjs/scene" {
  47116. interface Scene {
  47117. /**
  47118. * @hidden
  47119. * Backing field
  47120. */
  47121. _debugLayer: DebugLayer;
  47122. /**
  47123. * Gets the debug layer (aka Inspector) associated with the scene
  47124. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47125. */
  47126. debugLayer: DebugLayer;
  47127. }
  47128. }
  47129. /**
  47130. * Enum of inspector action tab
  47131. */
  47132. export enum DebugLayerTab {
  47133. /**
  47134. * Properties tag (default)
  47135. */
  47136. Properties = 0,
  47137. /**
  47138. * Debug tab
  47139. */
  47140. Debug = 1,
  47141. /**
  47142. * Statistics tab
  47143. */
  47144. Statistics = 2,
  47145. /**
  47146. * Tools tab
  47147. */
  47148. Tools = 3,
  47149. /**
  47150. * Settings tab
  47151. */
  47152. Settings = 4
  47153. }
  47154. /**
  47155. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47156. * what is happening in your scene
  47157. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47158. */
  47159. export class DebugLayer {
  47160. /**
  47161. * Define the url to get the inspector script from.
  47162. * By default it uses the babylonjs CDN.
  47163. * @ignoreNaming
  47164. */
  47165. static InspectorURL: string;
  47166. private _scene;
  47167. private BJSINSPECTOR;
  47168. private _onPropertyChangedObservable?;
  47169. /**
  47170. * Observable triggered when a property is changed through the inspector.
  47171. */
  47172. get onPropertyChangedObservable(): any;
  47173. /**
  47174. * Instantiates a new debug layer.
  47175. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47176. * what is happening in your scene
  47177. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47178. * @param scene Defines the scene to inspect
  47179. */
  47180. constructor(scene: Scene);
  47181. /** Creates the inspector window. */
  47182. private _createInspector;
  47183. /**
  47184. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  47185. * @param entity defines the entity to select
  47186. * @param lineContainerTitle defines the specific block to highlight
  47187. */
  47188. select(entity: any, lineContainerTitle?: string): void;
  47189. /** Get the inspector from bundle or global */
  47190. private _getGlobalInspector;
  47191. /**
  47192. * Get if the inspector is visible or not.
  47193. * @returns true if visible otherwise, false
  47194. */
  47195. isVisible(): boolean;
  47196. /**
  47197. * Hide the inspector and close its window.
  47198. */
  47199. hide(): void;
  47200. /**
  47201. * Launch the debugLayer.
  47202. * @param config Define the configuration of the inspector
  47203. * @return a promise fulfilled when the debug layer is visible
  47204. */
  47205. show(config?: IInspectorOptions): Promise<DebugLayer>;
  47206. }
  47207. }
  47208. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  47209. import { Nullable } from "babylonjs/types";
  47210. import { Scene } from "babylonjs/scene";
  47211. import { Vector4 } from "babylonjs/Maths/math.vector";
  47212. import { Color4 } from "babylonjs/Maths/math.color";
  47213. import { Mesh } from "babylonjs/Meshes/mesh";
  47214. /**
  47215. * Class containing static functions to help procedurally build meshes
  47216. */
  47217. export class BoxBuilder {
  47218. /**
  47219. * Creates a box mesh
  47220. * * The parameter `size` sets the size (float) of each box side (default 1)
  47221. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  47222. * * 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)
  47223. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47224. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47225. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47227. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  47228. * @param name defines the name of the mesh
  47229. * @param options defines the options used to create the mesh
  47230. * @param scene defines the hosting scene
  47231. * @returns the box mesh
  47232. */
  47233. static CreateBox(name: string, options: {
  47234. size?: number;
  47235. width?: number;
  47236. height?: number;
  47237. depth?: number;
  47238. faceUV?: Vector4[];
  47239. faceColors?: Color4[];
  47240. sideOrientation?: number;
  47241. frontUVs?: Vector4;
  47242. backUVs?: Vector4;
  47243. wrap?: boolean;
  47244. topBaseAt?: number;
  47245. bottomBaseAt?: number;
  47246. updatable?: boolean;
  47247. }, scene?: Nullable<Scene>): Mesh;
  47248. }
  47249. }
  47250. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  47251. import { Vector4 } from "babylonjs/Maths/math.vector";
  47252. import { Mesh } from "babylonjs/Meshes/mesh";
  47253. import { Scene } from "babylonjs/scene";
  47254. import { Nullable } from "babylonjs/types";
  47255. /**
  47256. * Class containing static functions to help procedurally build meshes
  47257. */
  47258. export class SphereBuilder {
  47259. /**
  47260. * Creates a sphere mesh
  47261. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47262. * * 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`)
  47263. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47264. * * 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
  47265. * * 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)
  47266. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47267. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47269. * @param name defines the name of the mesh
  47270. * @param options defines the options used to create the mesh
  47271. * @param scene defines the hosting scene
  47272. * @returns the sphere mesh
  47273. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47274. */
  47275. static CreateSphere(name: string, options: {
  47276. segments?: number;
  47277. diameter?: number;
  47278. diameterX?: number;
  47279. diameterY?: number;
  47280. diameterZ?: number;
  47281. arc?: number;
  47282. slice?: number;
  47283. sideOrientation?: number;
  47284. frontUVs?: Vector4;
  47285. backUVs?: Vector4;
  47286. updatable?: boolean;
  47287. }, scene?: Nullable<Scene>): Mesh;
  47288. }
  47289. }
  47290. declare module "babylonjs/Debug/physicsViewer" {
  47291. import { Nullable } from "babylonjs/types";
  47292. import { Scene } from "babylonjs/scene";
  47293. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47294. import { Mesh } from "babylonjs/Meshes/mesh";
  47295. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47296. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47297. /**
  47298. * Used to show the physics impostor around the specific mesh
  47299. */
  47300. export class PhysicsViewer {
  47301. /** @hidden */
  47302. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  47303. /** @hidden */
  47304. protected _meshes: Array<Nullable<AbstractMesh>>;
  47305. /** @hidden */
  47306. protected _scene: Nullable<Scene>;
  47307. /** @hidden */
  47308. protected _numMeshes: number;
  47309. /** @hidden */
  47310. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  47311. private _renderFunction;
  47312. private _utilityLayer;
  47313. private _debugBoxMesh;
  47314. private _debugSphereMesh;
  47315. private _debugCylinderMesh;
  47316. private _debugMaterial;
  47317. private _debugMeshMeshes;
  47318. /**
  47319. * Creates a new PhysicsViewer
  47320. * @param scene defines the hosting scene
  47321. */
  47322. constructor(scene: Scene);
  47323. /** @hidden */
  47324. protected _updateDebugMeshes(): void;
  47325. /**
  47326. * Renders a specified physic impostor
  47327. * @param impostor defines the impostor to render
  47328. * @param targetMesh defines the mesh represented by the impostor
  47329. * @returns the new debug mesh used to render the impostor
  47330. */
  47331. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  47332. /**
  47333. * Hides a specified physic impostor
  47334. * @param impostor defines the impostor to hide
  47335. */
  47336. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  47337. private _getDebugMaterial;
  47338. private _getDebugBoxMesh;
  47339. private _getDebugSphereMesh;
  47340. private _getDebugCylinderMesh;
  47341. private _getDebugMeshMesh;
  47342. private _getDebugMesh;
  47343. /** Releases all resources */
  47344. dispose(): void;
  47345. }
  47346. }
  47347. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  47348. import { Vector3 } from "babylonjs/Maths/math.vector";
  47349. import { Color4 } from "babylonjs/Maths/math.color";
  47350. import { Nullable } from "babylonjs/types";
  47351. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  47352. import { Scene } from "babylonjs/scene";
  47353. /**
  47354. * Class containing static functions to help procedurally build meshes
  47355. */
  47356. export class LinesBuilder {
  47357. /**
  47358. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  47359. * * 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
  47360. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  47361. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  47362. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  47363. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  47364. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47365. * * 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
  47366. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  47367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47368. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  47369. * @param name defines the name of the new line system
  47370. * @param options defines the options used to create the line system
  47371. * @param scene defines the hosting scene
  47372. * @returns a new line system mesh
  47373. */
  47374. static CreateLineSystem(name: string, options: {
  47375. lines: Vector3[][];
  47376. updatable?: boolean;
  47377. instance?: Nullable<LinesMesh>;
  47378. colors?: Nullable<Color4[][]>;
  47379. useVertexAlpha?: boolean;
  47380. }, scene: Nullable<Scene>): LinesMesh;
  47381. /**
  47382. * Creates a line mesh
  47383. * 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
  47384. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47385. * * The parameter `points` is an array successive Vector3
  47386. * * 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
  47387. * * The optional parameter `colors` is an array of successive Color4, one per line point
  47388. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  47389. * * When updating an instance, remember that only point positions can change, not the number of points
  47390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47391. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  47392. * @param name defines the name of the new line system
  47393. * @param options defines the options used to create the line system
  47394. * @param scene defines the hosting scene
  47395. * @returns a new line mesh
  47396. */
  47397. static CreateLines(name: string, options: {
  47398. points: Vector3[];
  47399. updatable?: boolean;
  47400. instance?: Nullable<LinesMesh>;
  47401. colors?: Color4[];
  47402. useVertexAlpha?: boolean;
  47403. }, scene?: Nullable<Scene>): LinesMesh;
  47404. /**
  47405. * Creates a dashed line mesh
  47406. * * 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
  47407. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47408. * * The parameter `points` is an array successive Vector3
  47409. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  47410. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  47411. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  47412. * * 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
  47413. * * When updating an instance, remember that only point positions can change, not the number of points
  47414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47415. * @param name defines the name of the mesh
  47416. * @param options defines the options used to create the mesh
  47417. * @param scene defines the hosting scene
  47418. * @returns the dashed line mesh
  47419. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  47420. */
  47421. static CreateDashedLines(name: string, options: {
  47422. points: Vector3[];
  47423. dashSize?: number;
  47424. gapSize?: number;
  47425. dashNb?: number;
  47426. updatable?: boolean;
  47427. instance?: LinesMesh;
  47428. }, scene?: Nullable<Scene>): LinesMesh;
  47429. }
  47430. }
  47431. declare module "babylonjs/Debug/rayHelper" {
  47432. import { Nullable } from "babylonjs/types";
  47433. import { Ray } from "babylonjs/Culling/ray";
  47434. import { Vector3 } from "babylonjs/Maths/math.vector";
  47435. import { Color3 } from "babylonjs/Maths/math.color";
  47436. import { Scene } from "babylonjs/scene";
  47437. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47438. import "babylonjs/Meshes/Builders/linesBuilder";
  47439. /**
  47440. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  47441. * in order to better appreciate the issue one might have.
  47442. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  47443. */
  47444. export class RayHelper {
  47445. /**
  47446. * Defines the ray we are currently tryin to visualize.
  47447. */
  47448. ray: Nullable<Ray>;
  47449. private _renderPoints;
  47450. private _renderLine;
  47451. private _renderFunction;
  47452. private _scene;
  47453. private _updateToMeshFunction;
  47454. private _attachedToMesh;
  47455. private _meshSpaceDirection;
  47456. private _meshSpaceOrigin;
  47457. /**
  47458. * Helper function to create a colored helper in a scene in one line.
  47459. * @param ray Defines the ray we are currently tryin to visualize
  47460. * @param scene Defines the scene the ray is used in
  47461. * @param color Defines the color we want to see the ray in
  47462. * @returns The newly created ray helper.
  47463. */
  47464. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  47465. /**
  47466. * Instantiate a new ray helper.
  47467. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  47468. * in order to better appreciate the issue one might have.
  47469. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  47470. * @param ray Defines the ray we are currently tryin to visualize
  47471. */
  47472. constructor(ray: Ray);
  47473. /**
  47474. * Shows the ray we are willing to debug.
  47475. * @param scene Defines the scene the ray needs to be rendered in
  47476. * @param color Defines the color the ray needs to be rendered in
  47477. */
  47478. show(scene: Scene, color?: Color3): void;
  47479. /**
  47480. * Hides the ray we are debugging.
  47481. */
  47482. hide(): void;
  47483. private _render;
  47484. /**
  47485. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  47486. * @param mesh Defines the mesh we want the helper attached to
  47487. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  47488. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  47489. * @param length Defines the length of the ray
  47490. */
  47491. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  47492. /**
  47493. * Detach the ray helper from the mesh it has previously been attached to.
  47494. */
  47495. detachFromMesh(): void;
  47496. private _updateToMesh;
  47497. /**
  47498. * Dispose the helper and release its associated resources.
  47499. */
  47500. dispose(): void;
  47501. }
  47502. }
  47503. declare module "babylonjs/Debug/skeletonViewer" {
  47504. import { Color3 } from "babylonjs/Maths/math.color";
  47505. import { Scene } from "babylonjs/scene";
  47506. import { Nullable } from "babylonjs/types";
  47507. import { Skeleton } from "babylonjs/Bones/skeleton";
  47508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47509. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  47510. /**
  47511. * Class used to render a debug view of a given skeleton
  47512. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  47513. */
  47514. export class SkeletonViewer {
  47515. /** defines the skeleton to render */
  47516. skeleton: Skeleton;
  47517. /** defines the mesh attached to the skeleton */
  47518. mesh: AbstractMesh;
  47519. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47520. autoUpdateBonesMatrices: boolean;
  47521. /** defines the rendering group id to use with the viewer */
  47522. renderingGroupId: number;
  47523. /** Gets or sets the color used to render the skeleton */
  47524. color: Color3;
  47525. private _scene;
  47526. private _debugLines;
  47527. private _debugMesh;
  47528. private _isEnabled;
  47529. private _renderFunction;
  47530. private _utilityLayer;
  47531. /**
  47532. * Returns the mesh used to render the bones
  47533. */
  47534. get debugMesh(): Nullable<LinesMesh>;
  47535. /**
  47536. * Creates a new SkeletonViewer
  47537. * @param skeleton defines the skeleton to render
  47538. * @param mesh defines the mesh attached to the skeleton
  47539. * @param scene defines the hosting scene
  47540. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  47541. * @param renderingGroupId defines the rendering group id to use with the viewer
  47542. */
  47543. constructor(
  47544. /** defines the skeleton to render */
  47545. skeleton: Skeleton,
  47546. /** defines the mesh attached to the skeleton */
  47547. mesh: AbstractMesh, scene: Scene,
  47548. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47549. autoUpdateBonesMatrices?: boolean,
  47550. /** defines the rendering group id to use with the viewer */
  47551. renderingGroupId?: number);
  47552. /** Gets or sets a boolean indicating if the viewer is enabled */
  47553. set isEnabled(value: boolean);
  47554. get isEnabled(): boolean;
  47555. private _getBonePosition;
  47556. private _getLinesForBonesWithLength;
  47557. private _getLinesForBonesNoLength;
  47558. /** Update the viewer to sync with current skeleton state */
  47559. update(): void;
  47560. /** Release associated resources */
  47561. dispose(): void;
  47562. }
  47563. }
  47564. declare module "babylonjs/Debug/index" {
  47565. export * from "babylonjs/Debug/axesViewer";
  47566. export * from "babylonjs/Debug/boneAxesViewer";
  47567. export * from "babylonjs/Debug/debugLayer";
  47568. export * from "babylonjs/Debug/physicsViewer";
  47569. export * from "babylonjs/Debug/rayHelper";
  47570. export * from "babylonjs/Debug/skeletonViewer";
  47571. }
  47572. declare module "babylonjs/Engines/nullEngine" {
  47573. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  47574. import { Scene } from "babylonjs/scene";
  47575. import { Engine } from "babylonjs/Engines/engine";
  47576. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  47577. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  47578. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47579. import { Effect } from "babylonjs/Materials/effect";
  47580. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  47581. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  47582. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  47583. /**
  47584. * Options to create the null engine
  47585. */
  47586. export class NullEngineOptions {
  47587. /**
  47588. * Render width (Default: 512)
  47589. */
  47590. renderWidth: number;
  47591. /**
  47592. * Render height (Default: 256)
  47593. */
  47594. renderHeight: number;
  47595. /**
  47596. * Texture size (Default: 512)
  47597. */
  47598. textureSize: number;
  47599. /**
  47600. * If delta time between frames should be constant
  47601. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47602. */
  47603. deterministicLockstep: boolean;
  47604. /**
  47605. * Maximum about of steps between frames (Default: 4)
  47606. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47607. */
  47608. lockstepMaxSteps: number;
  47609. }
  47610. /**
  47611. * The null engine class provides support for headless version of babylon.js.
  47612. * This can be used in server side scenario or for testing purposes
  47613. */
  47614. export class NullEngine extends Engine {
  47615. private _options;
  47616. /**
  47617. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  47618. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47619. * @returns true if engine is in deterministic lock step mode
  47620. */
  47621. isDeterministicLockStep(): boolean;
  47622. /**
  47623. * Gets the max steps when engine is running in deterministic lock step
  47624. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47625. * @returns the max steps
  47626. */
  47627. getLockstepMaxSteps(): number;
  47628. /**
  47629. * Gets the current hardware scaling level.
  47630. * By default the hardware scaling level is computed from the window device ratio.
  47631. * 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.
  47632. * @returns a number indicating the current hardware scaling level
  47633. */
  47634. getHardwareScalingLevel(): number;
  47635. constructor(options?: NullEngineOptions);
  47636. /**
  47637. * Creates a vertex buffer
  47638. * @param vertices the data for the vertex buffer
  47639. * @returns the new WebGL static buffer
  47640. */
  47641. createVertexBuffer(vertices: FloatArray): DataBuffer;
  47642. /**
  47643. * Creates a new index buffer
  47644. * @param indices defines the content of the index buffer
  47645. * @param updatable defines if the index buffer must be updatable
  47646. * @returns a new webGL buffer
  47647. */
  47648. createIndexBuffer(indices: IndicesArray): DataBuffer;
  47649. /**
  47650. * Clear the current render buffer or the current render target (if any is set up)
  47651. * @param color defines the color to use
  47652. * @param backBuffer defines if the back buffer must be cleared
  47653. * @param depth defines if the depth buffer must be cleared
  47654. * @param stencil defines if the stencil buffer must be cleared
  47655. */
  47656. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47657. /**
  47658. * Gets the current render width
  47659. * @param useScreen defines if screen size must be used (or the current render target if any)
  47660. * @returns a number defining the current render width
  47661. */
  47662. getRenderWidth(useScreen?: boolean): number;
  47663. /**
  47664. * Gets the current render height
  47665. * @param useScreen defines if screen size must be used (or the current render target if any)
  47666. * @returns a number defining the current render height
  47667. */
  47668. getRenderHeight(useScreen?: boolean): number;
  47669. /**
  47670. * Set the WebGL's viewport
  47671. * @param viewport defines the viewport element to be used
  47672. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  47673. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  47674. */
  47675. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  47676. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  47677. /**
  47678. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  47679. * @param pipelineContext defines the pipeline context to use
  47680. * @param uniformsNames defines the list of uniform names
  47681. * @returns an array of webGL uniform locations
  47682. */
  47683. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  47684. /**
  47685. * Gets the lsit of active attributes for a given webGL program
  47686. * @param pipelineContext defines the pipeline context to use
  47687. * @param attributesNames defines the list of attribute names to get
  47688. * @returns an array of indices indicating the offset of each attribute
  47689. */
  47690. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47691. /**
  47692. * Binds an effect to the webGL context
  47693. * @param effect defines the effect to bind
  47694. */
  47695. bindSamplers(effect: Effect): void;
  47696. /**
  47697. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  47698. * @param effect defines the effect to activate
  47699. */
  47700. enableEffect(effect: Effect): void;
  47701. /**
  47702. * Set various states to the webGL context
  47703. * @param culling defines backface culling state
  47704. * @param zOffset defines the value to apply to zOffset (0 by default)
  47705. * @param force defines if states must be applied even if cache is up to date
  47706. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  47707. */
  47708. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47709. /**
  47710. * Set the value of an uniform to an array of int32
  47711. * @param uniform defines the webGL uniform location where to store the value
  47712. * @param array defines the array of int32 to store
  47713. */
  47714. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47715. /**
  47716. * Set the value of an uniform to an array of int32 (stored as vec2)
  47717. * @param uniform defines the webGL uniform location where to store the value
  47718. * @param array defines the array of int32 to store
  47719. */
  47720. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47721. /**
  47722. * Set the value of an uniform to an array of int32 (stored as vec3)
  47723. * @param uniform defines the webGL uniform location where to store the value
  47724. * @param array defines the array of int32 to store
  47725. */
  47726. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47727. /**
  47728. * Set the value of an uniform to an array of int32 (stored as vec4)
  47729. * @param uniform defines the webGL uniform location where to store the value
  47730. * @param array defines the array of int32 to store
  47731. */
  47732. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47733. /**
  47734. * Set the value of an uniform to an array of float32
  47735. * @param uniform defines the webGL uniform location where to store the value
  47736. * @param array defines the array of float32 to store
  47737. */
  47738. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47739. /**
  47740. * Set the value of an uniform to an array of float32 (stored as vec2)
  47741. * @param uniform defines the webGL uniform location where to store the value
  47742. * @param array defines the array of float32 to store
  47743. */
  47744. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47745. /**
  47746. * Set the value of an uniform to an array of float32 (stored as vec3)
  47747. * @param uniform defines the webGL uniform location where to store the value
  47748. * @param array defines the array of float32 to store
  47749. */
  47750. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47751. /**
  47752. * Set the value of an uniform to an array of float32 (stored as vec4)
  47753. * @param uniform defines the webGL uniform location where to store the value
  47754. * @param array defines the array of float32 to store
  47755. */
  47756. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47757. /**
  47758. * Set the value of an uniform to an array of number
  47759. * @param uniform defines the webGL uniform location where to store the value
  47760. * @param array defines the array of number to store
  47761. */
  47762. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47763. /**
  47764. * Set the value of an uniform to an array of number (stored as vec2)
  47765. * @param uniform defines the webGL uniform location where to store the value
  47766. * @param array defines the array of number to store
  47767. */
  47768. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47769. /**
  47770. * Set the value of an uniform to an array of number (stored as vec3)
  47771. * @param uniform defines the webGL uniform location where to store the value
  47772. * @param array defines the array of number to store
  47773. */
  47774. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47775. /**
  47776. * Set the value of an uniform to an array of number (stored as vec4)
  47777. * @param uniform defines the webGL uniform location where to store the value
  47778. * @param array defines the array of number to store
  47779. */
  47780. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47781. /**
  47782. * Set the value of an uniform to an array of float32 (stored as matrices)
  47783. * @param uniform defines the webGL uniform location where to store the value
  47784. * @param matrices defines the array of float32 to store
  47785. */
  47786. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47787. /**
  47788. * Set the value of an uniform to a matrix (3x3)
  47789. * @param uniform defines the webGL uniform location where to store the value
  47790. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  47791. */
  47792. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47793. /**
  47794. * Set the value of an uniform to a matrix (2x2)
  47795. * @param uniform defines the webGL uniform location where to store the value
  47796. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47797. */
  47798. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47799. /**
  47800. * Set the value of an uniform to a number (float)
  47801. * @param uniform defines the webGL uniform location where to store the value
  47802. * @param value defines the float number to store
  47803. */
  47804. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47805. /**
  47806. * Set the value of an uniform to a vec2
  47807. * @param uniform defines the webGL uniform location where to store the value
  47808. * @param x defines the 1st component of the value
  47809. * @param y defines the 2nd component of the value
  47810. */
  47811. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47812. /**
  47813. * Set the value of an uniform to a vec3
  47814. * @param uniform defines the webGL uniform location where to store the value
  47815. * @param x defines the 1st component of the value
  47816. * @param y defines the 2nd component of the value
  47817. * @param z defines the 3rd component of the value
  47818. */
  47819. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47820. /**
  47821. * Set the value of an uniform to a boolean
  47822. * @param uniform defines the webGL uniform location where to store the value
  47823. * @param bool defines the boolean to store
  47824. */
  47825. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47826. /**
  47827. * Set the value of an uniform to a vec4
  47828. * @param uniform defines the webGL uniform location where to store the value
  47829. * @param x defines the 1st component of the value
  47830. * @param y defines the 2nd component of the value
  47831. * @param z defines the 3rd component of the value
  47832. * @param w defines the 4th component of the value
  47833. */
  47834. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47835. /**
  47836. * Sets the current alpha mode
  47837. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47838. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47839. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47840. */
  47841. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47842. /**
  47843. * Bind webGl buffers directly to the webGL context
  47844. * @param vertexBuffers defines the vertex buffer to bind
  47845. * @param indexBuffer defines the index buffer to bind
  47846. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47847. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47848. * @param effect defines the effect associated with the vertex buffer
  47849. */
  47850. bindBuffers(vertexBuffers: {
  47851. [key: string]: VertexBuffer;
  47852. }, indexBuffer: DataBuffer, effect: Effect): void;
  47853. /**
  47854. * Force the entire cache to be cleared
  47855. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47856. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47857. */
  47858. wipeCaches(bruteForce?: boolean): void;
  47859. /**
  47860. * Send a draw order
  47861. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47862. * @param indexStart defines the starting index
  47863. * @param indexCount defines the number of index to draw
  47864. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47865. */
  47866. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47867. /**
  47868. * Draw a list of indexed primitives
  47869. * @param fillMode defines the primitive to use
  47870. * @param indexStart defines the starting index
  47871. * @param indexCount defines the number of index to draw
  47872. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47873. */
  47874. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47875. /**
  47876. * Draw a list of unindexed primitives
  47877. * @param fillMode defines the primitive to use
  47878. * @param verticesStart defines the index of first vertex to draw
  47879. * @param verticesCount defines the count of vertices to draw
  47880. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47881. */
  47882. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47883. /** @hidden */
  47884. _createTexture(): WebGLTexture;
  47885. /** @hidden */
  47886. _releaseTexture(texture: InternalTexture): void;
  47887. /**
  47888. * Usually called from Texture.ts.
  47889. * Passed information to create a WebGLTexture
  47890. * @param urlArg defines a value which contains one of the following:
  47891. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47892. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47893. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47894. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47895. * @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)
  47896. * @param scene needed for loading to the correct scene
  47897. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47898. * @param onLoad optional callback to be called upon successful completion
  47899. * @param onError optional callback to be called upon failure
  47900. * @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
  47901. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47902. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47903. * @param forcedExtension defines the extension to use to pick the right loader
  47904. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  47905. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47906. */
  47907. 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;
  47908. /**
  47909. * Creates a new render target texture
  47910. * @param size defines the size of the texture
  47911. * @param options defines the options used to create the texture
  47912. * @returns a new render target texture stored in an InternalTexture
  47913. */
  47914. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47915. /**
  47916. * Update the sampling mode of a given texture
  47917. * @param samplingMode defines the required sampling mode
  47918. * @param texture defines the texture to update
  47919. */
  47920. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47921. /**
  47922. * Binds the frame buffer to the specified texture.
  47923. * @param texture The texture to render to or null for the default canvas
  47924. * @param faceIndex The face of the texture to render to in case of cube texture
  47925. * @param requiredWidth The width of the target to render to
  47926. * @param requiredHeight The height of the target to render to
  47927. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47928. * @param depthStencilTexture The depth stencil texture to use to render
  47929. * @param lodLevel defines le lod level to bind to the frame buffer
  47930. */
  47931. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47932. /**
  47933. * Unbind the current render target texture from the webGL context
  47934. * @param texture defines the render target texture to unbind
  47935. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47936. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47937. */
  47938. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47939. /**
  47940. * Creates a dynamic vertex buffer
  47941. * @param vertices the data for the dynamic vertex buffer
  47942. * @returns the new WebGL dynamic buffer
  47943. */
  47944. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47945. /**
  47946. * Update the content of a dynamic texture
  47947. * @param texture defines the texture to update
  47948. * @param canvas defines the canvas containing the source
  47949. * @param invertY defines if data must be stored with Y axis inverted
  47950. * @param premulAlpha defines if alpha is stored as premultiplied
  47951. * @param format defines the format of the data
  47952. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47953. */
  47954. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47955. /**
  47956. * Gets a boolean indicating if all created effects are ready
  47957. * @returns true if all effects are ready
  47958. */
  47959. areAllEffectsReady(): boolean;
  47960. /**
  47961. * @hidden
  47962. * Get the current error code of the webGL context
  47963. * @returns the error code
  47964. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47965. */
  47966. getError(): number;
  47967. /** @hidden */
  47968. _getUnpackAlignement(): number;
  47969. /** @hidden */
  47970. _unpackFlipY(value: boolean): void;
  47971. /**
  47972. * Update a dynamic index buffer
  47973. * @param indexBuffer defines the target index buffer
  47974. * @param indices defines the data to update
  47975. * @param offset defines the offset in the target index buffer where update should start
  47976. */
  47977. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47978. /**
  47979. * Updates a dynamic vertex buffer.
  47980. * @param vertexBuffer the vertex buffer to update
  47981. * @param vertices the data used to update the vertex buffer
  47982. * @param byteOffset the byte offset of the data (optional)
  47983. * @param byteLength the byte length of the data (optional)
  47984. */
  47985. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47986. /** @hidden */
  47987. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47988. /** @hidden */
  47989. _bindTexture(channel: number, texture: InternalTexture): void;
  47990. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47991. /**
  47992. * 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
  47993. */
  47994. releaseEffects(): void;
  47995. displayLoadingUI(): void;
  47996. hideLoadingUI(): void;
  47997. /** @hidden */
  47998. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47999. /** @hidden */
  48000. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48001. /** @hidden */
  48002. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48003. /** @hidden */
  48004. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48005. }
  48006. }
  48007. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48008. import { Nullable, int } from "babylonjs/types";
  48009. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48010. /** @hidden */
  48011. export class _OcclusionDataStorage {
  48012. /** @hidden */
  48013. occlusionInternalRetryCounter: number;
  48014. /** @hidden */
  48015. isOcclusionQueryInProgress: boolean;
  48016. /** @hidden */
  48017. isOccluded: boolean;
  48018. /** @hidden */
  48019. occlusionRetryCount: number;
  48020. /** @hidden */
  48021. occlusionType: number;
  48022. /** @hidden */
  48023. occlusionQueryAlgorithmType: number;
  48024. }
  48025. module "babylonjs/Engines/engine" {
  48026. interface Engine {
  48027. /**
  48028. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48029. * @return the new query
  48030. */
  48031. createQuery(): WebGLQuery;
  48032. /**
  48033. * Delete and release a webGL query
  48034. * @param query defines the query to delete
  48035. * @return the current engine
  48036. */
  48037. deleteQuery(query: WebGLQuery): Engine;
  48038. /**
  48039. * Check if a given query has resolved and got its value
  48040. * @param query defines the query to check
  48041. * @returns true if the query got its value
  48042. */
  48043. isQueryResultAvailable(query: WebGLQuery): boolean;
  48044. /**
  48045. * Gets the value of a given query
  48046. * @param query defines the query to check
  48047. * @returns the value of the query
  48048. */
  48049. getQueryResult(query: WebGLQuery): number;
  48050. /**
  48051. * Initiates an occlusion query
  48052. * @param algorithmType defines the algorithm to use
  48053. * @param query defines the query to use
  48054. * @returns the current engine
  48055. * @see http://doc.babylonjs.com/features/occlusionquery
  48056. */
  48057. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48058. /**
  48059. * Ends an occlusion query
  48060. * @see http://doc.babylonjs.com/features/occlusionquery
  48061. * @param algorithmType defines the algorithm to use
  48062. * @returns the current engine
  48063. */
  48064. endOcclusionQuery(algorithmType: number): Engine;
  48065. /**
  48066. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48067. * Please note that only one query can be issued at a time
  48068. * @returns a time token used to track the time span
  48069. */
  48070. startTimeQuery(): Nullable<_TimeToken>;
  48071. /**
  48072. * Ends a time query
  48073. * @param token defines the token used to measure the time span
  48074. * @returns the time spent (in ns)
  48075. */
  48076. endTimeQuery(token: _TimeToken): int;
  48077. /** @hidden */
  48078. _currentNonTimestampToken: Nullable<_TimeToken>;
  48079. /** @hidden */
  48080. _createTimeQuery(): WebGLQuery;
  48081. /** @hidden */
  48082. _deleteTimeQuery(query: WebGLQuery): void;
  48083. /** @hidden */
  48084. _getGlAlgorithmType(algorithmType: number): number;
  48085. /** @hidden */
  48086. _getTimeQueryResult(query: WebGLQuery): any;
  48087. /** @hidden */
  48088. _getTimeQueryAvailability(query: WebGLQuery): any;
  48089. }
  48090. }
  48091. module "babylonjs/Meshes/abstractMesh" {
  48092. interface AbstractMesh {
  48093. /**
  48094. * Backing filed
  48095. * @hidden
  48096. */
  48097. __occlusionDataStorage: _OcclusionDataStorage;
  48098. /**
  48099. * Access property
  48100. * @hidden
  48101. */
  48102. _occlusionDataStorage: _OcclusionDataStorage;
  48103. /**
  48104. * 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.
  48105. * The default value is -1 which means don't break the query and wait till the result
  48106. * @see http://doc.babylonjs.com/features/occlusionquery
  48107. */
  48108. occlusionRetryCount: number;
  48109. /**
  48110. * 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:
  48111. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48112. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48113. * * 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.
  48114. * @see http://doc.babylonjs.com/features/occlusionquery
  48115. */
  48116. occlusionType: number;
  48117. /**
  48118. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48119. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48120. * * 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.
  48121. * @see http://doc.babylonjs.com/features/occlusionquery
  48122. */
  48123. occlusionQueryAlgorithmType: number;
  48124. /**
  48125. * 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
  48126. * @see http://doc.babylonjs.com/features/occlusionquery
  48127. */
  48128. isOccluded: boolean;
  48129. /**
  48130. * Flag to check the progress status of the query
  48131. * @see http://doc.babylonjs.com/features/occlusionquery
  48132. */
  48133. isOcclusionQueryInProgress: boolean;
  48134. }
  48135. }
  48136. }
  48137. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48138. import { Nullable } from "babylonjs/types";
  48139. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48140. /** @hidden */
  48141. export var _forceTransformFeedbackToBundle: boolean;
  48142. module "babylonjs/Engines/engine" {
  48143. interface Engine {
  48144. /**
  48145. * Creates a webGL transform feedback object
  48146. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48147. * @returns the webGL transform feedback object
  48148. */
  48149. createTransformFeedback(): WebGLTransformFeedback;
  48150. /**
  48151. * Delete a webGL transform feedback object
  48152. * @param value defines the webGL transform feedback object to delete
  48153. */
  48154. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48155. /**
  48156. * Bind a webGL transform feedback object to the webgl context
  48157. * @param value defines the webGL transform feedback object to bind
  48158. */
  48159. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48160. /**
  48161. * Begins a transform feedback operation
  48162. * @param usePoints defines if points or triangles must be used
  48163. */
  48164. beginTransformFeedback(usePoints: boolean): void;
  48165. /**
  48166. * Ends a transform feedback operation
  48167. */
  48168. endTransformFeedback(): void;
  48169. /**
  48170. * Specify the varyings to use with transform feedback
  48171. * @param program defines the associated webGL program
  48172. * @param value defines the list of strings representing the varying names
  48173. */
  48174. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48175. /**
  48176. * Bind a webGL buffer for a transform feedback operation
  48177. * @param value defines the webGL buffer to bind
  48178. */
  48179. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48180. }
  48181. }
  48182. }
  48183. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48184. import { Scene } from "babylonjs/scene";
  48185. import { Engine } from "babylonjs/Engines/engine";
  48186. import { Texture } from "babylonjs/Materials/Textures/texture";
  48187. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48188. import "babylonjs/Engines/Extensions/engine.multiRender";
  48189. /**
  48190. * Creation options of the multi render target texture.
  48191. */
  48192. export interface IMultiRenderTargetOptions {
  48193. /**
  48194. * Define if the texture needs to create mip maps after render.
  48195. */
  48196. generateMipMaps?: boolean;
  48197. /**
  48198. * Define the types of all the draw buffers we want to create
  48199. */
  48200. types?: number[];
  48201. /**
  48202. * Define the sampling modes of all the draw buffers we want to create
  48203. */
  48204. samplingModes?: number[];
  48205. /**
  48206. * Define if a depth buffer is required
  48207. */
  48208. generateDepthBuffer?: boolean;
  48209. /**
  48210. * Define if a stencil buffer is required
  48211. */
  48212. generateStencilBuffer?: boolean;
  48213. /**
  48214. * Define if a depth texture is required instead of a depth buffer
  48215. */
  48216. generateDepthTexture?: boolean;
  48217. /**
  48218. * Define the number of desired draw buffers
  48219. */
  48220. textureCount?: number;
  48221. /**
  48222. * Define if aspect ratio should be adapted to the texture or stay the scene one
  48223. */
  48224. doNotChangeAspectRatio?: boolean;
  48225. /**
  48226. * Define the default type of the buffers we are creating
  48227. */
  48228. defaultType?: number;
  48229. }
  48230. /**
  48231. * A multi render target, like a render target provides the ability to render to a texture.
  48232. * Unlike the render target, it can render to several draw buffers in one draw.
  48233. * This is specially interesting in deferred rendering or for any effects requiring more than
  48234. * just one color from a single pass.
  48235. */
  48236. export class MultiRenderTarget extends RenderTargetTexture {
  48237. private _internalTextures;
  48238. private _textures;
  48239. private _multiRenderTargetOptions;
  48240. /**
  48241. * Get if draw buffers are currently supported by the used hardware and browser.
  48242. */
  48243. get isSupported(): boolean;
  48244. /**
  48245. * Get the list of textures generated by the multi render target.
  48246. */
  48247. get textures(): Texture[];
  48248. /**
  48249. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  48250. */
  48251. get depthTexture(): Texture;
  48252. /**
  48253. * Set the wrapping mode on U of all the textures we are rendering to.
  48254. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48255. */
  48256. set wrapU(wrap: number);
  48257. /**
  48258. * Set the wrapping mode on V of all the textures we are rendering to.
  48259. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48260. */
  48261. set wrapV(wrap: number);
  48262. /**
  48263. * Instantiate a new multi render target texture.
  48264. * A multi render target, like a render target provides the ability to render to a texture.
  48265. * Unlike the render target, it can render to several draw buffers in one draw.
  48266. * This is specially interesting in deferred rendering or for any effects requiring more than
  48267. * just one color from a single pass.
  48268. * @param name Define the name of the texture
  48269. * @param size Define the size of the buffers to render to
  48270. * @param count Define the number of target we are rendering into
  48271. * @param scene Define the scene the texture belongs to
  48272. * @param options Define the options used to create the multi render target
  48273. */
  48274. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  48275. /** @hidden */
  48276. _rebuild(): void;
  48277. private _createInternalTextures;
  48278. private _createTextures;
  48279. /**
  48280. * Define the number of samples used if MSAA is enabled.
  48281. */
  48282. get samples(): number;
  48283. set samples(value: number);
  48284. /**
  48285. * Resize all the textures in the multi render target.
  48286. * Be carrefull as it will recreate all the data in the new texture.
  48287. * @param size Define the new size
  48288. */
  48289. resize(size: any): void;
  48290. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48291. /**
  48292. * Dispose the render targets and their associated resources
  48293. */
  48294. dispose(): void;
  48295. /**
  48296. * Release all the underlying texture used as draw buffers.
  48297. */
  48298. releaseInternalTextures(): void;
  48299. }
  48300. }
  48301. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  48302. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48303. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  48304. import { Nullable } from "babylonjs/types";
  48305. module "babylonjs/Engines/thinEngine" {
  48306. interface ThinEngine {
  48307. /**
  48308. * Unbind a list of render target textures from the webGL context
  48309. * This is used only when drawBuffer extension or webGL2 are active
  48310. * @param textures defines the render target textures to unbind
  48311. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48312. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48313. */
  48314. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  48315. /**
  48316. * Create a multi render target texture
  48317. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  48318. * @param size defines the size of the texture
  48319. * @param options defines the creation options
  48320. * @returns the cube texture as an InternalTexture
  48321. */
  48322. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  48323. /**
  48324. * Update the sample count for a given multiple render target texture
  48325. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  48326. * @param textures defines the textures to update
  48327. * @param samples defines the sample count to set
  48328. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  48329. */
  48330. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  48331. }
  48332. }
  48333. }
  48334. declare module "babylonjs/Engines/Extensions/engine.views" {
  48335. import { Camera } from "babylonjs/Cameras/camera";
  48336. import { Nullable } from "babylonjs/types";
  48337. /**
  48338. * Class used to define an additional view for the engine
  48339. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48340. */
  48341. export class EngineView {
  48342. /** Defines the canvas where to render the view */
  48343. target: HTMLCanvasElement;
  48344. /** Defines an optional camera used to render the view (will use active camera else) */
  48345. camera?: Camera;
  48346. }
  48347. module "babylonjs/Engines/engine" {
  48348. interface Engine {
  48349. /**
  48350. * Gets or sets the HTML element to use for attaching events
  48351. */
  48352. inputElement: Nullable<HTMLElement>;
  48353. /**
  48354. * Gets the current engine view
  48355. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48356. */
  48357. activeView: Nullable<EngineView>;
  48358. /** Gets or sets the list of views */
  48359. views: EngineView[];
  48360. /**
  48361. * Register a new child canvas
  48362. * @param canvas defines the canvas to register
  48363. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  48364. * @returns the associated view
  48365. */
  48366. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  48367. /**
  48368. * Remove a registered child canvas
  48369. * @param canvas defines the canvas to remove
  48370. * @returns the current engine
  48371. */
  48372. unRegisterView(canvas: HTMLCanvasElement): Engine;
  48373. }
  48374. }
  48375. }
  48376. declare module "babylonjs/Engines/Extensions/index" {
  48377. export * from "babylonjs/Engines/Extensions/engine.alpha";
  48378. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  48379. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  48380. export * from "babylonjs/Engines/Extensions/engine.multiview";
  48381. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  48382. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48383. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  48384. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  48385. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  48386. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  48387. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  48388. export * from "babylonjs/Engines/Extensions/engine.webVR";
  48389. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  48390. export * from "babylonjs/Engines/Extensions/engine.views";
  48391. }
  48392. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  48393. import { Nullable } from "babylonjs/types";
  48394. /**
  48395. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  48396. */
  48397. export interface CubeMapInfo {
  48398. /**
  48399. * The pixel array for the front face.
  48400. * This is stored in format, left to right, up to down format.
  48401. */
  48402. front: Nullable<ArrayBufferView>;
  48403. /**
  48404. * The pixel array for the back face.
  48405. * This is stored in format, left to right, up to down format.
  48406. */
  48407. back: Nullable<ArrayBufferView>;
  48408. /**
  48409. * The pixel array for the left face.
  48410. * This is stored in format, left to right, up to down format.
  48411. */
  48412. left: Nullable<ArrayBufferView>;
  48413. /**
  48414. * The pixel array for the right face.
  48415. * This is stored in format, left to right, up to down format.
  48416. */
  48417. right: Nullable<ArrayBufferView>;
  48418. /**
  48419. * The pixel array for the up face.
  48420. * This is stored in format, left to right, up to down format.
  48421. */
  48422. up: Nullable<ArrayBufferView>;
  48423. /**
  48424. * The pixel array for the down face.
  48425. * This is stored in format, left to right, up to down format.
  48426. */
  48427. down: Nullable<ArrayBufferView>;
  48428. /**
  48429. * The size of the cubemap stored.
  48430. *
  48431. * Each faces will be size * size pixels.
  48432. */
  48433. size: number;
  48434. /**
  48435. * The format of the texture.
  48436. *
  48437. * RGBA, RGB.
  48438. */
  48439. format: number;
  48440. /**
  48441. * The type of the texture data.
  48442. *
  48443. * UNSIGNED_INT, FLOAT.
  48444. */
  48445. type: number;
  48446. /**
  48447. * Specifies whether the texture is in gamma space.
  48448. */
  48449. gammaSpace: boolean;
  48450. }
  48451. /**
  48452. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  48453. */
  48454. export class PanoramaToCubeMapTools {
  48455. private static FACE_FRONT;
  48456. private static FACE_BACK;
  48457. private static FACE_RIGHT;
  48458. private static FACE_LEFT;
  48459. private static FACE_DOWN;
  48460. private static FACE_UP;
  48461. /**
  48462. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  48463. *
  48464. * @param float32Array The source data.
  48465. * @param inputWidth The width of the input panorama.
  48466. * @param inputHeight The height of the input panorama.
  48467. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  48468. * @return The cubemap data
  48469. */
  48470. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  48471. private static CreateCubemapTexture;
  48472. private static CalcProjectionSpherical;
  48473. }
  48474. }
  48475. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  48476. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48477. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48478. import { Nullable } from "babylonjs/types";
  48479. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  48480. /**
  48481. * Helper class dealing with the extraction of spherical polynomial dataArray
  48482. * from a cube map.
  48483. */
  48484. export class CubeMapToSphericalPolynomialTools {
  48485. private static FileFaces;
  48486. /**
  48487. * Converts a texture to the according Spherical Polynomial data.
  48488. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48489. *
  48490. * @param texture The texture to extract the information from.
  48491. * @return The Spherical Polynomial data.
  48492. */
  48493. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  48494. /**
  48495. * Converts a cubemap to the according Spherical Polynomial data.
  48496. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48497. *
  48498. * @param cubeInfo The Cube map to extract the information from.
  48499. * @return The Spherical Polynomial data.
  48500. */
  48501. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  48502. }
  48503. }
  48504. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  48505. import { Nullable } from "babylonjs/types";
  48506. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48507. module "babylonjs/Materials/Textures/baseTexture" {
  48508. interface BaseTexture {
  48509. /**
  48510. * Get the polynomial representation of the texture data.
  48511. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  48512. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  48513. */
  48514. sphericalPolynomial: Nullable<SphericalPolynomial>;
  48515. }
  48516. }
  48517. }
  48518. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48519. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48520. /** @hidden */
  48521. export var rgbdEncodePixelShader: {
  48522. name: string;
  48523. shader: string;
  48524. };
  48525. }
  48526. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  48527. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48528. /** @hidden */
  48529. export var rgbdDecodePixelShader: {
  48530. name: string;
  48531. shader: string;
  48532. };
  48533. }
  48534. declare module "babylonjs/Misc/environmentTextureTools" {
  48535. import { Nullable } from "babylonjs/types";
  48536. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48537. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48538. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48539. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  48540. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  48541. import "babylonjs/Shaders/rgbdEncode.fragment";
  48542. import "babylonjs/Shaders/rgbdDecode.fragment";
  48543. /**
  48544. * Raw texture data and descriptor sufficient for WebGL texture upload
  48545. */
  48546. export interface EnvironmentTextureInfo {
  48547. /**
  48548. * Version of the environment map
  48549. */
  48550. version: number;
  48551. /**
  48552. * Width of image
  48553. */
  48554. width: number;
  48555. /**
  48556. * Irradiance information stored in the file.
  48557. */
  48558. irradiance: any;
  48559. /**
  48560. * Specular information stored in the file.
  48561. */
  48562. specular: any;
  48563. }
  48564. /**
  48565. * Defines One Image in the file. It requires only the position in the file
  48566. * as well as the length.
  48567. */
  48568. interface BufferImageData {
  48569. /**
  48570. * Length of the image data.
  48571. */
  48572. length: number;
  48573. /**
  48574. * Position of the data from the null terminator delimiting the end of the JSON.
  48575. */
  48576. position: number;
  48577. }
  48578. /**
  48579. * Defines the specular data enclosed in the file.
  48580. * This corresponds to the version 1 of the data.
  48581. */
  48582. export interface EnvironmentTextureSpecularInfoV1 {
  48583. /**
  48584. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  48585. */
  48586. specularDataPosition?: number;
  48587. /**
  48588. * This contains all the images data needed to reconstruct the cubemap.
  48589. */
  48590. mipmaps: Array<BufferImageData>;
  48591. /**
  48592. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  48593. */
  48594. lodGenerationScale: number;
  48595. }
  48596. /**
  48597. * Sets of helpers addressing the serialization and deserialization of environment texture
  48598. * stored in a BabylonJS env file.
  48599. * Those files are usually stored as .env files.
  48600. */
  48601. export class EnvironmentTextureTools {
  48602. /**
  48603. * Magic number identifying the env file.
  48604. */
  48605. private static _MagicBytes;
  48606. /**
  48607. * Gets the environment info from an env file.
  48608. * @param data The array buffer containing the .env bytes.
  48609. * @returns the environment file info (the json header) if successfully parsed.
  48610. */
  48611. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48612. /**
  48613. * Creates an environment texture from a loaded cube texture.
  48614. * @param texture defines the cube texture to convert in env file
  48615. * @return a promise containing the environment data if succesfull.
  48616. */
  48617. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48618. /**
  48619. * Creates a JSON representation of the spherical data.
  48620. * @param texture defines the texture containing the polynomials
  48621. * @return the JSON representation of the spherical info
  48622. */
  48623. private static _CreateEnvTextureIrradiance;
  48624. /**
  48625. * Creates the ArrayBufferViews used for initializing environment texture image data.
  48626. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  48627. * @param info parameters that determine what views will be created for accessing the underlying buffer
  48628. * @return the views described by info providing access to the underlying buffer
  48629. */
  48630. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  48631. /**
  48632. * Uploads the texture info contained in the env file to the GPU.
  48633. * @param texture defines the internal texture to upload to
  48634. * @param arrayBuffer defines the buffer cotaining the data to load
  48635. * @param info defines the texture info retrieved through the GetEnvInfo method
  48636. * @returns a promise
  48637. */
  48638. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48639. private static _OnImageReadyAsync;
  48640. /**
  48641. * Uploads the levels of image data to the GPU.
  48642. * @param texture defines the internal texture to upload to
  48643. * @param imageData defines the array buffer views of image data [mipmap][face]
  48644. * @returns a promise
  48645. */
  48646. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48647. /**
  48648. * Uploads spherical polynomials information to the texture.
  48649. * @param texture defines the texture we are trying to upload the information to
  48650. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48651. */
  48652. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48653. /** @hidden */
  48654. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48655. }
  48656. }
  48657. declare module "babylonjs/Maths/math.vertexFormat" {
  48658. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  48659. /**
  48660. * Contains position and normal vectors for a vertex
  48661. */
  48662. export class PositionNormalVertex {
  48663. /** the position of the vertex (defaut: 0,0,0) */
  48664. position: Vector3;
  48665. /** the normal of the vertex (defaut: 0,1,0) */
  48666. normal: Vector3;
  48667. /**
  48668. * Creates a PositionNormalVertex
  48669. * @param position the position of the vertex (defaut: 0,0,0)
  48670. * @param normal the normal of the vertex (defaut: 0,1,0)
  48671. */
  48672. constructor(
  48673. /** the position of the vertex (defaut: 0,0,0) */
  48674. position?: Vector3,
  48675. /** the normal of the vertex (defaut: 0,1,0) */
  48676. normal?: Vector3);
  48677. /**
  48678. * Clones the PositionNormalVertex
  48679. * @returns the cloned PositionNormalVertex
  48680. */
  48681. clone(): PositionNormalVertex;
  48682. }
  48683. /**
  48684. * Contains position, normal and uv vectors for a vertex
  48685. */
  48686. export class PositionNormalTextureVertex {
  48687. /** the position of the vertex (defaut: 0,0,0) */
  48688. position: Vector3;
  48689. /** the normal of the vertex (defaut: 0,1,0) */
  48690. normal: Vector3;
  48691. /** the uv of the vertex (default: 0,0) */
  48692. uv: Vector2;
  48693. /**
  48694. * Creates a PositionNormalTextureVertex
  48695. * @param position the position of the vertex (defaut: 0,0,0)
  48696. * @param normal the normal of the vertex (defaut: 0,1,0)
  48697. * @param uv the uv of the vertex (default: 0,0)
  48698. */
  48699. constructor(
  48700. /** the position of the vertex (defaut: 0,0,0) */
  48701. position?: Vector3,
  48702. /** the normal of the vertex (defaut: 0,1,0) */
  48703. normal?: Vector3,
  48704. /** the uv of the vertex (default: 0,0) */
  48705. uv?: Vector2);
  48706. /**
  48707. * Clones the PositionNormalTextureVertex
  48708. * @returns the cloned PositionNormalTextureVertex
  48709. */
  48710. clone(): PositionNormalTextureVertex;
  48711. }
  48712. }
  48713. declare module "babylonjs/Maths/math" {
  48714. export * from "babylonjs/Maths/math.axis";
  48715. export * from "babylonjs/Maths/math.color";
  48716. export * from "babylonjs/Maths/math.constants";
  48717. export * from "babylonjs/Maths/math.frustum";
  48718. export * from "babylonjs/Maths/math.path";
  48719. export * from "babylonjs/Maths/math.plane";
  48720. export * from "babylonjs/Maths/math.size";
  48721. export * from "babylonjs/Maths/math.vector";
  48722. export * from "babylonjs/Maths/math.vertexFormat";
  48723. export * from "babylonjs/Maths/math.viewport";
  48724. }
  48725. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  48726. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  48727. /** @hidden */
  48728. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  48729. private _genericAttributeLocation;
  48730. private _varyingLocationCount;
  48731. private _varyingLocationMap;
  48732. private _replacements;
  48733. private _textureCount;
  48734. private _uniforms;
  48735. lineProcessor(line: string): string;
  48736. attributeProcessor(attribute: string): string;
  48737. varyingProcessor(varying: string, isFragment: boolean): string;
  48738. uniformProcessor(uniform: string): string;
  48739. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  48740. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  48741. }
  48742. }
  48743. declare module "babylonjs/Engines/nativeEngine" {
  48744. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  48745. import { Engine } from "babylonjs/Engines/engine";
  48746. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48747. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48748. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48749. import { Effect } from "babylonjs/Materials/effect";
  48750. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48751. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  48752. import { IColor4Like } from "babylonjs/Maths/math.like";
  48753. import { Scene } from "babylonjs/scene";
  48754. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48755. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48756. /**
  48757. * Container for accessors for natively-stored mesh data buffers.
  48758. */
  48759. class NativeDataBuffer extends DataBuffer {
  48760. /**
  48761. * Accessor value used to identify/retrieve a natively-stored index buffer.
  48762. */
  48763. nativeIndexBuffer?: any;
  48764. /**
  48765. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  48766. */
  48767. nativeVertexBuffer?: any;
  48768. }
  48769. /** @hidden */
  48770. class NativeTexture extends InternalTexture {
  48771. getInternalTexture(): InternalTexture;
  48772. getViewCount(): number;
  48773. }
  48774. /** @hidden */
  48775. export class NativeEngine extends Engine {
  48776. private readonly _native;
  48777. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  48778. private readonly INVALID_HANDLE;
  48779. getHardwareScalingLevel(): number;
  48780. constructor();
  48781. /**
  48782. * Can be used to override the current requestAnimationFrame requester.
  48783. * @hidden
  48784. */
  48785. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  48786. /**
  48787. * Override default engine behavior.
  48788. * @param color
  48789. * @param backBuffer
  48790. * @param depth
  48791. * @param stencil
  48792. */
  48793. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  48794. /**
  48795. * Gets host document
  48796. * @returns the host document object
  48797. */
  48798. getHostDocument(): Nullable<Document>;
  48799. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48800. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  48801. createVertexBuffer(data: DataArray): NativeDataBuffer;
  48802. recordVertexArrayObject(vertexBuffers: {
  48803. [key: string]: VertexBuffer;
  48804. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  48805. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48806. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48807. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48808. /**
  48809. * Draw a list of indexed primitives
  48810. * @param fillMode defines the primitive to use
  48811. * @param indexStart defines the starting index
  48812. * @param indexCount defines the number of index to draw
  48813. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48814. */
  48815. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48816. /**
  48817. * Draw a list of unindexed primitives
  48818. * @param fillMode defines the primitive to use
  48819. * @param verticesStart defines the index of first vertex to draw
  48820. * @param verticesCount defines the count of vertices to draw
  48821. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48822. */
  48823. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48824. createPipelineContext(): IPipelineContext;
  48825. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  48826. /** @hidden */
  48827. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  48828. /** @hidden */
  48829. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  48830. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48831. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48832. protected _setProgram(program: WebGLProgram): void;
  48833. _releaseEffect(effect: Effect): void;
  48834. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  48835. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  48836. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  48837. bindSamplers(effect: Effect): void;
  48838. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  48839. getRenderWidth(useScreen?: boolean): number;
  48840. getRenderHeight(useScreen?: boolean): number;
  48841. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  48842. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48843. /**
  48844. * Set the z offset to apply to current rendering
  48845. * @param value defines the offset to apply
  48846. */
  48847. setZOffset(value: number): void;
  48848. /**
  48849. * Gets the current value of the zOffset
  48850. * @returns the current zOffset state
  48851. */
  48852. getZOffset(): number;
  48853. /**
  48854. * Enable or disable depth buffering
  48855. * @param enable defines the state to set
  48856. */
  48857. setDepthBuffer(enable: boolean): void;
  48858. /**
  48859. * Gets a boolean indicating if depth writing is enabled
  48860. * @returns the current depth writing state
  48861. */
  48862. getDepthWrite(): boolean;
  48863. /**
  48864. * Enable or disable depth writing
  48865. * @param enable defines the state to set
  48866. */
  48867. setDepthWrite(enable: boolean): void;
  48868. /**
  48869. * Enable or disable color writing
  48870. * @param enable defines the state to set
  48871. */
  48872. setColorWrite(enable: boolean): void;
  48873. /**
  48874. * Gets a boolean indicating if color writing is enabled
  48875. * @returns the current color writing state
  48876. */
  48877. getColorWrite(): boolean;
  48878. /**
  48879. * Sets alpha constants used by some alpha blending modes
  48880. * @param r defines the red component
  48881. * @param g defines the green component
  48882. * @param b defines the blue component
  48883. * @param a defines the alpha component
  48884. */
  48885. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48886. /**
  48887. * Sets the current alpha mode
  48888. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48889. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48890. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48891. */
  48892. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48893. /**
  48894. * Gets the current alpha mode
  48895. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48896. * @returns the current alpha mode
  48897. */
  48898. getAlphaMode(): number;
  48899. setInt(uniform: WebGLUniformLocation, int: number): void;
  48900. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48901. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48902. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48903. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48904. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48905. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48906. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48907. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48908. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48909. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48910. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48911. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48912. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48913. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48914. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48915. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48916. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48917. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48918. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48919. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48920. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48921. wipeCaches(bruteForce?: boolean): void;
  48922. _createTexture(): WebGLTexture;
  48923. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48924. /**
  48925. * Usually called from BABYLON.Texture.ts.
  48926. * Passed information to create a WebGLTexture
  48927. * @param urlArg defines a value which contains one of the following:
  48928. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48929. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48930. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48931. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48932. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  48933. * @param scene needed for loading to the correct scene
  48934. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  48935. * @param onLoad optional callback to be called upon successful completion
  48936. * @param onError optional callback to be called upon failure
  48937. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  48938. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48939. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48940. * @param forcedExtension defines the extension to use to pick the right loader
  48941. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48942. */
  48943. 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;
  48944. /**
  48945. * Creates a cube texture
  48946. * @param rootUrl defines the url where the files to load is located
  48947. * @param scene defines the current scene
  48948. * @param files defines the list of files to load (1 per face)
  48949. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48950. * @param onLoad defines an optional callback raised when the texture is loaded
  48951. * @param onError defines an optional callback raised if there is an issue to load the texture
  48952. * @param format defines the format of the data
  48953. * @param forcedExtension defines the extension to use to pick the right loader
  48954. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48955. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48956. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48957. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48958. * @returns the cube texture as an InternalTexture
  48959. */
  48960. 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;
  48961. private _getSamplingFilter;
  48962. private static _GetNativeTextureFormat;
  48963. createRenderTargetTexture(size: number | {
  48964. width: number;
  48965. height: number;
  48966. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48967. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48968. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48969. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48970. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48971. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48972. /**
  48973. * Updates a dynamic vertex buffer.
  48974. * @param vertexBuffer the vertex buffer to update
  48975. * @param data the data used to update the vertex buffer
  48976. * @param byteOffset the byte offset of the data (optional)
  48977. * @param byteLength the byte length of the data (optional)
  48978. */
  48979. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48980. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48981. private _updateAnisotropicLevel;
  48982. private _getAddressMode;
  48983. /** @hidden */
  48984. _bindTexture(channel: number, texture: InternalTexture): void;
  48985. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48986. releaseEffects(): void;
  48987. /** @hidden */
  48988. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48989. /** @hidden */
  48990. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48991. /** @hidden */
  48992. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48993. /** @hidden */
  48994. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48995. }
  48996. }
  48997. declare module "babylonjs/Engines/index" {
  48998. export * from "babylonjs/Engines/constants";
  48999. export * from "babylonjs/Engines/engineCapabilities";
  49000. export * from "babylonjs/Engines/instancingAttributeInfo";
  49001. export * from "babylonjs/Engines/thinEngine";
  49002. export * from "babylonjs/Engines/engine";
  49003. export * from "babylonjs/Engines/engineStore";
  49004. export * from "babylonjs/Engines/nullEngine";
  49005. export * from "babylonjs/Engines/Extensions/index";
  49006. export * from "babylonjs/Engines/IPipelineContext";
  49007. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49008. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49009. export * from "babylonjs/Engines/nativeEngine";
  49010. }
  49011. declare module "babylonjs/Events/clipboardEvents" {
  49012. /**
  49013. * Gather the list of clipboard event types as constants.
  49014. */
  49015. export class ClipboardEventTypes {
  49016. /**
  49017. * The clipboard event is fired when a copy command is active (pressed).
  49018. */
  49019. static readonly COPY: number;
  49020. /**
  49021. * The clipboard event is fired when a cut command is active (pressed).
  49022. */
  49023. static readonly CUT: number;
  49024. /**
  49025. * The clipboard event is fired when a paste command is active (pressed).
  49026. */
  49027. static readonly PASTE: number;
  49028. }
  49029. /**
  49030. * This class is used to store clipboard related info for the onClipboardObservable event.
  49031. */
  49032. export class ClipboardInfo {
  49033. /**
  49034. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49035. */
  49036. type: number;
  49037. /**
  49038. * Defines the related dom event
  49039. */
  49040. event: ClipboardEvent;
  49041. /**
  49042. *Creates an instance of ClipboardInfo.
  49043. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49044. * @param event Defines the related dom event
  49045. */
  49046. constructor(
  49047. /**
  49048. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49049. */
  49050. type: number,
  49051. /**
  49052. * Defines the related dom event
  49053. */
  49054. event: ClipboardEvent);
  49055. /**
  49056. * Get the clipboard event's type from the keycode.
  49057. * @param keyCode Defines the keyCode for the current keyboard event.
  49058. * @return {number}
  49059. */
  49060. static GetTypeFromCharacter(keyCode: number): number;
  49061. }
  49062. }
  49063. declare module "babylonjs/Events/index" {
  49064. export * from "babylonjs/Events/keyboardEvents";
  49065. export * from "babylonjs/Events/pointerEvents";
  49066. export * from "babylonjs/Events/clipboardEvents";
  49067. }
  49068. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49069. import { Scene } from "babylonjs/scene";
  49070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49071. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49072. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49073. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49074. /**
  49075. * Google Daydream controller
  49076. */
  49077. export class DaydreamController extends WebVRController {
  49078. /**
  49079. * Base Url for the controller model.
  49080. */
  49081. static MODEL_BASE_URL: string;
  49082. /**
  49083. * File name for the controller model.
  49084. */
  49085. static MODEL_FILENAME: string;
  49086. /**
  49087. * Gamepad Id prefix used to identify Daydream Controller.
  49088. */
  49089. static readonly GAMEPAD_ID_PREFIX: string;
  49090. /**
  49091. * Creates a new DaydreamController from a gamepad
  49092. * @param vrGamepad the gamepad that the controller should be created from
  49093. */
  49094. constructor(vrGamepad: any);
  49095. /**
  49096. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49097. * @param scene scene in which to add meshes
  49098. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49099. */
  49100. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49101. /**
  49102. * Called once for each button that changed state since the last frame
  49103. * @param buttonIdx Which button index changed
  49104. * @param state New state of the button
  49105. * @param changes Which properties on the state changed since last frame
  49106. */
  49107. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49108. }
  49109. }
  49110. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49111. import { Scene } from "babylonjs/scene";
  49112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49113. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49114. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49115. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49116. /**
  49117. * Gear VR Controller
  49118. */
  49119. export class GearVRController extends WebVRController {
  49120. /**
  49121. * Base Url for the controller model.
  49122. */
  49123. static MODEL_BASE_URL: string;
  49124. /**
  49125. * File name for the controller model.
  49126. */
  49127. static MODEL_FILENAME: string;
  49128. /**
  49129. * Gamepad Id prefix used to identify this controller.
  49130. */
  49131. static readonly GAMEPAD_ID_PREFIX: string;
  49132. private readonly _buttonIndexToObservableNameMap;
  49133. /**
  49134. * Creates a new GearVRController from a gamepad
  49135. * @param vrGamepad the gamepad that the controller should be created from
  49136. */
  49137. constructor(vrGamepad: any);
  49138. /**
  49139. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49140. * @param scene scene in which to add meshes
  49141. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49142. */
  49143. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49144. /**
  49145. * Called once for each button that changed state since the last frame
  49146. * @param buttonIdx Which button index changed
  49147. * @param state New state of the button
  49148. * @param changes Which properties on the state changed since last frame
  49149. */
  49150. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49151. }
  49152. }
  49153. declare module "babylonjs/Gamepads/Controllers/index" {
  49154. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  49155. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  49156. export * from "babylonjs/Gamepads/Controllers/genericController";
  49157. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  49158. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49159. export * from "babylonjs/Gamepads/Controllers/viveController";
  49160. export * from "babylonjs/Gamepads/Controllers/webVRController";
  49161. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  49162. }
  49163. declare module "babylonjs/Gamepads/index" {
  49164. export * from "babylonjs/Gamepads/Controllers/index";
  49165. export * from "babylonjs/Gamepads/gamepad";
  49166. export * from "babylonjs/Gamepads/gamepadManager";
  49167. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  49168. export * from "babylonjs/Gamepads/xboxGamepad";
  49169. export * from "babylonjs/Gamepads/dualShockGamepad";
  49170. }
  49171. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  49172. import { Scene } from "babylonjs/scene";
  49173. import { Vector4 } from "babylonjs/Maths/math.vector";
  49174. import { Color4 } from "babylonjs/Maths/math.color";
  49175. import { Mesh } from "babylonjs/Meshes/mesh";
  49176. import { Nullable } from "babylonjs/types";
  49177. /**
  49178. * Class containing static functions to help procedurally build meshes
  49179. */
  49180. export class PolyhedronBuilder {
  49181. /**
  49182. * Creates a polyhedron mesh
  49183. * * 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
  49184. * * The parameter `size` (positive float, default 1) sets the polygon size
  49185. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  49186. * * 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`
  49187. * * 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
  49188. * * 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)`)
  49189. * * 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
  49190. * * 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
  49191. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49192. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49194. * @param name defines the name of the mesh
  49195. * @param options defines the options used to create the mesh
  49196. * @param scene defines the hosting scene
  49197. * @returns the polyhedron mesh
  49198. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  49199. */
  49200. static CreatePolyhedron(name: string, options: {
  49201. type?: number;
  49202. size?: number;
  49203. sizeX?: number;
  49204. sizeY?: number;
  49205. sizeZ?: number;
  49206. custom?: any;
  49207. faceUV?: Vector4[];
  49208. faceColors?: Color4[];
  49209. flat?: boolean;
  49210. updatable?: boolean;
  49211. sideOrientation?: number;
  49212. frontUVs?: Vector4;
  49213. backUVs?: Vector4;
  49214. }, scene?: Nullable<Scene>): Mesh;
  49215. }
  49216. }
  49217. declare module "babylonjs/Gizmos/scaleGizmo" {
  49218. import { Observable } from "babylonjs/Misc/observable";
  49219. import { Nullable } from "babylonjs/types";
  49220. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49221. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49222. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  49223. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49224. /**
  49225. * Gizmo that enables scaling a mesh along 3 axis
  49226. */
  49227. export class ScaleGizmo extends Gizmo {
  49228. /**
  49229. * Internal gizmo used for interactions on the x axis
  49230. */
  49231. xGizmo: AxisScaleGizmo;
  49232. /**
  49233. * Internal gizmo used for interactions on the y axis
  49234. */
  49235. yGizmo: AxisScaleGizmo;
  49236. /**
  49237. * Internal gizmo used for interactions on the z axis
  49238. */
  49239. zGizmo: AxisScaleGizmo;
  49240. /**
  49241. * Internal gizmo used to scale all axis equally
  49242. */
  49243. uniformScaleGizmo: AxisScaleGizmo;
  49244. private _meshAttached;
  49245. private _updateGizmoRotationToMatchAttachedMesh;
  49246. private _snapDistance;
  49247. private _scaleRatio;
  49248. private _uniformScalingMesh;
  49249. private _octahedron;
  49250. private _sensitivity;
  49251. /** Fires an event when any of it's sub gizmos are dragged */
  49252. onDragStartObservable: Observable<unknown>;
  49253. /** Fires an event when any of it's sub gizmos are released from dragging */
  49254. onDragEndObservable: Observable<unknown>;
  49255. get attachedMesh(): Nullable<AbstractMesh>;
  49256. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49257. /**
  49258. * Creates a ScaleGizmo
  49259. * @param gizmoLayer The utility layer the gizmo will be added to
  49260. */
  49261. constructor(gizmoLayer?: UtilityLayerRenderer);
  49262. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49263. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49264. /**
  49265. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49266. */
  49267. set snapDistance(value: number);
  49268. get snapDistance(): number;
  49269. /**
  49270. * Ratio for the scale of the gizmo (Default: 1)
  49271. */
  49272. set scaleRatio(value: number);
  49273. get scaleRatio(): number;
  49274. /**
  49275. * Sensitivity factor for dragging (Default: 1)
  49276. */
  49277. set sensitivity(value: number);
  49278. get sensitivity(): number;
  49279. /**
  49280. * Disposes of the gizmo
  49281. */
  49282. dispose(): void;
  49283. }
  49284. }
  49285. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  49286. import { Observable } from "babylonjs/Misc/observable";
  49287. import { Nullable } from "babylonjs/types";
  49288. import { Vector3 } from "babylonjs/Maths/math.vector";
  49289. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49290. import { Mesh } from "babylonjs/Meshes/mesh";
  49291. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  49292. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49293. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49294. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  49295. import { Color3 } from "babylonjs/Maths/math.color";
  49296. /**
  49297. * Single axis scale gizmo
  49298. */
  49299. export class AxisScaleGizmo extends Gizmo {
  49300. /**
  49301. * Drag behavior responsible for the gizmos dragging interactions
  49302. */
  49303. dragBehavior: PointerDragBehavior;
  49304. private _pointerObserver;
  49305. /**
  49306. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49307. */
  49308. snapDistance: number;
  49309. /**
  49310. * Event that fires each time the gizmo snaps to a new location.
  49311. * * snapDistance is the the change in distance
  49312. */
  49313. onSnapObservable: Observable<{
  49314. snapDistance: number;
  49315. }>;
  49316. /**
  49317. * If the scaling operation should be done on all axis (default: false)
  49318. */
  49319. uniformScaling: boolean;
  49320. /**
  49321. * Custom sensitivity value for the drag strength
  49322. */
  49323. sensitivity: number;
  49324. private _isEnabled;
  49325. private _parent;
  49326. private _arrow;
  49327. private _coloredMaterial;
  49328. private _hoverMaterial;
  49329. /**
  49330. * Creates an AxisScaleGizmo
  49331. * @param gizmoLayer The utility layer the gizmo will be added to
  49332. * @param dragAxis The axis which the gizmo will be able to scale on
  49333. * @param color The color of the gizmo
  49334. */
  49335. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  49336. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49337. /**
  49338. * If the gizmo is enabled
  49339. */
  49340. set isEnabled(value: boolean);
  49341. get isEnabled(): boolean;
  49342. /**
  49343. * Disposes of the gizmo
  49344. */
  49345. dispose(): void;
  49346. /**
  49347. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49348. * @param mesh The mesh to replace the default mesh of the gizmo
  49349. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  49350. */
  49351. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  49352. }
  49353. }
  49354. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  49355. import { Observable } from "babylonjs/Misc/observable";
  49356. import { Nullable } from "babylonjs/types";
  49357. import { Vector3 } from "babylonjs/Maths/math.vector";
  49358. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49359. import { Mesh } from "babylonjs/Meshes/mesh";
  49360. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49361. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49362. import { Color3 } from "babylonjs/Maths/math.color";
  49363. import "babylonjs/Meshes/Builders/boxBuilder";
  49364. /**
  49365. * Bounding box gizmo
  49366. */
  49367. export class BoundingBoxGizmo extends Gizmo {
  49368. private _lineBoundingBox;
  49369. private _rotateSpheresParent;
  49370. private _scaleBoxesParent;
  49371. private _boundingDimensions;
  49372. private _renderObserver;
  49373. private _pointerObserver;
  49374. private _scaleDragSpeed;
  49375. private _tmpQuaternion;
  49376. private _tmpVector;
  49377. private _tmpRotationMatrix;
  49378. /**
  49379. * 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)
  49380. */
  49381. ignoreChildren: boolean;
  49382. /**
  49383. * 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)
  49384. */
  49385. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  49386. /**
  49387. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  49388. */
  49389. rotationSphereSize: number;
  49390. /**
  49391. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  49392. */
  49393. scaleBoxSize: number;
  49394. /**
  49395. * 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)
  49396. */
  49397. fixedDragMeshScreenSize: boolean;
  49398. /**
  49399. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  49400. */
  49401. fixedDragMeshScreenSizeDistanceFactor: number;
  49402. /**
  49403. * Fired when a rotation sphere or scale box is dragged
  49404. */
  49405. onDragStartObservable: Observable<{}>;
  49406. /**
  49407. * Fired when a scale box is dragged
  49408. */
  49409. onScaleBoxDragObservable: Observable<{}>;
  49410. /**
  49411. * Fired when a scale box drag is ended
  49412. */
  49413. onScaleBoxDragEndObservable: Observable<{}>;
  49414. /**
  49415. * Fired when a rotation sphere is dragged
  49416. */
  49417. onRotationSphereDragObservable: Observable<{}>;
  49418. /**
  49419. * Fired when a rotation sphere drag is ended
  49420. */
  49421. onRotationSphereDragEndObservable: Observable<{}>;
  49422. /**
  49423. * 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)
  49424. */
  49425. scalePivot: Nullable<Vector3>;
  49426. /**
  49427. * Mesh used as a pivot to rotate the attached mesh
  49428. */
  49429. private _anchorMesh;
  49430. private _existingMeshScale;
  49431. private _dragMesh;
  49432. private pointerDragBehavior;
  49433. private coloredMaterial;
  49434. private hoverColoredMaterial;
  49435. /**
  49436. * Sets the color of the bounding box gizmo
  49437. * @param color the color to set
  49438. */
  49439. setColor(color: Color3): void;
  49440. /**
  49441. * Creates an BoundingBoxGizmo
  49442. * @param gizmoLayer The utility layer the gizmo will be added to
  49443. * @param color The color of the gizmo
  49444. */
  49445. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  49446. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49447. private _selectNode;
  49448. /**
  49449. * Updates the bounding box information for the Gizmo
  49450. */
  49451. updateBoundingBox(): void;
  49452. private _updateRotationSpheres;
  49453. private _updateScaleBoxes;
  49454. /**
  49455. * Enables rotation on the specified axis and disables rotation on the others
  49456. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  49457. */
  49458. setEnabledRotationAxis(axis: string): void;
  49459. /**
  49460. * Enables/disables scaling
  49461. * @param enable if scaling should be enabled
  49462. */
  49463. setEnabledScaling(enable: boolean): void;
  49464. private _updateDummy;
  49465. /**
  49466. * Enables a pointer drag behavior on the bounding box of the gizmo
  49467. */
  49468. enableDragBehavior(): void;
  49469. /**
  49470. * Disposes of the gizmo
  49471. */
  49472. dispose(): void;
  49473. /**
  49474. * 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)
  49475. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  49476. * @returns the bounding box mesh with the passed in mesh as a child
  49477. */
  49478. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  49479. /**
  49480. * CustomMeshes are not supported by this gizmo
  49481. * @param mesh The mesh to replace the default mesh of the gizmo
  49482. */
  49483. setCustomMesh(mesh: Mesh): void;
  49484. }
  49485. }
  49486. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  49487. import { Observable } from "babylonjs/Misc/observable";
  49488. import { Nullable } from "babylonjs/types";
  49489. import { Vector3 } from "babylonjs/Maths/math.vector";
  49490. import { Color3 } from "babylonjs/Maths/math.color";
  49491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49492. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  49493. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49494. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49495. import "babylonjs/Meshes/Builders/linesBuilder";
  49496. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  49497. /**
  49498. * Single plane rotation gizmo
  49499. */
  49500. export class PlaneRotationGizmo extends Gizmo {
  49501. /**
  49502. * Drag behavior responsible for the gizmos dragging interactions
  49503. */
  49504. dragBehavior: PointerDragBehavior;
  49505. private _pointerObserver;
  49506. /**
  49507. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  49508. */
  49509. snapDistance: number;
  49510. /**
  49511. * Event that fires each time the gizmo snaps to a new location.
  49512. * * snapDistance is the the change in distance
  49513. */
  49514. onSnapObservable: Observable<{
  49515. snapDistance: number;
  49516. }>;
  49517. private _isEnabled;
  49518. private _parent;
  49519. /**
  49520. * Creates a PlaneRotationGizmo
  49521. * @param gizmoLayer The utility layer the gizmo will be added to
  49522. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  49523. * @param color The color of the gizmo
  49524. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49525. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49526. */
  49527. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  49528. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49529. /**
  49530. * If the gizmo is enabled
  49531. */
  49532. set isEnabled(value: boolean);
  49533. get isEnabled(): boolean;
  49534. /**
  49535. * Disposes of the gizmo
  49536. */
  49537. dispose(): void;
  49538. }
  49539. }
  49540. declare module "babylonjs/Gizmos/rotationGizmo" {
  49541. import { Observable } from "babylonjs/Misc/observable";
  49542. import { Nullable } from "babylonjs/types";
  49543. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49544. import { Mesh } from "babylonjs/Meshes/mesh";
  49545. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49546. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  49547. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49548. /**
  49549. * Gizmo that enables rotating a mesh along 3 axis
  49550. */
  49551. export class RotationGizmo extends Gizmo {
  49552. /**
  49553. * Internal gizmo used for interactions on the x axis
  49554. */
  49555. xGizmo: PlaneRotationGizmo;
  49556. /**
  49557. * Internal gizmo used for interactions on the y axis
  49558. */
  49559. yGizmo: PlaneRotationGizmo;
  49560. /**
  49561. * Internal gizmo used for interactions on the z axis
  49562. */
  49563. zGizmo: PlaneRotationGizmo;
  49564. /** Fires an event when any of it's sub gizmos are dragged */
  49565. onDragStartObservable: Observable<unknown>;
  49566. /** Fires an event when any of it's sub gizmos are released from dragging */
  49567. onDragEndObservable: Observable<unknown>;
  49568. private _meshAttached;
  49569. get attachedMesh(): Nullable<AbstractMesh>;
  49570. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49571. /**
  49572. * Creates a RotationGizmo
  49573. * @param gizmoLayer The utility layer the gizmo will be added to
  49574. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49575. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49576. */
  49577. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  49578. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49579. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49580. /**
  49581. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49582. */
  49583. set snapDistance(value: number);
  49584. get snapDistance(): number;
  49585. /**
  49586. * Ratio for the scale of the gizmo (Default: 1)
  49587. */
  49588. set scaleRatio(value: number);
  49589. get scaleRatio(): number;
  49590. /**
  49591. * Disposes of the gizmo
  49592. */
  49593. dispose(): void;
  49594. /**
  49595. * CustomMeshes are not supported by this gizmo
  49596. * @param mesh The mesh to replace the default mesh of the gizmo
  49597. */
  49598. setCustomMesh(mesh: Mesh): void;
  49599. }
  49600. }
  49601. declare module "babylonjs/Gizmos/gizmoManager" {
  49602. import { Observable } from "babylonjs/Misc/observable";
  49603. import { Nullable } from "babylonjs/types";
  49604. import { Scene, IDisposable } from "babylonjs/scene";
  49605. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49606. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49607. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  49608. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  49609. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  49610. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  49611. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  49612. /**
  49613. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49614. */
  49615. export class GizmoManager implements IDisposable {
  49616. private scene;
  49617. /**
  49618. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49619. */
  49620. gizmos: {
  49621. positionGizmo: Nullable<PositionGizmo>;
  49622. rotationGizmo: Nullable<RotationGizmo>;
  49623. scaleGizmo: Nullable<ScaleGizmo>;
  49624. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49625. };
  49626. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49627. clearGizmoOnEmptyPointerEvent: boolean;
  49628. /** Fires an event when the manager is attached to a mesh */
  49629. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49630. private _gizmosEnabled;
  49631. private _pointerObserver;
  49632. private _attachedMesh;
  49633. private _boundingBoxColor;
  49634. private _defaultUtilityLayer;
  49635. private _defaultKeepDepthUtilityLayer;
  49636. /**
  49637. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49638. */
  49639. boundingBoxDragBehavior: SixDofDragBehavior;
  49640. /**
  49641. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49642. */
  49643. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49644. /**
  49645. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49646. */
  49647. usePointerToAttachGizmos: boolean;
  49648. /**
  49649. * Utility layer that the bounding box gizmo belongs to
  49650. */
  49651. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49652. /**
  49653. * Utility layer that all gizmos besides bounding box belong to
  49654. */
  49655. get utilityLayer(): UtilityLayerRenderer;
  49656. /**
  49657. * Instatiates a gizmo manager
  49658. * @param scene the scene to overlay the gizmos on top of
  49659. */
  49660. constructor(scene: Scene);
  49661. /**
  49662. * Attaches a set of gizmos to the specified mesh
  49663. * @param mesh The mesh the gizmo's should be attached to
  49664. */
  49665. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49666. /**
  49667. * If the position gizmo is enabled
  49668. */
  49669. set positionGizmoEnabled(value: boolean);
  49670. get positionGizmoEnabled(): boolean;
  49671. /**
  49672. * If the rotation gizmo is enabled
  49673. */
  49674. set rotationGizmoEnabled(value: boolean);
  49675. get rotationGizmoEnabled(): boolean;
  49676. /**
  49677. * If the scale gizmo is enabled
  49678. */
  49679. set scaleGizmoEnabled(value: boolean);
  49680. get scaleGizmoEnabled(): boolean;
  49681. /**
  49682. * If the boundingBox gizmo is enabled
  49683. */
  49684. set boundingBoxGizmoEnabled(value: boolean);
  49685. get boundingBoxGizmoEnabled(): boolean;
  49686. /**
  49687. * Disposes of the gizmo manager
  49688. */
  49689. dispose(): void;
  49690. }
  49691. }
  49692. declare module "babylonjs/Lights/directionalLight" {
  49693. import { Camera } from "babylonjs/Cameras/camera";
  49694. import { Scene } from "babylonjs/scene";
  49695. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  49696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49697. import { Light } from "babylonjs/Lights/light";
  49698. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49699. import { Effect } from "babylonjs/Materials/effect";
  49700. /**
  49701. * A directional light is defined by a direction (what a surprise!).
  49702. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49703. * 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.
  49704. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49705. */
  49706. export class DirectionalLight extends ShadowLight {
  49707. private _shadowFrustumSize;
  49708. /**
  49709. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49710. */
  49711. get shadowFrustumSize(): number;
  49712. /**
  49713. * Specifies a fix frustum size for the shadow generation.
  49714. */
  49715. set shadowFrustumSize(value: number);
  49716. private _shadowOrthoScale;
  49717. /**
  49718. * Gets the shadow projection scale against the optimal computed one.
  49719. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49720. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49721. */
  49722. get shadowOrthoScale(): number;
  49723. /**
  49724. * Sets the shadow projection scale against the optimal computed one.
  49725. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49726. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49727. */
  49728. set shadowOrthoScale(value: number);
  49729. /**
  49730. * Automatically compute the projection matrix to best fit (including all the casters)
  49731. * on each frame.
  49732. */
  49733. autoUpdateExtends: boolean;
  49734. private _orthoLeft;
  49735. private _orthoRight;
  49736. private _orthoTop;
  49737. private _orthoBottom;
  49738. /**
  49739. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49740. * The directional light is emitted from everywhere in the given direction.
  49741. * It can cast shadows.
  49742. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49743. * @param name The friendly name of the light
  49744. * @param direction The direction of the light
  49745. * @param scene The scene the light belongs to
  49746. */
  49747. constructor(name: string, direction: Vector3, scene: Scene);
  49748. /**
  49749. * Returns the string "DirectionalLight".
  49750. * @return The class name
  49751. */
  49752. getClassName(): string;
  49753. /**
  49754. * Returns the integer 1.
  49755. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49756. */
  49757. getTypeID(): number;
  49758. /**
  49759. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49760. * Returns the DirectionalLight Shadow projection matrix.
  49761. */
  49762. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49763. /**
  49764. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49765. * Returns the DirectionalLight Shadow projection matrix.
  49766. */
  49767. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49768. /**
  49769. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49770. * Returns the DirectionalLight Shadow projection matrix.
  49771. */
  49772. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49773. protected _buildUniformLayout(): void;
  49774. /**
  49775. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49776. * @param effect The effect to update
  49777. * @param lightIndex The index of the light in the effect to update
  49778. * @returns The directional light
  49779. */
  49780. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49781. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49782. /**
  49783. * Gets the minZ used for shadow according to both the scene and the light.
  49784. *
  49785. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49786. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49787. * @param activeCamera The camera we are returning the min for
  49788. * @returns the depth min z
  49789. */
  49790. getDepthMinZ(activeCamera: Camera): number;
  49791. /**
  49792. * Gets the maxZ used for shadow according to both the scene and the light.
  49793. *
  49794. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49795. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49796. * @param activeCamera The camera we are returning the max for
  49797. * @returns the depth max z
  49798. */
  49799. getDepthMaxZ(activeCamera: Camera): number;
  49800. /**
  49801. * Prepares the list of defines specific to the light type.
  49802. * @param defines the list of defines
  49803. * @param lightIndex defines the index of the light for the effect
  49804. */
  49805. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49806. }
  49807. }
  49808. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  49809. import { Mesh } from "babylonjs/Meshes/mesh";
  49810. /**
  49811. * Class containing static functions to help procedurally build meshes
  49812. */
  49813. export class HemisphereBuilder {
  49814. /**
  49815. * Creates a hemisphere mesh
  49816. * @param name defines the name of the mesh
  49817. * @param options defines the options used to create the mesh
  49818. * @param scene defines the hosting scene
  49819. * @returns the hemisphere mesh
  49820. */
  49821. static CreateHemisphere(name: string, options: {
  49822. segments?: number;
  49823. diameter?: number;
  49824. sideOrientation?: number;
  49825. }, scene: any): Mesh;
  49826. }
  49827. }
  49828. declare module "babylonjs/Lights/spotLight" {
  49829. import { Nullable } from "babylonjs/types";
  49830. import { Scene } from "babylonjs/scene";
  49831. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  49832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49833. import { Effect } from "babylonjs/Materials/effect";
  49834. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49835. import { Light } from "babylonjs/Lights/light";
  49836. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49837. /**
  49838. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49839. * These values define a cone of light starting from the position, emitting toward the direction.
  49840. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49841. * and the exponent defines the speed of the decay of the light with distance (reach).
  49842. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49843. */
  49844. export class SpotLight extends ShadowLight {
  49845. private _angle;
  49846. private _innerAngle;
  49847. private _cosHalfAngle;
  49848. private _lightAngleScale;
  49849. private _lightAngleOffset;
  49850. /**
  49851. * Gets the cone angle of the spot light in Radians.
  49852. */
  49853. get angle(): number;
  49854. /**
  49855. * Sets the cone angle of the spot light in Radians.
  49856. */
  49857. set angle(value: number);
  49858. /**
  49859. * Only used in gltf falloff mode, this defines the angle where
  49860. * the directional falloff will start before cutting at angle which could be seen
  49861. * as outer angle.
  49862. */
  49863. get innerAngle(): number;
  49864. /**
  49865. * Only used in gltf falloff mode, this defines the angle where
  49866. * the directional falloff will start before cutting at angle which could be seen
  49867. * as outer angle.
  49868. */
  49869. set innerAngle(value: number);
  49870. private _shadowAngleScale;
  49871. /**
  49872. * Allows scaling the angle of the light for shadow generation only.
  49873. */
  49874. get shadowAngleScale(): number;
  49875. /**
  49876. * Allows scaling the angle of the light for shadow generation only.
  49877. */
  49878. set shadowAngleScale(value: number);
  49879. /**
  49880. * The light decay speed with the distance from the emission spot.
  49881. */
  49882. exponent: number;
  49883. private _projectionTextureMatrix;
  49884. /**
  49885. * Allows reading the projecton texture
  49886. */
  49887. get projectionTextureMatrix(): Matrix;
  49888. protected _projectionTextureLightNear: number;
  49889. /**
  49890. * Gets the near clip of the Spotlight for texture projection.
  49891. */
  49892. get projectionTextureLightNear(): number;
  49893. /**
  49894. * Sets the near clip of the Spotlight for texture projection.
  49895. */
  49896. set projectionTextureLightNear(value: number);
  49897. protected _projectionTextureLightFar: number;
  49898. /**
  49899. * Gets the far clip of the Spotlight for texture projection.
  49900. */
  49901. get projectionTextureLightFar(): number;
  49902. /**
  49903. * Sets the far clip of the Spotlight for texture projection.
  49904. */
  49905. set projectionTextureLightFar(value: number);
  49906. protected _projectionTextureUpDirection: Vector3;
  49907. /**
  49908. * Gets the Up vector of the Spotlight for texture projection.
  49909. */
  49910. get projectionTextureUpDirection(): Vector3;
  49911. /**
  49912. * Sets the Up vector of the Spotlight for texture projection.
  49913. */
  49914. set projectionTextureUpDirection(value: Vector3);
  49915. private _projectionTexture;
  49916. /**
  49917. * Gets the projection texture of the light.
  49918. */
  49919. get projectionTexture(): Nullable<BaseTexture>;
  49920. /**
  49921. * Sets the projection texture of the light.
  49922. */
  49923. set projectionTexture(value: Nullable<BaseTexture>);
  49924. private _projectionTextureViewLightDirty;
  49925. private _projectionTextureProjectionLightDirty;
  49926. private _projectionTextureDirty;
  49927. private _projectionTextureViewTargetVector;
  49928. private _projectionTextureViewLightMatrix;
  49929. private _projectionTextureProjectionLightMatrix;
  49930. private _projectionTextureScalingMatrix;
  49931. /**
  49932. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49933. * It can cast shadows.
  49934. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49935. * @param name The light friendly name
  49936. * @param position The position of the spot light in the scene
  49937. * @param direction The direction of the light in the scene
  49938. * @param angle The cone angle of the light in Radians
  49939. * @param exponent The light decay speed with the distance from the emission spot
  49940. * @param scene The scene the lights belongs to
  49941. */
  49942. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49943. /**
  49944. * Returns the string "SpotLight".
  49945. * @returns the class name
  49946. */
  49947. getClassName(): string;
  49948. /**
  49949. * Returns the integer 2.
  49950. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49951. */
  49952. getTypeID(): number;
  49953. /**
  49954. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49955. */
  49956. protected _setDirection(value: Vector3): void;
  49957. /**
  49958. * Overrides the position setter to recompute the projection texture view light Matrix.
  49959. */
  49960. protected _setPosition(value: Vector3): void;
  49961. /**
  49962. * 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.
  49963. * Returns the SpotLight.
  49964. */
  49965. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49966. protected _computeProjectionTextureViewLightMatrix(): void;
  49967. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49968. /**
  49969. * Main function for light texture projection matrix computing.
  49970. */
  49971. protected _computeProjectionTextureMatrix(): void;
  49972. protected _buildUniformLayout(): void;
  49973. private _computeAngleValues;
  49974. /**
  49975. * Sets the passed Effect "effect" with the Light textures.
  49976. * @param effect The effect to update
  49977. * @param lightIndex The index of the light in the effect to update
  49978. * @returns The light
  49979. */
  49980. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49981. /**
  49982. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49983. * @param effect The effect to update
  49984. * @param lightIndex The index of the light in the effect to update
  49985. * @returns The spot light
  49986. */
  49987. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49988. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49989. /**
  49990. * Disposes the light and the associated resources.
  49991. */
  49992. dispose(): void;
  49993. /**
  49994. * Prepares the list of defines specific to the light type.
  49995. * @param defines the list of defines
  49996. * @param lightIndex defines the index of the light for the effect
  49997. */
  49998. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49999. }
  50000. }
  50001. declare module "babylonjs/Gizmos/lightGizmo" {
  50002. import { Nullable } from "babylonjs/types";
  50003. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50004. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50005. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  50006. import { Light } from "babylonjs/Lights/light";
  50007. /**
  50008. * Gizmo that enables viewing a light
  50009. */
  50010. export class LightGizmo extends Gizmo {
  50011. private _lightMesh;
  50012. private _material;
  50013. private _cachedPosition;
  50014. private _cachedForward;
  50015. private _attachedMeshParent;
  50016. /**
  50017. * Creates a LightGizmo
  50018. * @param gizmoLayer The utility layer the gizmo will be added to
  50019. */
  50020. constructor(gizmoLayer?: UtilityLayerRenderer);
  50021. private _light;
  50022. /**
  50023. * The light that the gizmo is attached to
  50024. */
  50025. set light(light: Nullable<Light>);
  50026. get light(): Nullable<Light>;
  50027. /**
  50028. * Gets the material used to render the light gizmo
  50029. */
  50030. get material(): StandardMaterial;
  50031. /**
  50032. * @hidden
  50033. * Updates the gizmo to match the attached mesh's position/rotation
  50034. */
  50035. protected _update(): void;
  50036. private static _Scale;
  50037. /**
  50038. * Creates the lines for a light mesh
  50039. */
  50040. private static _CreateLightLines;
  50041. /**
  50042. * Disposes of the light gizmo
  50043. */
  50044. dispose(): void;
  50045. private static _CreateHemisphericLightMesh;
  50046. private static _CreatePointLightMesh;
  50047. private static _CreateSpotLightMesh;
  50048. private static _CreateDirectionalLightMesh;
  50049. }
  50050. }
  50051. declare module "babylonjs/Gizmos/index" {
  50052. export * from "babylonjs/Gizmos/axisDragGizmo";
  50053. export * from "babylonjs/Gizmos/axisScaleGizmo";
  50054. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  50055. export * from "babylonjs/Gizmos/gizmo";
  50056. export * from "babylonjs/Gizmos/gizmoManager";
  50057. export * from "babylonjs/Gizmos/planeRotationGizmo";
  50058. export * from "babylonjs/Gizmos/positionGizmo";
  50059. export * from "babylonjs/Gizmos/rotationGizmo";
  50060. export * from "babylonjs/Gizmos/scaleGizmo";
  50061. export * from "babylonjs/Gizmos/lightGizmo";
  50062. export * from "babylonjs/Gizmos/planeDragGizmo";
  50063. }
  50064. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  50065. /** @hidden */
  50066. export var backgroundFragmentDeclaration: {
  50067. name: string;
  50068. shader: string;
  50069. };
  50070. }
  50071. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  50072. /** @hidden */
  50073. export var backgroundUboDeclaration: {
  50074. name: string;
  50075. shader: string;
  50076. };
  50077. }
  50078. declare module "babylonjs/Shaders/background.fragment" {
  50079. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  50080. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  50081. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  50082. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50083. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50084. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50085. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50086. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  50087. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  50088. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50089. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  50090. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  50091. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50092. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  50093. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  50094. /** @hidden */
  50095. export var backgroundPixelShader: {
  50096. name: string;
  50097. shader: string;
  50098. };
  50099. }
  50100. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  50101. /** @hidden */
  50102. export var backgroundVertexDeclaration: {
  50103. name: string;
  50104. shader: string;
  50105. };
  50106. }
  50107. declare module "babylonjs/Shaders/background.vertex" {
  50108. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  50109. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  50110. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50111. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50112. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50113. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  50114. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  50115. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50116. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50117. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50118. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50119. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50120. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  50121. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  50122. /** @hidden */
  50123. export var backgroundVertexShader: {
  50124. name: string;
  50125. shader: string;
  50126. };
  50127. }
  50128. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  50129. import { Nullable, int, float } from "babylonjs/types";
  50130. import { Scene } from "babylonjs/scene";
  50131. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50132. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50133. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50134. import { Mesh } from "babylonjs/Meshes/mesh";
  50135. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  50136. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50137. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50138. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50139. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  50140. import { Color3 } from "babylonjs/Maths/math.color";
  50141. import "babylonjs/Shaders/background.fragment";
  50142. import "babylonjs/Shaders/background.vertex";
  50143. /**
  50144. * Background material used to create an efficient environement around your scene.
  50145. */
  50146. export class BackgroundMaterial extends PushMaterial {
  50147. /**
  50148. * Standard reflectance value at parallel view angle.
  50149. */
  50150. static StandardReflectance0: number;
  50151. /**
  50152. * Standard reflectance value at grazing angle.
  50153. */
  50154. static StandardReflectance90: number;
  50155. protected _primaryColor: Color3;
  50156. /**
  50157. * Key light Color (multiply against the environement texture)
  50158. */
  50159. primaryColor: Color3;
  50160. protected __perceptualColor: Nullable<Color3>;
  50161. /**
  50162. * Experimental Internal Use Only.
  50163. *
  50164. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  50165. * This acts as a helper to set the primary color to a more "human friendly" value.
  50166. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  50167. * output color as close as possible from the chosen value.
  50168. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  50169. * part of lighting setup.)
  50170. */
  50171. get _perceptualColor(): Nullable<Color3>;
  50172. set _perceptualColor(value: Nullable<Color3>);
  50173. protected _primaryColorShadowLevel: float;
  50174. /**
  50175. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  50176. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  50177. */
  50178. get primaryColorShadowLevel(): float;
  50179. set primaryColorShadowLevel(value: float);
  50180. protected _primaryColorHighlightLevel: float;
  50181. /**
  50182. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  50183. * The primary color is used at the level chosen to define what the white area would look.
  50184. */
  50185. get primaryColorHighlightLevel(): float;
  50186. set primaryColorHighlightLevel(value: float);
  50187. protected _reflectionTexture: Nullable<BaseTexture>;
  50188. /**
  50189. * Reflection Texture used in the material.
  50190. * Should be author in a specific way for the best result (refer to the documentation).
  50191. */
  50192. reflectionTexture: Nullable<BaseTexture>;
  50193. protected _reflectionBlur: float;
  50194. /**
  50195. * Reflection Texture level of blur.
  50196. *
  50197. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  50198. * texture twice.
  50199. */
  50200. reflectionBlur: float;
  50201. protected _diffuseTexture: Nullable<BaseTexture>;
  50202. /**
  50203. * Diffuse Texture used in the material.
  50204. * Should be author in a specific way for the best result (refer to the documentation).
  50205. */
  50206. diffuseTexture: Nullable<BaseTexture>;
  50207. protected _shadowLights: Nullable<IShadowLight[]>;
  50208. /**
  50209. * Specify the list of lights casting shadow on the material.
  50210. * All scene shadow lights will be included if null.
  50211. */
  50212. shadowLights: Nullable<IShadowLight[]>;
  50213. protected _shadowLevel: float;
  50214. /**
  50215. * Helps adjusting the shadow to a softer level if required.
  50216. * 0 means black shadows and 1 means no shadows.
  50217. */
  50218. shadowLevel: float;
  50219. protected _sceneCenter: Vector3;
  50220. /**
  50221. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  50222. * It is usually zero but might be interesting to modify according to your setup.
  50223. */
  50224. sceneCenter: Vector3;
  50225. protected _opacityFresnel: boolean;
  50226. /**
  50227. * This helps specifying that the material is falling off to the sky box at grazing angle.
  50228. * This helps ensuring a nice transition when the camera goes under the ground.
  50229. */
  50230. opacityFresnel: boolean;
  50231. protected _reflectionFresnel: boolean;
  50232. /**
  50233. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  50234. * This helps adding a mirror texture on the ground.
  50235. */
  50236. reflectionFresnel: boolean;
  50237. protected _reflectionFalloffDistance: number;
  50238. /**
  50239. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  50240. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  50241. */
  50242. reflectionFalloffDistance: number;
  50243. protected _reflectionAmount: number;
  50244. /**
  50245. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  50246. */
  50247. reflectionAmount: number;
  50248. protected _reflectionReflectance0: number;
  50249. /**
  50250. * This specifies the weight of the reflection at grazing angle.
  50251. */
  50252. reflectionReflectance0: number;
  50253. protected _reflectionReflectance90: number;
  50254. /**
  50255. * This specifies the weight of the reflection at a perpendicular point of view.
  50256. */
  50257. reflectionReflectance90: number;
  50258. /**
  50259. * Sets the reflection reflectance fresnel values according to the default standard
  50260. * empirically know to work well :-)
  50261. */
  50262. set reflectionStandardFresnelWeight(value: number);
  50263. protected _useRGBColor: boolean;
  50264. /**
  50265. * Helps to directly use the maps channels instead of their level.
  50266. */
  50267. useRGBColor: boolean;
  50268. protected _enableNoise: boolean;
  50269. /**
  50270. * This helps reducing the banding effect that could occur on the background.
  50271. */
  50272. enableNoise: boolean;
  50273. /**
  50274. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50275. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  50276. * Recommended to be keep at 1.0 except for special cases.
  50277. */
  50278. get fovMultiplier(): number;
  50279. set fovMultiplier(value: number);
  50280. private _fovMultiplier;
  50281. /**
  50282. * Enable the FOV adjustment feature controlled by fovMultiplier.
  50283. */
  50284. useEquirectangularFOV: boolean;
  50285. private _maxSimultaneousLights;
  50286. /**
  50287. * Number of Simultaneous lights allowed on the material.
  50288. */
  50289. maxSimultaneousLights: int;
  50290. /**
  50291. * Default configuration related to image processing available in the Background Material.
  50292. */
  50293. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50294. /**
  50295. * Keep track of the image processing observer to allow dispose and replace.
  50296. */
  50297. private _imageProcessingObserver;
  50298. /**
  50299. * Attaches a new image processing configuration to the PBR Material.
  50300. * @param configuration (if null the scene configuration will be use)
  50301. */
  50302. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50303. /**
  50304. * Gets the image processing configuration used either in this material.
  50305. */
  50306. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  50307. /**
  50308. * Sets the Default image processing configuration used either in the this material.
  50309. *
  50310. * If sets to null, the scene one is in use.
  50311. */
  50312. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  50313. /**
  50314. * Gets wether the color curves effect is enabled.
  50315. */
  50316. get cameraColorCurvesEnabled(): boolean;
  50317. /**
  50318. * Sets wether the color curves effect is enabled.
  50319. */
  50320. set cameraColorCurvesEnabled(value: boolean);
  50321. /**
  50322. * Gets wether the color grading effect is enabled.
  50323. */
  50324. get cameraColorGradingEnabled(): boolean;
  50325. /**
  50326. * Gets wether the color grading effect is enabled.
  50327. */
  50328. set cameraColorGradingEnabled(value: boolean);
  50329. /**
  50330. * Gets wether tonemapping is enabled or not.
  50331. */
  50332. get cameraToneMappingEnabled(): boolean;
  50333. /**
  50334. * Sets wether tonemapping is enabled or not
  50335. */
  50336. set cameraToneMappingEnabled(value: boolean);
  50337. /**
  50338. * The camera exposure used on this material.
  50339. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50340. * This corresponds to a photographic exposure.
  50341. */
  50342. get cameraExposure(): float;
  50343. /**
  50344. * The camera exposure used on this material.
  50345. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50346. * This corresponds to a photographic exposure.
  50347. */
  50348. set cameraExposure(value: float);
  50349. /**
  50350. * Gets The camera contrast used on this material.
  50351. */
  50352. get cameraContrast(): float;
  50353. /**
  50354. * Sets The camera contrast used on this material.
  50355. */
  50356. set cameraContrast(value: float);
  50357. /**
  50358. * Gets the Color Grading 2D Lookup Texture.
  50359. */
  50360. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  50361. /**
  50362. * Sets the Color Grading 2D Lookup Texture.
  50363. */
  50364. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  50365. /**
  50366. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50367. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50368. * 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;
  50369. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50370. */
  50371. get cameraColorCurves(): Nullable<ColorCurves>;
  50372. /**
  50373. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50374. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50375. * 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;
  50376. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50377. */
  50378. set cameraColorCurves(value: Nullable<ColorCurves>);
  50379. /**
  50380. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  50381. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  50382. */
  50383. switchToBGR: boolean;
  50384. private _renderTargets;
  50385. private _reflectionControls;
  50386. private _white;
  50387. private _primaryShadowColor;
  50388. private _primaryHighlightColor;
  50389. /**
  50390. * Instantiates a Background Material in the given scene
  50391. * @param name The friendly name of the material
  50392. * @param scene The scene to add the material to
  50393. */
  50394. constructor(name: string, scene: Scene);
  50395. /**
  50396. * Gets a boolean indicating that current material needs to register RTT
  50397. */
  50398. get hasRenderTargetTextures(): boolean;
  50399. /**
  50400. * The entire material has been created in order to prevent overdraw.
  50401. * @returns false
  50402. */
  50403. needAlphaTesting(): boolean;
  50404. /**
  50405. * The entire material has been created in order to prevent overdraw.
  50406. * @returns true if blending is enable
  50407. */
  50408. needAlphaBlending(): boolean;
  50409. /**
  50410. * Checks wether the material is ready to be rendered for a given mesh.
  50411. * @param mesh The mesh to render
  50412. * @param subMesh The submesh to check against
  50413. * @param useInstances Specify wether or not the material is used with instances
  50414. * @returns true if all the dependencies are ready (Textures, Effects...)
  50415. */
  50416. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50417. /**
  50418. * Compute the primary color according to the chosen perceptual color.
  50419. */
  50420. private _computePrimaryColorFromPerceptualColor;
  50421. /**
  50422. * Compute the highlights and shadow colors according to their chosen levels.
  50423. */
  50424. private _computePrimaryColors;
  50425. /**
  50426. * Build the uniform buffer used in the material.
  50427. */
  50428. buildUniformLayout(): void;
  50429. /**
  50430. * Unbind the material.
  50431. */
  50432. unbind(): void;
  50433. /**
  50434. * Bind only the world matrix to the material.
  50435. * @param world The world matrix to bind.
  50436. */
  50437. bindOnlyWorldMatrix(world: Matrix): void;
  50438. /**
  50439. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  50440. * @param world The world matrix to bind.
  50441. * @param subMesh The submesh to bind for.
  50442. */
  50443. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50444. /**
  50445. * Checks to see if a texture is used in the material.
  50446. * @param texture - Base texture to use.
  50447. * @returns - Boolean specifying if a texture is used in the material.
  50448. */
  50449. hasTexture(texture: BaseTexture): boolean;
  50450. /**
  50451. * Dispose the material.
  50452. * @param forceDisposeEffect Force disposal of the associated effect.
  50453. * @param forceDisposeTextures Force disposal of the associated textures.
  50454. */
  50455. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50456. /**
  50457. * Clones the material.
  50458. * @param name The cloned name.
  50459. * @returns The cloned material.
  50460. */
  50461. clone(name: string): BackgroundMaterial;
  50462. /**
  50463. * Serializes the current material to its JSON representation.
  50464. * @returns The JSON representation.
  50465. */
  50466. serialize(): any;
  50467. /**
  50468. * Gets the class name of the material
  50469. * @returns "BackgroundMaterial"
  50470. */
  50471. getClassName(): string;
  50472. /**
  50473. * Parse a JSON input to create back a background material.
  50474. * @param source The JSON data to parse
  50475. * @param scene The scene to create the parsed material in
  50476. * @param rootUrl The root url of the assets the material depends upon
  50477. * @returns the instantiated BackgroundMaterial.
  50478. */
  50479. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  50480. }
  50481. }
  50482. declare module "babylonjs/Helpers/environmentHelper" {
  50483. import { Observable } from "babylonjs/Misc/observable";
  50484. import { Nullable } from "babylonjs/types";
  50485. import { Scene } from "babylonjs/scene";
  50486. import { Vector3 } from "babylonjs/Maths/math.vector";
  50487. import { Color3 } from "babylonjs/Maths/math.color";
  50488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50489. import { Mesh } from "babylonjs/Meshes/mesh";
  50490. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50491. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  50492. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50493. import "babylonjs/Meshes/Builders/planeBuilder";
  50494. import "babylonjs/Meshes/Builders/boxBuilder";
  50495. /**
  50496. * Represents the different options available during the creation of
  50497. * a Environment helper.
  50498. *
  50499. * This can control the default ground, skybox and image processing setup of your scene.
  50500. */
  50501. export interface IEnvironmentHelperOptions {
  50502. /**
  50503. * Specifies wether or not to create a ground.
  50504. * True by default.
  50505. */
  50506. createGround: boolean;
  50507. /**
  50508. * Specifies the ground size.
  50509. * 15 by default.
  50510. */
  50511. groundSize: number;
  50512. /**
  50513. * The texture used on the ground for the main color.
  50514. * Comes from the BabylonJS CDN by default.
  50515. *
  50516. * Remarks: Can be either a texture or a url.
  50517. */
  50518. groundTexture: string | BaseTexture;
  50519. /**
  50520. * The color mixed in the ground texture by default.
  50521. * BabylonJS clearColor by default.
  50522. */
  50523. groundColor: Color3;
  50524. /**
  50525. * Specifies the ground opacity.
  50526. * 1 by default.
  50527. */
  50528. groundOpacity: number;
  50529. /**
  50530. * Enables the ground to receive shadows.
  50531. * True by default.
  50532. */
  50533. enableGroundShadow: boolean;
  50534. /**
  50535. * Helps preventing the shadow to be fully black on the ground.
  50536. * 0.5 by default.
  50537. */
  50538. groundShadowLevel: number;
  50539. /**
  50540. * Creates a mirror texture attach to the ground.
  50541. * false by default.
  50542. */
  50543. enableGroundMirror: boolean;
  50544. /**
  50545. * Specifies the ground mirror size ratio.
  50546. * 0.3 by default as the default kernel is 64.
  50547. */
  50548. groundMirrorSizeRatio: number;
  50549. /**
  50550. * Specifies the ground mirror blur kernel size.
  50551. * 64 by default.
  50552. */
  50553. groundMirrorBlurKernel: number;
  50554. /**
  50555. * Specifies the ground mirror visibility amount.
  50556. * 1 by default
  50557. */
  50558. groundMirrorAmount: number;
  50559. /**
  50560. * Specifies the ground mirror reflectance weight.
  50561. * This uses the standard weight of the background material to setup the fresnel effect
  50562. * of the mirror.
  50563. * 1 by default.
  50564. */
  50565. groundMirrorFresnelWeight: number;
  50566. /**
  50567. * Specifies the ground mirror Falloff distance.
  50568. * This can helps reducing the size of the reflection.
  50569. * 0 by Default.
  50570. */
  50571. groundMirrorFallOffDistance: number;
  50572. /**
  50573. * Specifies the ground mirror texture type.
  50574. * Unsigned Int by Default.
  50575. */
  50576. groundMirrorTextureType: number;
  50577. /**
  50578. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  50579. * the shown objects.
  50580. */
  50581. groundYBias: number;
  50582. /**
  50583. * Specifies wether or not to create a skybox.
  50584. * True by default.
  50585. */
  50586. createSkybox: boolean;
  50587. /**
  50588. * Specifies the skybox size.
  50589. * 20 by default.
  50590. */
  50591. skyboxSize: number;
  50592. /**
  50593. * The texture used on the skybox for the main color.
  50594. * Comes from the BabylonJS CDN by default.
  50595. *
  50596. * Remarks: Can be either a texture or a url.
  50597. */
  50598. skyboxTexture: string | BaseTexture;
  50599. /**
  50600. * The color mixed in the skybox texture by default.
  50601. * BabylonJS clearColor by default.
  50602. */
  50603. skyboxColor: Color3;
  50604. /**
  50605. * The background rotation around the Y axis of the scene.
  50606. * This helps aligning the key lights of your scene with the background.
  50607. * 0 by default.
  50608. */
  50609. backgroundYRotation: number;
  50610. /**
  50611. * Compute automatically the size of the elements to best fit with the scene.
  50612. */
  50613. sizeAuto: boolean;
  50614. /**
  50615. * Default position of the rootMesh if autoSize is not true.
  50616. */
  50617. rootPosition: Vector3;
  50618. /**
  50619. * Sets up the image processing in the scene.
  50620. * true by default.
  50621. */
  50622. setupImageProcessing: boolean;
  50623. /**
  50624. * The texture used as your environment texture in the scene.
  50625. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  50626. *
  50627. * Remarks: Can be either a texture or a url.
  50628. */
  50629. environmentTexture: string | BaseTexture;
  50630. /**
  50631. * The value of the exposure to apply to the scene.
  50632. * 0.6 by default if setupImageProcessing is true.
  50633. */
  50634. cameraExposure: number;
  50635. /**
  50636. * The value of the contrast to apply to the scene.
  50637. * 1.6 by default if setupImageProcessing is true.
  50638. */
  50639. cameraContrast: number;
  50640. /**
  50641. * Specifies wether or not tonemapping should be enabled in the scene.
  50642. * true by default if setupImageProcessing is true.
  50643. */
  50644. toneMappingEnabled: boolean;
  50645. }
  50646. /**
  50647. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  50648. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  50649. * It also helps with the default setup of your imageProcessing configuration.
  50650. */
  50651. export class EnvironmentHelper {
  50652. /**
  50653. * Default ground texture URL.
  50654. */
  50655. private static _groundTextureCDNUrl;
  50656. /**
  50657. * Default skybox texture URL.
  50658. */
  50659. private static _skyboxTextureCDNUrl;
  50660. /**
  50661. * Default environment texture URL.
  50662. */
  50663. private static _environmentTextureCDNUrl;
  50664. /**
  50665. * Creates the default options for the helper.
  50666. */
  50667. private static _getDefaultOptions;
  50668. private _rootMesh;
  50669. /**
  50670. * Gets the root mesh created by the helper.
  50671. */
  50672. get rootMesh(): Mesh;
  50673. private _skybox;
  50674. /**
  50675. * Gets the skybox created by the helper.
  50676. */
  50677. get skybox(): Nullable<Mesh>;
  50678. private _skyboxTexture;
  50679. /**
  50680. * Gets the skybox texture created by the helper.
  50681. */
  50682. get skyboxTexture(): Nullable<BaseTexture>;
  50683. private _skyboxMaterial;
  50684. /**
  50685. * Gets the skybox material created by the helper.
  50686. */
  50687. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  50688. private _ground;
  50689. /**
  50690. * Gets the ground mesh created by the helper.
  50691. */
  50692. get ground(): Nullable<Mesh>;
  50693. private _groundTexture;
  50694. /**
  50695. * Gets the ground texture created by the helper.
  50696. */
  50697. get groundTexture(): Nullable<BaseTexture>;
  50698. private _groundMirror;
  50699. /**
  50700. * Gets the ground mirror created by the helper.
  50701. */
  50702. get groundMirror(): Nullable<MirrorTexture>;
  50703. /**
  50704. * Gets the ground mirror render list to helps pushing the meshes
  50705. * you wish in the ground reflection.
  50706. */
  50707. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50708. private _groundMaterial;
  50709. /**
  50710. * Gets the ground material created by the helper.
  50711. */
  50712. get groundMaterial(): Nullable<BackgroundMaterial>;
  50713. /**
  50714. * Stores the creation options.
  50715. */
  50716. private readonly _scene;
  50717. private _options;
  50718. /**
  50719. * This observable will be notified with any error during the creation of the environment,
  50720. * mainly texture creation errors.
  50721. */
  50722. onErrorObservable: Observable<{
  50723. message?: string;
  50724. exception?: any;
  50725. }>;
  50726. /**
  50727. * constructor
  50728. * @param options Defines the options we want to customize the helper
  50729. * @param scene The scene to add the material to
  50730. */
  50731. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50732. /**
  50733. * Updates the background according to the new options
  50734. * @param options
  50735. */
  50736. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50737. /**
  50738. * Sets the primary color of all the available elements.
  50739. * @param color the main color to affect to the ground and the background
  50740. */
  50741. setMainColor(color: Color3): void;
  50742. /**
  50743. * Setup the image processing according to the specified options.
  50744. */
  50745. private _setupImageProcessing;
  50746. /**
  50747. * Setup the environment texture according to the specified options.
  50748. */
  50749. private _setupEnvironmentTexture;
  50750. /**
  50751. * Setup the background according to the specified options.
  50752. */
  50753. private _setupBackground;
  50754. /**
  50755. * Get the scene sizes according to the setup.
  50756. */
  50757. private _getSceneSize;
  50758. /**
  50759. * Setup the ground according to the specified options.
  50760. */
  50761. private _setupGround;
  50762. /**
  50763. * Setup the ground material according to the specified options.
  50764. */
  50765. private _setupGroundMaterial;
  50766. /**
  50767. * Setup the ground diffuse texture according to the specified options.
  50768. */
  50769. private _setupGroundDiffuseTexture;
  50770. /**
  50771. * Setup the ground mirror texture according to the specified options.
  50772. */
  50773. private _setupGroundMirrorTexture;
  50774. /**
  50775. * Setup the ground to receive the mirror texture.
  50776. */
  50777. private _setupMirrorInGroundMaterial;
  50778. /**
  50779. * Setup the skybox according to the specified options.
  50780. */
  50781. private _setupSkybox;
  50782. /**
  50783. * Setup the skybox material according to the specified options.
  50784. */
  50785. private _setupSkyboxMaterial;
  50786. /**
  50787. * Setup the skybox reflection texture according to the specified options.
  50788. */
  50789. private _setupSkyboxReflectionTexture;
  50790. private _errorHandler;
  50791. /**
  50792. * Dispose all the elements created by the Helper.
  50793. */
  50794. dispose(): void;
  50795. }
  50796. }
  50797. declare module "babylonjs/Helpers/photoDome" {
  50798. import { Observable } from "babylonjs/Misc/observable";
  50799. import { Nullable } from "babylonjs/types";
  50800. import { Scene } from "babylonjs/scene";
  50801. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50802. import { Mesh } from "babylonjs/Meshes/mesh";
  50803. import { Texture } from "babylonjs/Materials/Textures/texture";
  50804. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50805. import "babylonjs/Meshes/Builders/sphereBuilder";
  50806. /**
  50807. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50808. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50809. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50810. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50811. */
  50812. export class PhotoDome extends TransformNode {
  50813. /**
  50814. * Define the image as a Monoscopic panoramic 360 image.
  50815. */
  50816. static readonly MODE_MONOSCOPIC: number;
  50817. /**
  50818. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50819. */
  50820. static readonly MODE_TOPBOTTOM: number;
  50821. /**
  50822. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50823. */
  50824. static readonly MODE_SIDEBYSIDE: number;
  50825. private _useDirectMapping;
  50826. /**
  50827. * The texture being displayed on the sphere
  50828. */
  50829. protected _photoTexture: Texture;
  50830. /**
  50831. * Gets or sets the texture being displayed on the sphere
  50832. */
  50833. get photoTexture(): Texture;
  50834. set photoTexture(value: Texture);
  50835. /**
  50836. * Observable raised when an error occured while loading the 360 image
  50837. */
  50838. onLoadErrorObservable: Observable<string>;
  50839. /**
  50840. * The skybox material
  50841. */
  50842. protected _material: BackgroundMaterial;
  50843. /**
  50844. * The surface used for the skybox
  50845. */
  50846. protected _mesh: Mesh;
  50847. /**
  50848. * Gets the mesh used for the skybox.
  50849. */
  50850. get mesh(): Mesh;
  50851. /**
  50852. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50853. * Also see the options.resolution property.
  50854. */
  50855. get fovMultiplier(): number;
  50856. set fovMultiplier(value: number);
  50857. private _imageMode;
  50858. /**
  50859. * Gets or set the current video mode for the video. It can be:
  50860. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50861. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50862. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50863. */
  50864. get imageMode(): number;
  50865. set imageMode(value: number);
  50866. /**
  50867. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50868. * @param name Element's name, child elements will append suffixes for their own names.
  50869. * @param urlsOfPhoto defines the url of the photo to display
  50870. * @param options defines an object containing optional or exposed sub element properties
  50871. * @param onError defines a callback called when an error occured while loading the texture
  50872. */
  50873. constructor(name: string, urlOfPhoto: string, options: {
  50874. resolution?: number;
  50875. size?: number;
  50876. useDirectMapping?: boolean;
  50877. faceForward?: boolean;
  50878. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50879. private _onBeforeCameraRenderObserver;
  50880. private _changeImageMode;
  50881. /**
  50882. * Releases resources associated with this node.
  50883. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50884. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50885. */
  50886. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50887. }
  50888. }
  50889. declare module "babylonjs/Misc/rgbdTextureTools" {
  50890. import "babylonjs/Shaders/rgbdDecode.fragment";
  50891. import "babylonjs/Engines/Extensions/engine.renderTarget";
  50892. import { Texture } from "babylonjs/Materials/Textures/texture";
  50893. /**
  50894. * Class used to host RGBD texture specific utilities
  50895. */
  50896. export class RGBDTextureTools {
  50897. /**
  50898. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50899. * @param texture the texture to expand.
  50900. */
  50901. static ExpandRGBDTexture(texture: Texture): void;
  50902. }
  50903. }
  50904. declare module "babylonjs/Misc/brdfTextureTools" {
  50905. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50906. import { Scene } from "babylonjs/scene";
  50907. /**
  50908. * Class used to host texture specific utilities
  50909. */
  50910. export class BRDFTextureTools {
  50911. /**
  50912. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50913. * @param scene defines the hosting scene
  50914. * @returns the environment BRDF texture
  50915. */
  50916. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50917. private static _environmentBRDFBase64Texture;
  50918. }
  50919. }
  50920. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  50921. import { Nullable } from "babylonjs/types";
  50922. import { Color3 } from "babylonjs/Maths/math.color";
  50923. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50924. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  50925. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50926. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  50927. import { Engine } from "babylonjs/Engines/engine";
  50928. import { Scene } from "babylonjs/scene";
  50929. /**
  50930. * @hidden
  50931. */
  50932. export interface IMaterialClearCoatDefines {
  50933. CLEARCOAT: boolean;
  50934. CLEARCOAT_DEFAULTIOR: boolean;
  50935. CLEARCOAT_TEXTURE: boolean;
  50936. CLEARCOAT_TEXTUREDIRECTUV: number;
  50937. CLEARCOAT_BUMP: boolean;
  50938. CLEARCOAT_BUMPDIRECTUV: number;
  50939. CLEARCOAT_TINT: boolean;
  50940. CLEARCOAT_TINT_TEXTURE: boolean;
  50941. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50942. /** @hidden */
  50943. _areTexturesDirty: boolean;
  50944. }
  50945. /**
  50946. * Define the code related to the clear coat parameters of the pbr material.
  50947. */
  50948. export class PBRClearCoatConfiguration {
  50949. /**
  50950. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50951. * The default fits with a polyurethane material.
  50952. */
  50953. private static readonly _DefaultIndexOfRefraction;
  50954. private _isEnabled;
  50955. /**
  50956. * Defines if the clear coat is enabled in the material.
  50957. */
  50958. isEnabled: boolean;
  50959. /**
  50960. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50961. */
  50962. intensity: number;
  50963. /**
  50964. * Defines the clear coat layer roughness.
  50965. */
  50966. roughness: number;
  50967. private _indexOfRefraction;
  50968. /**
  50969. * Defines the index of refraction of the clear coat.
  50970. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50971. * The default fits with a polyurethane material.
  50972. * Changing the default value is more performance intensive.
  50973. */
  50974. indexOfRefraction: number;
  50975. private _texture;
  50976. /**
  50977. * Stores the clear coat values in a texture.
  50978. */
  50979. texture: Nullable<BaseTexture>;
  50980. private _bumpTexture;
  50981. /**
  50982. * Define the clear coat specific bump texture.
  50983. */
  50984. bumpTexture: Nullable<BaseTexture>;
  50985. private _isTintEnabled;
  50986. /**
  50987. * Defines if the clear coat tint is enabled in the material.
  50988. */
  50989. isTintEnabled: boolean;
  50990. /**
  50991. * Defines the clear coat tint of the material.
  50992. * This is only use if tint is enabled
  50993. */
  50994. tintColor: Color3;
  50995. /**
  50996. * Defines the distance at which the tint color should be found in the
  50997. * clear coat media.
  50998. * This is only use if tint is enabled
  50999. */
  51000. tintColorAtDistance: number;
  51001. /**
  51002. * Defines the clear coat layer thickness.
  51003. * This is only use if tint is enabled
  51004. */
  51005. tintThickness: number;
  51006. private _tintTexture;
  51007. /**
  51008. * Stores the clear tint values in a texture.
  51009. * rgb is tint
  51010. * a is a thickness factor
  51011. */
  51012. tintTexture: Nullable<BaseTexture>;
  51013. /** @hidden */
  51014. private _internalMarkAllSubMeshesAsTexturesDirty;
  51015. /** @hidden */
  51016. _markAllSubMeshesAsTexturesDirty(): void;
  51017. /**
  51018. * Instantiate a new istance of clear coat configuration.
  51019. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51020. */
  51021. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51022. /**
  51023. * Gets wehter the submesh is ready to be used or not.
  51024. * @param defines the list of "defines" to update.
  51025. * @param scene defines the scene the material belongs to.
  51026. * @param engine defines the engine the material belongs to.
  51027. * @param disableBumpMap defines wether the material disables bump or not.
  51028. * @returns - boolean indicating that the submesh is ready or not.
  51029. */
  51030. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  51031. /**
  51032. * Checks to see if a texture is used in the material.
  51033. * @param defines the list of "defines" to update.
  51034. * @param scene defines the scene to the material belongs to.
  51035. */
  51036. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  51037. /**
  51038. * Binds the material data.
  51039. * @param uniformBuffer defines the Uniform buffer to fill in.
  51040. * @param scene defines the scene the material belongs to.
  51041. * @param engine defines the engine the material belongs to.
  51042. * @param disableBumpMap defines wether the material disables bump or not.
  51043. * @param isFrozen defines wether the material is frozen or not.
  51044. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51045. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51046. */
  51047. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  51048. /**
  51049. * Checks to see if a texture is used in the material.
  51050. * @param texture - Base texture to use.
  51051. * @returns - Boolean specifying if a texture is used in the material.
  51052. */
  51053. hasTexture(texture: BaseTexture): boolean;
  51054. /**
  51055. * Returns an array of the actively used textures.
  51056. * @param activeTextures Array of BaseTextures
  51057. */
  51058. getActiveTextures(activeTextures: BaseTexture[]): void;
  51059. /**
  51060. * Returns the animatable textures.
  51061. * @param animatables Array of animatable textures.
  51062. */
  51063. getAnimatables(animatables: IAnimatable[]): void;
  51064. /**
  51065. * Disposes the resources of the material.
  51066. * @param forceDisposeTextures - Forces the disposal of all textures.
  51067. */
  51068. dispose(forceDisposeTextures?: boolean): void;
  51069. /**
  51070. * Get the current class name of the texture useful for serialization or dynamic coding.
  51071. * @returns "PBRClearCoatConfiguration"
  51072. */
  51073. getClassName(): string;
  51074. /**
  51075. * Add fallbacks to the effect fallbacks list.
  51076. * @param defines defines the Base texture to use.
  51077. * @param fallbacks defines the current fallback list.
  51078. * @param currentRank defines the current fallback rank.
  51079. * @returns the new fallback rank.
  51080. */
  51081. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51082. /**
  51083. * Add the required uniforms to the current list.
  51084. * @param uniforms defines the current uniform list.
  51085. */
  51086. static AddUniforms(uniforms: string[]): void;
  51087. /**
  51088. * Add the required samplers to the current list.
  51089. * @param samplers defines the current sampler list.
  51090. */
  51091. static AddSamplers(samplers: string[]): void;
  51092. /**
  51093. * Add the required uniforms to the current buffer.
  51094. * @param uniformBuffer defines the current uniform buffer.
  51095. */
  51096. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51097. /**
  51098. * Makes a duplicate of the current configuration into another one.
  51099. * @param clearCoatConfiguration define the config where to copy the info
  51100. */
  51101. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  51102. /**
  51103. * Serializes this clear coat configuration.
  51104. * @returns - An object with the serialized config.
  51105. */
  51106. serialize(): any;
  51107. /**
  51108. * Parses a anisotropy Configuration from a serialized object.
  51109. * @param source - Serialized object.
  51110. * @param scene Defines the scene we are parsing for
  51111. * @param rootUrl Defines the rootUrl to load from
  51112. */
  51113. parse(source: any, scene: Scene, rootUrl: string): void;
  51114. }
  51115. }
  51116. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  51117. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51119. import { Vector2 } from "babylonjs/Maths/math.vector";
  51120. import { Scene } from "babylonjs/scene";
  51121. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51122. import { Nullable } from "babylonjs/types";
  51123. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51124. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51125. /**
  51126. * @hidden
  51127. */
  51128. export interface IMaterialAnisotropicDefines {
  51129. ANISOTROPIC: boolean;
  51130. ANISOTROPIC_TEXTURE: boolean;
  51131. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51132. MAINUV1: boolean;
  51133. _areTexturesDirty: boolean;
  51134. _needUVs: boolean;
  51135. }
  51136. /**
  51137. * Define the code related to the anisotropic parameters of the pbr material.
  51138. */
  51139. export class PBRAnisotropicConfiguration {
  51140. private _isEnabled;
  51141. /**
  51142. * Defines if the anisotropy is enabled in the material.
  51143. */
  51144. isEnabled: boolean;
  51145. /**
  51146. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  51147. */
  51148. intensity: number;
  51149. /**
  51150. * Defines if the effect is along the tangents, bitangents or in between.
  51151. * By default, the effect is "strectching" the highlights along the tangents.
  51152. */
  51153. direction: Vector2;
  51154. private _texture;
  51155. /**
  51156. * Stores the anisotropy values in a texture.
  51157. * rg is direction (like normal from -1 to 1)
  51158. * b is a intensity
  51159. */
  51160. texture: Nullable<BaseTexture>;
  51161. /** @hidden */
  51162. private _internalMarkAllSubMeshesAsTexturesDirty;
  51163. /** @hidden */
  51164. _markAllSubMeshesAsTexturesDirty(): void;
  51165. /**
  51166. * Instantiate a new istance of anisotropy configuration.
  51167. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51168. */
  51169. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51170. /**
  51171. * Specifies that the submesh is ready to be used.
  51172. * @param defines the list of "defines" to update.
  51173. * @param scene defines the scene the material belongs to.
  51174. * @returns - boolean indicating that the submesh is ready or not.
  51175. */
  51176. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  51177. /**
  51178. * Checks to see if a texture is used in the material.
  51179. * @param defines the list of "defines" to update.
  51180. * @param mesh the mesh we are preparing the defines for.
  51181. * @param scene defines the scene the material belongs to.
  51182. */
  51183. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  51184. /**
  51185. * Binds the material data.
  51186. * @param uniformBuffer defines the Uniform buffer to fill in.
  51187. * @param scene defines the scene the material belongs to.
  51188. * @param isFrozen defines wether the material is frozen or not.
  51189. */
  51190. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  51191. /**
  51192. * Checks to see if a texture is used in the material.
  51193. * @param texture - Base texture to use.
  51194. * @returns - Boolean specifying if a texture is used in the material.
  51195. */
  51196. hasTexture(texture: BaseTexture): boolean;
  51197. /**
  51198. * Returns an array of the actively used textures.
  51199. * @param activeTextures Array of BaseTextures
  51200. */
  51201. getActiveTextures(activeTextures: BaseTexture[]): void;
  51202. /**
  51203. * Returns the animatable textures.
  51204. * @param animatables Array of animatable textures.
  51205. */
  51206. getAnimatables(animatables: IAnimatable[]): void;
  51207. /**
  51208. * Disposes the resources of the material.
  51209. * @param forceDisposeTextures - Forces the disposal of all textures.
  51210. */
  51211. dispose(forceDisposeTextures?: boolean): void;
  51212. /**
  51213. * Get the current class name of the texture useful for serialization or dynamic coding.
  51214. * @returns "PBRAnisotropicConfiguration"
  51215. */
  51216. getClassName(): string;
  51217. /**
  51218. * Add fallbacks to the effect fallbacks list.
  51219. * @param defines defines the Base texture to use.
  51220. * @param fallbacks defines the current fallback list.
  51221. * @param currentRank defines the current fallback rank.
  51222. * @returns the new fallback rank.
  51223. */
  51224. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51225. /**
  51226. * Add the required uniforms to the current list.
  51227. * @param uniforms defines the current uniform list.
  51228. */
  51229. static AddUniforms(uniforms: string[]): void;
  51230. /**
  51231. * Add the required uniforms to the current buffer.
  51232. * @param uniformBuffer defines the current uniform buffer.
  51233. */
  51234. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51235. /**
  51236. * Add the required samplers to the current list.
  51237. * @param samplers defines the current sampler list.
  51238. */
  51239. static AddSamplers(samplers: string[]): void;
  51240. /**
  51241. * Makes a duplicate of the current configuration into another one.
  51242. * @param anisotropicConfiguration define the config where to copy the info
  51243. */
  51244. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  51245. /**
  51246. * Serializes this anisotropy configuration.
  51247. * @returns - An object with the serialized config.
  51248. */
  51249. serialize(): any;
  51250. /**
  51251. * Parses a anisotropy Configuration from a serialized object.
  51252. * @param source - Serialized object.
  51253. * @param scene Defines the scene we are parsing for
  51254. * @param rootUrl Defines the rootUrl to load from
  51255. */
  51256. parse(source: any, scene: Scene, rootUrl: string): void;
  51257. }
  51258. }
  51259. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  51260. import { Scene } from "babylonjs/scene";
  51261. /**
  51262. * @hidden
  51263. */
  51264. export interface IMaterialBRDFDefines {
  51265. BRDF_V_HEIGHT_CORRELATED: boolean;
  51266. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51267. SPHERICAL_HARMONICS: boolean;
  51268. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51269. /** @hidden */
  51270. _areMiscDirty: boolean;
  51271. }
  51272. /**
  51273. * Define the code related to the BRDF parameters of the pbr material.
  51274. */
  51275. export class PBRBRDFConfiguration {
  51276. /**
  51277. * Default value used for the energy conservation.
  51278. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  51279. */
  51280. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  51281. /**
  51282. * Default value used for the Smith Visibility Height Correlated mode.
  51283. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  51284. */
  51285. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  51286. /**
  51287. * Default value used for the IBL diffuse part.
  51288. * This can help switching back to the polynomials mode globally which is a tiny bit
  51289. * less GPU intensive at the drawback of a lower quality.
  51290. */
  51291. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  51292. /**
  51293. * Default value used for activating energy conservation for the specular workflow.
  51294. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  51295. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  51296. */
  51297. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  51298. private _useEnergyConservation;
  51299. /**
  51300. * Defines if the material uses energy conservation.
  51301. */
  51302. useEnergyConservation: boolean;
  51303. private _useSmithVisibilityHeightCorrelated;
  51304. /**
  51305. * LEGACY Mode set to false
  51306. * Defines if the material uses height smith correlated visibility term.
  51307. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  51308. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  51309. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  51310. * Not relying on height correlated will also disable energy conservation.
  51311. */
  51312. useSmithVisibilityHeightCorrelated: boolean;
  51313. private _useSphericalHarmonics;
  51314. /**
  51315. * LEGACY Mode set to false
  51316. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  51317. * diffuse part of the IBL.
  51318. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  51319. * to the ground truth.
  51320. */
  51321. useSphericalHarmonics: boolean;
  51322. private _useSpecularGlossinessInputEnergyConservation;
  51323. /**
  51324. * Defines if the material uses energy conservation, when the specular workflow is active.
  51325. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  51326. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  51327. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  51328. */
  51329. useSpecularGlossinessInputEnergyConservation: boolean;
  51330. /** @hidden */
  51331. private _internalMarkAllSubMeshesAsMiscDirty;
  51332. /** @hidden */
  51333. _markAllSubMeshesAsMiscDirty(): void;
  51334. /**
  51335. * Instantiate a new istance of clear coat configuration.
  51336. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  51337. */
  51338. constructor(markAllSubMeshesAsMiscDirty: () => void);
  51339. /**
  51340. * Checks to see if a texture is used in the material.
  51341. * @param defines the list of "defines" to update.
  51342. */
  51343. prepareDefines(defines: IMaterialBRDFDefines): void;
  51344. /**
  51345. * Get the current class name of the texture useful for serialization or dynamic coding.
  51346. * @returns "PBRClearCoatConfiguration"
  51347. */
  51348. getClassName(): string;
  51349. /**
  51350. * Makes a duplicate of the current configuration into another one.
  51351. * @param brdfConfiguration define the config where to copy the info
  51352. */
  51353. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  51354. /**
  51355. * Serializes this BRDF configuration.
  51356. * @returns - An object with the serialized config.
  51357. */
  51358. serialize(): any;
  51359. /**
  51360. * Parses a anisotropy Configuration from a serialized object.
  51361. * @param source - Serialized object.
  51362. * @param scene Defines the scene we are parsing for
  51363. * @param rootUrl Defines the rootUrl to load from
  51364. */
  51365. parse(source: any, scene: Scene, rootUrl: string): void;
  51366. }
  51367. }
  51368. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  51369. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51370. import { Color3 } from "babylonjs/Maths/math.color";
  51371. import { Scene } from "babylonjs/scene";
  51372. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51373. import { Nullable } from "babylonjs/types";
  51374. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51375. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51376. /**
  51377. * @hidden
  51378. */
  51379. export interface IMaterialSheenDefines {
  51380. SHEEN: boolean;
  51381. SHEEN_TEXTURE: boolean;
  51382. SHEEN_TEXTUREDIRECTUV: number;
  51383. SHEEN_LINKWITHALBEDO: boolean;
  51384. /** @hidden */
  51385. _areTexturesDirty: boolean;
  51386. }
  51387. /**
  51388. * Define the code related to the Sheen parameters of the pbr material.
  51389. */
  51390. export class PBRSheenConfiguration {
  51391. private _isEnabled;
  51392. /**
  51393. * Defines if the material uses sheen.
  51394. */
  51395. isEnabled: boolean;
  51396. private _linkSheenWithAlbedo;
  51397. /**
  51398. * Defines if the sheen is linked to the sheen color.
  51399. */
  51400. linkSheenWithAlbedo: boolean;
  51401. /**
  51402. * Defines the sheen intensity.
  51403. */
  51404. intensity: number;
  51405. /**
  51406. * Defines the sheen color.
  51407. */
  51408. color: Color3;
  51409. private _texture;
  51410. /**
  51411. * Stores the sheen tint values in a texture.
  51412. * rgb is tint
  51413. * a is a intensity
  51414. */
  51415. texture: Nullable<BaseTexture>;
  51416. /** @hidden */
  51417. private _internalMarkAllSubMeshesAsTexturesDirty;
  51418. /** @hidden */
  51419. _markAllSubMeshesAsTexturesDirty(): void;
  51420. /**
  51421. * Instantiate a new istance of clear coat configuration.
  51422. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51423. */
  51424. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51425. /**
  51426. * Specifies that the submesh is ready to be used.
  51427. * @param defines the list of "defines" to update.
  51428. * @param scene defines the scene the material belongs to.
  51429. * @returns - boolean indicating that the submesh is ready or not.
  51430. */
  51431. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  51432. /**
  51433. * Checks to see if a texture is used in the material.
  51434. * @param defines the list of "defines" to update.
  51435. * @param scene defines the scene the material belongs to.
  51436. */
  51437. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  51438. /**
  51439. * Binds the material data.
  51440. * @param uniformBuffer defines the Uniform buffer to fill in.
  51441. * @param scene defines the scene the material belongs to.
  51442. * @param isFrozen defines wether the material is frozen or not.
  51443. */
  51444. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  51445. /**
  51446. * Checks to see if a texture is used in the material.
  51447. * @param texture - Base texture to use.
  51448. * @returns - Boolean specifying if a texture is used in the material.
  51449. */
  51450. hasTexture(texture: BaseTexture): boolean;
  51451. /**
  51452. * Returns an array of the actively used textures.
  51453. * @param activeTextures Array of BaseTextures
  51454. */
  51455. getActiveTextures(activeTextures: BaseTexture[]): void;
  51456. /**
  51457. * Returns the animatable textures.
  51458. * @param animatables Array of animatable textures.
  51459. */
  51460. getAnimatables(animatables: IAnimatable[]): void;
  51461. /**
  51462. * Disposes the resources of the material.
  51463. * @param forceDisposeTextures - Forces the disposal of all textures.
  51464. */
  51465. dispose(forceDisposeTextures?: boolean): void;
  51466. /**
  51467. * Get the current class name of the texture useful for serialization or dynamic coding.
  51468. * @returns "PBRSheenConfiguration"
  51469. */
  51470. getClassName(): string;
  51471. /**
  51472. * Add fallbacks to the effect fallbacks list.
  51473. * @param defines defines the Base texture to use.
  51474. * @param fallbacks defines the current fallback list.
  51475. * @param currentRank defines the current fallback rank.
  51476. * @returns the new fallback rank.
  51477. */
  51478. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51479. /**
  51480. * Add the required uniforms to the current list.
  51481. * @param uniforms defines the current uniform list.
  51482. */
  51483. static AddUniforms(uniforms: string[]): void;
  51484. /**
  51485. * Add the required uniforms to the current buffer.
  51486. * @param uniformBuffer defines the current uniform buffer.
  51487. */
  51488. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51489. /**
  51490. * Add the required samplers to the current list.
  51491. * @param samplers defines the current sampler list.
  51492. */
  51493. static AddSamplers(samplers: string[]): void;
  51494. /**
  51495. * Makes a duplicate of the current configuration into another one.
  51496. * @param sheenConfiguration define the config where to copy the info
  51497. */
  51498. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  51499. /**
  51500. * Serializes this BRDF configuration.
  51501. * @returns - An object with the serialized config.
  51502. */
  51503. serialize(): any;
  51504. /**
  51505. * Parses a anisotropy Configuration from a serialized object.
  51506. * @param source - Serialized object.
  51507. * @param scene Defines the scene we are parsing for
  51508. * @param rootUrl Defines the rootUrl to load from
  51509. */
  51510. parse(source: any, scene: Scene, rootUrl: string): void;
  51511. }
  51512. }
  51513. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  51514. import { Nullable } from "babylonjs/types";
  51515. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51516. import { Color3 } from "babylonjs/Maths/math.color";
  51517. import { SmartArray } from "babylonjs/Misc/smartArray";
  51518. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51519. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51520. import { Effect } from "babylonjs/Materials/effect";
  51521. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51522. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51523. import { Engine } from "babylonjs/Engines/engine";
  51524. import { Scene } from "babylonjs/scene";
  51525. /**
  51526. * @hidden
  51527. */
  51528. export interface IMaterialSubSurfaceDefines {
  51529. SUBSURFACE: boolean;
  51530. SS_REFRACTION: boolean;
  51531. SS_TRANSLUCENCY: boolean;
  51532. SS_SCATERRING: boolean;
  51533. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51534. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51535. SS_REFRACTIONMAP_3D: boolean;
  51536. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51537. SS_LODINREFRACTIONALPHA: boolean;
  51538. SS_GAMMAREFRACTION: boolean;
  51539. SS_RGBDREFRACTION: boolean;
  51540. SS_LINEARSPECULARREFRACTION: boolean;
  51541. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51542. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51543. /** @hidden */
  51544. _areTexturesDirty: boolean;
  51545. }
  51546. /**
  51547. * Define the code related to the sub surface parameters of the pbr material.
  51548. */
  51549. export class PBRSubSurfaceConfiguration {
  51550. private _isRefractionEnabled;
  51551. /**
  51552. * Defines if the refraction is enabled in the material.
  51553. */
  51554. isRefractionEnabled: boolean;
  51555. private _isTranslucencyEnabled;
  51556. /**
  51557. * Defines if the translucency is enabled in the material.
  51558. */
  51559. isTranslucencyEnabled: boolean;
  51560. private _isScatteringEnabled;
  51561. /**
  51562. * Defines the refraction intensity of the material.
  51563. * The refraction when enabled replaces the Diffuse part of the material.
  51564. * The intensity helps transitionning between diffuse and refraction.
  51565. */
  51566. refractionIntensity: number;
  51567. /**
  51568. * Defines the translucency intensity of the material.
  51569. * When translucency has been enabled, this defines how much of the "translucency"
  51570. * is addded to the diffuse part of the material.
  51571. */
  51572. translucencyIntensity: number;
  51573. /**
  51574. * Defines the scattering intensity of the material.
  51575. * When scattering has been enabled, this defines how much of the "scattered light"
  51576. * is addded to the diffuse part of the material.
  51577. */
  51578. scatteringIntensity: number;
  51579. private _thicknessTexture;
  51580. /**
  51581. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  51582. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  51583. * 0 would mean minimumThickness
  51584. * 1 would mean maximumThickness
  51585. * The other channels might be use as a mask to vary the different effects intensity.
  51586. */
  51587. thicknessTexture: Nullable<BaseTexture>;
  51588. private _refractionTexture;
  51589. /**
  51590. * Defines the texture to use for refraction.
  51591. */
  51592. refractionTexture: Nullable<BaseTexture>;
  51593. private _indexOfRefraction;
  51594. /**
  51595. * Defines the index of refraction used in the material.
  51596. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  51597. */
  51598. indexOfRefraction: number;
  51599. private _invertRefractionY;
  51600. /**
  51601. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51602. */
  51603. invertRefractionY: boolean;
  51604. private _linkRefractionWithTransparency;
  51605. /**
  51606. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51607. * Materials half opaque for instance using refraction could benefit from this control.
  51608. */
  51609. linkRefractionWithTransparency: boolean;
  51610. /**
  51611. * Defines the minimum thickness stored in the thickness map.
  51612. * If no thickness map is defined, this value will be used to simulate thickness.
  51613. */
  51614. minimumThickness: number;
  51615. /**
  51616. * Defines the maximum thickness stored in the thickness map.
  51617. */
  51618. maximumThickness: number;
  51619. /**
  51620. * Defines the volume tint of the material.
  51621. * This is used for both translucency and scattering.
  51622. */
  51623. tintColor: Color3;
  51624. /**
  51625. * Defines the distance at which the tint color should be found in the media.
  51626. * This is used for refraction only.
  51627. */
  51628. tintColorAtDistance: number;
  51629. /**
  51630. * Defines how far each channel transmit through the media.
  51631. * It is defined as a color to simplify it selection.
  51632. */
  51633. diffusionDistance: Color3;
  51634. private _useMaskFromThicknessTexture;
  51635. /**
  51636. * Stores the intensity of the different subsurface effects in the thickness texture.
  51637. * * the green channel is the translucency intensity.
  51638. * * the blue channel is the scattering intensity.
  51639. * * the alpha channel is the refraction intensity.
  51640. */
  51641. useMaskFromThicknessTexture: boolean;
  51642. /** @hidden */
  51643. private _internalMarkAllSubMeshesAsTexturesDirty;
  51644. /** @hidden */
  51645. _markAllSubMeshesAsTexturesDirty(): void;
  51646. /**
  51647. * Instantiate a new istance of sub surface configuration.
  51648. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51649. */
  51650. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51651. /**
  51652. * Gets wehter the submesh is ready to be used or not.
  51653. * @param defines the list of "defines" to update.
  51654. * @param scene defines the scene the material belongs to.
  51655. * @returns - boolean indicating that the submesh is ready or not.
  51656. */
  51657. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  51658. /**
  51659. * Checks to see if a texture is used in the material.
  51660. * @param defines the list of "defines" to update.
  51661. * @param scene defines the scene to the material belongs to.
  51662. */
  51663. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  51664. /**
  51665. * Binds the material data.
  51666. * @param uniformBuffer defines the Uniform buffer to fill in.
  51667. * @param scene defines the scene the material belongs to.
  51668. * @param engine defines the engine the material belongs to.
  51669. * @param isFrozen defines wether the material is frozen or not.
  51670. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  51671. */
  51672. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  51673. /**
  51674. * Unbinds the material from the mesh.
  51675. * @param activeEffect defines the effect that should be unbound from.
  51676. * @returns true if unbound, otherwise false
  51677. */
  51678. unbind(activeEffect: Effect): boolean;
  51679. /**
  51680. * Returns the texture used for refraction or null if none is used.
  51681. * @param scene defines the scene the material belongs to.
  51682. * @returns - Refraction texture if present. If no refraction texture and refraction
  51683. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51684. */
  51685. private _getRefractionTexture;
  51686. /**
  51687. * Returns true if alpha blending should be disabled.
  51688. */
  51689. get disableAlphaBlending(): boolean;
  51690. /**
  51691. * Fills the list of render target textures.
  51692. * @param renderTargets the list of render targets to update
  51693. */
  51694. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  51695. /**
  51696. * Checks to see if a texture is used in the material.
  51697. * @param texture - Base texture to use.
  51698. * @returns - Boolean specifying if a texture is used in the material.
  51699. */
  51700. hasTexture(texture: BaseTexture): boolean;
  51701. /**
  51702. * Gets a boolean indicating that current material needs to register RTT
  51703. * @returns true if this uses a render target otherwise false.
  51704. */
  51705. hasRenderTargetTextures(): boolean;
  51706. /**
  51707. * Returns an array of the actively used textures.
  51708. * @param activeTextures Array of BaseTextures
  51709. */
  51710. getActiveTextures(activeTextures: BaseTexture[]): void;
  51711. /**
  51712. * Returns the animatable textures.
  51713. * @param animatables Array of animatable textures.
  51714. */
  51715. getAnimatables(animatables: IAnimatable[]): void;
  51716. /**
  51717. * Disposes the resources of the material.
  51718. * @param forceDisposeTextures - Forces the disposal of all textures.
  51719. */
  51720. dispose(forceDisposeTextures?: boolean): void;
  51721. /**
  51722. * Get the current class name of the texture useful for serialization or dynamic coding.
  51723. * @returns "PBRSubSurfaceConfiguration"
  51724. */
  51725. getClassName(): string;
  51726. /**
  51727. * Add fallbacks to the effect fallbacks list.
  51728. * @param defines defines the Base texture to use.
  51729. * @param fallbacks defines the current fallback list.
  51730. * @param currentRank defines the current fallback rank.
  51731. * @returns the new fallback rank.
  51732. */
  51733. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51734. /**
  51735. * Add the required uniforms to the current list.
  51736. * @param uniforms defines the current uniform list.
  51737. */
  51738. static AddUniforms(uniforms: string[]): void;
  51739. /**
  51740. * Add the required samplers to the current list.
  51741. * @param samplers defines the current sampler list.
  51742. */
  51743. static AddSamplers(samplers: string[]): void;
  51744. /**
  51745. * Add the required uniforms to the current buffer.
  51746. * @param uniformBuffer defines the current uniform buffer.
  51747. */
  51748. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51749. /**
  51750. * Makes a duplicate of the current configuration into another one.
  51751. * @param configuration define the config where to copy the info
  51752. */
  51753. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51754. /**
  51755. * Serializes this Sub Surface configuration.
  51756. * @returns - An object with the serialized config.
  51757. */
  51758. serialize(): any;
  51759. /**
  51760. * Parses a anisotropy Configuration from a serialized object.
  51761. * @param source - Serialized object.
  51762. * @param scene Defines the scene we are parsing for
  51763. * @param rootUrl Defines the rootUrl to load from
  51764. */
  51765. parse(source: any, scene: Scene, rootUrl: string): void;
  51766. }
  51767. }
  51768. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  51769. /** @hidden */
  51770. export var pbrFragmentDeclaration: {
  51771. name: string;
  51772. shader: string;
  51773. };
  51774. }
  51775. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  51776. /** @hidden */
  51777. export var pbrUboDeclaration: {
  51778. name: string;
  51779. shader: string;
  51780. };
  51781. }
  51782. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  51783. /** @hidden */
  51784. export var pbrFragmentExtraDeclaration: {
  51785. name: string;
  51786. shader: string;
  51787. };
  51788. }
  51789. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  51790. /** @hidden */
  51791. export var pbrFragmentSamplersDeclaration: {
  51792. name: string;
  51793. shader: string;
  51794. };
  51795. }
  51796. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  51797. /** @hidden */
  51798. export var pbrHelperFunctions: {
  51799. name: string;
  51800. shader: string;
  51801. };
  51802. }
  51803. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  51804. /** @hidden */
  51805. export var harmonicsFunctions: {
  51806. name: string;
  51807. shader: string;
  51808. };
  51809. }
  51810. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  51811. /** @hidden */
  51812. export var pbrDirectLightingSetupFunctions: {
  51813. name: string;
  51814. shader: string;
  51815. };
  51816. }
  51817. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  51818. /** @hidden */
  51819. export var pbrDirectLightingFalloffFunctions: {
  51820. name: string;
  51821. shader: string;
  51822. };
  51823. }
  51824. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  51825. /** @hidden */
  51826. export var pbrBRDFFunctions: {
  51827. name: string;
  51828. shader: string;
  51829. };
  51830. }
  51831. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  51832. /** @hidden */
  51833. export var pbrDirectLightingFunctions: {
  51834. name: string;
  51835. shader: string;
  51836. };
  51837. }
  51838. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  51839. /** @hidden */
  51840. export var pbrIBLFunctions: {
  51841. name: string;
  51842. shader: string;
  51843. };
  51844. }
  51845. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  51846. /** @hidden */
  51847. export var pbrDebug: {
  51848. name: string;
  51849. shader: string;
  51850. };
  51851. }
  51852. declare module "babylonjs/Shaders/pbr.fragment" {
  51853. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  51854. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  51855. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  51856. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51857. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51858. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  51859. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51860. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51861. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  51862. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51863. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51864. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  51865. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51866. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51867. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  51868. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  51869. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  51870. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  51871. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  51872. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  51873. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  51874. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51875. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51876. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  51877. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  51878. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51879. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  51880. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51881. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  51882. /** @hidden */
  51883. export var pbrPixelShader: {
  51884. name: string;
  51885. shader: string;
  51886. };
  51887. }
  51888. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  51889. /** @hidden */
  51890. export var pbrVertexDeclaration: {
  51891. name: string;
  51892. shader: string;
  51893. };
  51894. }
  51895. declare module "babylonjs/Shaders/pbr.vertex" {
  51896. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  51897. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  51898. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51899. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51900. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51901. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  51902. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  51903. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51904. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51905. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51906. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51907. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51908. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51909. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  51910. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51911. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51912. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51913. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  51914. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51915. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51916. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51917. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  51918. /** @hidden */
  51919. export var pbrVertexShader: {
  51920. name: string;
  51921. shader: string;
  51922. };
  51923. }
  51924. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  51925. import { Nullable } from "babylonjs/types";
  51926. import { Scene } from "babylonjs/scene";
  51927. import { Matrix } from "babylonjs/Maths/math.vector";
  51928. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51929. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51930. import { Mesh } from "babylonjs/Meshes/mesh";
  51931. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  51932. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  51933. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  51934. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  51935. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  51936. import { Color3 } from "babylonjs/Maths/math.color";
  51937. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  51938. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  51939. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  51940. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51941. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51942. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51943. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  51944. import "babylonjs/Shaders/pbr.fragment";
  51945. import "babylonjs/Shaders/pbr.vertex";
  51946. /**
  51947. * Manages the defines for the PBR Material.
  51948. * @hidden
  51949. */
  51950. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51951. PBR: boolean;
  51952. MAINUV1: boolean;
  51953. MAINUV2: boolean;
  51954. UV1: boolean;
  51955. UV2: boolean;
  51956. ALBEDO: boolean;
  51957. ALBEDODIRECTUV: number;
  51958. VERTEXCOLOR: boolean;
  51959. AMBIENT: boolean;
  51960. AMBIENTDIRECTUV: number;
  51961. AMBIENTINGRAYSCALE: boolean;
  51962. OPACITY: boolean;
  51963. VERTEXALPHA: boolean;
  51964. OPACITYDIRECTUV: number;
  51965. OPACITYRGB: boolean;
  51966. ALPHATEST: boolean;
  51967. DEPTHPREPASS: boolean;
  51968. ALPHABLEND: boolean;
  51969. ALPHAFROMALBEDO: boolean;
  51970. ALPHATESTVALUE: string;
  51971. SPECULAROVERALPHA: boolean;
  51972. RADIANCEOVERALPHA: boolean;
  51973. ALPHAFRESNEL: boolean;
  51974. LINEARALPHAFRESNEL: boolean;
  51975. PREMULTIPLYALPHA: boolean;
  51976. EMISSIVE: boolean;
  51977. EMISSIVEDIRECTUV: number;
  51978. REFLECTIVITY: boolean;
  51979. REFLECTIVITYDIRECTUV: number;
  51980. SPECULARTERM: boolean;
  51981. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51982. MICROSURFACEAUTOMATIC: boolean;
  51983. LODBASEDMICROSFURACE: boolean;
  51984. MICROSURFACEMAP: boolean;
  51985. MICROSURFACEMAPDIRECTUV: number;
  51986. METALLICWORKFLOW: boolean;
  51987. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51988. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51989. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51990. AOSTOREINMETALMAPRED: boolean;
  51991. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51992. ENVIRONMENTBRDF: boolean;
  51993. ENVIRONMENTBRDF_RGBD: boolean;
  51994. NORMAL: boolean;
  51995. TANGENT: boolean;
  51996. BUMP: boolean;
  51997. BUMPDIRECTUV: number;
  51998. OBJECTSPACE_NORMALMAP: boolean;
  51999. PARALLAX: boolean;
  52000. PARALLAXOCCLUSION: boolean;
  52001. NORMALXYSCALE: boolean;
  52002. LIGHTMAP: boolean;
  52003. LIGHTMAPDIRECTUV: number;
  52004. USELIGHTMAPASSHADOWMAP: boolean;
  52005. GAMMALIGHTMAP: boolean;
  52006. RGBDLIGHTMAP: boolean;
  52007. REFLECTION: boolean;
  52008. REFLECTIONMAP_3D: boolean;
  52009. REFLECTIONMAP_SPHERICAL: boolean;
  52010. REFLECTIONMAP_PLANAR: boolean;
  52011. REFLECTIONMAP_CUBIC: boolean;
  52012. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  52013. REFLECTIONMAP_PROJECTION: boolean;
  52014. REFLECTIONMAP_SKYBOX: boolean;
  52015. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  52016. REFLECTIONMAP_EXPLICIT: boolean;
  52017. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  52018. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  52019. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  52020. INVERTCUBICMAP: boolean;
  52021. USESPHERICALFROMREFLECTIONMAP: boolean;
  52022. USEIRRADIANCEMAP: boolean;
  52023. SPHERICAL_HARMONICS: boolean;
  52024. USESPHERICALINVERTEX: boolean;
  52025. REFLECTIONMAP_OPPOSITEZ: boolean;
  52026. LODINREFLECTIONALPHA: boolean;
  52027. GAMMAREFLECTION: boolean;
  52028. RGBDREFLECTION: boolean;
  52029. LINEARSPECULARREFLECTION: boolean;
  52030. RADIANCEOCCLUSION: boolean;
  52031. HORIZONOCCLUSION: boolean;
  52032. INSTANCES: boolean;
  52033. NUM_BONE_INFLUENCERS: number;
  52034. BonesPerMesh: number;
  52035. BONETEXTURE: boolean;
  52036. NONUNIFORMSCALING: boolean;
  52037. MORPHTARGETS: boolean;
  52038. MORPHTARGETS_NORMAL: boolean;
  52039. MORPHTARGETS_TANGENT: boolean;
  52040. MORPHTARGETS_UV: boolean;
  52041. NUM_MORPH_INFLUENCERS: number;
  52042. IMAGEPROCESSING: boolean;
  52043. VIGNETTE: boolean;
  52044. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52045. VIGNETTEBLENDMODEOPAQUE: boolean;
  52046. TONEMAPPING: boolean;
  52047. TONEMAPPING_ACES: boolean;
  52048. CONTRAST: boolean;
  52049. COLORCURVES: boolean;
  52050. COLORGRADING: boolean;
  52051. COLORGRADING3D: boolean;
  52052. SAMPLER3DGREENDEPTH: boolean;
  52053. SAMPLER3DBGRMAP: boolean;
  52054. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52055. EXPOSURE: boolean;
  52056. MULTIVIEW: boolean;
  52057. USEPHYSICALLIGHTFALLOFF: boolean;
  52058. USEGLTFLIGHTFALLOFF: boolean;
  52059. TWOSIDEDLIGHTING: boolean;
  52060. SHADOWFLOAT: boolean;
  52061. CLIPPLANE: boolean;
  52062. CLIPPLANE2: boolean;
  52063. CLIPPLANE3: boolean;
  52064. CLIPPLANE4: boolean;
  52065. CLIPPLANE5: boolean;
  52066. CLIPPLANE6: boolean;
  52067. POINTSIZE: boolean;
  52068. FOG: boolean;
  52069. LOGARITHMICDEPTH: boolean;
  52070. FORCENORMALFORWARD: boolean;
  52071. SPECULARAA: boolean;
  52072. CLEARCOAT: boolean;
  52073. CLEARCOAT_DEFAULTIOR: boolean;
  52074. CLEARCOAT_TEXTURE: boolean;
  52075. CLEARCOAT_TEXTUREDIRECTUV: number;
  52076. CLEARCOAT_BUMP: boolean;
  52077. CLEARCOAT_BUMPDIRECTUV: number;
  52078. CLEARCOAT_TINT: boolean;
  52079. CLEARCOAT_TINT_TEXTURE: boolean;
  52080. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52081. ANISOTROPIC: boolean;
  52082. ANISOTROPIC_TEXTURE: boolean;
  52083. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52084. BRDF_V_HEIGHT_CORRELATED: boolean;
  52085. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52086. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52087. SHEEN: boolean;
  52088. SHEEN_TEXTURE: boolean;
  52089. SHEEN_TEXTUREDIRECTUV: number;
  52090. SHEEN_LINKWITHALBEDO: boolean;
  52091. SUBSURFACE: boolean;
  52092. SS_REFRACTION: boolean;
  52093. SS_TRANSLUCENCY: boolean;
  52094. SS_SCATERRING: boolean;
  52095. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52096. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52097. SS_REFRACTIONMAP_3D: boolean;
  52098. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52099. SS_LODINREFRACTIONALPHA: boolean;
  52100. SS_GAMMAREFRACTION: boolean;
  52101. SS_RGBDREFRACTION: boolean;
  52102. SS_LINEARSPECULARREFRACTION: boolean;
  52103. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52104. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52105. UNLIT: boolean;
  52106. DEBUGMODE: number;
  52107. /**
  52108. * Initializes the PBR Material defines.
  52109. */
  52110. constructor();
  52111. /**
  52112. * Resets the PBR Material defines.
  52113. */
  52114. reset(): void;
  52115. }
  52116. /**
  52117. * The Physically based material base class of BJS.
  52118. *
  52119. * This offers the main features of a standard PBR material.
  52120. * For more information, please refer to the documentation :
  52121. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52122. */
  52123. export abstract class PBRBaseMaterial extends PushMaterial {
  52124. /**
  52125. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52126. */
  52127. static readonly PBRMATERIAL_OPAQUE: number;
  52128. /**
  52129. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52130. */
  52131. static readonly PBRMATERIAL_ALPHATEST: number;
  52132. /**
  52133. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52134. */
  52135. static readonly PBRMATERIAL_ALPHABLEND: number;
  52136. /**
  52137. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52138. * They are also discarded below the alpha cutoff threshold to improve performances.
  52139. */
  52140. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52141. /**
  52142. * Defines the default value of how much AO map is occluding the analytical lights
  52143. * (point spot...).
  52144. */
  52145. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52146. /**
  52147. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  52148. */
  52149. static readonly LIGHTFALLOFF_PHYSICAL: number;
  52150. /**
  52151. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  52152. * to enhance interoperability with other engines.
  52153. */
  52154. static readonly LIGHTFALLOFF_GLTF: number;
  52155. /**
  52156. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  52157. * to enhance interoperability with other materials.
  52158. */
  52159. static readonly LIGHTFALLOFF_STANDARD: number;
  52160. /**
  52161. * Intensity of the direct lights e.g. the four lights available in your scene.
  52162. * This impacts both the direct diffuse and specular highlights.
  52163. */
  52164. protected _directIntensity: number;
  52165. /**
  52166. * Intensity of the emissive part of the material.
  52167. * This helps controlling the emissive effect without modifying the emissive color.
  52168. */
  52169. protected _emissiveIntensity: number;
  52170. /**
  52171. * Intensity of the environment e.g. how much the environment will light the object
  52172. * either through harmonics for rough material or through the refelction for shiny ones.
  52173. */
  52174. protected _environmentIntensity: number;
  52175. /**
  52176. * This is a special control allowing the reduction of the specular highlights coming from the
  52177. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52178. */
  52179. protected _specularIntensity: number;
  52180. /**
  52181. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  52182. */
  52183. private _lightingInfos;
  52184. /**
  52185. * Debug Control allowing disabling the bump map on this material.
  52186. */
  52187. protected _disableBumpMap: boolean;
  52188. /**
  52189. * AKA Diffuse Texture in standard nomenclature.
  52190. */
  52191. protected _albedoTexture: Nullable<BaseTexture>;
  52192. /**
  52193. * AKA Occlusion Texture in other nomenclature.
  52194. */
  52195. protected _ambientTexture: Nullable<BaseTexture>;
  52196. /**
  52197. * AKA Occlusion Texture Intensity in other nomenclature.
  52198. */
  52199. protected _ambientTextureStrength: number;
  52200. /**
  52201. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52202. * 1 means it completely occludes it
  52203. * 0 mean it has no impact
  52204. */
  52205. protected _ambientTextureImpactOnAnalyticalLights: number;
  52206. /**
  52207. * Stores the alpha values in a texture.
  52208. */
  52209. protected _opacityTexture: Nullable<BaseTexture>;
  52210. /**
  52211. * Stores the reflection values in a texture.
  52212. */
  52213. protected _reflectionTexture: Nullable<BaseTexture>;
  52214. /**
  52215. * Stores the emissive values in a texture.
  52216. */
  52217. protected _emissiveTexture: Nullable<BaseTexture>;
  52218. /**
  52219. * AKA Specular texture in other nomenclature.
  52220. */
  52221. protected _reflectivityTexture: Nullable<BaseTexture>;
  52222. /**
  52223. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52224. */
  52225. protected _metallicTexture: Nullable<BaseTexture>;
  52226. /**
  52227. * Specifies the metallic scalar of the metallic/roughness workflow.
  52228. * Can also be used to scale the metalness values of the metallic texture.
  52229. */
  52230. protected _metallic: Nullable<number>;
  52231. /**
  52232. * Specifies the roughness scalar of the metallic/roughness workflow.
  52233. * Can also be used to scale the roughness values of the metallic texture.
  52234. */
  52235. protected _roughness: Nullable<number>;
  52236. /**
  52237. * Specifies the an F0 factor to help configuring the material F0.
  52238. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52239. * to 0.5 the previously hard coded value stays the same.
  52240. * Can also be used to scale the F0 values of the metallic texture.
  52241. */
  52242. protected _metallicF0Factor: number;
  52243. /**
  52244. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52245. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52246. * your expectation as it multiplies with the texture data.
  52247. */
  52248. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  52249. /**
  52250. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52251. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52252. */
  52253. protected _microSurfaceTexture: Nullable<BaseTexture>;
  52254. /**
  52255. * Stores surface normal data used to displace a mesh in a texture.
  52256. */
  52257. protected _bumpTexture: Nullable<BaseTexture>;
  52258. /**
  52259. * Stores the pre-calculated light information of a mesh in a texture.
  52260. */
  52261. protected _lightmapTexture: Nullable<BaseTexture>;
  52262. /**
  52263. * The color of a material in ambient lighting.
  52264. */
  52265. protected _ambientColor: Color3;
  52266. /**
  52267. * AKA Diffuse Color in other nomenclature.
  52268. */
  52269. protected _albedoColor: Color3;
  52270. /**
  52271. * AKA Specular Color in other nomenclature.
  52272. */
  52273. protected _reflectivityColor: Color3;
  52274. /**
  52275. * The color applied when light is reflected from a material.
  52276. */
  52277. protected _reflectionColor: Color3;
  52278. /**
  52279. * The color applied when light is emitted from a material.
  52280. */
  52281. protected _emissiveColor: Color3;
  52282. /**
  52283. * AKA Glossiness in other nomenclature.
  52284. */
  52285. protected _microSurface: number;
  52286. /**
  52287. * Specifies that the material will use the light map as a show map.
  52288. */
  52289. protected _useLightmapAsShadowmap: boolean;
  52290. /**
  52291. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52292. * makes the reflect vector face the model (under horizon).
  52293. */
  52294. protected _useHorizonOcclusion: boolean;
  52295. /**
  52296. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52297. * too much the area relying on ambient texture to define their ambient occlusion.
  52298. */
  52299. protected _useRadianceOcclusion: boolean;
  52300. /**
  52301. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52302. */
  52303. protected _useAlphaFromAlbedoTexture: boolean;
  52304. /**
  52305. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  52306. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52307. */
  52308. protected _useSpecularOverAlpha: boolean;
  52309. /**
  52310. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52311. */
  52312. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52313. /**
  52314. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52315. */
  52316. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  52317. /**
  52318. * Specifies if the metallic texture contains the roughness information in its green channel.
  52319. */
  52320. protected _useRoughnessFromMetallicTextureGreen: boolean;
  52321. /**
  52322. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52323. */
  52324. protected _useMetallnessFromMetallicTextureBlue: boolean;
  52325. /**
  52326. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52327. */
  52328. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  52329. /**
  52330. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52331. */
  52332. protected _useAmbientInGrayScale: boolean;
  52333. /**
  52334. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52335. * The material will try to infer what glossiness each pixel should be.
  52336. */
  52337. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  52338. /**
  52339. * Defines the falloff type used in this material.
  52340. * It by default is Physical.
  52341. */
  52342. protected _lightFalloff: number;
  52343. /**
  52344. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52345. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52346. */
  52347. protected _useRadianceOverAlpha: boolean;
  52348. /**
  52349. * Allows using an object space normal map (instead of tangent space).
  52350. */
  52351. protected _useObjectSpaceNormalMap: boolean;
  52352. /**
  52353. * Allows using the bump map in parallax mode.
  52354. */
  52355. protected _useParallax: boolean;
  52356. /**
  52357. * Allows using the bump map in parallax occlusion mode.
  52358. */
  52359. protected _useParallaxOcclusion: boolean;
  52360. /**
  52361. * Controls the scale bias of the parallax mode.
  52362. */
  52363. protected _parallaxScaleBias: number;
  52364. /**
  52365. * If sets to true, disables all the lights affecting the material.
  52366. */
  52367. protected _disableLighting: boolean;
  52368. /**
  52369. * Number of Simultaneous lights allowed on the material.
  52370. */
  52371. protected _maxSimultaneousLights: number;
  52372. /**
  52373. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52374. */
  52375. protected _invertNormalMapX: boolean;
  52376. /**
  52377. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52378. */
  52379. protected _invertNormalMapY: boolean;
  52380. /**
  52381. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52382. */
  52383. protected _twoSidedLighting: boolean;
  52384. /**
  52385. * Defines the alpha limits in alpha test mode.
  52386. */
  52387. protected _alphaCutOff: number;
  52388. /**
  52389. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52390. */
  52391. protected _forceAlphaTest: boolean;
  52392. /**
  52393. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52394. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52395. */
  52396. protected _useAlphaFresnel: boolean;
  52397. /**
  52398. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52399. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52400. */
  52401. protected _useLinearAlphaFresnel: boolean;
  52402. /**
  52403. * The transparency mode of the material.
  52404. */
  52405. protected _transparencyMode: Nullable<number>;
  52406. /**
  52407. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  52408. * from cos thetav and roughness:
  52409. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  52410. */
  52411. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  52412. /**
  52413. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52414. */
  52415. protected _forceIrradianceInFragment: boolean;
  52416. /**
  52417. * Force normal to face away from face.
  52418. */
  52419. protected _forceNormalForward: boolean;
  52420. /**
  52421. * Enables specular anti aliasing in the PBR shader.
  52422. * It will both interacts on the Geometry for analytical and IBL lighting.
  52423. * It also prefilter the roughness map based on the bump values.
  52424. */
  52425. protected _enableSpecularAntiAliasing: boolean;
  52426. /**
  52427. * Default configuration related to image processing available in the PBR Material.
  52428. */
  52429. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52430. /**
  52431. * Keep track of the image processing observer to allow dispose and replace.
  52432. */
  52433. private _imageProcessingObserver;
  52434. /**
  52435. * Attaches a new image processing configuration to the PBR Material.
  52436. * @param configuration
  52437. */
  52438. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52439. /**
  52440. * Stores the available render targets.
  52441. */
  52442. private _renderTargets;
  52443. /**
  52444. * Sets the global ambient color for the material used in lighting calculations.
  52445. */
  52446. private _globalAmbientColor;
  52447. /**
  52448. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  52449. */
  52450. private _useLogarithmicDepth;
  52451. /**
  52452. * If set to true, no lighting calculations will be applied.
  52453. */
  52454. private _unlit;
  52455. private _debugMode;
  52456. /**
  52457. * @hidden
  52458. * This is reserved for the inspector.
  52459. * Defines the material debug mode.
  52460. * It helps seeing only some components of the material while troubleshooting.
  52461. */
  52462. debugMode: number;
  52463. /**
  52464. * @hidden
  52465. * This is reserved for the inspector.
  52466. * Specify from where on screen the debug mode should start.
  52467. * The value goes from -1 (full screen) to 1 (not visible)
  52468. * It helps with side by side comparison against the final render
  52469. * This defaults to -1
  52470. */
  52471. private debugLimit;
  52472. /**
  52473. * @hidden
  52474. * This is reserved for the inspector.
  52475. * As the default viewing range might not be enough (if the ambient is really small for instance)
  52476. * You can use the factor to better multiply the final value.
  52477. */
  52478. private debugFactor;
  52479. /**
  52480. * Defines the clear coat layer parameters for the material.
  52481. */
  52482. readonly clearCoat: PBRClearCoatConfiguration;
  52483. /**
  52484. * Defines the anisotropic parameters for the material.
  52485. */
  52486. readonly anisotropy: PBRAnisotropicConfiguration;
  52487. /**
  52488. * Defines the BRDF parameters for the material.
  52489. */
  52490. readonly brdf: PBRBRDFConfiguration;
  52491. /**
  52492. * Defines the Sheen parameters for the material.
  52493. */
  52494. readonly sheen: PBRSheenConfiguration;
  52495. /**
  52496. * Defines the SubSurface parameters for the material.
  52497. */
  52498. readonly subSurface: PBRSubSurfaceConfiguration;
  52499. /**
  52500. * Custom callback helping to override the default shader used in the material.
  52501. */
  52502. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  52503. protected _rebuildInParallel: boolean;
  52504. /**
  52505. * Instantiates a new PBRMaterial instance.
  52506. *
  52507. * @param name The material name
  52508. * @param scene The scene the material will be use in.
  52509. */
  52510. constructor(name: string, scene: Scene);
  52511. /**
  52512. * Gets a boolean indicating that current material needs to register RTT
  52513. */
  52514. get hasRenderTargetTextures(): boolean;
  52515. /**
  52516. * Gets the name of the material class.
  52517. */
  52518. getClassName(): string;
  52519. /**
  52520. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52521. */
  52522. get useLogarithmicDepth(): boolean;
  52523. /**
  52524. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52525. */
  52526. set useLogarithmicDepth(value: boolean);
  52527. /**
  52528. * Gets the current transparency mode.
  52529. */
  52530. get transparencyMode(): Nullable<number>;
  52531. /**
  52532. * Sets the transparency mode of the material.
  52533. *
  52534. * | Value | Type | Description |
  52535. * | ----- | ----------------------------------- | ----------- |
  52536. * | 0 | OPAQUE | |
  52537. * | 1 | ALPHATEST | |
  52538. * | 2 | ALPHABLEND | |
  52539. * | 3 | ALPHATESTANDBLEND | |
  52540. *
  52541. */
  52542. set transparencyMode(value: Nullable<number>);
  52543. /**
  52544. * Returns true if alpha blending should be disabled.
  52545. */
  52546. private get _disableAlphaBlending();
  52547. /**
  52548. * Specifies whether or not this material should be rendered in alpha blend mode.
  52549. */
  52550. needAlphaBlending(): boolean;
  52551. /**
  52552. * Specifies if the mesh will require alpha blending.
  52553. * @param mesh - BJS mesh.
  52554. */
  52555. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  52556. /**
  52557. * Specifies whether or not this material should be rendered in alpha test mode.
  52558. */
  52559. needAlphaTesting(): boolean;
  52560. /**
  52561. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  52562. */
  52563. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  52564. /**
  52565. * Gets the texture used for the alpha test.
  52566. */
  52567. getAlphaTestTexture(): Nullable<BaseTexture>;
  52568. /**
  52569. * Specifies that the submesh is ready to be used.
  52570. * @param mesh - BJS mesh.
  52571. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  52572. * @param useInstances - Specifies that instances should be used.
  52573. * @returns - boolean indicating that the submesh is ready or not.
  52574. */
  52575. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52576. /**
  52577. * Specifies if the material uses metallic roughness workflow.
  52578. * @returns boolean specifiying if the material uses metallic roughness workflow.
  52579. */
  52580. isMetallicWorkflow(): boolean;
  52581. private _prepareEffect;
  52582. private _prepareDefines;
  52583. /**
  52584. * Force shader compilation
  52585. */
  52586. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  52587. /**
  52588. * Initializes the uniform buffer layout for the shader.
  52589. */
  52590. buildUniformLayout(): void;
  52591. /**
  52592. * Unbinds the material from the mesh
  52593. */
  52594. unbind(): void;
  52595. /**
  52596. * Binds the submesh data.
  52597. * @param world - The world matrix.
  52598. * @param mesh - The BJS mesh.
  52599. * @param subMesh - A submesh of the BJS mesh.
  52600. */
  52601. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52602. /**
  52603. * Returns the animatable textures.
  52604. * @returns - Array of animatable textures.
  52605. */
  52606. getAnimatables(): IAnimatable[];
  52607. /**
  52608. * Returns the texture used for reflections.
  52609. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  52610. */
  52611. private _getReflectionTexture;
  52612. /**
  52613. * Returns an array of the actively used textures.
  52614. * @returns - Array of BaseTextures
  52615. */
  52616. getActiveTextures(): BaseTexture[];
  52617. /**
  52618. * Checks to see if a texture is used in the material.
  52619. * @param texture - Base texture to use.
  52620. * @returns - Boolean specifying if a texture is used in the material.
  52621. */
  52622. hasTexture(texture: BaseTexture): boolean;
  52623. /**
  52624. * Disposes the resources of the material.
  52625. * @param forceDisposeEffect - Forces the disposal of effects.
  52626. * @param forceDisposeTextures - Forces the disposal of all textures.
  52627. */
  52628. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52629. }
  52630. }
  52631. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  52632. import { Nullable } from "babylonjs/types";
  52633. import { Scene } from "babylonjs/scene";
  52634. import { Color3 } from "babylonjs/Maths/math.color";
  52635. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  52636. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  52637. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52638. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52639. /**
  52640. * The Physically based material of BJS.
  52641. *
  52642. * This offers the main features of a standard PBR material.
  52643. * For more information, please refer to the documentation :
  52644. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52645. */
  52646. export class PBRMaterial extends PBRBaseMaterial {
  52647. /**
  52648. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52649. */
  52650. static readonly PBRMATERIAL_OPAQUE: number;
  52651. /**
  52652. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52653. */
  52654. static readonly PBRMATERIAL_ALPHATEST: number;
  52655. /**
  52656. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52657. */
  52658. static readonly PBRMATERIAL_ALPHABLEND: number;
  52659. /**
  52660. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52661. * They are also discarded below the alpha cutoff threshold to improve performances.
  52662. */
  52663. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52664. /**
  52665. * Defines the default value of how much AO map is occluding the analytical lights
  52666. * (point spot...).
  52667. */
  52668. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52669. /**
  52670. * Intensity of the direct lights e.g. the four lights available in your scene.
  52671. * This impacts both the direct diffuse and specular highlights.
  52672. */
  52673. directIntensity: number;
  52674. /**
  52675. * Intensity of the emissive part of the material.
  52676. * This helps controlling the emissive effect without modifying the emissive color.
  52677. */
  52678. emissiveIntensity: number;
  52679. /**
  52680. * Intensity of the environment e.g. how much the environment will light the object
  52681. * either through harmonics for rough material or through the refelction for shiny ones.
  52682. */
  52683. environmentIntensity: number;
  52684. /**
  52685. * This is a special control allowing the reduction of the specular highlights coming from the
  52686. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52687. */
  52688. specularIntensity: number;
  52689. /**
  52690. * Debug Control allowing disabling the bump map on this material.
  52691. */
  52692. disableBumpMap: boolean;
  52693. /**
  52694. * AKA Diffuse Texture in standard nomenclature.
  52695. */
  52696. albedoTexture: BaseTexture;
  52697. /**
  52698. * AKA Occlusion Texture in other nomenclature.
  52699. */
  52700. ambientTexture: BaseTexture;
  52701. /**
  52702. * AKA Occlusion Texture Intensity in other nomenclature.
  52703. */
  52704. ambientTextureStrength: number;
  52705. /**
  52706. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52707. * 1 means it completely occludes it
  52708. * 0 mean it has no impact
  52709. */
  52710. ambientTextureImpactOnAnalyticalLights: number;
  52711. /**
  52712. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  52713. */
  52714. opacityTexture: BaseTexture;
  52715. /**
  52716. * Stores the reflection values in a texture.
  52717. */
  52718. reflectionTexture: Nullable<BaseTexture>;
  52719. /**
  52720. * Stores the emissive values in a texture.
  52721. */
  52722. emissiveTexture: BaseTexture;
  52723. /**
  52724. * AKA Specular texture in other nomenclature.
  52725. */
  52726. reflectivityTexture: BaseTexture;
  52727. /**
  52728. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52729. */
  52730. metallicTexture: BaseTexture;
  52731. /**
  52732. * Specifies the metallic scalar of the metallic/roughness workflow.
  52733. * Can also be used to scale the metalness values of the metallic texture.
  52734. */
  52735. metallic: Nullable<number>;
  52736. /**
  52737. * Specifies the roughness scalar of the metallic/roughness workflow.
  52738. * Can also be used to scale the roughness values of the metallic texture.
  52739. */
  52740. roughness: Nullable<number>;
  52741. /**
  52742. * Specifies the an F0 factor to help configuring the material F0.
  52743. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52744. * to 0.5 the previously hard coded value stays the same.
  52745. * Can also be used to scale the F0 values of the metallic texture.
  52746. */
  52747. metallicF0Factor: number;
  52748. /**
  52749. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52750. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52751. * your expectation as it multiplies with the texture data.
  52752. */
  52753. useMetallicF0FactorFromMetallicTexture: boolean;
  52754. /**
  52755. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52756. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52757. */
  52758. microSurfaceTexture: BaseTexture;
  52759. /**
  52760. * Stores surface normal data used to displace a mesh in a texture.
  52761. */
  52762. bumpTexture: BaseTexture;
  52763. /**
  52764. * Stores the pre-calculated light information of a mesh in a texture.
  52765. */
  52766. lightmapTexture: BaseTexture;
  52767. /**
  52768. * Stores the refracted light information in a texture.
  52769. */
  52770. get refractionTexture(): Nullable<BaseTexture>;
  52771. set refractionTexture(value: Nullable<BaseTexture>);
  52772. /**
  52773. * The color of a material in ambient lighting.
  52774. */
  52775. ambientColor: Color3;
  52776. /**
  52777. * AKA Diffuse Color in other nomenclature.
  52778. */
  52779. albedoColor: Color3;
  52780. /**
  52781. * AKA Specular Color in other nomenclature.
  52782. */
  52783. reflectivityColor: Color3;
  52784. /**
  52785. * The color reflected from the material.
  52786. */
  52787. reflectionColor: Color3;
  52788. /**
  52789. * The color emitted from the material.
  52790. */
  52791. emissiveColor: Color3;
  52792. /**
  52793. * AKA Glossiness in other nomenclature.
  52794. */
  52795. microSurface: number;
  52796. /**
  52797. * source material index of refraction (IOR)' / 'destination material IOR.
  52798. */
  52799. get indexOfRefraction(): number;
  52800. set indexOfRefraction(value: number);
  52801. /**
  52802. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52803. */
  52804. get invertRefractionY(): boolean;
  52805. set invertRefractionY(value: boolean);
  52806. /**
  52807. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52808. * Materials half opaque for instance using refraction could benefit from this control.
  52809. */
  52810. get linkRefractionWithTransparency(): boolean;
  52811. set linkRefractionWithTransparency(value: boolean);
  52812. /**
  52813. * If true, the light map contains occlusion information instead of lighting info.
  52814. */
  52815. useLightmapAsShadowmap: boolean;
  52816. /**
  52817. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52818. */
  52819. useAlphaFromAlbedoTexture: boolean;
  52820. /**
  52821. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52822. */
  52823. forceAlphaTest: boolean;
  52824. /**
  52825. * Defines the alpha limits in alpha test mode.
  52826. */
  52827. alphaCutOff: number;
  52828. /**
  52829. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52830. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52831. */
  52832. useSpecularOverAlpha: boolean;
  52833. /**
  52834. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52835. */
  52836. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52837. /**
  52838. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52839. */
  52840. useRoughnessFromMetallicTextureAlpha: boolean;
  52841. /**
  52842. * Specifies if the metallic texture contains the roughness information in its green channel.
  52843. */
  52844. useRoughnessFromMetallicTextureGreen: boolean;
  52845. /**
  52846. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52847. */
  52848. useMetallnessFromMetallicTextureBlue: boolean;
  52849. /**
  52850. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52851. */
  52852. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52853. /**
  52854. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52855. */
  52856. useAmbientInGrayScale: boolean;
  52857. /**
  52858. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52859. * The material will try to infer what glossiness each pixel should be.
  52860. */
  52861. useAutoMicroSurfaceFromReflectivityMap: boolean;
  52862. /**
  52863. * BJS is using an harcoded light falloff based on a manually sets up range.
  52864. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52865. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52866. */
  52867. get usePhysicalLightFalloff(): boolean;
  52868. /**
  52869. * BJS is using an harcoded light falloff based on a manually sets up range.
  52870. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52871. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52872. */
  52873. set usePhysicalLightFalloff(value: boolean);
  52874. /**
  52875. * In order to support the falloff compatibility with gltf, a special mode has been added
  52876. * to reproduce the gltf light falloff.
  52877. */
  52878. get useGLTFLightFalloff(): boolean;
  52879. /**
  52880. * In order to support the falloff compatibility with gltf, a special mode has been added
  52881. * to reproduce the gltf light falloff.
  52882. */
  52883. set useGLTFLightFalloff(value: boolean);
  52884. /**
  52885. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52886. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52887. */
  52888. useRadianceOverAlpha: boolean;
  52889. /**
  52890. * Allows using an object space normal map (instead of tangent space).
  52891. */
  52892. useObjectSpaceNormalMap: boolean;
  52893. /**
  52894. * Allows using the bump map in parallax mode.
  52895. */
  52896. useParallax: boolean;
  52897. /**
  52898. * Allows using the bump map in parallax occlusion mode.
  52899. */
  52900. useParallaxOcclusion: boolean;
  52901. /**
  52902. * Controls the scale bias of the parallax mode.
  52903. */
  52904. parallaxScaleBias: number;
  52905. /**
  52906. * If sets to true, disables all the lights affecting the material.
  52907. */
  52908. disableLighting: boolean;
  52909. /**
  52910. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52911. */
  52912. forceIrradianceInFragment: boolean;
  52913. /**
  52914. * Number of Simultaneous lights allowed on the material.
  52915. */
  52916. maxSimultaneousLights: number;
  52917. /**
  52918. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52919. */
  52920. invertNormalMapX: boolean;
  52921. /**
  52922. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52923. */
  52924. invertNormalMapY: boolean;
  52925. /**
  52926. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52927. */
  52928. twoSidedLighting: boolean;
  52929. /**
  52930. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52931. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52932. */
  52933. useAlphaFresnel: boolean;
  52934. /**
  52935. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52936. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52937. */
  52938. useLinearAlphaFresnel: boolean;
  52939. /**
  52940. * Let user defines the brdf lookup texture used for IBL.
  52941. * A default 8bit version is embedded but you could point at :
  52942. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52943. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52944. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52945. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52946. */
  52947. environmentBRDFTexture: Nullable<BaseTexture>;
  52948. /**
  52949. * Force normal to face away from face.
  52950. */
  52951. forceNormalForward: boolean;
  52952. /**
  52953. * Enables specular anti aliasing in the PBR shader.
  52954. * It will both interacts on the Geometry for analytical and IBL lighting.
  52955. * It also prefilter the roughness map based on the bump values.
  52956. */
  52957. enableSpecularAntiAliasing: boolean;
  52958. /**
  52959. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52960. * makes the reflect vector face the model (under horizon).
  52961. */
  52962. useHorizonOcclusion: boolean;
  52963. /**
  52964. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52965. * too much the area relying on ambient texture to define their ambient occlusion.
  52966. */
  52967. useRadianceOcclusion: boolean;
  52968. /**
  52969. * If set to true, no lighting calculations will be applied.
  52970. */
  52971. unlit: boolean;
  52972. /**
  52973. * Gets the image processing configuration used either in this material.
  52974. */
  52975. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52976. /**
  52977. * Sets the Default image processing configuration used either in the this material.
  52978. *
  52979. * If sets to null, the scene one is in use.
  52980. */
  52981. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52982. /**
  52983. * Gets wether the color curves effect is enabled.
  52984. */
  52985. get cameraColorCurvesEnabled(): boolean;
  52986. /**
  52987. * Sets wether the color curves effect is enabled.
  52988. */
  52989. set cameraColorCurvesEnabled(value: boolean);
  52990. /**
  52991. * Gets wether the color grading effect is enabled.
  52992. */
  52993. get cameraColorGradingEnabled(): boolean;
  52994. /**
  52995. * Gets wether the color grading effect is enabled.
  52996. */
  52997. set cameraColorGradingEnabled(value: boolean);
  52998. /**
  52999. * Gets wether tonemapping is enabled or not.
  53000. */
  53001. get cameraToneMappingEnabled(): boolean;
  53002. /**
  53003. * Sets wether tonemapping is enabled or not
  53004. */
  53005. set cameraToneMappingEnabled(value: boolean);
  53006. /**
  53007. * The camera exposure used on this material.
  53008. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53009. * This corresponds to a photographic exposure.
  53010. */
  53011. get cameraExposure(): number;
  53012. /**
  53013. * The camera exposure used on this material.
  53014. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53015. * This corresponds to a photographic exposure.
  53016. */
  53017. set cameraExposure(value: number);
  53018. /**
  53019. * Gets The camera contrast used on this material.
  53020. */
  53021. get cameraContrast(): number;
  53022. /**
  53023. * Sets The camera contrast used on this material.
  53024. */
  53025. set cameraContrast(value: number);
  53026. /**
  53027. * Gets the Color Grading 2D Lookup Texture.
  53028. */
  53029. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  53030. /**
  53031. * Sets the Color Grading 2D Lookup Texture.
  53032. */
  53033. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  53034. /**
  53035. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53036. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53037. * 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;
  53038. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53039. */
  53040. get cameraColorCurves(): Nullable<ColorCurves>;
  53041. /**
  53042. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53043. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53044. * 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;
  53045. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53046. */
  53047. set cameraColorCurves(value: Nullable<ColorCurves>);
  53048. /**
  53049. * Instantiates a new PBRMaterial instance.
  53050. *
  53051. * @param name The material name
  53052. * @param scene The scene the material will be use in.
  53053. */
  53054. constructor(name: string, scene: Scene);
  53055. /**
  53056. * Returns the name of this material class.
  53057. */
  53058. getClassName(): string;
  53059. /**
  53060. * Makes a duplicate of the current material.
  53061. * @param name - name to use for the new material.
  53062. */
  53063. clone(name: string): PBRMaterial;
  53064. /**
  53065. * Serializes this PBR Material.
  53066. * @returns - An object with the serialized material.
  53067. */
  53068. serialize(): any;
  53069. /**
  53070. * Parses a PBR Material from a serialized object.
  53071. * @param source - Serialized object.
  53072. * @param scene - BJS scene instance.
  53073. * @param rootUrl - url for the scene object
  53074. * @returns - PBRMaterial
  53075. */
  53076. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  53077. }
  53078. }
  53079. declare module "babylonjs/Misc/dds" {
  53080. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53081. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53082. import { Nullable } from "babylonjs/types";
  53083. import { Scene } from "babylonjs/scene";
  53084. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  53085. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  53086. /**
  53087. * Direct draw surface info
  53088. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  53089. */
  53090. export interface DDSInfo {
  53091. /**
  53092. * Width of the texture
  53093. */
  53094. width: number;
  53095. /**
  53096. * Width of the texture
  53097. */
  53098. height: number;
  53099. /**
  53100. * Number of Mipmaps for the texture
  53101. * @see https://en.wikipedia.org/wiki/Mipmap
  53102. */
  53103. mipmapCount: number;
  53104. /**
  53105. * If the textures format is a known fourCC format
  53106. * @see https://www.fourcc.org/
  53107. */
  53108. isFourCC: boolean;
  53109. /**
  53110. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  53111. */
  53112. isRGB: boolean;
  53113. /**
  53114. * If the texture is a lumincance format
  53115. */
  53116. isLuminance: boolean;
  53117. /**
  53118. * If this is a cube texture
  53119. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  53120. */
  53121. isCube: boolean;
  53122. /**
  53123. * If the texture is a compressed format eg. FOURCC_DXT1
  53124. */
  53125. isCompressed: boolean;
  53126. /**
  53127. * The dxgiFormat of the texture
  53128. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  53129. */
  53130. dxgiFormat: number;
  53131. /**
  53132. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  53133. */
  53134. textureType: number;
  53135. /**
  53136. * Sphericle polynomial created for the dds texture
  53137. */
  53138. sphericalPolynomial?: SphericalPolynomial;
  53139. }
  53140. /**
  53141. * Class used to provide DDS decompression tools
  53142. */
  53143. export class DDSTools {
  53144. /**
  53145. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  53146. */
  53147. static StoreLODInAlphaChannel: boolean;
  53148. /**
  53149. * Gets DDS information from an array buffer
  53150. * @param arrayBuffer defines the array buffer to read data from
  53151. * @returns the DDS information
  53152. */
  53153. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  53154. private static _FloatView;
  53155. private static _Int32View;
  53156. private static _ToHalfFloat;
  53157. private static _FromHalfFloat;
  53158. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  53159. private static _GetHalfFloatRGBAArrayBuffer;
  53160. private static _GetFloatRGBAArrayBuffer;
  53161. private static _GetFloatAsUIntRGBAArrayBuffer;
  53162. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  53163. private static _GetRGBAArrayBuffer;
  53164. private static _ExtractLongWordOrder;
  53165. private static _GetRGBArrayBuffer;
  53166. private static _GetLuminanceArrayBuffer;
  53167. /**
  53168. * Uploads DDS Levels to a Babylon Texture
  53169. * @hidden
  53170. */
  53171. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  53172. }
  53173. module "babylonjs/Engines/thinEngine" {
  53174. interface ThinEngine {
  53175. /**
  53176. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  53177. * @param rootUrl defines the url where the file to load is located
  53178. * @param scene defines the current scene
  53179. * @param lodScale defines scale to apply to the mip map selection
  53180. * @param lodOffset defines offset to apply to the mip map selection
  53181. * @param onLoad defines an optional callback raised when the texture is loaded
  53182. * @param onError defines an optional callback raised if there is an issue to load the texture
  53183. * @param format defines the format of the data
  53184. * @param forcedExtension defines the extension to use to pick the right loader
  53185. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  53186. * @returns the cube texture as an InternalTexture
  53187. */
  53188. 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;
  53189. }
  53190. }
  53191. }
  53192. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  53193. import { Nullable } from "babylonjs/types";
  53194. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53195. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53196. /**
  53197. * Implementation of the DDS Texture Loader.
  53198. * @hidden
  53199. */
  53200. export class _DDSTextureLoader implements IInternalTextureLoader {
  53201. /**
  53202. * Defines wether the loader supports cascade loading the different faces.
  53203. */
  53204. readonly supportCascades: boolean;
  53205. /**
  53206. * This returns if the loader support the current file information.
  53207. * @param extension defines the file extension of the file being loaded
  53208. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53209. * @param fallback defines the fallback internal texture if any
  53210. * @param isBase64 defines whether the texture is encoded as a base64
  53211. * @param isBuffer defines whether the texture data are stored as a buffer
  53212. * @returns true if the loader can load the specified file
  53213. */
  53214. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53215. /**
  53216. * Transform the url before loading if required.
  53217. * @param rootUrl the url of the texture
  53218. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53219. * @returns the transformed texture
  53220. */
  53221. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53222. /**
  53223. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53224. * @param rootUrl the url of the texture
  53225. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53226. * @returns the fallback texture
  53227. */
  53228. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53229. /**
  53230. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53231. * @param data contains the texture data
  53232. * @param texture defines the BabylonJS internal texture
  53233. * @param createPolynomials will be true if polynomials have been requested
  53234. * @param onLoad defines the callback to trigger once the texture is ready
  53235. * @param onError defines the callback to trigger in case of error
  53236. */
  53237. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53238. /**
  53239. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53240. * @param data contains the texture data
  53241. * @param texture defines the BabylonJS internal texture
  53242. * @param callback defines the method to call once ready to upload
  53243. */
  53244. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53245. }
  53246. }
  53247. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  53248. import { Nullable } from "babylonjs/types";
  53249. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53250. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53251. /**
  53252. * Implementation of the ENV Texture Loader.
  53253. * @hidden
  53254. */
  53255. export class _ENVTextureLoader implements IInternalTextureLoader {
  53256. /**
  53257. * Defines wether the loader supports cascade loading the different faces.
  53258. */
  53259. readonly supportCascades: boolean;
  53260. /**
  53261. * This returns if the loader support the current file information.
  53262. * @param extension defines the file extension of the file being loaded
  53263. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53264. * @param fallback defines the fallback internal texture if any
  53265. * @param isBase64 defines whether the texture is encoded as a base64
  53266. * @param isBuffer defines whether the texture data are stored as a buffer
  53267. * @returns true if the loader can load the specified file
  53268. */
  53269. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53270. /**
  53271. * Transform the url before loading if required.
  53272. * @param rootUrl the url of the texture
  53273. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53274. * @returns the transformed texture
  53275. */
  53276. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53277. /**
  53278. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53279. * @param rootUrl the url of the texture
  53280. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53281. * @returns the fallback texture
  53282. */
  53283. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53284. /**
  53285. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53286. * @param data contains the texture data
  53287. * @param texture defines the BabylonJS internal texture
  53288. * @param createPolynomials will be true if polynomials have been requested
  53289. * @param onLoad defines the callback to trigger once the texture is ready
  53290. * @param onError defines the callback to trigger in case of error
  53291. */
  53292. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53293. /**
  53294. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53295. * @param data contains the texture data
  53296. * @param texture defines the BabylonJS internal texture
  53297. * @param callback defines the method to call once ready to upload
  53298. */
  53299. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53300. }
  53301. }
  53302. declare module "babylonjs/Misc/khronosTextureContainer" {
  53303. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53304. /**
  53305. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  53306. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  53307. */
  53308. export class KhronosTextureContainer {
  53309. /** contents of the KTX container file */
  53310. arrayBuffer: any;
  53311. private static HEADER_LEN;
  53312. private static COMPRESSED_2D;
  53313. private static COMPRESSED_3D;
  53314. private static TEX_2D;
  53315. private static TEX_3D;
  53316. /**
  53317. * Gets the openGL type
  53318. */
  53319. glType: number;
  53320. /**
  53321. * Gets the openGL type size
  53322. */
  53323. glTypeSize: number;
  53324. /**
  53325. * Gets the openGL format
  53326. */
  53327. glFormat: number;
  53328. /**
  53329. * Gets the openGL internal format
  53330. */
  53331. glInternalFormat: number;
  53332. /**
  53333. * Gets the base internal format
  53334. */
  53335. glBaseInternalFormat: number;
  53336. /**
  53337. * Gets image width in pixel
  53338. */
  53339. pixelWidth: number;
  53340. /**
  53341. * Gets image height in pixel
  53342. */
  53343. pixelHeight: number;
  53344. /**
  53345. * Gets image depth in pixels
  53346. */
  53347. pixelDepth: number;
  53348. /**
  53349. * Gets the number of array elements
  53350. */
  53351. numberOfArrayElements: number;
  53352. /**
  53353. * Gets the number of faces
  53354. */
  53355. numberOfFaces: number;
  53356. /**
  53357. * Gets the number of mipmap levels
  53358. */
  53359. numberOfMipmapLevels: number;
  53360. /**
  53361. * Gets the bytes of key value data
  53362. */
  53363. bytesOfKeyValueData: number;
  53364. /**
  53365. * Gets the load type
  53366. */
  53367. loadType: number;
  53368. /**
  53369. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  53370. */
  53371. isInvalid: boolean;
  53372. /**
  53373. * Creates a new KhronosTextureContainer
  53374. * @param arrayBuffer contents of the KTX container file
  53375. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  53376. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  53377. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  53378. */
  53379. constructor(
  53380. /** contents of the KTX container file */
  53381. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  53382. /**
  53383. * Uploads KTX content to a Babylon Texture.
  53384. * It is assumed that the texture has already been created & is currently bound
  53385. * @hidden
  53386. */
  53387. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  53388. private _upload2DCompressedLevels;
  53389. }
  53390. }
  53391. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  53392. import { Nullable } from "babylonjs/types";
  53393. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53394. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53395. /**
  53396. * Implementation of the KTX Texture Loader.
  53397. * @hidden
  53398. */
  53399. export class _KTXTextureLoader implements IInternalTextureLoader {
  53400. /**
  53401. * Defines wether the loader supports cascade loading the different faces.
  53402. */
  53403. readonly supportCascades: boolean;
  53404. /**
  53405. * This returns if the loader support the current file information.
  53406. * @param extension defines the file extension of the file being loaded
  53407. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53408. * @param fallback defines the fallback internal texture if any
  53409. * @param isBase64 defines whether the texture is encoded as a base64
  53410. * @param isBuffer defines whether the texture data are stored as a buffer
  53411. * @returns true if the loader can load the specified file
  53412. */
  53413. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53414. /**
  53415. * Transform the url before loading if required.
  53416. * @param rootUrl the url of the texture
  53417. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53418. * @returns the transformed texture
  53419. */
  53420. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53421. /**
  53422. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53423. * @param rootUrl the url of the texture
  53424. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53425. * @returns the fallback texture
  53426. */
  53427. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53428. /**
  53429. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53430. * @param data contains the texture data
  53431. * @param texture defines the BabylonJS internal texture
  53432. * @param createPolynomials will be true if polynomials have been requested
  53433. * @param onLoad defines the callback to trigger once the texture is ready
  53434. * @param onError defines the callback to trigger in case of error
  53435. */
  53436. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53437. /**
  53438. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53439. * @param data contains the texture data
  53440. * @param texture defines the BabylonJS internal texture
  53441. * @param callback defines the method to call once ready to upload
  53442. */
  53443. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  53444. }
  53445. }
  53446. declare module "babylonjs/Helpers/sceneHelpers" {
  53447. import { Nullable } from "babylonjs/types";
  53448. import { Mesh } from "babylonjs/Meshes/mesh";
  53449. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53450. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  53451. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  53452. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  53453. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  53454. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  53455. import "babylonjs/Meshes/Builders/boxBuilder";
  53456. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  53457. /** @hidden */
  53458. export var _forceSceneHelpersToBundle: boolean;
  53459. module "babylonjs/scene" {
  53460. interface Scene {
  53461. /**
  53462. * Creates a default light for the scene.
  53463. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  53464. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  53465. */
  53466. createDefaultLight(replace?: boolean): void;
  53467. /**
  53468. * Creates a default camera for the scene.
  53469. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  53470. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53471. * @param replace has default false, when true replaces the active camera in the scene
  53472. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  53473. */
  53474. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53475. /**
  53476. * Creates a default camera and a default light.
  53477. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  53478. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53479. * @param replace has the default false, when true replaces the active camera/light in the scene
  53480. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  53481. */
  53482. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53483. /**
  53484. * Creates a new sky box
  53485. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  53486. * @param environmentTexture defines the texture to use as environment texture
  53487. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  53488. * @param scale defines the overall scale of the skybox
  53489. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  53490. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  53491. * @returns a new mesh holding the sky box
  53492. */
  53493. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  53494. /**
  53495. * Creates a new environment
  53496. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  53497. * @param options defines the options you can use to configure the environment
  53498. * @returns the new EnvironmentHelper
  53499. */
  53500. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  53501. /**
  53502. * Creates a new VREXperienceHelper
  53503. * @see http://doc.babylonjs.com/how_to/webvr_helper
  53504. * @param webVROptions defines the options used to create the new VREXperienceHelper
  53505. * @returns a new VREXperienceHelper
  53506. */
  53507. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  53508. /**
  53509. * Creates a new WebXRDefaultExperience
  53510. * @see http://doc.babylonjs.com/how_to/webxr
  53511. * @param options experience options
  53512. * @returns a promise for a new WebXRDefaultExperience
  53513. */
  53514. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53515. }
  53516. }
  53517. }
  53518. declare module "babylonjs/Helpers/videoDome" {
  53519. import { Scene } from "babylonjs/scene";
  53520. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53521. import { Mesh } from "babylonjs/Meshes/mesh";
  53522. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  53523. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  53524. import "babylonjs/Meshes/Builders/sphereBuilder";
  53525. /**
  53526. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  53527. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  53528. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  53529. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53530. */
  53531. export class VideoDome extends TransformNode {
  53532. /**
  53533. * Define the video source as a Monoscopic panoramic 360 video.
  53534. */
  53535. static readonly MODE_MONOSCOPIC: number;
  53536. /**
  53537. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53538. */
  53539. static readonly MODE_TOPBOTTOM: number;
  53540. /**
  53541. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53542. */
  53543. static readonly MODE_SIDEBYSIDE: number;
  53544. private _halfDome;
  53545. private _useDirectMapping;
  53546. /**
  53547. * The video texture being displayed on the sphere
  53548. */
  53549. protected _videoTexture: VideoTexture;
  53550. /**
  53551. * Gets the video texture being displayed on the sphere
  53552. */
  53553. get videoTexture(): VideoTexture;
  53554. /**
  53555. * The skybox material
  53556. */
  53557. protected _material: BackgroundMaterial;
  53558. /**
  53559. * The surface used for the skybox
  53560. */
  53561. protected _mesh: Mesh;
  53562. /**
  53563. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  53564. */
  53565. private _halfDomeMask;
  53566. /**
  53567. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53568. * Also see the options.resolution property.
  53569. */
  53570. get fovMultiplier(): number;
  53571. set fovMultiplier(value: number);
  53572. private _videoMode;
  53573. /**
  53574. * Gets or set the current video mode for the video. It can be:
  53575. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  53576. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53577. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53578. */
  53579. get videoMode(): number;
  53580. set videoMode(value: number);
  53581. /**
  53582. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  53583. *
  53584. */
  53585. get halfDome(): boolean;
  53586. /**
  53587. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  53588. */
  53589. set halfDome(enabled: boolean);
  53590. /**
  53591. * Oberserver used in Stereoscopic VR Mode.
  53592. */
  53593. private _onBeforeCameraRenderObserver;
  53594. /**
  53595. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  53596. * @param name Element's name, child elements will append suffixes for their own names.
  53597. * @param urlsOrVideo defines the url(s) or the video element to use
  53598. * @param options An object containing optional or exposed sub element properties
  53599. */
  53600. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  53601. resolution?: number;
  53602. clickToPlay?: boolean;
  53603. autoPlay?: boolean;
  53604. loop?: boolean;
  53605. size?: number;
  53606. poster?: string;
  53607. faceForward?: boolean;
  53608. useDirectMapping?: boolean;
  53609. halfDomeMode?: boolean;
  53610. }, scene: Scene);
  53611. private _changeVideoMode;
  53612. /**
  53613. * Releases resources associated with this node.
  53614. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53615. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53616. */
  53617. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53618. }
  53619. }
  53620. declare module "babylonjs/Helpers/index" {
  53621. export * from "babylonjs/Helpers/environmentHelper";
  53622. export * from "babylonjs/Helpers/photoDome";
  53623. export * from "babylonjs/Helpers/sceneHelpers";
  53624. export * from "babylonjs/Helpers/videoDome";
  53625. }
  53626. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  53627. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  53628. import { IDisposable } from "babylonjs/scene";
  53629. import { Engine } from "babylonjs/Engines/engine";
  53630. /**
  53631. * This class can be used to get instrumentation data from a Babylon engine
  53632. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53633. */
  53634. export class EngineInstrumentation implements IDisposable {
  53635. /**
  53636. * Define the instrumented engine.
  53637. */
  53638. engine: Engine;
  53639. private _captureGPUFrameTime;
  53640. private _gpuFrameTimeToken;
  53641. private _gpuFrameTime;
  53642. private _captureShaderCompilationTime;
  53643. private _shaderCompilationTime;
  53644. private _onBeginFrameObserver;
  53645. private _onEndFrameObserver;
  53646. private _onBeforeShaderCompilationObserver;
  53647. private _onAfterShaderCompilationObserver;
  53648. /**
  53649. * Gets the perf counter used for GPU frame time
  53650. */
  53651. get gpuFrameTimeCounter(): PerfCounter;
  53652. /**
  53653. * Gets the GPU frame time capture status
  53654. */
  53655. get captureGPUFrameTime(): boolean;
  53656. /**
  53657. * Enable or disable the GPU frame time capture
  53658. */
  53659. set captureGPUFrameTime(value: boolean);
  53660. /**
  53661. * Gets the perf counter used for shader compilation time
  53662. */
  53663. get shaderCompilationTimeCounter(): PerfCounter;
  53664. /**
  53665. * Gets the shader compilation time capture status
  53666. */
  53667. get captureShaderCompilationTime(): boolean;
  53668. /**
  53669. * Enable or disable the shader compilation time capture
  53670. */
  53671. set captureShaderCompilationTime(value: boolean);
  53672. /**
  53673. * Instantiates a new engine instrumentation.
  53674. * This class can be used to get instrumentation data from a Babylon engine
  53675. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53676. * @param engine Defines the engine to instrument
  53677. */
  53678. constructor(
  53679. /**
  53680. * Define the instrumented engine.
  53681. */
  53682. engine: Engine);
  53683. /**
  53684. * Dispose and release associated resources.
  53685. */
  53686. dispose(): void;
  53687. }
  53688. }
  53689. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  53690. import { Scene, IDisposable } from "babylonjs/scene";
  53691. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  53692. /**
  53693. * This class can be used to get instrumentation data from a Babylon engine
  53694. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53695. */
  53696. export class SceneInstrumentation implements IDisposable {
  53697. /**
  53698. * Defines the scene to instrument
  53699. */
  53700. scene: Scene;
  53701. private _captureActiveMeshesEvaluationTime;
  53702. private _activeMeshesEvaluationTime;
  53703. private _captureRenderTargetsRenderTime;
  53704. private _renderTargetsRenderTime;
  53705. private _captureFrameTime;
  53706. private _frameTime;
  53707. private _captureRenderTime;
  53708. private _renderTime;
  53709. private _captureInterFrameTime;
  53710. private _interFrameTime;
  53711. private _captureParticlesRenderTime;
  53712. private _particlesRenderTime;
  53713. private _captureSpritesRenderTime;
  53714. private _spritesRenderTime;
  53715. private _capturePhysicsTime;
  53716. private _physicsTime;
  53717. private _captureAnimationsTime;
  53718. private _animationsTime;
  53719. private _captureCameraRenderTime;
  53720. private _cameraRenderTime;
  53721. private _onBeforeActiveMeshesEvaluationObserver;
  53722. private _onAfterActiveMeshesEvaluationObserver;
  53723. private _onBeforeRenderTargetsRenderObserver;
  53724. private _onAfterRenderTargetsRenderObserver;
  53725. private _onAfterRenderObserver;
  53726. private _onBeforeDrawPhaseObserver;
  53727. private _onAfterDrawPhaseObserver;
  53728. private _onBeforeAnimationsObserver;
  53729. private _onBeforeParticlesRenderingObserver;
  53730. private _onAfterParticlesRenderingObserver;
  53731. private _onBeforeSpritesRenderingObserver;
  53732. private _onAfterSpritesRenderingObserver;
  53733. private _onBeforePhysicsObserver;
  53734. private _onAfterPhysicsObserver;
  53735. private _onAfterAnimationsObserver;
  53736. private _onBeforeCameraRenderObserver;
  53737. private _onAfterCameraRenderObserver;
  53738. /**
  53739. * Gets the perf counter used for active meshes evaluation time
  53740. */
  53741. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  53742. /**
  53743. * Gets the active meshes evaluation time capture status
  53744. */
  53745. get captureActiveMeshesEvaluationTime(): boolean;
  53746. /**
  53747. * Enable or disable the active meshes evaluation time capture
  53748. */
  53749. set captureActiveMeshesEvaluationTime(value: boolean);
  53750. /**
  53751. * Gets the perf counter used for render targets render time
  53752. */
  53753. get renderTargetsRenderTimeCounter(): PerfCounter;
  53754. /**
  53755. * Gets the render targets render time capture status
  53756. */
  53757. get captureRenderTargetsRenderTime(): boolean;
  53758. /**
  53759. * Enable or disable the render targets render time capture
  53760. */
  53761. set captureRenderTargetsRenderTime(value: boolean);
  53762. /**
  53763. * Gets the perf counter used for particles render time
  53764. */
  53765. get particlesRenderTimeCounter(): PerfCounter;
  53766. /**
  53767. * Gets the particles render time capture status
  53768. */
  53769. get captureParticlesRenderTime(): boolean;
  53770. /**
  53771. * Enable or disable the particles render time capture
  53772. */
  53773. set captureParticlesRenderTime(value: boolean);
  53774. /**
  53775. * Gets the perf counter used for sprites render time
  53776. */
  53777. get spritesRenderTimeCounter(): PerfCounter;
  53778. /**
  53779. * Gets the sprites render time capture status
  53780. */
  53781. get captureSpritesRenderTime(): boolean;
  53782. /**
  53783. * Enable or disable the sprites render time capture
  53784. */
  53785. set captureSpritesRenderTime(value: boolean);
  53786. /**
  53787. * Gets the perf counter used for physics time
  53788. */
  53789. get physicsTimeCounter(): PerfCounter;
  53790. /**
  53791. * Gets the physics time capture status
  53792. */
  53793. get capturePhysicsTime(): boolean;
  53794. /**
  53795. * Enable or disable the physics time capture
  53796. */
  53797. set capturePhysicsTime(value: boolean);
  53798. /**
  53799. * Gets the perf counter used for animations time
  53800. */
  53801. get animationsTimeCounter(): PerfCounter;
  53802. /**
  53803. * Gets the animations time capture status
  53804. */
  53805. get captureAnimationsTime(): boolean;
  53806. /**
  53807. * Enable or disable the animations time capture
  53808. */
  53809. set captureAnimationsTime(value: boolean);
  53810. /**
  53811. * Gets the perf counter used for frame time capture
  53812. */
  53813. get frameTimeCounter(): PerfCounter;
  53814. /**
  53815. * Gets the frame time capture status
  53816. */
  53817. get captureFrameTime(): boolean;
  53818. /**
  53819. * Enable or disable the frame time capture
  53820. */
  53821. set captureFrameTime(value: boolean);
  53822. /**
  53823. * Gets the perf counter used for inter-frames time capture
  53824. */
  53825. get interFrameTimeCounter(): PerfCounter;
  53826. /**
  53827. * Gets the inter-frames time capture status
  53828. */
  53829. get captureInterFrameTime(): boolean;
  53830. /**
  53831. * Enable or disable the inter-frames time capture
  53832. */
  53833. set captureInterFrameTime(value: boolean);
  53834. /**
  53835. * Gets the perf counter used for render time capture
  53836. */
  53837. get renderTimeCounter(): PerfCounter;
  53838. /**
  53839. * Gets the render time capture status
  53840. */
  53841. get captureRenderTime(): boolean;
  53842. /**
  53843. * Enable or disable the render time capture
  53844. */
  53845. set captureRenderTime(value: boolean);
  53846. /**
  53847. * Gets the perf counter used for camera render time capture
  53848. */
  53849. get cameraRenderTimeCounter(): PerfCounter;
  53850. /**
  53851. * Gets the camera render time capture status
  53852. */
  53853. get captureCameraRenderTime(): boolean;
  53854. /**
  53855. * Enable or disable the camera render time capture
  53856. */
  53857. set captureCameraRenderTime(value: boolean);
  53858. /**
  53859. * Gets the perf counter used for draw calls
  53860. */
  53861. get drawCallsCounter(): PerfCounter;
  53862. /**
  53863. * Instantiates a new scene instrumentation.
  53864. * This class can be used to get instrumentation data from a Babylon engine
  53865. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53866. * @param scene Defines the scene to instrument
  53867. */
  53868. constructor(
  53869. /**
  53870. * Defines the scene to instrument
  53871. */
  53872. scene: Scene);
  53873. /**
  53874. * Dispose and release associated resources.
  53875. */
  53876. dispose(): void;
  53877. }
  53878. }
  53879. declare module "babylonjs/Instrumentation/index" {
  53880. export * from "babylonjs/Instrumentation/engineInstrumentation";
  53881. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  53882. export * from "babylonjs/Instrumentation/timeToken";
  53883. }
  53884. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  53885. /** @hidden */
  53886. export var glowMapGenerationPixelShader: {
  53887. name: string;
  53888. shader: string;
  53889. };
  53890. }
  53891. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  53892. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53893. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  53894. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  53895. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53896. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  53897. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53898. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53899. /** @hidden */
  53900. export var glowMapGenerationVertexShader: {
  53901. name: string;
  53902. shader: string;
  53903. };
  53904. }
  53905. declare module "babylonjs/Layers/effectLayer" {
  53906. import { Observable } from "babylonjs/Misc/observable";
  53907. import { Nullable } from "babylonjs/types";
  53908. import { Camera } from "babylonjs/Cameras/camera";
  53909. import { Scene } from "babylonjs/scene";
  53910. import { ISize } from "babylonjs/Maths/math.size";
  53911. import { Color4 } from "babylonjs/Maths/math.color";
  53912. import { Engine } from "babylonjs/Engines/engine";
  53913. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53915. import { Mesh } from "babylonjs/Meshes/mesh";
  53916. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53917. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53918. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53919. import { Effect } from "babylonjs/Materials/effect";
  53920. import { Material } from "babylonjs/Materials/material";
  53921. import "babylonjs/Shaders/glowMapGeneration.fragment";
  53922. import "babylonjs/Shaders/glowMapGeneration.vertex";
  53923. /**
  53924. * Effect layer options. This helps customizing the behaviour
  53925. * of the effect layer.
  53926. */
  53927. export interface IEffectLayerOptions {
  53928. /**
  53929. * Multiplication factor apply to the canvas size to compute the render target size
  53930. * used to generated the objects (the smaller the faster).
  53931. */
  53932. mainTextureRatio: number;
  53933. /**
  53934. * Enforces a fixed size texture to ensure effect stability across devices.
  53935. */
  53936. mainTextureFixedSize?: number;
  53937. /**
  53938. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53939. */
  53940. alphaBlendingMode: number;
  53941. /**
  53942. * The camera attached to the layer.
  53943. */
  53944. camera: Nullable<Camera>;
  53945. /**
  53946. * The rendering group to draw the layer in.
  53947. */
  53948. renderingGroupId: number;
  53949. }
  53950. /**
  53951. * The effect layer Helps adding post process effect blended with the main pass.
  53952. *
  53953. * This can be for instance use to generate glow or higlight effects on the scene.
  53954. *
  53955. * The effect layer class can not be used directly and is intented to inherited from to be
  53956. * customized per effects.
  53957. */
  53958. export abstract class EffectLayer {
  53959. private _vertexBuffers;
  53960. private _indexBuffer;
  53961. private _cachedDefines;
  53962. private _effectLayerMapGenerationEffect;
  53963. private _effectLayerOptions;
  53964. private _mergeEffect;
  53965. protected _scene: Scene;
  53966. protected _engine: Engine;
  53967. protected _maxSize: number;
  53968. protected _mainTextureDesiredSize: ISize;
  53969. protected _mainTexture: RenderTargetTexture;
  53970. protected _shouldRender: boolean;
  53971. protected _postProcesses: PostProcess[];
  53972. protected _textures: BaseTexture[];
  53973. protected _emissiveTextureAndColor: {
  53974. texture: Nullable<BaseTexture>;
  53975. color: Color4;
  53976. };
  53977. /**
  53978. * The name of the layer
  53979. */
  53980. name: string;
  53981. /**
  53982. * The clear color of the texture used to generate the glow map.
  53983. */
  53984. neutralColor: Color4;
  53985. /**
  53986. * Specifies wether the highlight layer is enabled or not.
  53987. */
  53988. isEnabled: boolean;
  53989. /**
  53990. * Gets the camera attached to the layer.
  53991. */
  53992. get camera(): Nullable<Camera>;
  53993. /**
  53994. * Gets the rendering group id the layer should render in.
  53995. */
  53996. get renderingGroupId(): number;
  53997. set renderingGroupId(renderingGroupId: number);
  53998. /**
  53999. * An event triggered when the effect layer has been disposed.
  54000. */
  54001. onDisposeObservable: Observable<EffectLayer>;
  54002. /**
  54003. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  54004. */
  54005. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  54006. /**
  54007. * An event triggered when the generated texture is being merged in the scene.
  54008. */
  54009. onBeforeComposeObservable: Observable<EffectLayer>;
  54010. /**
  54011. * An event triggered when the mesh is rendered into the effect render target.
  54012. */
  54013. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  54014. /**
  54015. * An event triggered after the mesh has been rendered into the effect render target.
  54016. */
  54017. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  54018. /**
  54019. * An event triggered when the generated texture has been merged in the scene.
  54020. */
  54021. onAfterComposeObservable: Observable<EffectLayer>;
  54022. /**
  54023. * An event triggered when the efffect layer changes its size.
  54024. */
  54025. onSizeChangedObservable: Observable<EffectLayer>;
  54026. /** @hidden */
  54027. static _SceneComponentInitialization: (scene: Scene) => void;
  54028. /**
  54029. * Instantiates a new effect Layer and references it in the scene.
  54030. * @param name The name of the layer
  54031. * @param scene The scene to use the layer in
  54032. */
  54033. constructor(
  54034. /** The Friendly of the effect in the scene */
  54035. name: string, scene: Scene);
  54036. /**
  54037. * Get the effect name of the layer.
  54038. * @return The effect name
  54039. */
  54040. abstract getEffectName(): string;
  54041. /**
  54042. * Checks for the readiness of the element composing the layer.
  54043. * @param subMesh the mesh to check for
  54044. * @param useInstances specify wether or not to use instances to render the mesh
  54045. * @return true if ready otherwise, false
  54046. */
  54047. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54048. /**
  54049. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54050. * @returns true if the effect requires stencil during the main canvas render pass.
  54051. */
  54052. abstract needStencil(): boolean;
  54053. /**
  54054. * Create the merge effect. This is the shader use to blit the information back
  54055. * to the main canvas at the end of the scene rendering.
  54056. * @returns The effect containing the shader used to merge the effect on the main canvas
  54057. */
  54058. protected abstract _createMergeEffect(): Effect;
  54059. /**
  54060. * Creates the render target textures and post processes used in the effect layer.
  54061. */
  54062. protected abstract _createTextureAndPostProcesses(): void;
  54063. /**
  54064. * Implementation specific of rendering the generating effect on the main canvas.
  54065. * @param effect The effect used to render through
  54066. */
  54067. protected abstract _internalRender(effect: Effect): void;
  54068. /**
  54069. * Sets the required values for both the emissive texture and and the main color.
  54070. */
  54071. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54072. /**
  54073. * Free any resources and references associated to a mesh.
  54074. * Internal use
  54075. * @param mesh The mesh to free.
  54076. */
  54077. abstract _disposeMesh(mesh: Mesh): void;
  54078. /**
  54079. * Serializes this layer (Glow or Highlight for example)
  54080. * @returns a serialized layer object
  54081. */
  54082. abstract serialize?(): any;
  54083. /**
  54084. * Initializes the effect layer with the required options.
  54085. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  54086. */
  54087. protected _init(options: Partial<IEffectLayerOptions>): void;
  54088. /**
  54089. * Generates the index buffer of the full screen quad blending to the main canvas.
  54090. */
  54091. private _generateIndexBuffer;
  54092. /**
  54093. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  54094. */
  54095. private _generateVertexBuffer;
  54096. /**
  54097. * Sets the main texture desired size which is the closest power of two
  54098. * of the engine canvas size.
  54099. */
  54100. private _setMainTextureSize;
  54101. /**
  54102. * Creates the main texture for the effect layer.
  54103. */
  54104. protected _createMainTexture(): void;
  54105. /**
  54106. * Adds specific effects defines.
  54107. * @param defines The defines to add specifics to.
  54108. */
  54109. protected _addCustomEffectDefines(defines: string[]): void;
  54110. /**
  54111. * Checks for the readiness of the element composing the layer.
  54112. * @param subMesh the mesh to check for
  54113. * @param useInstances specify wether or not to use instances to render the mesh
  54114. * @param emissiveTexture the associated emissive texture used to generate the glow
  54115. * @return true if ready otherwise, false
  54116. */
  54117. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  54118. /**
  54119. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  54120. */
  54121. render(): void;
  54122. /**
  54123. * Determine if a given mesh will be used in the current effect.
  54124. * @param mesh mesh to test
  54125. * @returns true if the mesh will be used
  54126. */
  54127. hasMesh(mesh: AbstractMesh): boolean;
  54128. /**
  54129. * Returns true if the layer contains information to display, otherwise false.
  54130. * @returns true if the glow layer should be rendered
  54131. */
  54132. shouldRender(): boolean;
  54133. /**
  54134. * Returns true if the mesh should render, otherwise false.
  54135. * @param mesh The mesh to render
  54136. * @returns true if it should render otherwise false
  54137. */
  54138. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  54139. /**
  54140. * Returns true if the mesh can be rendered, otherwise false.
  54141. * @param mesh The mesh to render
  54142. * @param material The material used on the mesh
  54143. * @returns true if it can be rendered otherwise false
  54144. */
  54145. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  54146. /**
  54147. * Returns true if the mesh should render, otherwise false.
  54148. * @param mesh The mesh to render
  54149. * @returns true if it should render otherwise false
  54150. */
  54151. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  54152. /**
  54153. * Renders the submesh passed in parameter to the generation map.
  54154. */
  54155. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  54156. /**
  54157. * Defines wether the current material of the mesh should be use to render the effect.
  54158. * @param mesh defines the current mesh to render
  54159. */
  54160. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  54161. /**
  54162. * Rebuild the required buffers.
  54163. * @hidden Internal use only.
  54164. */
  54165. _rebuild(): void;
  54166. /**
  54167. * Dispose only the render target textures and post process.
  54168. */
  54169. private _disposeTextureAndPostProcesses;
  54170. /**
  54171. * Dispose the highlight layer and free resources.
  54172. */
  54173. dispose(): void;
  54174. /**
  54175. * Gets the class name of the effect layer
  54176. * @returns the string with the class name of the effect layer
  54177. */
  54178. getClassName(): string;
  54179. /**
  54180. * Creates an effect layer from parsed effect layer data
  54181. * @param parsedEffectLayer defines effect layer data
  54182. * @param scene defines the current scene
  54183. * @param rootUrl defines the root URL containing the effect layer information
  54184. * @returns a parsed effect Layer
  54185. */
  54186. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  54187. }
  54188. }
  54189. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  54190. import { Scene } from "babylonjs/scene";
  54191. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  54192. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  54193. import { AbstractScene } from "babylonjs/abstractScene";
  54194. module "babylonjs/abstractScene" {
  54195. interface AbstractScene {
  54196. /**
  54197. * The list of effect layers (highlights/glow) added to the scene
  54198. * @see http://doc.babylonjs.com/how_to/highlight_layer
  54199. * @see http://doc.babylonjs.com/how_to/glow_layer
  54200. */
  54201. effectLayers: Array<EffectLayer>;
  54202. /**
  54203. * Removes the given effect layer from this scene.
  54204. * @param toRemove defines the effect layer to remove
  54205. * @returns the index of the removed effect layer
  54206. */
  54207. removeEffectLayer(toRemove: EffectLayer): number;
  54208. /**
  54209. * Adds the given effect layer to this scene
  54210. * @param newEffectLayer defines the effect layer to add
  54211. */
  54212. addEffectLayer(newEffectLayer: EffectLayer): void;
  54213. }
  54214. }
  54215. /**
  54216. * Defines the layer scene component responsible to manage any effect layers
  54217. * in a given scene.
  54218. */
  54219. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  54220. /**
  54221. * The component name helpfull to identify the component in the list of scene components.
  54222. */
  54223. readonly name: string;
  54224. /**
  54225. * The scene the component belongs to.
  54226. */
  54227. scene: Scene;
  54228. private _engine;
  54229. private _renderEffects;
  54230. private _needStencil;
  54231. private _previousStencilState;
  54232. /**
  54233. * Creates a new instance of the component for the given scene
  54234. * @param scene Defines the scene to register the component in
  54235. */
  54236. constructor(scene: Scene);
  54237. /**
  54238. * Registers the component in a given scene
  54239. */
  54240. register(): void;
  54241. /**
  54242. * Rebuilds the elements related to this component in case of
  54243. * context lost for instance.
  54244. */
  54245. rebuild(): void;
  54246. /**
  54247. * Serializes the component data to the specified json object
  54248. * @param serializationObject The object to serialize to
  54249. */
  54250. serialize(serializationObject: any): void;
  54251. /**
  54252. * Adds all the elements from the container to the scene
  54253. * @param container the container holding the elements
  54254. */
  54255. addFromContainer(container: AbstractScene): void;
  54256. /**
  54257. * Removes all the elements in the container from the scene
  54258. * @param container contains the elements to remove
  54259. * @param dispose if the removed element should be disposed (default: false)
  54260. */
  54261. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54262. /**
  54263. * Disposes the component and the associated ressources.
  54264. */
  54265. dispose(): void;
  54266. private _isReadyForMesh;
  54267. private _renderMainTexture;
  54268. private _setStencil;
  54269. private _setStencilBack;
  54270. private _draw;
  54271. private _drawCamera;
  54272. private _drawRenderingGroup;
  54273. }
  54274. }
  54275. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  54276. /** @hidden */
  54277. export var glowMapMergePixelShader: {
  54278. name: string;
  54279. shader: string;
  54280. };
  54281. }
  54282. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  54283. /** @hidden */
  54284. export var glowMapMergeVertexShader: {
  54285. name: string;
  54286. shader: string;
  54287. };
  54288. }
  54289. declare module "babylonjs/Layers/glowLayer" {
  54290. import { Nullable } from "babylonjs/types";
  54291. import { Camera } from "babylonjs/Cameras/camera";
  54292. import { Scene } from "babylonjs/scene";
  54293. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54294. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54295. import { Mesh } from "babylonjs/Meshes/mesh";
  54296. import { Texture } from "babylonjs/Materials/Textures/texture";
  54297. import { Effect } from "babylonjs/Materials/effect";
  54298. import { Material } from "babylonjs/Materials/material";
  54299. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  54300. import { Color4 } from "babylonjs/Maths/math.color";
  54301. import "babylonjs/Shaders/glowMapMerge.fragment";
  54302. import "babylonjs/Shaders/glowMapMerge.vertex";
  54303. import "babylonjs/Layers/effectLayerSceneComponent";
  54304. module "babylonjs/abstractScene" {
  54305. interface AbstractScene {
  54306. /**
  54307. * Return a the first highlight layer of the scene with a given name.
  54308. * @param name The name of the highlight layer to look for.
  54309. * @return The highlight layer if found otherwise null.
  54310. */
  54311. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  54312. }
  54313. }
  54314. /**
  54315. * Glow layer options. This helps customizing the behaviour
  54316. * of the glow layer.
  54317. */
  54318. export interface IGlowLayerOptions {
  54319. /**
  54320. * Multiplication factor apply to the canvas size to compute the render target size
  54321. * used to generated the glowing objects (the smaller the faster).
  54322. */
  54323. mainTextureRatio: number;
  54324. /**
  54325. * Enforces a fixed size texture to ensure resize independant blur.
  54326. */
  54327. mainTextureFixedSize?: number;
  54328. /**
  54329. * How big is the kernel of the blur texture.
  54330. */
  54331. blurKernelSize: number;
  54332. /**
  54333. * The camera attached to the layer.
  54334. */
  54335. camera: Nullable<Camera>;
  54336. /**
  54337. * Enable MSAA by chosing the number of samples.
  54338. */
  54339. mainTextureSamples?: number;
  54340. /**
  54341. * The rendering group to draw the layer in.
  54342. */
  54343. renderingGroupId: number;
  54344. }
  54345. /**
  54346. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  54347. *
  54348. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  54349. *
  54350. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  54351. */
  54352. export class GlowLayer extends EffectLayer {
  54353. /**
  54354. * Effect Name of the layer.
  54355. */
  54356. static readonly EffectName: string;
  54357. /**
  54358. * The default blur kernel size used for the glow.
  54359. */
  54360. static DefaultBlurKernelSize: number;
  54361. /**
  54362. * The default texture size ratio used for the glow.
  54363. */
  54364. static DefaultTextureRatio: number;
  54365. /**
  54366. * Sets the kernel size of the blur.
  54367. */
  54368. set blurKernelSize(value: number);
  54369. /**
  54370. * Gets the kernel size of the blur.
  54371. */
  54372. get blurKernelSize(): number;
  54373. /**
  54374. * Sets the glow intensity.
  54375. */
  54376. set intensity(value: number);
  54377. /**
  54378. * Gets the glow intensity.
  54379. */
  54380. get intensity(): number;
  54381. private _options;
  54382. private _intensity;
  54383. private _horizontalBlurPostprocess1;
  54384. private _verticalBlurPostprocess1;
  54385. private _horizontalBlurPostprocess2;
  54386. private _verticalBlurPostprocess2;
  54387. private _blurTexture1;
  54388. private _blurTexture2;
  54389. private _postProcesses1;
  54390. private _postProcesses2;
  54391. private _includedOnlyMeshes;
  54392. private _excludedMeshes;
  54393. private _meshesUsingTheirOwnMaterials;
  54394. /**
  54395. * Callback used to let the user override the color selection on a per mesh basis
  54396. */
  54397. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  54398. /**
  54399. * Callback used to let the user override the texture selection on a per mesh basis
  54400. */
  54401. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  54402. /**
  54403. * Instantiates a new glow Layer and references it to the scene.
  54404. * @param name The name of the layer
  54405. * @param scene The scene to use the layer in
  54406. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  54407. */
  54408. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  54409. /**
  54410. * Get the effect name of the layer.
  54411. * @return The effect name
  54412. */
  54413. getEffectName(): string;
  54414. /**
  54415. * Create the merge effect. This is the shader use to blit the information back
  54416. * to the main canvas at the end of the scene rendering.
  54417. */
  54418. protected _createMergeEffect(): Effect;
  54419. /**
  54420. * Creates the render target textures and post processes used in the glow layer.
  54421. */
  54422. protected _createTextureAndPostProcesses(): void;
  54423. /**
  54424. * Checks for the readiness of the element composing the layer.
  54425. * @param subMesh the mesh to check for
  54426. * @param useInstances specify wether or not to use instances to render the mesh
  54427. * @param emissiveTexture the associated emissive texture used to generate the glow
  54428. * @return true if ready otherwise, false
  54429. */
  54430. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54431. /**
  54432. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54433. */
  54434. needStencil(): boolean;
  54435. /**
  54436. * Returns true if the mesh can be rendered, otherwise false.
  54437. * @param mesh The mesh to render
  54438. * @param material The material used on the mesh
  54439. * @returns true if it can be rendered otherwise false
  54440. */
  54441. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  54442. /**
  54443. * Implementation specific of rendering the generating effect on the main canvas.
  54444. * @param effect The effect used to render through
  54445. */
  54446. protected _internalRender(effect: Effect): void;
  54447. /**
  54448. * Sets the required values for both the emissive texture and and the main color.
  54449. */
  54450. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54451. /**
  54452. * Returns true if the mesh should render, otherwise false.
  54453. * @param mesh The mesh to render
  54454. * @returns true if it should render otherwise false
  54455. */
  54456. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54457. /**
  54458. * Adds specific effects defines.
  54459. * @param defines The defines to add specifics to.
  54460. */
  54461. protected _addCustomEffectDefines(defines: string[]): void;
  54462. /**
  54463. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  54464. * @param mesh The mesh to exclude from the glow layer
  54465. */
  54466. addExcludedMesh(mesh: Mesh): void;
  54467. /**
  54468. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  54469. * @param mesh The mesh to remove
  54470. */
  54471. removeExcludedMesh(mesh: Mesh): void;
  54472. /**
  54473. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  54474. * @param mesh The mesh to include in the glow layer
  54475. */
  54476. addIncludedOnlyMesh(mesh: Mesh): void;
  54477. /**
  54478. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  54479. * @param mesh The mesh to remove
  54480. */
  54481. removeIncludedOnlyMesh(mesh: Mesh): void;
  54482. /**
  54483. * Determine if a given mesh will be used in the glow layer
  54484. * @param mesh The mesh to test
  54485. * @returns true if the mesh will be highlighted by the current glow layer
  54486. */
  54487. hasMesh(mesh: AbstractMesh): boolean;
  54488. /**
  54489. * Defines wether the current material of the mesh should be use to render the effect.
  54490. * @param mesh defines the current mesh to render
  54491. */
  54492. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  54493. /**
  54494. * Add a mesh to be rendered through its own material and not with emissive only.
  54495. * @param mesh The mesh for which we need to use its material
  54496. */
  54497. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  54498. /**
  54499. * Remove a mesh from being rendered through its own material and not with emissive only.
  54500. * @param mesh The mesh for which we need to not use its material
  54501. */
  54502. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  54503. /**
  54504. * Free any resources and references associated to a mesh.
  54505. * Internal use
  54506. * @param mesh The mesh to free.
  54507. * @hidden
  54508. */
  54509. _disposeMesh(mesh: Mesh): void;
  54510. /**
  54511. * Gets the class name of the effect layer
  54512. * @returns the string with the class name of the effect layer
  54513. */
  54514. getClassName(): string;
  54515. /**
  54516. * Serializes this glow layer
  54517. * @returns a serialized glow layer object
  54518. */
  54519. serialize(): any;
  54520. /**
  54521. * Creates a Glow Layer from parsed glow layer data
  54522. * @param parsedGlowLayer defines glow layer data
  54523. * @param scene defines the current scene
  54524. * @param rootUrl defines the root URL containing the glow layer information
  54525. * @returns a parsed Glow Layer
  54526. */
  54527. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  54528. }
  54529. }
  54530. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  54531. /** @hidden */
  54532. export var glowBlurPostProcessPixelShader: {
  54533. name: string;
  54534. shader: string;
  54535. };
  54536. }
  54537. declare module "babylonjs/Layers/highlightLayer" {
  54538. import { Observable } from "babylonjs/Misc/observable";
  54539. import { Nullable } from "babylonjs/types";
  54540. import { Camera } from "babylonjs/Cameras/camera";
  54541. import { Scene } from "babylonjs/scene";
  54542. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54543. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54544. import { Mesh } from "babylonjs/Meshes/mesh";
  54545. import { Effect } from "babylonjs/Materials/effect";
  54546. import { Material } from "babylonjs/Materials/material";
  54547. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  54548. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  54549. import "babylonjs/Shaders/glowMapMerge.fragment";
  54550. import "babylonjs/Shaders/glowMapMerge.vertex";
  54551. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  54552. module "babylonjs/abstractScene" {
  54553. interface AbstractScene {
  54554. /**
  54555. * Return a the first highlight layer of the scene with a given name.
  54556. * @param name The name of the highlight layer to look for.
  54557. * @return The highlight layer if found otherwise null.
  54558. */
  54559. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  54560. }
  54561. }
  54562. /**
  54563. * Highlight layer options. This helps customizing the behaviour
  54564. * of the highlight layer.
  54565. */
  54566. export interface IHighlightLayerOptions {
  54567. /**
  54568. * Multiplication factor apply to the canvas size to compute the render target size
  54569. * used to generated the glowing objects (the smaller the faster).
  54570. */
  54571. mainTextureRatio: number;
  54572. /**
  54573. * Enforces a fixed size texture to ensure resize independant blur.
  54574. */
  54575. mainTextureFixedSize?: number;
  54576. /**
  54577. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  54578. * of the picture to blur (the smaller the faster).
  54579. */
  54580. blurTextureSizeRatio: number;
  54581. /**
  54582. * How big in texel of the blur texture is the vertical blur.
  54583. */
  54584. blurVerticalSize: number;
  54585. /**
  54586. * How big in texel of the blur texture is the horizontal blur.
  54587. */
  54588. blurHorizontalSize: number;
  54589. /**
  54590. * Alpha blending mode used to apply the blur. Default is combine.
  54591. */
  54592. alphaBlendingMode: number;
  54593. /**
  54594. * The camera attached to the layer.
  54595. */
  54596. camera: Nullable<Camera>;
  54597. /**
  54598. * Should we display highlight as a solid stroke?
  54599. */
  54600. isStroke?: boolean;
  54601. /**
  54602. * The rendering group to draw the layer in.
  54603. */
  54604. renderingGroupId: number;
  54605. }
  54606. /**
  54607. * The highlight layer Helps adding a glow effect around a mesh.
  54608. *
  54609. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  54610. * glowy meshes to your scene.
  54611. *
  54612. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  54613. */
  54614. export class HighlightLayer extends EffectLayer {
  54615. name: string;
  54616. /**
  54617. * Effect Name of the highlight layer.
  54618. */
  54619. static readonly EffectName: string;
  54620. /**
  54621. * The neutral color used during the preparation of the glow effect.
  54622. * This is black by default as the blend operation is a blend operation.
  54623. */
  54624. static NeutralColor: Color4;
  54625. /**
  54626. * Stencil value used for glowing meshes.
  54627. */
  54628. static GlowingMeshStencilReference: number;
  54629. /**
  54630. * Stencil value used for the other meshes in the scene.
  54631. */
  54632. static NormalMeshStencilReference: number;
  54633. /**
  54634. * Specifies whether or not the inner glow is ACTIVE in the layer.
  54635. */
  54636. innerGlow: boolean;
  54637. /**
  54638. * Specifies whether or not the outer glow is ACTIVE in the layer.
  54639. */
  54640. outerGlow: boolean;
  54641. /**
  54642. * Specifies the horizontal size of the blur.
  54643. */
  54644. set blurHorizontalSize(value: number);
  54645. /**
  54646. * Specifies the vertical size of the blur.
  54647. */
  54648. set blurVerticalSize(value: number);
  54649. /**
  54650. * Gets the horizontal size of the blur.
  54651. */
  54652. get blurHorizontalSize(): number;
  54653. /**
  54654. * Gets the vertical size of the blur.
  54655. */
  54656. get blurVerticalSize(): number;
  54657. /**
  54658. * An event triggered when the highlight layer is being blurred.
  54659. */
  54660. onBeforeBlurObservable: Observable<HighlightLayer>;
  54661. /**
  54662. * An event triggered when the highlight layer has been blurred.
  54663. */
  54664. onAfterBlurObservable: Observable<HighlightLayer>;
  54665. private _instanceGlowingMeshStencilReference;
  54666. private _options;
  54667. private _downSamplePostprocess;
  54668. private _horizontalBlurPostprocess;
  54669. private _verticalBlurPostprocess;
  54670. private _blurTexture;
  54671. private _meshes;
  54672. private _excludedMeshes;
  54673. /**
  54674. * Instantiates a new highlight Layer and references it to the scene..
  54675. * @param name The name of the layer
  54676. * @param scene The scene to use the layer in
  54677. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  54678. */
  54679. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  54680. /**
  54681. * Get the effect name of the layer.
  54682. * @return The effect name
  54683. */
  54684. getEffectName(): string;
  54685. /**
  54686. * Create the merge effect. This is the shader use to blit the information back
  54687. * to the main canvas at the end of the scene rendering.
  54688. */
  54689. protected _createMergeEffect(): Effect;
  54690. /**
  54691. * Creates the render target textures and post processes used in the highlight layer.
  54692. */
  54693. protected _createTextureAndPostProcesses(): void;
  54694. /**
  54695. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54696. */
  54697. needStencil(): boolean;
  54698. /**
  54699. * Checks for the readiness of the element composing the layer.
  54700. * @param subMesh the mesh to check for
  54701. * @param useInstances specify wether or not to use instances to render the mesh
  54702. * @param emissiveTexture the associated emissive texture used to generate the glow
  54703. * @return true if ready otherwise, false
  54704. */
  54705. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54706. /**
  54707. * Implementation specific of rendering the generating effect on the main canvas.
  54708. * @param effect The effect used to render through
  54709. */
  54710. protected _internalRender(effect: Effect): void;
  54711. /**
  54712. * Returns true if the layer contains information to display, otherwise false.
  54713. */
  54714. shouldRender(): boolean;
  54715. /**
  54716. * Returns true if the mesh should render, otherwise false.
  54717. * @param mesh The mesh to render
  54718. * @returns true if it should render otherwise false
  54719. */
  54720. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54721. /**
  54722. * Sets the required values for both the emissive texture and and the main color.
  54723. */
  54724. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54725. /**
  54726. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  54727. * @param mesh The mesh to exclude from the highlight layer
  54728. */
  54729. addExcludedMesh(mesh: Mesh): void;
  54730. /**
  54731. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  54732. * @param mesh The mesh to highlight
  54733. */
  54734. removeExcludedMesh(mesh: Mesh): void;
  54735. /**
  54736. * Determine if a given mesh will be highlighted by the current HighlightLayer
  54737. * @param mesh mesh to test
  54738. * @returns true if the mesh will be highlighted by the current HighlightLayer
  54739. */
  54740. hasMesh(mesh: AbstractMesh): boolean;
  54741. /**
  54742. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  54743. * @param mesh The mesh to highlight
  54744. * @param color The color of the highlight
  54745. * @param glowEmissiveOnly Extract the glow from the emissive texture
  54746. */
  54747. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  54748. /**
  54749. * Remove a mesh from the highlight layer in order to make it stop glowing.
  54750. * @param mesh The mesh to highlight
  54751. */
  54752. removeMesh(mesh: Mesh): void;
  54753. /**
  54754. * Force the stencil to the normal expected value for none glowing parts
  54755. */
  54756. private _defaultStencilReference;
  54757. /**
  54758. * Free any resources and references associated to a mesh.
  54759. * Internal use
  54760. * @param mesh The mesh to free.
  54761. * @hidden
  54762. */
  54763. _disposeMesh(mesh: Mesh): void;
  54764. /**
  54765. * Dispose the highlight layer and free resources.
  54766. */
  54767. dispose(): void;
  54768. /**
  54769. * Gets the class name of the effect layer
  54770. * @returns the string with the class name of the effect layer
  54771. */
  54772. getClassName(): string;
  54773. /**
  54774. * Serializes this Highlight layer
  54775. * @returns a serialized Highlight layer object
  54776. */
  54777. serialize(): any;
  54778. /**
  54779. * Creates a Highlight layer from parsed Highlight layer data
  54780. * @param parsedHightlightLayer defines the Highlight layer data
  54781. * @param scene defines the current scene
  54782. * @param rootUrl defines the root URL containing the Highlight layer information
  54783. * @returns a parsed Highlight layer
  54784. */
  54785. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  54786. }
  54787. }
  54788. declare module "babylonjs/Layers/layerSceneComponent" {
  54789. import { Scene } from "babylonjs/scene";
  54790. import { ISceneComponent } from "babylonjs/sceneComponent";
  54791. import { Layer } from "babylonjs/Layers/layer";
  54792. import { AbstractScene } from "babylonjs/abstractScene";
  54793. module "babylonjs/abstractScene" {
  54794. interface AbstractScene {
  54795. /**
  54796. * The list of layers (background and foreground) of the scene
  54797. */
  54798. layers: Array<Layer>;
  54799. }
  54800. }
  54801. /**
  54802. * Defines the layer scene component responsible to manage any layers
  54803. * in a given scene.
  54804. */
  54805. export class LayerSceneComponent implements ISceneComponent {
  54806. /**
  54807. * The component name helpfull to identify the component in the list of scene components.
  54808. */
  54809. readonly name: string;
  54810. /**
  54811. * The scene the component belongs to.
  54812. */
  54813. scene: Scene;
  54814. private _engine;
  54815. /**
  54816. * Creates a new instance of the component for the given scene
  54817. * @param scene Defines the scene to register the component in
  54818. */
  54819. constructor(scene: Scene);
  54820. /**
  54821. * Registers the component in a given scene
  54822. */
  54823. register(): void;
  54824. /**
  54825. * Rebuilds the elements related to this component in case of
  54826. * context lost for instance.
  54827. */
  54828. rebuild(): void;
  54829. /**
  54830. * Disposes the component and the associated ressources.
  54831. */
  54832. dispose(): void;
  54833. private _draw;
  54834. private _drawCameraPredicate;
  54835. private _drawCameraBackground;
  54836. private _drawCameraForeground;
  54837. private _drawRenderTargetPredicate;
  54838. private _drawRenderTargetBackground;
  54839. private _drawRenderTargetForeground;
  54840. /**
  54841. * Adds all the elements from the container to the scene
  54842. * @param container the container holding the elements
  54843. */
  54844. addFromContainer(container: AbstractScene): void;
  54845. /**
  54846. * Removes all the elements in the container from the scene
  54847. * @param container contains the elements to remove
  54848. * @param dispose if the removed element should be disposed (default: false)
  54849. */
  54850. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54851. }
  54852. }
  54853. declare module "babylonjs/Shaders/layer.fragment" {
  54854. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54855. /** @hidden */
  54856. export var layerPixelShader: {
  54857. name: string;
  54858. shader: string;
  54859. };
  54860. }
  54861. declare module "babylonjs/Shaders/layer.vertex" {
  54862. /** @hidden */
  54863. export var layerVertexShader: {
  54864. name: string;
  54865. shader: string;
  54866. };
  54867. }
  54868. declare module "babylonjs/Layers/layer" {
  54869. import { Observable } from "babylonjs/Misc/observable";
  54870. import { Nullable } from "babylonjs/types";
  54871. import { Scene } from "babylonjs/scene";
  54872. import { Vector2 } from "babylonjs/Maths/math.vector";
  54873. import { Color4 } from "babylonjs/Maths/math.color";
  54874. import { Texture } from "babylonjs/Materials/Textures/texture";
  54875. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54876. import "babylonjs/Shaders/layer.fragment";
  54877. import "babylonjs/Shaders/layer.vertex";
  54878. /**
  54879. * This represents a full screen 2d layer.
  54880. * This can be useful to display a picture in the background of your scene for instance.
  54881. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54882. */
  54883. export class Layer {
  54884. /**
  54885. * Define the name of the layer.
  54886. */
  54887. name: string;
  54888. /**
  54889. * Define the texture the layer should display.
  54890. */
  54891. texture: Nullable<Texture>;
  54892. /**
  54893. * Is the layer in background or foreground.
  54894. */
  54895. isBackground: boolean;
  54896. /**
  54897. * Define the color of the layer (instead of texture).
  54898. */
  54899. color: Color4;
  54900. /**
  54901. * Define the scale of the layer in order to zoom in out of the texture.
  54902. */
  54903. scale: Vector2;
  54904. /**
  54905. * Define an offset for the layer in order to shift the texture.
  54906. */
  54907. offset: Vector2;
  54908. /**
  54909. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  54910. */
  54911. alphaBlendingMode: number;
  54912. /**
  54913. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  54914. * Alpha test will not mix with the background color in case of transparency.
  54915. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  54916. */
  54917. alphaTest: boolean;
  54918. /**
  54919. * Define a mask to restrict the layer to only some of the scene cameras.
  54920. */
  54921. layerMask: number;
  54922. /**
  54923. * Define the list of render target the layer is visible into.
  54924. */
  54925. renderTargetTextures: RenderTargetTexture[];
  54926. /**
  54927. * Define if the layer is only used in renderTarget or if it also
  54928. * renders in the main frame buffer of the canvas.
  54929. */
  54930. renderOnlyInRenderTargetTextures: boolean;
  54931. private _scene;
  54932. private _vertexBuffers;
  54933. private _indexBuffer;
  54934. private _effect;
  54935. private _previousDefines;
  54936. /**
  54937. * An event triggered when the layer is disposed.
  54938. */
  54939. onDisposeObservable: Observable<Layer>;
  54940. private _onDisposeObserver;
  54941. /**
  54942. * Back compatibility with callback before the onDisposeObservable existed.
  54943. * The set callback will be triggered when the layer has been disposed.
  54944. */
  54945. set onDispose(callback: () => void);
  54946. /**
  54947. * An event triggered before rendering the scene
  54948. */
  54949. onBeforeRenderObservable: Observable<Layer>;
  54950. private _onBeforeRenderObserver;
  54951. /**
  54952. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54953. * The set callback will be triggered just before rendering the layer.
  54954. */
  54955. set onBeforeRender(callback: () => void);
  54956. /**
  54957. * An event triggered after rendering the scene
  54958. */
  54959. onAfterRenderObservable: Observable<Layer>;
  54960. private _onAfterRenderObserver;
  54961. /**
  54962. * Back compatibility with callback before the onAfterRenderObservable existed.
  54963. * The set callback will be triggered just after rendering the layer.
  54964. */
  54965. set onAfterRender(callback: () => void);
  54966. /**
  54967. * Instantiates a new layer.
  54968. * This represents a full screen 2d layer.
  54969. * This can be useful to display a picture in the background of your scene for instance.
  54970. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54971. * @param name Define the name of the layer in the scene
  54972. * @param imgUrl Define the url of the texture to display in the layer
  54973. * @param scene Define the scene the layer belongs to
  54974. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  54975. * @param color Defines a color for the layer
  54976. */
  54977. constructor(
  54978. /**
  54979. * Define the name of the layer.
  54980. */
  54981. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  54982. private _createIndexBuffer;
  54983. /** @hidden */
  54984. _rebuild(): void;
  54985. /**
  54986. * Renders the layer in the scene.
  54987. */
  54988. render(): void;
  54989. /**
  54990. * Disposes and releases the associated ressources.
  54991. */
  54992. dispose(): void;
  54993. }
  54994. }
  54995. declare module "babylonjs/Layers/index" {
  54996. export * from "babylonjs/Layers/effectLayer";
  54997. export * from "babylonjs/Layers/effectLayerSceneComponent";
  54998. export * from "babylonjs/Layers/glowLayer";
  54999. export * from "babylonjs/Layers/highlightLayer";
  55000. export * from "babylonjs/Layers/layer";
  55001. export * from "babylonjs/Layers/layerSceneComponent";
  55002. }
  55003. declare module "babylonjs/Shaders/lensFlare.fragment" {
  55004. /** @hidden */
  55005. export var lensFlarePixelShader: {
  55006. name: string;
  55007. shader: string;
  55008. };
  55009. }
  55010. declare module "babylonjs/Shaders/lensFlare.vertex" {
  55011. /** @hidden */
  55012. export var lensFlareVertexShader: {
  55013. name: string;
  55014. shader: string;
  55015. };
  55016. }
  55017. declare module "babylonjs/LensFlares/lensFlareSystem" {
  55018. import { Scene } from "babylonjs/scene";
  55019. import { Vector3 } from "babylonjs/Maths/math.vector";
  55020. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55021. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  55022. import "babylonjs/Shaders/lensFlare.fragment";
  55023. import "babylonjs/Shaders/lensFlare.vertex";
  55024. import { Viewport } from "babylonjs/Maths/math.viewport";
  55025. /**
  55026. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  55027. * It is usually composed of several `lensFlare`.
  55028. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55029. */
  55030. export class LensFlareSystem {
  55031. /**
  55032. * Define the name of the lens flare system
  55033. */
  55034. name: string;
  55035. /**
  55036. * List of lens flares used in this system.
  55037. */
  55038. lensFlares: LensFlare[];
  55039. /**
  55040. * Define a limit from the border the lens flare can be visible.
  55041. */
  55042. borderLimit: number;
  55043. /**
  55044. * Define a viewport border we do not want to see the lens flare in.
  55045. */
  55046. viewportBorder: number;
  55047. /**
  55048. * Define a predicate which could limit the list of meshes able to occlude the effect.
  55049. */
  55050. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  55051. /**
  55052. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  55053. */
  55054. layerMask: number;
  55055. /**
  55056. * Define the id of the lens flare system in the scene.
  55057. * (equal to name by default)
  55058. */
  55059. id: string;
  55060. private _scene;
  55061. private _emitter;
  55062. private _vertexBuffers;
  55063. private _indexBuffer;
  55064. private _effect;
  55065. private _positionX;
  55066. private _positionY;
  55067. private _isEnabled;
  55068. /** @hidden */
  55069. static _SceneComponentInitialization: (scene: Scene) => void;
  55070. /**
  55071. * Instantiates a lens flare system.
  55072. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  55073. * It is usually composed of several `lensFlare`.
  55074. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55075. * @param name Define the name of the lens flare system in the scene
  55076. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  55077. * @param scene Define the scene the lens flare system belongs to
  55078. */
  55079. constructor(
  55080. /**
  55081. * Define the name of the lens flare system
  55082. */
  55083. name: string, emitter: any, scene: Scene);
  55084. /**
  55085. * Define if the lens flare system is enabled.
  55086. */
  55087. get isEnabled(): boolean;
  55088. set isEnabled(value: boolean);
  55089. /**
  55090. * Get the scene the effects belongs to.
  55091. * @returns the scene holding the lens flare system
  55092. */
  55093. getScene(): Scene;
  55094. /**
  55095. * Get the emitter of the lens flare system.
  55096. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  55097. * @returns the emitter of the lens flare system
  55098. */
  55099. getEmitter(): any;
  55100. /**
  55101. * Set the emitter of the lens flare system.
  55102. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  55103. * @param newEmitter Define the new emitter of the system
  55104. */
  55105. setEmitter(newEmitter: any): void;
  55106. /**
  55107. * Get the lens flare system emitter position.
  55108. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  55109. * @returns the position
  55110. */
  55111. getEmitterPosition(): Vector3;
  55112. /**
  55113. * @hidden
  55114. */
  55115. computeEffectivePosition(globalViewport: Viewport): boolean;
  55116. /** @hidden */
  55117. _isVisible(): boolean;
  55118. /**
  55119. * @hidden
  55120. */
  55121. render(): boolean;
  55122. /**
  55123. * Dispose and release the lens flare with its associated resources.
  55124. */
  55125. dispose(): void;
  55126. /**
  55127. * Parse a lens flare system from a JSON repressentation
  55128. * @param parsedLensFlareSystem Define the JSON to parse
  55129. * @param scene Define the scene the parsed system should be instantiated in
  55130. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  55131. * @returns the parsed system
  55132. */
  55133. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  55134. /**
  55135. * Serialize the current Lens Flare System into a JSON representation.
  55136. * @returns the serialized JSON
  55137. */
  55138. serialize(): any;
  55139. }
  55140. }
  55141. declare module "babylonjs/LensFlares/lensFlare" {
  55142. import { Nullable } from "babylonjs/types";
  55143. import { Color3 } from "babylonjs/Maths/math.color";
  55144. import { Texture } from "babylonjs/Materials/Textures/texture";
  55145. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  55146. /**
  55147. * This represents one of the lens effect in a `lensFlareSystem`.
  55148. * It controls one of the indiviual texture used in the effect.
  55149. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55150. */
  55151. export class LensFlare {
  55152. /**
  55153. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  55154. */
  55155. size: number;
  55156. /**
  55157. * 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.
  55158. */
  55159. position: number;
  55160. /**
  55161. * Define the lens color.
  55162. */
  55163. color: Color3;
  55164. /**
  55165. * Define the lens texture.
  55166. */
  55167. texture: Nullable<Texture>;
  55168. /**
  55169. * Define the alpha mode to render this particular lens.
  55170. */
  55171. alphaMode: number;
  55172. private _system;
  55173. /**
  55174. * Creates a new Lens Flare.
  55175. * This represents one of the lens effect in a `lensFlareSystem`.
  55176. * It controls one of the indiviual texture used in the effect.
  55177. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55178. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  55179. * @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.
  55180. * @param color Define the lens color
  55181. * @param imgUrl Define the lens texture url
  55182. * @param system Define the `lensFlareSystem` this flare is part of
  55183. * @returns The newly created Lens Flare
  55184. */
  55185. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  55186. /**
  55187. * Instantiates a new Lens Flare.
  55188. * This represents one of the lens effect in a `lensFlareSystem`.
  55189. * It controls one of the indiviual texture used in the effect.
  55190. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55191. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  55192. * @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.
  55193. * @param color Define the lens color
  55194. * @param imgUrl Define the lens texture url
  55195. * @param system Define the `lensFlareSystem` this flare is part of
  55196. */
  55197. constructor(
  55198. /**
  55199. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  55200. */
  55201. size: number,
  55202. /**
  55203. * 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.
  55204. */
  55205. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  55206. /**
  55207. * Dispose and release the lens flare with its associated resources.
  55208. */
  55209. dispose(): void;
  55210. }
  55211. }
  55212. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  55213. import { Nullable } from "babylonjs/types";
  55214. import { Scene } from "babylonjs/scene";
  55215. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55216. import { AbstractScene } from "babylonjs/abstractScene";
  55217. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  55218. module "babylonjs/abstractScene" {
  55219. interface AbstractScene {
  55220. /**
  55221. * The list of lens flare system added to the scene
  55222. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55223. */
  55224. lensFlareSystems: Array<LensFlareSystem>;
  55225. /**
  55226. * Removes the given lens flare system from this scene.
  55227. * @param toRemove The lens flare system to remove
  55228. * @returns The index of the removed lens flare system
  55229. */
  55230. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  55231. /**
  55232. * Adds the given lens flare system to this scene
  55233. * @param newLensFlareSystem The lens flare system to add
  55234. */
  55235. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  55236. /**
  55237. * Gets a lens flare system using its name
  55238. * @param name defines the name to look for
  55239. * @returns the lens flare system or null if not found
  55240. */
  55241. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  55242. /**
  55243. * Gets a lens flare system using its id
  55244. * @param id defines the id to look for
  55245. * @returns the lens flare system or null if not found
  55246. */
  55247. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  55248. }
  55249. }
  55250. /**
  55251. * Defines the lens flare scene component responsible to manage any lens flares
  55252. * in a given scene.
  55253. */
  55254. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  55255. /**
  55256. * The component name helpfull to identify the component in the list of scene components.
  55257. */
  55258. readonly name: string;
  55259. /**
  55260. * The scene the component belongs to.
  55261. */
  55262. scene: Scene;
  55263. /**
  55264. * Creates a new instance of the component for the given scene
  55265. * @param scene Defines the scene to register the component in
  55266. */
  55267. constructor(scene: Scene);
  55268. /**
  55269. * Registers the component in a given scene
  55270. */
  55271. register(): void;
  55272. /**
  55273. * Rebuilds the elements related to this component in case of
  55274. * context lost for instance.
  55275. */
  55276. rebuild(): void;
  55277. /**
  55278. * Adds all the elements from the container to the scene
  55279. * @param container the container holding the elements
  55280. */
  55281. addFromContainer(container: AbstractScene): void;
  55282. /**
  55283. * Removes all the elements in the container from the scene
  55284. * @param container contains the elements to remove
  55285. * @param dispose if the removed element should be disposed (default: false)
  55286. */
  55287. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55288. /**
  55289. * Serializes the component data to the specified json object
  55290. * @param serializationObject The object to serialize to
  55291. */
  55292. serialize(serializationObject: any): void;
  55293. /**
  55294. * Disposes the component and the associated ressources.
  55295. */
  55296. dispose(): void;
  55297. private _draw;
  55298. }
  55299. }
  55300. declare module "babylonjs/LensFlares/index" {
  55301. export * from "babylonjs/LensFlares/lensFlare";
  55302. export * from "babylonjs/LensFlares/lensFlareSystem";
  55303. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  55304. }
  55305. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  55306. import { Scene } from "babylonjs/scene";
  55307. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55308. import { AbstractScene } from "babylonjs/abstractScene";
  55309. /**
  55310. * Defines the shadow generator component responsible to manage any shadow generators
  55311. * in a given scene.
  55312. */
  55313. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  55314. /**
  55315. * The component name helpfull to identify the component in the list of scene components.
  55316. */
  55317. readonly name: string;
  55318. /**
  55319. * The scene the component belongs to.
  55320. */
  55321. scene: Scene;
  55322. /**
  55323. * Creates a new instance of the component for the given scene
  55324. * @param scene Defines the scene to register the component in
  55325. */
  55326. constructor(scene: Scene);
  55327. /**
  55328. * Registers the component in a given scene
  55329. */
  55330. register(): void;
  55331. /**
  55332. * Rebuilds the elements related to this component in case of
  55333. * context lost for instance.
  55334. */
  55335. rebuild(): void;
  55336. /**
  55337. * Serializes the component data to the specified json object
  55338. * @param serializationObject The object to serialize to
  55339. */
  55340. serialize(serializationObject: any): void;
  55341. /**
  55342. * Adds all the elements from the container to the scene
  55343. * @param container the container holding the elements
  55344. */
  55345. addFromContainer(container: AbstractScene): void;
  55346. /**
  55347. * Removes all the elements in the container from the scene
  55348. * @param container contains the elements to remove
  55349. * @param dispose if the removed element should be disposed (default: false)
  55350. */
  55351. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55352. /**
  55353. * Rebuilds the elements related to this component in case of
  55354. * context lost for instance.
  55355. */
  55356. dispose(): void;
  55357. private _gatherRenderTargets;
  55358. }
  55359. }
  55360. declare module "babylonjs/Lights/Shadows/index" {
  55361. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  55362. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  55363. }
  55364. declare module "babylonjs/Lights/pointLight" {
  55365. import { Scene } from "babylonjs/scene";
  55366. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55368. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55369. import { Effect } from "babylonjs/Materials/effect";
  55370. /**
  55371. * A point light is a light defined by an unique point in world space.
  55372. * The light is emitted in every direction from this point.
  55373. * A good example of a point light is a standard light bulb.
  55374. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55375. */
  55376. export class PointLight extends ShadowLight {
  55377. private _shadowAngle;
  55378. /**
  55379. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55380. * This specifies what angle the shadow will use to be created.
  55381. *
  55382. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55383. */
  55384. get shadowAngle(): number;
  55385. /**
  55386. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55387. * This specifies what angle the shadow will use to be created.
  55388. *
  55389. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55390. */
  55391. set shadowAngle(value: number);
  55392. /**
  55393. * Gets the direction if it has been set.
  55394. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55395. */
  55396. get direction(): Vector3;
  55397. /**
  55398. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55399. */
  55400. set direction(value: Vector3);
  55401. /**
  55402. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  55403. * A PointLight emits the light in every direction.
  55404. * It can cast shadows.
  55405. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  55406. * ```javascript
  55407. * var pointLight = new PointLight("pl", camera.position, scene);
  55408. * ```
  55409. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55410. * @param name The light friendly name
  55411. * @param position The position of the point light in the scene
  55412. * @param scene The scene the lights belongs to
  55413. */
  55414. constructor(name: string, position: Vector3, scene: Scene);
  55415. /**
  55416. * Returns the string "PointLight"
  55417. * @returns the class name
  55418. */
  55419. getClassName(): string;
  55420. /**
  55421. * Returns the integer 0.
  55422. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55423. */
  55424. getTypeID(): number;
  55425. /**
  55426. * Specifies wether or not the shadowmap should be a cube texture.
  55427. * @returns true if the shadowmap needs to be a cube texture.
  55428. */
  55429. needCube(): boolean;
  55430. /**
  55431. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  55432. * @param faceIndex The index of the face we are computed the direction to generate shadow
  55433. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  55434. */
  55435. getShadowDirection(faceIndex?: number): Vector3;
  55436. /**
  55437. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  55438. * - fov = PI / 2
  55439. * - aspect ratio : 1.0
  55440. * - z-near and far equal to the active camera minZ and maxZ.
  55441. * Returns the PointLight.
  55442. */
  55443. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55444. protected _buildUniformLayout(): void;
  55445. /**
  55446. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  55447. * @param effect The effect to update
  55448. * @param lightIndex The index of the light in the effect to update
  55449. * @returns The point light
  55450. */
  55451. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  55452. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55453. /**
  55454. * Prepares the list of defines specific to the light type.
  55455. * @param defines the list of defines
  55456. * @param lightIndex defines the index of the light for the effect
  55457. */
  55458. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55459. }
  55460. }
  55461. declare module "babylonjs/Lights/index" {
  55462. export * from "babylonjs/Lights/light";
  55463. export * from "babylonjs/Lights/shadowLight";
  55464. export * from "babylonjs/Lights/Shadows/index";
  55465. export * from "babylonjs/Lights/directionalLight";
  55466. export * from "babylonjs/Lights/hemisphericLight";
  55467. export * from "babylonjs/Lights/pointLight";
  55468. export * from "babylonjs/Lights/spotLight";
  55469. }
  55470. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  55471. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  55472. /**
  55473. * Header information of HDR texture files.
  55474. */
  55475. export interface HDRInfo {
  55476. /**
  55477. * The height of the texture in pixels.
  55478. */
  55479. height: number;
  55480. /**
  55481. * The width of the texture in pixels.
  55482. */
  55483. width: number;
  55484. /**
  55485. * The index of the beginning of the data in the binary file.
  55486. */
  55487. dataPosition: number;
  55488. }
  55489. /**
  55490. * This groups tools to convert HDR texture to native colors array.
  55491. */
  55492. export class HDRTools {
  55493. private static Ldexp;
  55494. private static Rgbe2float;
  55495. private static readStringLine;
  55496. /**
  55497. * Reads header information from an RGBE texture stored in a native array.
  55498. * More information on this format are available here:
  55499. * https://en.wikipedia.org/wiki/RGBE_image_format
  55500. *
  55501. * @param uint8array The binary file stored in native array.
  55502. * @return The header information.
  55503. */
  55504. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  55505. /**
  55506. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  55507. * This RGBE texture needs to store the information as a panorama.
  55508. *
  55509. * More information on this format are available here:
  55510. * https://en.wikipedia.org/wiki/RGBE_image_format
  55511. *
  55512. * @param buffer The binary file stored in an array buffer.
  55513. * @param size The expected size of the extracted cubemap.
  55514. * @return The Cube Map information.
  55515. */
  55516. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  55517. /**
  55518. * Returns the pixels data extracted from an RGBE texture.
  55519. * This pixels will be stored left to right up to down in the R G B order in one array.
  55520. *
  55521. * More information on this format are available here:
  55522. * https://en.wikipedia.org/wiki/RGBE_image_format
  55523. *
  55524. * @param uint8array The binary file stored in an array buffer.
  55525. * @param hdrInfo The header information of the file.
  55526. * @return The pixels data in RGB right to left up to down order.
  55527. */
  55528. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  55529. private static RGBE_ReadPixels_RLE;
  55530. }
  55531. }
  55532. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  55533. import { Nullable } from "babylonjs/types";
  55534. import { Scene } from "babylonjs/scene";
  55535. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55536. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55537. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55538. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  55539. /**
  55540. * This represents a texture coming from an HDR input.
  55541. *
  55542. * The only supported format is currently panorama picture stored in RGBE format.
  55543. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55544. */
  55545. export class HDRCubeTexture extends BaseTexture {
  55546. private static _facesMapping;
  55547. private _generateHarmonics;
  55548. private _noMipmap;
  55549. private _textureMatrix;
  55550. private _size;
  55551. private _onLoad;
  55552. private _onError;
  55553. /**
  55554. * The texture URL.
  55555. */
  55556. url: string;
  55557. /**
  55558. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55559. */
  55560. coordinatesMode: number;
  55561. protected _isBlocking: boolean;
  55562. /**
  55563. * Sets wether or not the texture is blocking during loading.
  55564. */
  55565. set isBlocking(value: boolean);
  55566. /**
  55567. * Gets wether or not the texture is blocking during loading.
  55568. */
  55569. get isBlocking(): boolean;
  55570. protected _rotationY: number;
  55571. /**
  55572. * Sets texture matrix rotation angle around Y axis in radians.
  55573. */
  55574. set rotationY(value: number);
  55575. /**
  55576. * Gets texture matrix rotation angle around Y axis radians.
  55577. */
  55578. get rotationY(): number;
  55579. /**
  55580. * Gets or sets the center of the bounding box associated with the cube texture
  55581. * It must define where the camera used to render the texture was set
  55582. */
  55583. boundingBoxPosition: Vector3;
  55584. private _boundingBoxSize;
  55585. /**
  55586. * Gets or sets the size of the bounding box associated with the cube texture
  55587. * When defined, the cubemap will switch to local mode
  55588. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55589. * @example https://www.babylonjs-playground.com/#RNASML
  55590. */
  55591. set boundingBoxSize(value: Vector3);
  55592. get boundingBoxSize(): Vector3;
  55593. /**
  55594. * Instantiates an HDRTexture from the following parameters.
  55595. *
  55596. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55597. * @param scene The scene the texture will be used in
  55598. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55599. * @param noMipmap Forces to not generate the mipmap if true
  55600. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55601. * @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)
  55602. * @param reserved Reserved flag for internal use.
  55603. */
  55604. 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>);
  55605. /**
  55606. * Get the current class name of the texture useful for serialization or dynamic coding.
  55607. * @returns "HDRCubeTexture"
  55608. */
  55609. getClassName(): string;
  55610. /**
  55611. * Occurs when the file is raw .hdr file.
  55612. */
  55613. private loadTexture;
  55614. clone(): HDRCubeTexture;
  55615. delayLoad(): void;
  55616. /**
  55617. * Get the texture reflection matrix used to rotate/transform the reflection.
  55618. * @returns the reflection matrix
  55619. */
  55620. getReflectionTextureMatrix(): Matrix;
  55621. /**
  55622. * Set the texture reflection matrix used to rotate/transform the reflection.
  55623. * @param value Define the reflection matrix to set
  55624. */
  55625. setReflectionTextureMatrix(value: Matrix): void;
  55626. /**
  55627. * Parses a JSON representation of an HDR Texture in order to create the texture
  55628. * @param parsedTexture Define the JSON representation
  55629. * @param scene Define the scene the texture should be created in
  55630. * @param rootUrl Define the root url in case we need to load relative dependencies
  55631. * @returns the newly created texture after parsing
  55632. */
  55633. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55634. serialize(): any;
  55635. }
  55636. }
  55637. declare module "babylonjs/Physics/physicsEngine" {
  55638. import { Nullable } from "babylonjs/types";
  55639. import { Vector3 } from "babylonjs/Maths/math.vector";
  55640. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  55641. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  55642. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  55643. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  55644. /**
  55645. * Class used to control physics engine
  55646. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55647. */
  55648. export class PhysicsEngine implements IPhysicsEngine {
  55649. private _physicsPlugin;
  55650. /**
  55651. * Global value used to control the smallest number supported by the simulation
  55652. */
  55653. static Epsilon: number;
  55654. private _impostors;
  55655. private _joints;
  55656. private _subTimeStep;
  55657. /**
  55658. * Gets the gravity vector used by the simulation
  55659. */
  55660. gravity: Vector3;
  55661. /**
  55662. * Factory used to create the default physics plugin.
  55663. * @returns The default physics plugin
  55664. */
  55665. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55666. /**
  55667. * Creates a new Physics Engine
  55668. * @param gravity defines the gravity vector used by the simulation
  55669. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55670. */
  55671. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55672. /**
  55673. * Sets the gravity vector used by the simulation
  55674. * @param gravity defines the gravity vector to use
  55675. */
  55676. setGravity(gravity: Vector3): void;
  55677. /**
  55678. * Set the time step of the physics engine.
  55679. * Default is 1/60.
  55680. * To slow it down, enter 1/600 for example.
  55681. * To speed it up, 1/30
  55682. * @param newTimeStep defines the new timestep to apply to this world.
  55683. */
  55684. setTimeStep(newTimeStep?: number): void;
  55685. /**
  55686. * Get the time step of the physics engine.
  55687. * @returns the current time step
  55688. */
  55689. getTimeStep(): number;
  55690. /**
  55691. * Set the sub time step of the physics engine.
  55692. * Default is 0 meaning there is no sub steps
  55693. * To increase physics resolution precision, set a small value (like 1 ms)
  55694. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55695. */
  55696. setSubTimeStep(subTimeStep?: number): void;
  55697. /**
  55698. * Get the sub time step of the physics engine.
  55699. * @returns the current sub time step
  55700. */
  55701. getSubTimeStep(): number;
  55702. /**
  55703. * Release all resources
  55704. */
  55705. dispose(): void;
  55706. /**
  55707. * Gets the name of the current physics plugin
  55708. * @returns the name of the plugin
  55709. */
  55710. getPhysicsPluginName(): string;
  55711. /**
  55712. * Adding a new impostor for the impostor tracking.
  55713. * This will be done by the impostor itself.
  55714. * @param impostor the impostor to add
  55715. */
  55716. addImpostor(impostor: PhysicsImpostor): void;
  55717. /**
  55718. * Remove an impostor from the engine.
  55719. * This impostor and its mesh will not longer be updated by the physics engine.
  55720. * @param impostor the impostor to remove
  55721. */
  55722. removeImpostor(impostor: PhysicsImpostor): void;
  55723. /**
  55724. * Add a joint to the physics engine
  55725. * @param mainImpostor defines the main impostor to which the joint is added.
  55726. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55727. * @param joint defines the joint that will connect both impostors.
  55728. */
  55729. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55730. /**
  55731. * Removes a joint from the simulation
  55732. * @param mainImpostor defines the impostor used with the joint
  55733. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55734. * @param joint defines the joint to remove
  55735. */
  55736. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55737. /**
  55738. * Called by the scene. No need to call it.
  55739. * @param delta defines the timespam between frames
  55740. */
  55741. _step(delta: number): void;
  55742. /**
  55743. * Gets the current plugin used to run the simulation
  55744. * @returns current plugin
  55745. */
  55746. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55747. /**
  55748. * Gets the list of physic impostors
  55749. * @returns an array of PhysicsImpostor
  55750. */
  55751. getImpostors(): Array<PhysicsImpostor>;
  55752. /**
  55753. * Gets the impostor for a physics enabled object
  55754. * @param object defines the object impersonated by the impostor
  55755. * @returns the PhysicsImpostor or null if not found
  55756. */
  55757. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55758. /**
  55759. * Gets the impostor for a physics body object
  55760. * @param body defines physics body used by the impostor
  55761. * @returns the PhysicsImpostor or null if not found
  55762. */
  55763. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55764. /**
  55765. * Does a raycast in the physics world
  55766. * @param from when should the ray start?
  55767. * @param to when should the ray end?
  55768. * @returns PhysicsRaycastResult
  55769. */
  55770. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55771. }
  55772. }
  55773. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  55774. import { Nullable } from "babylonjs/types";
  55775. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  55776. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55777. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  55778. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  55779. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  55780. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  55781. /** @hidden */
  55782. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55783. private _useDeltaForWorldStep;
  55784. world: any;
  55785. name: string;
  55786. private _physicsMaterials;
  55787. private _fixedTimeStep;
  55788. private _cannonRaycastResult;
  55789. private _raycastResult;
  55790. private _physicsBodysToRemoveAfterStep;
  55791. BJSCANNON: any;
  55792. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55793. setGravity(gravity: Vector3): void;
  55794. setTimeStep(timeStep: number): void;
  55795. getTimeStep(): number;
  55796. executeStep(delta: number): void;
  55797. private _removeMarkedPhysicsBodiesFromWorld;
  55798. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55799. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55800. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55801. private _processChildMeshes;
  55802. removePhysicsBody(impostor: PhysicsImpostor): void;
  55803. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55804. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55805. private _addMaterial;
  55806. private _checkWithEpsilon;
  55807. private _createShape;
  55808. private _createHeightmap;
  55809. private _minus90X;
  55810. private _plus90X;
  55811. private _tmpPosition;
  55812. private _tmpDeltaPosition;
  55813. private _tmpUnityRotation;
  55814. private _updatePhysicsBodyTransformation;
  55815. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55816. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55817. isSupported(): boolean;
  55818. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55819. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55820. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55821. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55822. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55823. getBodyMass(impostor: PhysicsImpostor): number;
  55824. getBodyFriction(impostor: PhysicsImpostor): number;
  55825. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55826. getBodyRestitution(impostor: PhysicsImpostor): number;
  55827. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55828. sleepBody(impostor: PhysicsImpostor): void;
  55829. wakeUpBody(impostor: PhysicsImpostor): void;
  55830. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55831. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55832. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55833. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55834. getRadius(impostor: PhysicsImpostor): number;
  55835. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55836. dispose(): void;
  55837. private _extendNamespace;
  55838. /**
  55839. * Does a raycast in the physics world
  55840. * @param from when should the ray start?
  55841. * @param to when should the ray end?
  55842. * @returns PhysicsRaycastResult
  55843. */
  55844. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55845. }
  55846. }
  55847. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  55848. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  55849. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  55850. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  55851. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55852. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  55853. import { Nullable } from "babylonjs/types";
  55854. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  55855. /** @hidden */
  55856. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55857. world: any;
  55858. name: string;
  55859. BJSOIMO: any;
  55860. private _raycastResult;
  55861. constructor(iterations?: number, oimoInjection?: any);
  55862. setGravity(gravity: Vector3): void;
  55863. setTimeStep(timeStep: number): void;
  55864. getTimeStep(): number;
  55865. private _tmpImpostorsArray;
  55866. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55867. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55868. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55869. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55870. private _tmpPositionVector;
  55871. removePhysicsBody(impostor: PhysicsImpostor): void;
  55872. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55873. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55874. isSupported(): boolean;
  55875. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55876. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55877. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55878. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55879. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55880. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55881. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55882. getBodyMass(impostor: PhysicsImpostor): number;
  55883. getBodyFriction(impostor: PhysicsImpostor): number;
  55884. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55885. getBodyRestitution(impostor: PhysicsImpostor): number;
  55886. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55887. sleepBody(impostor: PhysicsImpostor): void;
  55888. wakeUpBody(impostor: PhysicsImpostor): void;
  55889. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55890. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55891. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55892. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55893. getRadius(impostor: PhysicsImpostor): number;
  55894. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55895. dispose(): void;
  55896. /**
  55897. * Does a raycast in the physics world
  55898. * @param from when should the ray start?
  55899. * @param to when should the ray end?
  55900. * @returns PhysicsRaycastResult
  55901. */
  55902. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55903. }
  55904. }
  55905. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  55906. import { Nullable } from "babylonjs/types";
  55907. import { Scene } from "babylonjs/scene";
  55908. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  55909. import { Color4 } from "babylonjs/Maths/math.color";
  55910. import { Mesh } from "babylonjs/Meshes/mesh";
  55911. /**
  55912. * Class containing static functions to help procedurally build meshes
  55913. */
  55914. export class RibbonBuilder {
  55915. /**
  55916. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55917. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55918. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55919. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55920. * * 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
  55921. * * 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
  55922. * * 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
  55923. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55924. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55925. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55926. * * 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
  55927. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55928. * * 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
  55929. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55931. * @param name defines the name of the mesh
  55932. * @param options defines the options used to create the mesh
  55933. * @param scene defines the hosting scene
  55934. * @returns the ribbon mesh
  55935. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55936. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55937. */
  55938. static CreateRibbon(name: string, options: {
  55939. pathArray: Vector3[][];
  55940. closeArray?: boolean;
  55941. closePath?: boolean;
  55942. offset?: number;
  55943. updatable?: boolean;
  55944. sideOrientation?: number;
  55945. frontUVs?: Vector4;
  55946. backUVs?: Vector4;
  55947. instance?: Mesh;
  55948. invertUV?: boolean;
  55949. uvs?: Vector2[];
  55950. colors?: Color4[];
  55951. }, scene?: Nullable<Scene>): Mesh;
  55952. }
  55953. }
  55954. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  55955. import { Nullable } from "babylonjs/types";
  55956. import { Scene } from "babylonjs/scene";
  55957. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  55958. import { Mesh } from "babylonjs/Meshes/mesh";
  55959. /**
  55960. * Class containing static functions to help procedurally build meshes
  55961. */
  55962. export class ShapeBuilder {
  55963. /**
  55964. * 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.
  55965. * * 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.
  55966. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55967. * * 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.
  55968. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55969. * * 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
  55970. * * 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
  55971. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55972. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55973. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55974. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55975. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55976. * @param name defines the name of the mesh
  55977. * @param options defines the options used to create the mesh
  55978. * @param scene defines the hosting scene
  55979. * @returns the extruded shape mesh
  55980. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55981. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55982. */
  55983. static ExtrudeShape(name: string, options: {
  55984. shape: Vector3[];
  55985. path: Vector3[];
  55986. scale?: number;
  55987. rotation?: number;
  55988. cap?: number;
  55989. updatable?: boolean;
  55990. sideOrientation?: number;
  55991. frontUVs?: Vector4;
  55992. backUVs?: Vector4;
  55993. instance?: Mesh;
  55994. invertUV?: boolean;
  55995. }, scene?: Nullable<Scene>): Mesh;
  55996. /**
  55997. * Creates an custom extruded shape mesh.
  55998. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55999. * * 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.
  56000. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56001. * * 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
  56002. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56003. * * 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
  56004. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56005. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56006. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56007. * * 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
  56008. * * 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
  56009. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56010. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56011. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56012. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56014. * @param name defines the name of the mesh
  56015. * @param options defines the options used to create the mesh
  56016. * @param scene defines the hosting scene
  56017. * @returns the custom extruded shape mesh
  56018. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56019. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56020. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56021. */
  56022. static ExtrudeShapeCustom(name: string, options: {
  56023. shape: Vector3[];
  56024. path: Vector3[];
  56025. scaleFunction?: any;
  56026. rotationFunction?: any;
  56027. ribbonCloseArray?: boolean;
  56028. ribbonClosePath?: boolean;
  56029. cap?: number;
  56030. updatable?: boolean;
  56031. sideOrientation?: number;
  56032. frontUVs?: Vector4;
  56033. backUVs?: Vector4;
  56034. instance?: Mesh;
  56035. invertUV?: boolean;
  56036. }, scene?: Nullable<Scene>): Mesh;
  56037. private static _ExtrudeShapeGeneric;
  56038. }
  56039. }
  56040. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  56041. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  56042. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  56043. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56044. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  56045. import { Nullable } from "babylonjs/types";
  56046. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56047. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  56048. /**
  56049. * AmmoJS Physics plugin
  56050. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  56051. * @see https://github.com/kripken/ammo.js/
  56052. */
  56053. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  56054. private _useDeltaForWorldStep;
  56055. /**
  56056. * Reference to the Ammo library
  56057. */
  56058. bjsAMMO: any;
  56059. /**
  56060. * Created ammoJS world which physics bodies are added to
  56061. */
  56062. world: any;
  56063. /**
  56064. * Name of the plugin
  56065. */
  56066. name: string;
  56067. private _timeStep;
  56068. private _fixedTimeStep;
  56069. private _maxSteps;
  56070. private _tmpQuaternion;
  56071. private _tmpAmmoTransform;
  56072. private _tmpAmmoQuaternion;
  56073. private _tmpAmmoConcreteContactResultCallback;
  56074. private _collisionConfiguration;
  56075. private _dispatcher;
  56076. private _overlappingPairCache;
  56077. private _solver;
  56078. private _softBodySolver;
  56079. private _tmpAmmoVectorA;
  56080. private _tmpAmmoVectorB;
  56081. private _tmpAmmoVectorC;
  56082. private _tmpAmmoVectorD;
  56083. private _tmpContactCallbackResult;
  56084. private _tmpAmmoVectorRCA;
  56085. private _tmpAmmoVectorRCB;
  56086. private _raycastResult;
  56087. private static readonly DISABLE_COLLISION_FLAG;
  56088. private static readonly KINEMATIC_FLAG;
  56089. private static readonly DISABLE_DEACTIVATION_FLAG;
  56090. /**
  56091. * Initializes the ammoJS plugin
  56092. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  56093. * @param ammoInjection can be used to inject your own ammo reference
  56094. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  56095. */
  56096. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  56097. /**
  56098. * Sets the gravity of the physics world (m/(s^2))
  56099. * @param gravity Gravity to set
  56100. */
  56101. setGravity(gravity: Vector3): void;
  56102. /**
  56103. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  56104. * @param timeStep timestep to use in seconds
  56105. */
  56106. setTimeStep(timeStep: number): void;
  56107. /**
  56108. * 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)
  56109. * @param fixedTimeStep fixedTimeStep to use in seconds
  56110. */
  56111. setFixedTimeStep(fixedTimeStep: number): void;
  56112. /**
  56113. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  56114. * @param maxSteps the maximum number of steps by the physics engine per frame
  56115. */
  56116. setMaxSteps(maxSteps: number): void;
  56117. /**
  56118. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  56119. * @returns the current timestep in seconds
  56120. */
  56121. getTimeStep(): number;
  56122. /**
  56123. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  56124. */
  56125. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  56126. private _isImpostorInContact;
  56127. private _isImpostorPairInContact;
  56128. private _stepSimulation;
  56129. /**
  56130. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  56131. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  56132. * After the step the babylon meshes are set to the position of the physics imposters
  56133. * @param delta amount of time to step forward
  56134. * @param impostors array of imposters to update before/after the step
  56135. */
  56136. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  56137. /**
  56138. * Update babylon mesh to match physics world object
  56139. * @param impostor imposter to match
  56140. */
  56141. private _afterSoftStep;
  56142. /**
  56143. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  56144. * @param impostor imposter to match
  56145. */
  56146. private _ropeStep;
  56147. /**
  56148. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  56149. * @param impostor imposter to match
  56150. */
  56151. private _softbodyOrClothStep;
  56152. private _tmpVector;
  56153. private _tmpMatrix;
  56154. /**
  56155. * Applies an impulse on the imposter
  56156. * @param impostor imposter to apply impulse to
  56157. * @param force amount of force to be applied to the imposter
  56158. * @param contactPoint the location to apply the impulse on the imposter
  56159. */
  56160. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56161. /**
  56162. * Applies a force on the imposter
  56163. * @param impostor imposter to apply force
  56164. * @param force amount of force to be applied to the imposter
  56165. * @param contactPoint the location to apply the force on the imposter
  56166. */
  56167. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56168. /**
  56169. * Creates a physics body using the plugin
  56170. * @param impostor the imposter to create the physics body on
  56171. */
  56172. generatePhysicsBody(impostor: PhysicsImpostor): void;
  56173. /**
  56174. * Removes the physics body from the imposter and disposes of the body's memory
  56175. * @param impostor imposter to remove the physics body from
  56176. */
  56177. removePhysicsBody(impostor: PhysicsImpostor): void;
  56178. /**
  56179. * Generates a joint
  56180. * @param impostorJoint the imposter joint to create the joint with
  56181. */
  56182. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  56183. /**
  56184. * Removes a joint
  56185. * @param impostorJoint the imposter joint to remove the joint from
  56186. */
  56187. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  56188. private _addMeshVerts;
  56189. /**
  56190. * Initialise the soft body vertices to match its object's (mesh) vertices
  56191. * Softbody vertices (nodes) are in world space and to match this
  56192. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  56193. * @param impostor to create the softbody for
  56194. */
  56195. private _softVertexData;
  56196. /**
  56197. * Create an impostor's soft body
  56198. * @param impostor to create the softbody for
  56199. */
  56200. private _createSoftbody;
  56201. /**
  56202. * Create cloth for an impostor
  56203. * @param impostor to create the softbody for
  56204. */
  56205. private _createCloth;
  56206. /**
  56207. * Create rope for an impostor
  56208. * @param impostor to create the softbody for
  56209. */
  56210. private _createRope;
  56211. /**
  56212. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  56213. * @param impostor to create the custom physics shape for
  56214. */
  56215. private _createCustom;
  56216. private _addHullVerts;
  56217. private _createShape;
  56218. /**
  56219. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  56220. * @param impostor imposter containing the physics body and babylon object
  56221. */
  56222. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  56223. /**
  56224. * Sets the babylon object's position/rotation from the physics body's position/rotation
  56225. * @param impostor imposter containing the physics body and babylon object
  56226. * @param newPosition new position
  56227. * @param newRotation new rotation
  56228. */
  56229. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  56230. /**
  56231. * If this plugin is supported
  56232. * @returns true if its supported
  56233. */
  56234. isSupported(): boolean;
  56235. /**
  56236. * Sets the linear velocity of the physics body
  56237. * @param impostor imposter to set the velocity on
  56238. * @param velocity velocity to set
  56239. */
  56240. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56241. /**
  56242. * Sets the angular velocity of the physics body
  56243. * @param impostor imposter to set the velocity on
  56244. * @param velocity velocity to set
  56245. */
  56246. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56247. /**
  56248. * gets the linear velocity
  56249. * @param impostor imposter to get linear velocity from
  56250. * @returns linear velocity
  56251. */
  56252. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56253. /**
  56254. * gets the angular velocity
  56255. * @param impostor imposter to get angular velocity from
  56256. * @returns angular velocity
  56257. */
  56258. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56259. /**
  56260. * Sets the mass of physics body
  56261. * @param impostor imposter to set the mass on
  56262. * @param mass mass to set
  56263. */
  56264. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  56265. /**
  56266. * Gets the mass of the physics body
  56267. * @param impostor imposter to get the mass from
  56268. * @returns mass
  56269. */
  56270. getBodyMass(impostor: PhysicsImpostor): number;
  56271. /**
  56272. * Gets friction of the impostor
  56273. * @param impostor impostor to get friction from
  56274. * @returns friction value
  56275. */
  56276. getBodyFriction(impostor: PhysicsImpostor): number;
  56277. /**
  56278. * Sets friction of the impostor
  56279. * @param impostor impostor to set friction on
  56280. * @param friction friction value
  56281. */
  56282. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  56283. /**
  56284. * Gets restitution of the impostor
  56285. * @param impostor impostor to get restitution from
  56286. * @returns restitution value
  56287. */
  56288. getBodyRestitution(impostor: PhysicsImpostor): number;
  56289. /**
  56290. * Sets resitution of the impostor
  56291. * @param impostor impostor to set resitution on
  56292. * @param restitution resitution value
  56293. */
  56294. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  56295. /**
  56296. * Gets pressure inside the impostor
  56297. * @param impostor impostor to get pressure from
  56298. * @returns pressure value
  56299. */
  56300. getBodyPressure(impostor: PhysicsImpostor): number;
  56301. /**
  56302. * Sets pressure inside a soft body impostor
  56303. * Cloth and rope must remain 0 pressure
  56304. * @param impostor impostor to set pressure on
  56305. * @param pressure pressure value
  56306. */
  56307. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  56308. /**
  56309. * Gets stiffness of the impostor
  56310. * @param impostor impostor to get stiffness from
  56311. * @returns pressure value
  56312. */
  56313. getBodyStiffness(impostor: PhysicsImpostor): number;
  56314. /**
  56315. * Sets stiffness of the impostor
  56316. * @param impostor impostor to set stiffness on
  56317. * @param stiffness stiffness value from 0 to 1
  56318. */
  56319. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  56320. /**
  56321. * Gets velocityIterations of the impostor
  56322. * @param impostor impostor to get velocity iterations from
  56323. * @returns velocityIterations value
  56324. */
  56325. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  56326. /**
  56327. * Sets velocityIterations of the impostor
  56328. * @param impostor impostor to set velocity iterations on
  56329. * @param velocityIterations velocityIterations value
  56330. */
  56331. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  56332. /**
  56333. * Gets positionIterations of the impostor
  56334. * @param impostor impostor to get position iterations from
  56335. * @returns positionIterations value
  56336. */
  56337. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  56338. /**
  56339. * Sets positionIterations of the impostor
  56340. * @param impostor impostor to set position on
  56341. * @param positionIterations positionIterations value
  56342. */
  56343. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  56344. /**
  56345. * Append an anchor to a cloth object
  56346. * @param impostor is the cloth impostor to add anchor to
  56347. * @param otherImpostor is the rigid impostor to anchor to
  56348. * @param width ratio across width from 0 to 1
  56349. * @param height ratio up height from 0 to 1
  56350. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  56351. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56352. */
  56353. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56354. /**
  56355. * Append an hook to a rope object
  56356. * @param impostor is the rope impostor to add hook to
  56357. * @param otherImpostor is the rigid impostor to hook to
  56358. * @param length ratio along the rope from 0 to 1
  56359. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  56360. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56361. */
  56362. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56363. /**
  56364. * Sleeps the physics body and stops it from being active
  56365. * @param impostor impostor to sleep
  56366. */
  56367. sleepBody(impostor: PhysicsImpostor): void;
  56368. /**
  56369. * Activates the physics body
  56370. * @param impostor impostor to activate
  56371. */
  56372. wakeUpBody(impostor: PhysicsImpostor): void;
  56373. /**
  56374. * Updates the distance parameters of the joint
  56375. * @param joint joint to update
  56376. * @param maxDistance maximum distance of the joint
  56377. * @param minDistance minimum distance of the joint
  56378. */
  56379. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  56380. /**
  56381. * Sets a motor on the joint
  56382. * @param joint joint to set motor on
  56383. * @param speed speed of the motor
  56384. * @param maxForce maximum force of the motor
  56385. * @param motorIndex index of the motor
  56386. */
  56387. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  56388. /**
  56389. * Sets the motors limit
  56390. * @param joint joint to set limit on
  56391. * @param upperLimit upper limit
  56392. * @param lowerLimit lower limit
  56393. */
  56394. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  56395. /**
  56396. * Syncs the position and rotation of a mesh with the impostor
  56397. * @param mesh mesh to sync
  56398. * @param impostor impostor to update the mesh with
  56399. */
  56400. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56401. /**
  56402. * Gets the radius of the impostor
  56403. * @param impostor impostor to get radius from
  56404. * @returns the radius
  56405. */
  56406. getRadius(impostor: PhysicsImpostor): number;
  56407. /**
  56408. * Gets the box size of the impostor
  56409. * @param impostor impostor to get box size from
  56410. * @param result the resulting box size
  56411. */
  56412. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56413. /**
  56414. * Disposes of the impostor
  56415. */
  56416. dispose(): void;
  56417. /**
  56418. * Does a raycast in the physics world
  56419. * @param from when should the ray start?
  56420. * @param to when should the ray end?
  56421. * @returns PhysicsRaycastResult
  56422. */
  56423. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56424. }
  56425. }
  56426. declare module "babylonjs/Probes/reflectionProbe" {
  56427. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56428. import { Vector3 } from "babylonjs/Maths/math.vector";
  56429. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56430. import { Nullable } from "babylonjs/types";
  56431. import { Scene } from "babylonjs/scene";
  56432. module "babylonjs/abstractScene" {
  56433. interface AbstractScene {
  56434. /**
  56435. * The list of reflection probes added to the scene
  56436. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56437. */
  56438. reflectionProbes: Array<ReflectionProbe>;
  56439. /**
  56440. * Removes the given reflection probe from this scene.
  56441. * @param toRemove The reflection probe to remove
  56442. * @returns The index of the removed reflection probe
  56443. */
  56444. removeReflectionProbe(toRemove: ReflectionProbe): number;
  56445. /**
  56446. * Adds the given reflection probe to this scene.
  56447. * @param newReflectionProbe The reflection probe to add
  56448. */
  56449. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  56450. }
  56451. }
  56452. /**
  56453. * Class used to generate realtime reflection / refraction cube textures
  56454. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56455. */
  56456. export class ReflectionProbe {
  56457. /** defines the name of the probe */
  56458. name: string;
  56459. private _scene;
  56460. private _renderTargetTexture;
  56461. private _projectionMatrix;
  56462. private _viewMatrix;
  56463. private _target;
  56464. private _add;
  56465. private _attachedMesh;
  56466. private _invertYAxis;
  56467. /** Gets or sets probe position (center of the cube map) */
  56468. position: Vector3;
  56469. /**
  56470. * Creates a new reflection probe
  56471. * @param name defines the name of the probe
  56472. * @param size defines the texture resolution (for each face)
  56473. * @param scene defines the hosting scene
  56474. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  56475. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  56476. */
  56477. constructor(
  56478. /** defines the name of the probe */
  56479. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  56480. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  56481. get samples(): number;
  56482. set samples(value: number);
  56483. /** Gets or sets the refresh rate to use (on every frame by default) */
  56484. get refreshRate(): number;
  56485. set refreshRate(value: number);
  56486. /**
  56487. * Gets the hosting scene
  56488. * @returns a Scene
  56489. */
  56490. getScene(): Scene;
  56491. /** Gets the internal CubeTexture used to render to */
  56492. get cubeTexture(): RenderTargetTexture;
  56493. /** Gets the list of meshes to render */
  56494. get renderList(): Nullable<AbstractMesh[]>;
  56495. /**
  56496. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  56497. * @param mesh defines the mesh to attach to
  56498. */
  56499. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56500. /**
  56501. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  56502. * @param renderingGroupId The rendering group id corresponding to its index
  56503. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  56504. */
  56505. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  56506. /**
  56507. * Clean all associated resources
  56508. */
  56509. dispose(): void;
  56510. /**
  56511. * Converts the reflection probe information to a readable string for debug purpose.
  56512. * @param fullDetails Supports for multiple levels of logging within scene loading
  56513. * @returns the human readable reflection probe info
  56514. */
  56515. toString(fullDetails?: boolean): string;
  56516. /**
  56517. * Get the class name of the relfection probe.
  56518. * @returns "ReflectionProbe"
  56519. */
  56520. getClassName(): string;
  56521. /**
  56522. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  56523. * @returns The JSON representation of the texture
  56524. */
  56525. serialize(): any;
  56526. /**
  56527. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  56528. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  56529. * @param scene Define the scene the parsed reflection probe should be instantiated in
  56530. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  56531. * @returns The parsed reflection probe if successful
  56532. */
  56533. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  56534. }
  56535. }
  56536. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  56537. /** @hidden */
  56538. export var _BabylonLoaderRegistered: boolean;
  56539. /**
  56540. * Helps setting up some configuration for the babylon file loader.
  56541. */
  56542. export class BabylonFileLoaderConfiguration {
  56543. /**
  56544. * The loader does not allow injecting custom physix engine into the plugins.
  56545. * Unfortunately in ES6, we need to manually inject them into the plugin.
  56546. * So you could set this variable to your engine import to make it work.
  56547. */
  56548. static LoaderInjectedPhysicsEngine: any;
  56549. }
  56550. }
  56551. declare module "babylonjs/Loading/Plugins/index" {
  56552. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  56553. }
  56554. declare module "babylonjs/Loading/index" {
  56555. export * from "babylonjs/Loading/loadingScreen";
  56556. export * from "babylonjs/Loading/Plugins/index";
  56557. export * from "babylonjs/Loading/sceneLoader";
  56558. export * from "babylonjs/Loading/sceneLoaderFlags";
  56559. }
  56560. declare module "babylonjs/Materials/Background/index" {
  56561. export * from "babylonjs/Materials/Background/backgroundMaterial";
  56562. }
  56563. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  56564. import { Scene } from "babylonjs/scene";
  56565. import { Color3 } from "babylonjs/Maths/math.color";
  56566. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  56567. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56568. /**
  56569. * The Physically based simple base material of BJS.
  56570. *
  56571. * This enables better naming and convention enforcements on top of the pbrMaterial.
  56572. * It is used as the base class for both the specGloss and metalRough conventions.
  56573. */
  56574. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  56575. /**
  56576. * Number of Simultaneous lights allowed on the material.
  56577. */
  56578. maxSimultaneousLights: number;
  56579. /**
  56580. * If sets to true, disables all the lights affecting the material.
  56581. */
  56582. disableLighting: boolean;
  56583. /**
  56584. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  56585. */
  56586. environmentTexture: BaseTexture;
  56587. /**
  56588. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56589. */
  56590. invertNormalMapX: boolean;
  56591. /**
  56592. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56593. */
  56594. invertNormalMapY: boolean;
  56595. /**
  56596. * Normal map used in the model.
  56597. */
  56598. normalTexture: BaseTexture;
  56599. /**
  56600. * Emissivie color used to self-illuminate the model.
  56601. */
  56602. emissiveColor: Color3;
  56603. /**
  56604. * Emissivie texture used to self-illuminate the model.
  56605. */
  56606. emissiveTexture: BaseTexture;
  56607. /**
  56608. * Occlusion Channel Strenght.
  56609. */
  56610. occlusionStrength: number;
  56611. /**
  56612. * Occlusion Texture of the material (adding extra occlusion effects).
  56613. */
  56614. occlusionTexture: BaseTexture;
  56615. /**
  56616. * Defines the alpha limits in alpha test mode.
  56617. */
  56618. alphaCutOff: number;
  56619. /**
  56620. * Gets the current double sided mode.
  56621. */
  56622. get doubleSided(): boolean;
  56623. /**
  56624. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56625. */
  56626. set doubleSided(value: boolean);
  56627. /**
  56628. * Stores the pre-calculated light information of a mesh in a texture.
  56629. */
  56630. lightmapTexture: BaseTexture;
  56631. /**
  56632. * If true, the light map contains occlusion information instead of lighting info.
  56633. */
  56634. useLightmapAsShadowmap: boolean;
  56635. /**
  56636. * Instantiates a new PBRMaterial instance.
  56637. *
  56638. * @param name The material name
  56639. * @param scene The scene the material will be use in.
  56640. */
  56641. constructor(name: string, scene: Scene);
  56642. getClassName(): string;
  56643. }
  56644. }
  56645. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  56646. import { Scene } from "babylonjs/scene";
  56647. import { Color3 } from "babylonjs/Maths/math.color";
  56648. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56649. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  56650. /**
  56651. * The PBR material of BJS following the metal roughness convention.
  56652. *
  56653. * This fits to the PBR convention in the GLTF definition:
  56654. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56655. */
  56656. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56657. /**
  56658. * The base color has two different interpretations depending on the value of metalness.
  56659. * When the material is a metal, the base color is the specific measured reflectance value
  56660. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56661. * of the material.
  56662. */
  56663. baseColor: Color3;
  56664. /**
  56665. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56666. * well as opacity information in the alpha channel.
  56667. */
  56668. baseTexture: BaseTexture;
  56669. /**
  56670. * Specifies the metallic scalar value of the material.
  56671. * Can also be used to scale the metalness values of the metallic texture.
  56672. */
  56673. metallic: number;
  56674. /**
  56675. * Specifies the roughness scalar value of the material.
  56676. * Can also be used to scale the roughness values of the metallic texture.
  56677. */
  56678. roughness: number;
  56679. /**
  56680. * Texture containing both the metallic value in the B channel and the
  56681. * roughness value in the G channel to keep better precision.
  56682. */
  56683. metallicRoughnessTexture: BaseTexture;
  56684. /**
  56685. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56686. *
  56687. * @param name The material name
  56688. * @param scene The scene the material will be use in.
  56689. */
  56690. constructor(name: string, scene: Scene);
  56691. /**
  56692. * Return the currrent class name of the material.
  56693. */
  56694. getClassName(): string;
  56695. /**
  56696. * Makes a duplicate of the current material.
  56697. * @param name - name to use for the new material.
  56698. */
  56699. clone(name: string): PBRMetallicRoughnessMaterial;
  56700. /**
  56701. * Serialize the material to a parsable JSON object.
  56702. */
  56703. serialize(): any;
  56704. /**
  56705. * Parses a JSON object correponding to the serialize function.
  56706. */
  56707. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56708. }
  56709. }
  56710. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  56711. import { Scene } from "babylonjs/scene";
  56712. import { Color3 } from "babylonjs/Maths/math.color";
  56713. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56714. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  56715. /**
  56716. * The PBR material of BJS following the specular glossiness convention.
  56717. *
  56718. * This fits to the PBR convention in the GLTF definition:
  56719. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56720. */
  56721. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56722. /**
  56723. * Specifies the diffuse color of the material.
  56724. */
  56725. diffuseColor: Color3;
  56726. /**
  56727. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56728. * channel.
  56729. */
  56730. diffuseTexture: BaseTexture;
  56731. /**
  56732. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56733. */
  56734. specularColor: Color3;
  56735. /**
  56736. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56737. */
  56738. glossiness: number;
  56739. /**
  56740. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56741. */
  56742. specularGlossinessTexture: BaseTexture;
  56743. /**
  56744. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56745. *
  56746. * @param name The material name
  56747. * @param scene The scene the material will be use in.
  56748. */
  56749. constructor(name: string, scene: Scene);
  56750. /**
  56751. * Return the currrent class name of the material.
  56752. */
  56753. getClassName(): string;
  56754. /**
  56755. * Makes a duplicate of the current material.
  56756. * @param name - name to use for the new material.
  56757. */
  56758. clone(name: string): PBRSpecularGlossinessMaterial;
  56759. /**
  56760. * Serialize the material to a parsable JSON object.
  56761. */
  56762. serialize(): any;
  56763. /**
  56764. * Parses a JSON object correponding to the serialize function.
  56765. */
  56766. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56767. }
  56768. }
  56769. declare module "babylonjs/Materials/PBR/index" {
  56770. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  56771. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  56772. export * from "babylonjs/Materials/PBR/pbrMaterial";
  56773. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  56774. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  56775. }
  56776. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  56777. import { Nullable } from "babylonjs/types";
  56778. import { Scene } from "babylonjs/scene";
  56779. import { Matrix } from "babylonjs/Maths/math.vector";
  56780. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56781. /**
  56782. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56783. * It can help converting any input color in a desired output one. This can then be used to create effects
  56784. * from sepia, black and white to sixties or futuristic rendering...
  56785. *
  56786. * The only supported format is currently 3dl.
  56787. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56788. */
  56789. export class ColorGradingTexture extends BaseTexture {
  56790. /**
  56791. * The current texture matrix. (will always be identity in color grading texture)
  56792. */
  56793. private _textureMatrix;
  56794. /**
  56795. * The texture URL.
  56796. */
  56797. url: string;
  56798. /**
  56799. * Empty line regex stored for GC.
  56800. */
  56801. private static _noneEmptyLineRegex;
  56802. private _engine;
  56803. /**
  56804. * Instantiates a ColorGradingTexture from the following parameters.
  56805. *
  56806. * @param url The location of the color gradind data (currently only supporting 3dl)
  56807. * @param scene The scene the texture will be used in
  56808. */
  56809. constructor(url: string, scene: Scene);
  56810. /**
  56811. * Returns the texture matrix used in most of the material.
  56812. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56813. */
  56814. getTextureMatrix(): Matrix;
  56815. /**
  56816. * Occurs when the file being loaded is a .3dl LUT file.
  56817. */
  56818. private load3dlTexture;
  56819. /**
  56820. * Starts the loading process of the texture.
  56821. */
  56822. private loadTexture;
  56823. /**
  56824. * Clones the color gradind texture.
  56825. */
  56826. clone(): ColorGradingTexture;
  56827. /**
  56828. * Called during delayed load for textures.
  56829. */
  56830. delayLoad(): void;
  56831. /**
  56832. * Parses a color grading texture serialized by Babylon.
  56833. * @param parsedTexture The texture information being parsedTexture
  56834. * @param scene The scene to load the texture in
  56835. * @param rootUrl The root url of the data assets to load
  56836. * @return A color gradind texture
  56837. */
  56838. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56839. /**
  56840. * Serializes the LUT texture to json format.
  56841. */
  56842. serialize(): any;
  56843. }
  56844. }
  56845. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  56846. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56847. import { Scene } from "babylonjs/scene";
  56848. import { Nullable } from "babylonjs/types";
  56849. import "babylonjs/Engines/Extensions/engine.rawTexture";
  56850. /**
  56851. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56852. */
  56853. export class EquiRectangularCubeTexture extends BaseTexture {
  56854. /** The six faces of the cube. */
  56855. private static _FacesMapping;
  56856. private _noMipmap;
  56857. private _onLoad;
  56858. private _onError;
  56859. /** The size of the cubemap. */
  56860. private _size;
  56861. /** The buffer of the image. */
  56862. private _buffer;
  56863. /** The width of the input image. */
  56864. private _width;
  56865. /** The height of the input image. */
  56866. private _height;
  56867. /** The URL to the image. */
  56868. url: string;
  56869. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56870. coordinatesMode: number;
  56871. /**
  56872. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56873. * @param url The location of the image
  56874. * @param scene The scene the texture will be used in
  56875. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56876. * @param noMipmap Forces to not generate the mipmap if true
  56877. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56878. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56879. * @param onLoad — defines a callback called when texture is loaded
  56880. * @param onError — defines a callback called if there is an error
  56881. */
  56882. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56883. /**
  56884. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56885. */
  56886. private loadImage;
  56887. /**
  56888. * Convert the image buffer into a cubemap and create a CubeTexture.
  56889. */
  56890. private loadTexture;
  56891. /**
  56892. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56893. * @param buffer The ArrayBuffer that should be converted.
  56894. * @returns The buffer as Float32Array.
  56895. */
  56896. private getFloat32ArrayFromArrayBuffer;
  56897. /**
  56898. * Get the current class name of the texture useful for serialization or dynamic coding.
  56899. * @returns "EquiRectangularCubeTexture"
  56900. */
  56901. getClassName(): string;
  56902. /**
  56903. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56904. * @returns A clone of the current EquiRectangularCubeTexture.
  56905. */
  56906. clone(): EquiRectangularCubeTexture;
  56907. }
  56908. }
  56909. declare module "babylonjs/Misc/tga" {
  56910. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  56911. /**
  56912. * Based on jsTGALoader - Javascript loader for TGA file
  56913. * By Vincent Thibault
  56914. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56915. */
  56916. export class TGATools {
  56917. private static _TYPE_INDEXED;
  56918. private static _TYPE_RGB;
  56919. private static _TYPE_GREY;
  56920. private static _TYPE_RLE_INDEXED;
  56921. private static _TYPE_RLE_RGB;
  56922. private static _TYPE_RLE_GREY;
  56923. private static _ORIGIN_MASK;
  56924. private static _ORIGIN_SHIFT;
  56925. private static _ORIGIN_BL;
  56926. private static _ORIGIN_BR;
  56927. private static _ORIGIN_UL;
  56928. private static _ORIGIN_UR;
  56929. /**
  56930. * Gets the header of a TGA file
  56931. * @param data defines the TGA data
  56932. * @returns the header
  56933. */
  56934. static GetTGAHeader(data: Uint8Array): any;
  56935. /**
  56936. * Uploads TGA content to a Babylon Texture
  56937. * @hidden
  56938. */
  56939. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56940. /** @hidden */
  56941. 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;
  56942. /** @hidden */
  56943. 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;
  56944. /** @hidden */
  56945. 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;
  56946. /** @hidden */
  56947. 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;
  56948. /** @hidden */
  56949. 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;
  56950. /** @hidden */
  56951. 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;
  56952. }
  56953. }
  56954. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  56955. import { Nullable } from "babylonjs/types";
  56956. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  56957. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  56958. /**
  56959. * Implementation of the TGA Texture Loader.
  56960. * @hidden
  56961. */
  56962. export class _TGATextureLoader implements IInternalTextureLoader {
  56963. /**
  56964. * Defines wether the loader supports cascade loading the different faces.
  56965. */
  56966. readonly supportCascades: boolean;
  56967. /**
  56968. * This returns if the loader support the current file information.
  56969. * @param extension defines the file extension of the file being loaded
  56970. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56971. * @param fallback defines the fallback internal texture if any
  56972. * @param isBase64 defines whether the texture is encoded as a base64
  56973. * @param isBuffer defines whether the texture data are stored as a buffer
  56974. * @returns true if the loader can load the specified file
  56975. */
  56976. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  56977. /**
  56978. * Transform the url before loading if required.
  56979. * @param rootUrl the url of the texture
  56980. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56981. * @returns the transformed texture
  56982. */
  56983. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  56984. /**
  56985. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56986. * @param rootUrl the url of the texture
  56987. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56988. * @returns the fallback texture
  56989. */
  56990. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  56991. /**
  56992. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  56993. * @param data contains the texture data
  56994. * @param texture defines the BabylonJS internal texture
  56995. * @param createPolynomials will be true if polynomials have been requested
  56996. * @param onLoad defines the callback to trigger once the texture is ready
  56997. * @param onError defines the callback to trigger in case of error
  56998. */
  56999. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57000. /**
  57001. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  57002. * @param data contains the texture data
  57003. * @param texture defines the BabylonJS internal texture
  57004. * @param callback defines the method to call once ready to upload
  57005. */
  57006. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57007. }
  57008. }
  57009. declare module "babylonjs/Misc/basis" {
  57010. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57011. /**
  57012. * Info about the .basis files
  57013. */
  57014. class BasisFileInfo {
  57015. /**
  57016. * If the file has alpha
  57017. */
  57018. hasAlpha: boolean;
  57019. /**
  57020. * Info about each image of the basis file
  57021. */
  57022. images: Array<{
  57023. levels: Array<{
  57024. width: number;
  57025. height: number;
  57026. transcodedPixels: ArrayBufferView;
  57027. }>;
  57028. }>;
  57029. }
  57030. /**
  57031. * Result of transcoding a basis file
  57032. */
  57033. class TranscodeResult {
  57034. /**
  57035. * Info about the .basis file
  57036. */
  57037. fileInfo: BasisFileInfo;
  57038. /**
  57039. * Format to use when loading the file
  57040. */
  57041. format: number;
  57042. }
  57043. /**
  57044. * Configuration options for the Basis transcoder
  57045. */
  57046. export class BasisTranscodeConfiguration {
  57047. /**
  57048. * Supported compression formats used to determine the supported output format of the transcoder
  57049. */
  57050. supportedCompressionFormats?: {
  57051. /**
  57052. * etc1 compression format
  57053. */
  57054. etc1?: boolean;
  57055. /**
  57056. * s3tc compression format
  57057. */
  57058. s3tc?: boolean;
  57059. /**
  57060. * pvrtc compression format
  57061. */
  57062. pvrtc?: boolean;
  57063. /**
  57064. * etc2 compression format
  57065. */
  57066. etc2?: boolean;
  57067. };
  57068. /**
  57069. * If mipmap levels should be loaded for transcoded images (Default: true)
  57070. */
  57071. loadMipmapLevels?: boolean;
  57072. /**
  57073. * Index of a single image to load (Default: all images)
  57074. */
  57075. loadSingleImage?: number;
  57076. }
  57077. /**
  57078. * Used to load .Basis files
  57079. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  57080. */
  57081. export class BasisTools {
  57082. private static _IgnoreSupportedFormats;
  57083. /**
  57084. * URL to use when loading the basis transcoder
  57085. */
  57086. static JSModuleURL: string;
  57087. /**
  57088. * URL to use when loading the wasm module for the transcoder
  57089. */
  57090. static WasmModuleURL: string;
  57091. /**
  57092. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  57093. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  57094. * @returns internal format corresponding to the Basis format
  57095. */
  57096. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  57097. private static _WorkerPromise;
  57098. private static _Worker;
  57099. private static _actionId;
  57100. private static _CreateWorkerAsync;
  57101. /**
  57102. * Transcodes a loaded image file to compressed pixel data
  57103. * @param imageData image data to transcode
  57104. * @param config configuration options for the transcoding
  57105. * @returns a promise resulting in the transcoded image
  57106. */
  57107. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  57108. /**
  57109. * Loads a texture from the transcode result
  57110. * @param texture texture load to
  57111. * @param transcodeResult the result of transcoding the basis file to load from
  57112. */
  57113. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  57114. }
  57115. }
  57116. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  57117. import { Nullable } from "babylonjs/types";
  57118. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57119. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  57120. /**
  57121. * Loader for .basis file format
  57122. */
  57123. export class _BasisTextureLoader implements IInternalTextureLoader {
  57124. /**
  57125. * Defines whether the loader supports cascade loading the different faces.
  57126. */
  57127. readonly supportCascades: boolean;
  57128. /**
  57129. * This returns if the loader support the current file information.
  57130. * @param extension defines the file extension of the file being loaded
  57131. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57132. * @param fallback defines the fallback internal texture if any
  57133. * @param isBase64 defines whether the texture is encoded as a base64
  57134. * @param isBuffer defines whether the texture data are stored as a buffer
  57135. * @returns true if the loader can load the specified file
  57136. */
  57137. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  57138. /**
  57139. * Transform the url before loading if required.
  57140. * @param rootUrl the url of the texture
  57141. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57142. * @returns the transformed texture
  57143. */
  57144. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  57145. /**
  57146. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  57147. * @param rootUrl the url of the texture
  57148. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57149. * @returns the fallback texture
  57150. */
  57151. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  57152. /**
  57153. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  57154. * @param data contains the texture data
  57155. * @param texture defines the BabylonJS internal texture
  57156. * @param createPolynomials will be true if polynomials have been requested
  57157. * @param onLoad defines the callback to trigger once the texture is ready
  57158. * @param onError defines the callback to trigger in case of error
  57159. */
  57160. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57161. /**
  57162. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  57163. * @param data contains the texture data
  57164. * @param texture defines the BabylonJS internal texture
  57165. * @param callback defines the method to call once ready to upload
  57166. */
  57167. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57168. }
  57169. }
  57170. declare module "babylonjs/Materials/Textures/Loaders/index" {
  57171. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  57172. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  57173. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  57174. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  57175. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  57176. }
  57177. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  57178. import { Scene } from "babylonjs/scene";
  57179. import { Texture } from "babylonjs/Materials/Textures/texture";
  57180. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  57181. /**
  57182. * 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.
  57183. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  57184. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  57185. */
  57186. export class CustomProceduralTexture extends ProceduralTexture {
  57187. private _animate;
  57188. private _time;
  57189. private _config;
  57190. private _texturePath;
  57191. /**
  57192. * Instantiates a new Custom Procedural Texture.
  57193. * 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.
  57194. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  57195. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  57196. * @param name Define the name of the texture
  57197. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  57198. * @param size Define the size of the texture to create
  57199. * @param scene Define the scene the texture belongs to
  57200. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  57201. * @param generateMipMaps Define if the texture should creates mip maps or not
  57202. */
  57203. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  57204. private _loadJson;
  57205. /**
  57206. * Is the texture ready to be used ? (rendered at least once)
  57207. * @returns true if ready, otherwise, false.
  57208. */
  57209. isReady(): boolean;
  57210. /**
  57211. * Render the texture to its associated render target.
  57212. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  57213. */
  57214. render(useCameraPostProcess?: boolean): void;
  57215. /**
  57216. * Update the list of dependant textures samplers in the shader.
  57217. */
  57218. updateTextures(): void;
  57219. /**
  57220. * Update the uniform values of the procedural texture in the shader.
  57221. */
  57222. updateShaderUniforms(): void;
  57223. /**
  57224. * Define if the texture animates or not.
  57225. */
  57226. get animate(): boolean;
  57227. set animate(value: boolean);
  57228. }
  57229. }
  57230. declare module "babylonjs/Shaders/noise.fragment" {
  57231. /** @hidden */
  57232. export var noisePixelShader: {
  57233. name: string;
  57234. shader: string;
  57235. };
  57236. }
  57237. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  57238. import { Nullable } from "babylonjs/types";
  57239. import { Scene } from "babylonjs/scene";
  57240. import { Texture } from "babylonjs/Materials/Textures/texture";
  57241. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  57242. import "babylonjs/Shaders/noise.fragment";
  57243. /**
  57244. * Class used to generate noise procedural textures
  57245. */
  57246. export class NoiseProceduralTexture extends ProceduralTexture {
  57247. private _time;
  57248. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  57249. brightness: number;
  57250. /** Defines the number of octaves to process */
  57251. octaves: number;
  57252. /** Defines the level of persistence (0.8 by default) */
  57253. persistence: number;
  57254. /** Gets or sets animation speed factor (default is 1) */
  57255. animationSpeedFactor: number;
  57256. /**
  57257. * Creates a new NoiseProceduralTexture
  57258. * @param name defines the name fo the texture
  57259. * @param size defines the size of the texture (default is 256)
  57260. * @param scene defines the hosting scene
  57261. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  57262. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  57263. */
  57264. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  57265. private _updateShaderUniforms;
  57266. protected _getDefines(): string;
  57267. /** Generate the current state of the procedural texture */
  57268. render(useCameraPostProcess?: boolean): void;
  57269. /**
  57270. * Serializes this noise procedural texture
  57271. * @returns a serialized noise procedural texture object
  57272. */
  57273. serialize(): any;
  57274. /**
  57275. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  57276. * @param parsedTexture defines parsed texture data
  57277. * @param scene defines the current scene
  57278. * @param rootUrl defines the root URL containing noise procedural texture information
  57279. * @returns a parsed NoiseProceduralTexture
  57280. */
  57281. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  57282. }
  57283. }
  57284. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  57285. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  57286. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  57287. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  57288. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  57289. }
  57290. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  57291. import { Nullable } from "babylonjs/types";
  57292. import { Scene } from "babylonjs/scene";
  57293. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  57294. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57295. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  57296. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57297. /**
  57298. * Raw cube texture where the raw buffers are passed in
  57299. */
  57300. export class RawCubeTexture extends CubeTexture {
  57301. /**
  57302. * Creates a cube texture where the raw buffers are passed in.
  57303. * @param scene defines the scene the texture is attached to
  57304. * @param data defines the array of data to use to create each face
  57305. * @param size defines the size of the textures
  57306. * @param format defines the format of the data
  57307. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  57308. * @param generateMipMaps defines if the engine should generate the mip levels
  57309. * @param invertY defines if data must be stored with Y axis inverted
  57310. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  57311. * @param compression defines the compression used (null by default)
  57312. */
  57313. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  57314. /**
  57315. * Updates the raw cube texture.
  57316. * @param data defines the data to store
  57317. * @param format defines the data format
  57318. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57319. * @param invertY defines if data must be stored with Y axis inverted
  57320. * @param compression defines the compression used (null by default)
  57321. * @param level defines which level of the texture to update
  57322. */
  57323. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  57324. /**
  57325. * Updates a raw cube texture with RGBD encoded data.
  57326. * @param data defines the array of data [mipmap][face] to use to create each face
  57327. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  57328. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57329. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57330. * @returns a promsie that resolves when the operation is complete
  57331. */
  57332. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  57333. /**
  57334. * Clones the raw cube texture.
  57335. * @return a new cube texture
  57336. */
  57337. clone(): CubeTexture;
  57338. /** @hidden */
  57339. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  57340. }
  57341. }
  57342. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  57343. import { Scene } from "babylonjs/scene";
  57344. import { Texture } from "babylonjs/Materials/Textures/texture";
  57345. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57346. /**
  57347. * Class used to store 3D textures containing user data
  57348. */
  57349. export class RawTexture3D extends Texture {
  57350. /** Gets or sets the texture format to use */
  57351. format: number;
  57352. private _engine;
  57353. /**
  57354. * Create a new RawTexture3D
  57355. * @param data defines the data of the texture
  57356. * @param width defines the width of the texture
  57357. * @param height defines the height of the texture
  57358. * @param depth defines the depth of the texture
  57359. * @param format defines the texture format to use
  57360. * @param scene defines the hosting scene
  57361. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57362. * @param invertY defines if texture must be stored with Y axis inverted
  57363. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57364. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57365. */
  57366. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57367. /** Gets or sets the texture format to use */
  57368. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57369. /**
  57370. * Update the texture with new data
  57371. * @param data defines the data to store in the texture
  57372. */
  57373. update(data: ArrayBufferView): void;
  57374. }
  57375. }
  57376. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  57377. import { Scene } from "babylonjs/scene";
  57378. import { Texture } from "babylonjs/Materials/Textures/texture";
  57379. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57380. /**
  57381. * Class used to store 2D array textures containing user data
  57382. */
  57383. export class RawTexture2DArray extends Texture {
  57384. /** Gets or sets the texture format to use */
  57385. format: number;
  57386. private _engine;
  57387. /**
  57388. * Create a new RawTexture2DArray
  57389. * @param data defines the data of the texture
  57390. * @param width defines the width of the texture
  57391. * @param height defines the height of the texture
  57392. * @param depth defines the number of layers of the texture
  57393. * @param format defines the texture format to use
  57394. * @param scene defines the hosting scene
  57395. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57396. * @param invertY defines if texture must be stored with Y axis inverted
  57397. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57398. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57399. */
  57400. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57401. /** Gets or sets the texture format to use */
  57402. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57403. /**
  57404. * Update the texture with new data
  57405. * @param data defines the data to store in the texture
  57406. */
  57407. update(data: ArrayBufferView): void;
  57408. }
  57409. }
  57410. declare module "babylonjs/Materials/Textures/refractionTexture" {
  57411. import { Scene } from "babylonjs/scene";
  57412. import { Plane } from "babylonjs/Maths/math.plane";
  57413. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57414. /**
  57415. * Creates a refraction texture used by refraction channel of the standard material.
  57416. * It is like a mirror but to see through a material.
  57417. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57418. */
  57419. export class RefractionTexture extends RenderTargetTexture {
  57420. /**
  57421. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  57422. * 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.
  57423. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57424. */
  57425. refractionPlane: Plane;
  57426. /**
  57427. * Define how deep under the surface we should see.
  57428. */
  57429. depth: number;
  57430. /**
  57431. * Creates a refraction texture used by refraction channel of the standard material.
  57432. * It is like a mirror but to see through a material.
  57433. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57434. * @param name Define the texture name
  57435. * @param size Define the size of the underlying texture
  57436. * @param scene Define the scene the refraction belongs to
  57437. * @param generateMipMaps Define if we need to generate mips level for the refraction
  57438. */
  57439. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  57440. /**
  57441. * Clone the refraction texture.
  57442. * @returns the cloned texture
  57443. */
  57444. clone(): RefractionTexture;
  57445. /**
  57446. * Serialize the texture to a JSON representation you could use in Parse later on
  57447. * @returns the serialized JSON representation
  57448. */
  57449. serialize(): any;
  57450. }
  57451. }
  57452. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  57453. import { Nullable } from "babylonjs/types";
  57454. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57455. import { Matrix } from "babylonjs/Maths/math.vector";
  57456. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  57457. import "babylonjs/Engines/Extensions/engine.videoTexture";
  57458. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  57459. import { Scene } from "babylonjs/scene";
  57460. /**
  57461. * Defines the options related to the creation of an HtmlElementTexture
  57462. */
  57463. export interface IHtmlElementTextureOptions {
  57464. /**
  57465. * Defines wether mip maps should be created or not.
  57466. */
  57467. generateMipMaps?: boolean;
  57468. /**
  57469. * Defines the sampling mode of the texture.
  57470. */
  57471. samplingMode?: number;
  57472. /**
  57473. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  57474. */
  57475. engine: Nullable<ThinEngine>;
  57476. /**
  57477. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  57478. */
  57479. scene: Nullable<Scene>;
  57480. }
  57481. /**
  57482. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  57483. * To be as efficient as possible depending on your constraints nothing aside the first upload
  57484. * is automatically managed.
  57485. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  57486. * in your application.
  57487. *
  57488. * As the update is not automatic, you need to call them manually.
  57489. */
  57490. export class HtmlElementTexture extends BaseTexture {
  57491. /**
  57492. * The texture URL.
  57493. */
  57494. element: HTMLVideoElement | HTMLCanvasElement;
  57495. private static readonly DefaultOptions;
  57496. private _textureMatrix;
  57497. private _engine;
  57498. private _isVideo;
  57499. private _generateMipMaps;
  57500. private _samplingMode;
  57501. /**
  57502. * Instantiates a HtmlElementTexture from the following parameters.
  57503. *
  57504. * @param name Defines the name of the texture
  57505. * @param element Defines the video or canvas the texture is filled with
  57506. * @param options Defines the other none mandatory texture creation options
  57507. */
  57508. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  57509. private _createInternalTexture;
  57510. /**
  57511. * Returns the texture matrix used in most of the material.
  57512. */
  57513. getTextureMatrix(): Matrix;
  57514. /**
  57515. * Updates the content of the texture.
  57516. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  57517. */
  57518. update(invertY?: Nullable<boolean>): void;
  57519. }
  57520. }
  57521. declare module "babylonjs/Materials/Textures/index" {
  57522. export * from "babylonjs/Materials/Textures/baseTexture";
  57523. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  57524. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  57525. export * from "babylonjs/Materials/Textures/cubeTexture";
  57526. export * from "babylonjs/Materials/Textures/dynamicTexture";
  57527. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  57528. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  57529. export * from "babylonjs/Materials/Textures/internalTexture";
  57530. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  57531. export * from "babylonjs/Materials/Textures/Loaders/index";
  57532. export * from "babylonjs/Materials/Textures/mirrorTexture";
  57533. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  57534. export * from "babylonjs/Materials/Textures/Procedurals/index";
  57535. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  57536. export * from "babylonjs/Materials/Textures/rawTexture";
  57537. export * from "babylonjs/Materials/Textures/rawTexture3D";
  57538. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  57539. export * from "babylonjs/Materials/Textures/refractionTexture";
  57540. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  57541. export * from "babylonjs/Materials/Textures/texture";
  57542. export * from "babylonjs/Materials/Textures/videoTexture";
  57543. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  57544. }
  57545. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  57546. /**
  57547. * Enum used to define the target of a block
  57548. */
  57549. export enum NodeMaterialBlockTargets {
  57550. /** Vertex shader */
  57551. Vertex = 1,
  57552. /** Fragment shader */
  57553. Fragment = 2,
  57554. /** Neutral */
  57555. Neutral = 4,
  57556. /** Vertex and Fragment */
  57557. VertexAndFragment = 3
  57558. }
  57559. }
  57560. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  57561. /**
  57562. * Defines the kind of connection point for node based material
  57563. */
  57564. export enum NodeMaterialBlockConnectionPointTypes {
  57565. /** Float */
  57566. Float = 1,
  57567. /** Int */
  57568. Int = 2,
  57569. /** Vector2 */
  57570. Vector2 = 4,
  57571. /** Vector3 */
  57572. Vector3 = 8,
  57573. /** Vector4 */
  57574. Vector4 = 16,
  57575. /** Color3 */
  57576. Color3 = 32,
  57577. /** Color4 */
  57578. Color4 = 64,
  57579. /** Matrix */
  57580. Matrix = 128,
  57581. /** Detect type based on connection */
  57582. AutoDetect = 1024,
  57583. /** Output type that will be defined by input type */
  57584. BasedOnInput = 2048
  57585. }
  57586. }
  57587. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  57588. /**
  57589. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  57590. */
  57591. export enum NodeMaterialBlockConnectionPointMode {
  57592. /** Value is an uniform */
  57593. Uniform = 0,
  57594. /** Value is a mesh attribute */
  57595. Attribute = 1,
  57596. /** Value is a varying between vertex and fragment shaders */
  57597. Varying = 2,
  57598. /** Mode is undefined */
  57599. Undefined = 3
  57600. }
  57601. }
  57602. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  57603. /**
  57604. * Enum used to define system values e.g. values automatically provided by the system
  57605. */
  57606. export enum NodeMaterialSystemValues {
  57607. /** World */
  57608. World = 1,
  57609. /** View */
  57610. View = 2,
  57611. /** Projection */
  57612. Projection = 3,
  57613. /** ViewProjection */
  57614. ViewProjection = 4,
  57615. /** WorldView */
  57616. WorldView = 5,
  57617. /** WorldViewProjection */
  57618. WorldViewProjection = 6,
  57619. /** CameraPosition */
  57620. CameraPosition = 7,
  57621. /** Fog Color */
  57622. FogColor = 8,
  57623. /** Delta time */
  57624. DeltaTime = 9
  57625. }
  57626. }
  57627. declare module "babylonjs/Materials/Node/Enums/index" {
  57628. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57629. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57630. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  57631. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  57632. }
  57633. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  57634. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57635. /**
  57636. * Root class for all node material optimizers
  57637. */
  57638. export class NodeMaterialOptimizer {
  57639. /**
  57640. * Function used to optimize a NodeMaterial graph
  57641. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57642. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57643. */
  57644. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57645. }
  57646. }
  57647. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  57648. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57649. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57650. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57651. import { Scene } from "babylonjs/scene";
  57652. /**
  57653. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57654. */
  57655. export class TransformBlock extends NodeMaterialBlock {
  57656. /**
  57657. * Defines the value to use to complement W value to transform it to a Vector4
  57658. */
  57659. complementW: number;
  57660. /**
  57661. * Defines the value to use to complement z value to transform it to a Vector4
  57662. */
  57663. complementZ: number;
  57664. /**
  57665. * Creates a new TransformBlock
  57666. * @param name defines the block name
  57667. */
  57668. constructor(name: string);
  57669. /**
  57670. * Gets the current class name
  57671. * @returns the class name
  57672. */
  57673. getClassName(): string;
  57674. /**
  57675. * Gets the vector input
  57676. */
  57677. get vector(): NodeMaterialConnectionPoint;
  57678. /**
  57679. * Gets the output component
  57680. */
  57681. get output(): NodeMaterialConnectionPoint;
  57682. /**
  57683. * Gets the matrix transform input
  57684. */
  57685. get transform(): NodeMaterialConnectionPoint;
  57686. protected _buildBlock(state: NodeMaterialBuildState): this;
  57687. serialize(): any;
  57688. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57689. protected _dumpPropertiesCode(): string;
  57690. }
  57691. }
  57692. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  57693. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57694. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57695. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57696. /**
  57697. * Block used to output the vertex position
  57698. */
  57699. export class VertexOutputBlock extends NodeMaterialBlock {
  57700. /**
  57701. * Creates a new VertexOutputBlock
  57702. * @param name defines the block name
  57703. */
  57704. constructor(name: string);
  57705. /**
  57706. * Gets the current class name
  57707. * @returns the class name
  57708. */
  57709. getClassName(): string;
  57710. /**
  57711. * Gets the vector input component
  57712. */
  57713. get vector(): NodeMaterialConnectionPoint;
  57714. protected _buildBlock(state: NodeMaterialBuildState): this;
  57715. }
  57716. }
  57717. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  57718. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57719. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57720. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57721. /**
  57722. * Block used to output the final color
  57723. */
  57724. export class FragmentOutputBlock extends NodeMaterialBlock {
  57725. /**
  57726. * Create a new FragmentOutputBlock
  57727. * @param name defines the block name
  57728. */
  57729. constructor(name: string);
  57730. /**
  57731. * Gets the current class name
  57732. * @returns the class name
  57733. */
  57734. getClassName(): string;
  57735. /**
  57736. * Gets the rgba input component
  57737. */
  57738. get rgba(): NodeMaterialConnectionPoint;
  57739. /**
  57740. * Gets the rgb input component
  57741. */
  57742. get rgb(): NodeMaterialConnectionPoint;
  57743. /**
  57744. * Gets the a input component
  57745. */
  57746. get a(): NodeMaterialConnectionPoint;
  57747. protected _buildBlock(state: NodeMaterialBuildState): this;
  57748. }
  57749. }
  57750. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  57751. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57752. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57753. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57754. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57755. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57756. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57757. import { Effect } from "babylonjs/Materials/effect";
  57758. import { Mesh } from "babylonjs/Meshes/mesh";
  57759. import { Nullable } from "babylonjs/types";
  57760. import { Scene } from "babylonjs/scene";
  57761. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  57762. /**
  57763. * Block used to read a reflection texture from a sampler
  57764. */
  57765. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57766. private _define3DName;
  57767. private _defineCubicName;
  57768. private _defineExplicitName;
  57769. private _defineProjectionName;
  57770. private _defineLocalCubicName;
  57771. private _defineSphericalName;
  57772. private _definePlanarName;
  57773. private _defineEquirectangularName;
  57774. private _defineMirroredEquirectangularFixedName;
  57775. private _defineEquirectangularFixedName;
  57776. private _defineSkyboxName;
  57777. private _cubeSamplerName;
  57778. private _2DSamplerName;
  57779. private _positionUVWName;
  57780. private _directionWName;
  57781. private _reflectionCoordsName;
  57782. private _reflection2DCoordsName;
  57783. private _reflectionColorName;
  57784. private _reflectionMatrixName;
  57785. /**
  57786. * Gets or sets the texture associated with the node
  57787. */
  57788. texture: Nullable<BaseTexture>;
  57789. /**
  57790. * Create a new TextureBlock
  57791. * @param name defines the block name
  57792. */
  57793. constructor(name: string);
  57794. /**
  57795. * Gets the current class name
  57796. * @returns the class name
  57797. */
  57798. getClassName(): string;
  57799. /**
  57800. * Gets the world position input component
  57801. */
  57802. get position(): NodeMaterialConnectionPoint;
  57803. /**
  57804. * Gets the world position input component
  57805. */
  57806. get worldPosition(): NodeMaterialConnectionPoint;
  57807. /**
  57808. * Gets the world normal input component
  57809. */
  57810. get worldNormal(): NodeMaterialConnectionPoint;
  57811. /**
  57812. * Gets the world input component
  57813. */
  57814. get world(): NodeMaterialConnectionPoint;
  57815. /**
  57816. * Gets the camera (or eye) position component
  57817. */
  57818. get cameraPosition(): NodeMaterialConnectionPoint;
  57819. /**
  57820. * Gets the view input component
  57821. */
  57822. get view(): NodeMaterialConnectionPoint;
  57823. /**
  57824. * Gets the rgb output component
  57825. */
  57826. get rgb(): NodeMaterialConnectionPoint;
  57827. /**
  57828. * Gets the r output component
  57829. */
  57830. get r(): NodeMaterialConnectionPoint;
  57831. /**
  57832. * Gets the g output component
  57833. */
  57834. get g(): NodeMaterialConnectionPoint;
  57835. /**
  57836. * Gets the b output component
  57837. */
  57838. get b(): NodeMaterialConnectionPoint;
  57839. autoConfigure(material: NodeMaterial): void;
  57840. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57841. isReady(): boolean;
  57842. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57843. private _injectVertexCode;
  57844. private _writeOutput;
  57845. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57846. protected _dumpPropertiesCode(): string;
  57847. serialize(): any;
  57848. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57849. }
  57850. }
  57851. declare module "babylonjs/Materials/Node/nodeMaterial" {
  57852. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57853. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  57854. import { Scene } from "babylonjs/scene";
  57855. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57856. import { Matrix } from "babylonjs/Maths/math.vector";
  57857. import { Mesh } from "babylonjs/Meshes/mesh";
  57858. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57859. import { Observable } from "babylonjs/Misc/observable";
  57860. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57861. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  57862. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  57863. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  57864. import { Nullable } from "babylonjs/types";
  57865. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57866. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  57867. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  57868. /**
  57869. * Interface used to configure the node material editor
  57870. */
  57871. export interface INodeMaterialEditorOptions {
  57872. /** Define the URl to load node editor script */
  57873. editorURL?: string;
  57874. }
  57875. /** @hidden */
  57876. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57877. /** BONES */
  57878. NUM_BONE_INFLUENCERS: number;
  57879. BonesPerMesh: number;
  57880. BONETEXTURE: boolean;
  57881. /** MORPH TARGETS */
  57882. MORPHTARGETS: boolean;
  57883. MORPHTARGETS_NORMAL: boolean;
  57884. MORPHTARGETS_TANGENT: boolean;
  57885. MORPHTARGETS_UV: boolean;
  57886. NUM_MORPH_INFLUENCERS: number;
  57887. /** IMAGE PROCESSING */
  57888. IMAGEPROCESSING: boolean;
  57889. VIGNETTE: boolean;
  57890. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57891. VIGNETTEBLENDMODEOPAQUE: boolean;
  57892. TONEMAPPING: boolean;
  57893. TONEMAPPING_ACES: boolean;
  57894. CONTRAST: boolean;
  57895. EXPOSURE: boolean;
  57896. COLORCURVES: boolean;
  57897. COLORGRADING: boolean;
  57898. COLORGRADING3D: boolean;
  57899. SAMPLER3DGREENDEPTH: boolean;
  57900. SAMPLER3DBGRMAP: boolean;
  57901. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57902. /** MISC. */
  57903. BUMPDIRECTUV: number;
  57904. constructor();
  57905. setValue(name: string, value: boolean): void;
  57906. }
  57907. /**
  57908. * Class used to configure NodeMaterial
  57909. */
  57910. export interface INodeMaterialOptions {
  57911. /**
  57912. * Defines if blocks should emit comments
  57913. */
  57914. emitComments: boolean;
  57915. }
  57916. /**
  57917. * Class used to create a node based material built by assembling shader blocks
  57918. */
  57919. export class NodeMaterial extends PushMaterial {
  57920. private static _BuildIdGenerator;
  57921. private _options;
  57922. private _vertexCompilationState;
  57923. private _fragmentCompilationState;
  57924. private _sharedData;
  57925. private _buildId;
  57926. private _buildWasSuccessful;
  57927. private _cachedWorldViewMatrix;
  57928. private _cachedWorldViewProjectionMatrix;
  57929. private _optimizers;
  57930. private _animationFrame;
  57931. /** Define the URl to load node editor script */
  57932. static EditorURL: string;
  57933. private BJSNODEMATERIALEDITOR;
  57934. /** Get the inspector from bundle or global */
  57935. private _getGlobalNodeMaterialEditor;
  57936. /**
  57937. * Gets or sets data used by visual editor
  57938. * @see https://nme.babylonjs.com
  57939. */
  57940. editorData: any;
  57941. /**
  57942. * 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)
  57943. */
  57944. ignoreAlpha: boolean;
  57945. /**
  57946. * Defines the maximum number of lights that can be used in the material
  57947. */
  57948. maxSimultaneousLights: number;
  57949. /**
  57950. * Observable raised when the material is built
  57951. */
  57952. onBuildObservable: Observable<NodeMaterial>;
  57953. /**
  57954. * Gets or sets the root nodes of the material vertex shader
  57955. */
  57956. _vertexOutputNodes: NodeMaterialBlock[];
  57957. /**
  57958. * Gets or sets the root nodes of the material fragment (pixel) shader
  57959. */
  57960. _fragmentOutputNodes: NodeMaterialBlock[];
  57961. /** Gets or sets options to control the node material overall behavior */
  57962. get options(): INodeMaterialOptions;
  57963. set options(options: INodeMaterialOptions);
  57964. /**
  57965. * Default configuration related to image processing available in the standard Material.
  57966. */
  57967. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57968. /**
  57969. * Gets the image processing configuration used either in this material.
  57970. */
  57971. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57972. /**
  57973. * Sets the Default image processing configuration used either in the this material.
  57974. *
  57975. * If sets to null, the scene one is in use.
  57976. */
  57977. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57978. /**
  57979. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57980. */
  57981. attachedBlocks: NodeMaterialBlock[];
  57982. /**
  57983. * Create a new node based material
  57984. * @param name defines the material name
  57985. * @param scene defines the hosting scene
  57986. * @param options defines creation option
  57987. */
  57988. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57989. /**
  57990. * Gets the current class name of the material e.g. "NodeMaterial"
  57991. * @returns the class name
  57992. */
  57993. getClassName(): string;
  57994. /**
  57995. * Keep track of the image processing observer to allow dispose and replace.
  57996. */
  57997. private _imageProcessingObserver;
  57998. /**
  57999. * Attaches a new image processing configuration to the Standard Material.
  58000. * @param configuration
  58001. */
  58002. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58003. /**
  58004. * Get a block by its name
  58005. * @param name defines the name of the block to retrieve
  58006. * @returns the required block or null if not found
  58007. */
  58008. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  58009. /**
  58010. * Get a block by its name
  58011. * @param predicate defines the predicate used to find the good candidate
  58012. * @returns the required block or null if not found
  58013. */
  58014. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  58015. /**
  58016. * Get an input block by its name
  58017. * @param predicate defines the predicate used to find the good candidate
  58018. * @returns the required input block or null if not found
  58019. */
  58020. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  58021. /**
  58022. * Gets the list of input blocks attached to this material
  58023. * @returns an array of InputBlocks
  58024. */
  58025. getInputBlocks(): InputBlock[];
  58026. /**
  58027. * Adds a new optimizer to the list of optimizers
  58028. * @param optimizer defines the optimizers to add
  58029. * @returns the current material
  58030. */
  58031. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  58032. /**
  58033. * Remove an optimizer from the list of optimizers
  58034. * @param optimizer defines the optimizers to remove
  58035. * @returns the current material
  58036. */
  58037. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  58038. /**
  58039. * Add a new block to the list of output nodes
  58040. * @param node defines the node to add
  58041. * @returns the current material
  58042. */
  58043. addOutputNode(node: NodeMaterialBlock): this;
  58044. /**
  58045. * Remove a block from the list of root nodes
  58046. * @param node defines the node to remove
  58047. * @returns the current material
  58048. */
  58049. removeOutputNode(node: NodeMaterialBlock): this;
  58050. private _addVertexOutputNode;
  58051. private _removeVertexOutputNode;
  58052. private _addFragmentOutputNode;
  58053. private _removeFragmentOutputNode;
  58054. /**
  58055. * Specifies if the material will require alpha blending
  58056. * @returns a boolean specifying if alpha blending is needed
  58057. */
  58058. needAlphaBlending(): boolean;
  58059. /**
  58060. * Specifies if this material should be rendered in alpha test mode
  58061. * @returns a boolean specifying if an alpha test is needed.
  58062. */
  58063. needAlphaTesting(): boolean;
  58064. private _initializeBlock;
  58065. private _resetDualBlocks;
  58066. /**
  58067. * Remove a block from the current node material
  58068. * @param block defines the block to remove
  58069. */
  58070. removeBlock(block: NodeMaterialBlock): void;
  58071. /**
  58072. * Build the material and generates the inner effect
  58073. * @param verbose defines if the build should log activity
  58074. */
  58075. build(verbose?: boolean): void;
  58076. /**
  58077. * Runs an otpimization phase to try to improve the shader code
  58078. */
  58079. optimize(): void;
  58080. private _prepareDefinesForAttributes;
  58081. /**
  58082. * Get if the submesh is ready to be used and all its information available.
  58083. * Child classes can use it to update shaders
  58084. * @param mesh defines the mesh to check
  58085. * @param subMesh defines which submesh to check
  58086. * @param useInstances specifies that instances should be used
  58087. * @returns a boolean indicating that the submesh is ready or not
  58088. */
  58089. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58090. /**
  58091. * Get a string representing the shaders built by the current node graph
  58092. */
  58093. get compiledShaders(): string;
  58094. /**
  58095. * Binds the world matrix to the material
  58096. * @param world defines the world transformation matrix
  58097. */
  58098. bindOnlyWorldMatrix(world: Matrix): void;
  58099. /**
  58100. * Binds the submesh to this material by preparing the effect and shader to draw
  58101. * @param world defines the world transformation matrix
  58102. * @param mesh defines the mesh containing the submesh
  58103. * @param subMesh defines the submesh to bind the material to
  58104. */
  58105. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58106. /**
  58107. * Gets the active textures from the material
  58108. * @returns an array of textures
  58109. */
  58110. getActiveTextures(): BaseTexture[];
  58111. /**
  58112. * Gets the list of texture blocks
  58113. * @returns an array of texture blocks
  58114. */
  58115. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  58116. /**
  58117. * Specifies if the material uses a texture
  58118. * @param texture defines the texture to check against the material
  58119. * @returns a boolean specifying if the material uses the texture
  58120. */
  58121. hasTexture(texture: BaseTexture): boolean;
  58122. /**
  58123. * Disposes the material
  58124. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  58125. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  58126. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  58127. */
  58128. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  58129. /** Creates the node editor window. */
  58130. private _createNodeEditor;
  58131. /**
  58132. * Launch the node material editor
  58133. * @param config Define the configuration of the editor
  58134. * @return a promise fulfilled when the node editor is visible
  58135. */
  58136. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  58137. /**
  58138. * Clear the current material
  58139. */
  58140. clear(): void;
  58141. /**
  58142. * Clear the current material and set it to a default state
  58143. */
  58144. setToDefault(): void;
  58145. /**
  58146. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  58147. * @param url defines the url to load from
  58148. * @returns a promise that will fullfil when the material is fully loaded
  58149. */
  58150. loadAsync(url: string): Promise<void>;
  58151. private _gatherBlocks;
  58152. /**
  58153. * Generate a string containing the code declaration required to create an equivalent of this material
  58154. * @returns a string
  58155. */
  58156. generateCode(): string;
  58157. /**
  58158. * Serializes this material in a JSON representation
  58159. * @returns the serialized material object
  58160. */
  58161. serialize(): any;
  58162. private _restoreConnections;
  58163. /**
  58164. * Clear the current graph and load a new one from a serialization object
  58165. * @param source defines the JSON representation of the material
  58166. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58167. */
  58168. loadFromSerialization(source: any, rootUrl?: string): void;
  58169. /**
  58170. * Creates a node material from parsed material data
  58171. * @param source defines the JSON representation of the material
  58172. * @param scene defines the hosting scene
  58173. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58174. * @returns a new node material
  58175. */
  58176. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  58177. /**
  58178. * Creates a new node material set to default basic configuration
  58179. * @param name defines the name of the material
  58180. * @param scene defines the hosting scene
  58181. * @returns a new NodeMaterial
  58182. */
  58183. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  58184. }
  58185. }
  58186. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  58187. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58188. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58189. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58190. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58191. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58192. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58193. import { Effect } from "babylonjs/Materials/effect";
  58194. import { Mesh } from "babylonjs/Meshes/mesh";
  58195. import { Nullable } from "babylonjs/types";
  58196. import { Texture } from "babylonjs/Materials/Textures/texture";
  58197. import { Scene } from "babylonjs/scene";
  58198. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58199. /**
  58200. * Block used to read a texture from a sampler
  58201. */
  58202. export class TextureBlock extends NodeMaterialBlock {
  58203. private _defineName;
  58204. private _linearDefineName;
  58205. private _tempTextureRead;
  58206. private _samplerName;
  58207. private _transformedUVName;
  58208. private _textureTransformName;
  58209. private _textureInfoName;
  58210. private _mainUVName;
  58211. private _mainUVDefineName;
  58212. /**
  58213. * Gets or sets the texture associated with the node
  58214. */
  58215. texture: Nullable<Texture>;
  58216. /**
  58217. * Create a new TextureBlock
  58218. * @param name defines the block name
  58219. */
  58220. constructor(name: string);
  58221. /**
  58222. * Gets the current class name
  58223. * @returns the class name
  58224. */
  58225. getClassName(): string;
  58226. /**
  58227. * Gets the uv input component
  58228. */
  58229. get uv(): NodeMaterialConnectionPoint;
  58230. /**
  58231. * Gets the rgba output component
  58232. */
  58233. get rgba(): NodeMaterialConnectionPoint;
  58234. /**
  58235. * Gets the rgb output component
  58236. */
  58237. get rgb(): NodeMaterialConnectionPoint;
  58238. /**
  58239. * Gets the r output component
  58240. */
  58241. get r(): NodeMaterialConnectionPoint;
  58242. /**
  58243. * Gets the g output component
  58244. */
  58245. get g(): NodeMaterialConnectionPoint;
  58246. /**
  58247. * Gets the b output component
  58248. */
  58249. get b(): NodeMaterialConnectionPoint;
  58250. /**
  58251. * Gets the a output component
  58252. */
  58253. get a(): NodeMaterialConnectionPoint;
  58254. get target(): NodeMaterialBlockTargets;
  58255. autoConfigure(material: NodeMaterial): void;
  58256. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58257. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58258. private _getTextureBase;
  58259. isReady(): boolean;
  58260. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58261. private get _isMixed();
  58262. private _injectVertexCode;
  58263. private _writeTextureRead;
  58264. private _writeOutput;
  58265. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58266. protected _dumpPropertiesCode(): string;
  58267. serialize(): any;
  58268. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58269. }
  58270. }
  58271. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  58272. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58273. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58274. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  58275. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  58276. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  58277. import { Scene } from "babylonjs/scene";
  58278. /**
  58279. * Class used to store shared data between 2 NodeMaterialBuildState
  58280. */
  58281. export class NodeMaterialBuildStateSharedData {
  58282. /**
  58283. * Gets the list of emitted varyings
  58284. */
  58285. temps: string[];
  58286. /**
  58287. * Gets the list of emitted varyings
  58288. */
  58289. varyings: string[];
  58290. /**
  58291. * Gets the varying declaration string
  58292. */
  58293. varyingDeclaration: string;
  58294. /**
  58295. * Input blocks
  58296. */
  58297. inputBlocks: InputBlock[];
  58298. /**
  58299. * Input blocks
  58300. */
  58301. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  58302. /**
  58303. * Bindable blocks (Blocks that need to set data to the effect)
  58304. */
  58305. bindableBlocks: NodeMaterialBlock[];
  58306. /**
  58307. * List of blocks that can provide a compilation fallback
  58308. */
  58309. blocksWithFallbacks: NodeMaterialBlock[];
  58310. /**
  58311. * List of blocks that can provide a define update
  58312. */
  58313. blocksWithDefines: NodeMaterialBlock[];
  58314. /**
  58315. * List of blocks that can provide a repeatable content
  58316. */
  58317. repeatableContentBlocks: NodeMaterialBlock[];
  58318. /**
  58319. * List of blocks that can provide a dynamic list of uniforms
  58320. */
  58321. dynamicUniformBlocks: NodeMaterialBlock[];
  58322. /**
  58323. * List of blocks that can block the isReady function for the material
  58324. */
  58325. blockingBlocks: NodeMaterialBlock[];
  58326. /**
  58327. * Gets the list of animated inputs
  58328. */
  58329. animatedInputs: InputBlock[];
  58330. /**
  58331. * Build Id used to avoid multiple recompilations
  58332. */
  58333. buildId: number;
  58334. /** List of emitted variables */
  58335. variableNames: {
  58336. [key: string]: number;
  58337. };
  58338. /** List of emitted defines */
  58339. defineNames: {
  58340. [key: string]: number;
  58341. };
  58342. /** Should emit comments? */
  58343. emitComments: boolean;
  58344. /** Emit build activity */
  58345. verbose: boolean;
  58346. /** Gets or sets the hosting scene */
  58347. scene: Scene;
  58348. /**
  58349. * Gets the compilation hints emitted at compilation time
  58350. */
  58351. hints: {
  58352. needWorldViewMatrix: boolean;
  58353. needWorldViewProjectionMatrix: boolean;
  58354. needAlphaBlending: boolean;
  58355. needAlphaTesting: boolean;
  58356. };
  58357. /**
  58358. * List of compilation checks
  58359. */
  58360. checks: {
  58361. emitVertex: boolean;
  58362. emitFragment: boolean;
  58363. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  58364. };
  58365. /** Creates a new shared data */
  58366. constructor();
  58367. /**
  58368. * Emits console errors and exceptions if there is a failing check
  58369. */
  58370. emitErrors(): void;
  58371. }
  58372. }
  58373. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  58374. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58375. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58376. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  58377. /**
  58378. * Class used to store node based material build state
  58379. */
  58380. export class NodeMaterialBuildState {
  58381. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  58382. supportUniformBuffers: boolean;
  58383. /**
  58384. * Gets the list of emitted attributes
  58385. */
  58386. attributes: string[];
  58387. /**
  58388. * Gets the list of emitted uniforms
  58389. */
  58390. uniforms: string[];
  58391. /**
  58392. * Gets the list of emitted constants
  58393. */
  58394. constants: string[];
  58395. /**
  58396. * Gets the list of emitted samplers
  58397. */
  58398. samplers: string[];
  58399. /**
  58400. * Gets the list of emitted functions
  58401. */
  58402. functions: {
  58403. [key: string]: string;
  58404. };
  58405. /**
  58406. * Gets the list of emitted extensions
  58407. */
  58408. extensions: {
  58409. [key: string]: string;
  58410. };
  58411. /**
  58412. * Gets the target of the compilation state
  58413. */
  58414. target: NodeMaterialBlockTargets;
  58415. /**
  58416. * Gets the list of emitted counters
  58417. */
  58418. counters: {
  58419. [key: string]: number;
  58420. };
  58421. /**
  58422. * Shared data between multiple NodeMaterialBuildState instances
  58423. */
  58424. sharedData: NodeMaterialBuildStateSharedData;
  58425. /** @hidden */
  58426. _vertexState: NodeMaterialBuildState;
  58427. /** @hidden */
  58428. _attributeDeclaration: string;
  58429. /** @hidden */
  58430. _uniformDeclaration: string;
  58431. /** @hidden */
  58432. _constantDeclaration: string;
  58433. /** @hidden */
  58434. _samplerDeclaration: string;
  58435. /** @hidden */
  58436. _varyingTransfer: string;
  58437. private _repeatableContentAnchorIndex;
  58438. /** @hidden */
  58439. _builtCompilationString: string;
  58440. /**
  58441. * Gets the emitted compilation strings
  58442. */
  58443. compilationString: string;
  58444. /**
  58445. * Finalize the compilation strings
  58446. * @param state defines the current compilation state
  58447. */
  58448. finalize(state: NodeMaterialBuildState): void;
  58449. /** @hidden */
  58450. get _repeatableContentAnchor(): string;
  58451. /** @hidden */
  58452. _getFreeVariableName(prefix: string): string;
  58453. /** @hidden */
  58454. _getFreeDefineName(prefix: string): string;
  58455. /** @hidden */
  58456. _excludeVariableName(name: string): void;
  58457. /** @hidden */
  58458. _emit2DSampler(name: string): void;
  58459. /** @hidden */
  58460. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  58461. /** @hidden */
  58462. _emitExtension(name: string, extension: string): void;
  58463. /** @hidden */
  58464. _emitFunction(name: string, code: string, comments: string): void;
  58465. /** @hidden */
  58466. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  58467. replaceStrings?: {
  58468. search: RegExp;
  58469. replace: string;
  58470. }[];
  58471. repeatKey?: string;
  58472. }): string;
  58473. /** @hidden */
  58474. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  58475. repeatKey?: string;
  58476. removeAttributes?: boolean;
  58477. removeUniforms?: boolean;
  58478. removeVaryings?: boolean;
  58479. removeIfDef?: boolean;
  58480. replaceStrings?: {
  58481. search: RegExp;
  58482. replace: string;
  58483. }[];
  58484. }, storeKey?: string): void;
  58485. /** @hidden */
  58486. _registerTempVariable(name: string): boolean;
  58487. /** @hidden */
  58488. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  58489. /** @hidden */
  58490. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  58491. /** @hidden */
  58492. _emitFloat(value: number): string;
  58493. }
  58494. }
  58495. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  58496. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58497. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58498. import { Nullable } from "babylonjs/types";
  58499. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58500. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58501. import { Effect } from "babylonjs/Materials/effect";
  58502. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58503. import { Mesh } from "babylonjs/Meshes/mesh";
  58504. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58505. import { Scene } from "babylonjs/scene";
  58506. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58507. /**
  58508. * Defines a block that can be used inside a node based material
  58509. */
  58510. export class NodeMaterialBlock {
  58511. private _buildId;
  58512. private _buildTarget;
  58513. private _target;
  58514. private _isFinalMerger;
  58515. private _isInput;
  58516. protected _isUnique: boolean;
  58517. /** @hidden */
  58518. _codeVariableName: string;
  58519. /** @hidden */
  58520. _inputs: NodeMaterialConnectionPoint[];
  58521. /** @hidden */
  58522. _outputs: NodeMaterialConnectionPoint[];
  58523. /** @hidden */
  58524. _preparationId: number;
  58525. /**
  58526. * Gets or sets the name of the block
  58527. */
  58528. name: string;
  58529. /**
  58530. * Gets or sets the unique id of the node
  58531. */
  58532. uniqueId: number;
  58533. /**
  58534. * Gets or sets the comments associated with this block
  58535. */
  58536. comments: string;
  58537. /**
  58538. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  58539. */
  58540. get isUnique(): boolean;
  58541. /**
  58542. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  58543. */
  58544. get isFinalMerger(): boolean;
  58545. /**
  58546. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  58547. */
  58548. get isInput(): boolean;
  58549. /**
  58550. * Gets or sets the build Id
  58551. */
  58552. get buildId(): number;
  58553. set buildId(value: number);
  58554. /**
  58555. * Gets or sets the target of the block
  58556. */
  58557. get target(): NodeMaterialBlockTargets;
  58558. set target(value: NodeMaterialBlockTargets);
  58559. /**
  58560. * Gets the list of input points
  58561. */
  58562. get inputs(): NodeMaterialConnectionPoint[];
  58563. /** Gets the list of output points */
  58564. get outputs(): NodeMaterialConnectionPoint[];
  58565. /**
  58566. * Find an input by its name
  58567. * @param name defines the name of the input to look for
  58568. * @returns the input or null if not found
  58569. */
  58570. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58571. /**
  58572. * Find an output by its name
  58573. * @param name defines the name of the outputto look for
  58574. * @returns the output or null if not found
  58575. */
  58576. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58577. /**
  58578. * Creates a new NodeMaterialBlock
  58579. * @param name defines the block name
  58580. * @param target defines the target of that block (Vertex by default)
  58581. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  58582. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  58583. */
  58584. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  58585. /**
  58586. * Initialize the block and prepare the context for build
  58587. * @param state defines the state that will be used for the build
  58588. */
  58589. initialize(state: NodeMaterialBuildState): void;
  58590. /**
  58591. * Bind data to effect. Will only be called for blocks with isBindable === true
  58592. * @param effect defines the effect to bind data to
  58593. * @param nodeMaterial defines the hosting NodeMaterial
  58594. * @param mesh defines the mesh that will be rendered
  58595. */
  58596. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58597. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  58598. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  58599. protected _writeFloat(value: number): string;
  58600. /**
  58601. * Gets the current class name e.g. "NodeMaterialBlock"
  58602. * @returns the class name
  58603. */
  58604. getClassName(): string;
  58605. /**
  58606. * Register a new input. Must be called inside a block constructor
  58607. * @param name defines the connection point name
  58608. * @param type defines the connection point type
  58609. * @param isOptional defines a boolean indicating that this input can be omitted
  58610. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58611. * @returns the current block
  58612. */
  58613. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  58614. /**
  58615. * Register a new output. Must be called inside a block constructor
  58616. * @param name defines the connection point name
  58617. * @param type defines the connection point type
  58618. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58619. * @returns the current block
  58620. */
  58621. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  58622. /**
  58623. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  58624. * @param forOutput defines an optional connection point to check compatibility with
  58625. * @returns the first available input or null
  58626. */
  58627. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  58628. /**
  58629. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  58630. * @param forBlock defines an optional block to check compatibility with
  58631. * @returns the first available input or null
  58632. */
  58633. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  58634. /**
  58635. * Gets the sibling of the given output
  58636. * @param current defines the current output
  58637. * @returns the next output in the list or null
  58638. */
  58639. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  58640. /**
  58641. * Connect current block with another block
  58642. * @param other defines the block to connect with
  58643. * @param options define the various options to help pick the right connections
  58644. * @returns the current block
  58645. */
  58646. connectTo(other: NodeMaterialBlock, options?: {
  58647. input?: string;
  58648. output?: string;
  58649. outputSwizzle?: string;
  58650. }): this | undefined;
  58651. protected _buildBlock(state: NodeMaterialBuildState): void;
  58652. /**
  58653. * Add uniforms, samplers and uniform buffers at compilation time
  58654. * @param state defines the state to update
  58655. * @param nodeMaterial defines the node material requesting the update
  58656. * @param defines defines the material defines to update
  58657. * @param uniformBuffers defines the list of uniform buffer names
  58658. */
  58659. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58660. /**
  58661. * Add potential fallbacks if shader compilation fails
  58662. * @param mesh defines the mesh to be rendered
  58663. * @param fallbacks defines the current prioritized list of fallbacks
  58664. */
  58665. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58666. /**
  58667. * Initialize defines for shader compilation
  58668. * @param mesh defines the mesh to be rendered
  58669. * @param nodeMaterial defines the node material requesting the update
  58670. * @param defines defines the material defines to update
  58671. * @param useInstances specifies that instances should be used
  58672. */
  58673. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58674. /**
  58675. * Update defines for shader compilation
  58676. * @param mesh defines the mesh to be rendered
  58677. * @param nodeMaterial defines the node material requesting the update
  58678. * @param defines defines the material defines to update
  58679. * @param useInstances specifies that instances should be used
  58680. */
  58681. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58682. /**
  58683. * Lets the block try to connect some inputs automatically
  58684. * @param material defines the hosting NodeMaterial
  58685. */
  58686. autoConfigure(material: NodeMaterial): void;
  58687. /**
  58688. * Function called when a block is declared as repeatable content generator
  58689. * @param vertexShaderState defines the current compilation state for the vertex shader
  58690. * @param fragmentShaderState defines the current compilation state for the fragment shader
  58691. * @param mesh defines the mesh to be rendered
  58692. * @param defines defines the material defines to update
  58693. */
  58694. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58695. /**
  58696. * Checks if the block is ready
  58697. * @param mesh defines the mesh to be rendered
  58698. * @param nodeMaterial defines the node material requesting the update
  58699. * @param defines defines the material defines to update
  58700. * @param useInstances specifies that instances should be used
  58701. * @returns true if the block is ready
  58702. */
  58703. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  58704. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  58705. private _processBuild;
  58706. /**
  58707. * Compile the current node and generate the shader code
  58708. * @param state defines the current compilation state (uniforms, samplers, current string)
  58709. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  58710. * @returns true if already built
  58711. */
  58712. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  58713. protected _inputRename(name: string): string;
  58714. protected _outputRename(name: string): string;
  58715. protected _dumpPropertiesCode(): string;
  58716. /** @hidden */
  58717. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  58718. /** @hidden */
  58719. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  58720. /**
  58721. * Clone the current block to a new identical block
  58722. * @param scene defines the hosting scene
  58723. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58724. * @returns a copy of the current block
  58725. */
  58726. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  58727. /**
  58728. * Serializes this block in a JSON representation
  58729. * @returns the serialized block object
  58730. */
  58731. serialize(): any;
  58732. /** @hidden */
  58733. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58734. /**
  58735. * Release resources
  58736. */
  58737. dispose(): void;
  58738. }
  58739. }
  58740. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  58741. /**
  58742. * Enum defining the type of animations supported by InputBlock
  58743. */
  58744. export enum AnimatedInputBlockTypes {
  58745. /** No animation */
  58746. None = 0,
  58747. /** Time based animation. Will only work for floats */
  58748. Time = 1
  58749. }
  58750. }
  58751. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  58752. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58753. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58754. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  58755. import { Nullable } from "babylonjs/types";
  58756. import { Effect } from "babylonjs/Materials/effect";
  58757. import { Matrix } from "babylonjs/Maths/math.vector";
  58758. import { Scene } from "babylonjs/scene";
  58759. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58760. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58761. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58762. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  58763. /**
  58764. * Block used to expose an input value
  58765. */
  58766. export class InputBlock extends NodeMaterialBlock {
  58767. private _mode;
  58768. private _associatedVariableName;
  58769. private _storedValue;
  58770. private _valueCallback;
  58771. private _type;
  58772. private _animationType;
  58773. /** Gets or set a value used to limit the range of float values */
  58774. min: number;
  58775. /** Gets or set a value used to limit the range of float values */
  58776. max: number;
  58777. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58778. matrixMode: number;
  58779. /** @hidden */
  58780. _systemValue: Nullable<NodeMaterialSystemValues>;
  58781. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58782. visibleInInspector: boolean;
  58783. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58784. isConstant: boolean;
  58785. /** Gets or sets the group to use to display this block in the Inspector */
  58786. groupInInspector: string;
  58787. /**
  58788. * Gets or sets the connection point type (default is float)
  58789. */
  58790. get type(): NodeMaterialBlockConnectionPointTypes;
  58791. /**
  58792. * Creates a new InputBlock
  58793. * @param name defines the block name
  58794. * @param target defines the target of that block (Vertex by default)
  58795. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58796. */
  58797. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58798. /**
  58799. * Gets the output component
  58800. */
  58801. get output(): NodeMaterialConnectionPoint;
  58802. /**
  58803. * Set the source of this connection point to a vertex attribute
  58804. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58805. * @returns the current connection point
  58806. */
  58807. setAsAttribute(attributeName?: string): InputBlock;
  58808. /**
  58809. * Set the source of this connection point to a system value
  58810. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58811. * @returns the current connection point
  58812. */
  58813. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58814. /**
  58815. * Gets or sets the value of that point.
  58816. * Please note that this value will be ignored if valueCallback is defined
  58817. */
  58818. get value(): any;
  58819. set value(value: any);
  58820. /**
  58821. * Gets or sets a callback used to get the value of that point.
  58822. * Please note that setting this value will force the connection point to ignore the value property
  58823. */
  58824. get valueCallback(): () => any;
  58825. set valueCallback(value: () => any);
  58826. /**
  58827. * Gets or sets the associated variable name in the shader
  58828. */
  58829. get associatedVariableName(): string;
  58830. set associatedVariableName(value: string);
  58831. /** Gets or sets the type of animation applied to the input */
  58832. get animationType(): AnimatedInputBlockTypes;
  58833. set animationType(value: AnimatedInputBlockTypes);
  58834. /**
  58835. * Gets a boolean indicating that this connection point not defined yet
  58836. */
  58837. get isUndefined(): boolean;
  58838. /**
  58839. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58840. * In this case the connection point name must be the name of the uniform to use.
  58841. * Can only be set on inputs
  58842. */
  58843. get isUniform(): boolean;
  58844. set isUniform(value: boolean);
  58845. /**
  58846. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58847. * In this case the connection point name must be the name of the attribute to use
  58848. * Can only be set on inputs
  58849. */
  58850. get isAttribute(): boolean;
  58851. set isAttribute(value: boolean);
  58852. /**
  58853. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58854. * Can only be set on exit points
  58855. */
  58856. get isVarying(): boolean;
  58857. set isVarying(value: boolean);
  58858. /**
  58859. * Gets a boolean indicating that the current connection point is a system value
  58860. */
  58861. get isSystemValue(): boolean;
  58862. /**
  58863. * Gets or sets the current well known value or null if not defined as a system value
  58864. */
  58865. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58866. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58867. /**
  58868. * Gets the current class name
  58869. * @returns the class name
  58870. */
  58871. getClassName(): string;
  58872. /**
  58873. * Animate the input if animationType !== None
  58874. * @param scene defines the rendering scene
  58875. */
  58876. animate(scene: Scene): void;
  58877. private _emitDefine;
  58878. initialize(state: NodeMaterialBuildState): void;
  58879. /**
  58880. * Set the input block to its default value (based on its type)
  58881. */
  58882. setDefaultValue(): void;
  58883. private _emitConstant;
  58884. private _emit;
  58885. /** @hidden */
  58886. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58887. /** @hidden */
  58888. _transmit(effect: Effect, scene: Scene): void;
  58889. protected _buildBlock(state: NodeMaterialBuildState): void;
  58890. protected _dumpPropertiesCode(): string;
  58891. serialize(): any;
  58892. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58893. }
  58894. }
  58895. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  58896. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58897. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58898. import { Nullable } from "babylonjs/types";
  58899. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  58900. import { Observable } from "babylonjs/Misc/observable";
  58901. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58902. /**
  58903. * Enum used to define the compatibility state between two connection points
  58904. */
  58905. export enum NodeMaterialConnectionPointCompatibilityStates {
  58906. /** Points are compatibles */
  58907. Compatible = 0,
  58908. /** Points are incompatible because of their types */
  58909. TypeIncompatible = 1,
  58910. /** Points are incompatible because of their targets (vertex vs fragment) */
  58911. TargetIncompatible = 2
  58912. }
  58913. /**
  58914. * Defines the direction of a connection point
  58915. */
  58916. export enum NodeMaterialConnectionPointDirection {
  58917. /** Input */
  58918. Input = 0,
  58919. /** Output */
  58920. Output = 1
  58921. }
  58922. /**
  58923. * Defines a connection point for a block
  58924. */
  58925. export class NodeMaterialConnectionPoint {
  58926. /** @hidden */
  58927. _ownerBlock: NodeMaterialBlock;
  58928. /** @hidden */
  58929. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58930. private _endpoints;
  58931. private _associatedVariableName;
  58932. private _direction;
  58933. /** @hidden */
  58934. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58935. /** @hidden */
  58936. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58937. private _type;
  58938. /** @hidden */
  58939. _enforceAssociatedVariableName: boolean;
  58940. /** Gets the direction of the point */
  58941. get direction(): NodeMaterialConnectionPointDirection;
  58942. /**
  58943. * Gets or sets the additional types supported by this connection point
  58944. */
  58945. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58946. /**
  58947. * Gets or sets the additional types excluded by this connection point
  58948. */
  58949. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58950. /**
  58951. * Observable triggered when this point is connected
  58952. */
  58953. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58954. /**
  58955. * Gets or sets the associated variable name in the shader
  58956. */
  58957. get associatedVariableName(): string;
  58958. set associatedVariableName(value: string);
  58959. /**
  58960. * Gets or sets the connection point type (default is float)
  58961. */
  58962. get type(): NodeMaterialBlockConnectionPointTypes;
  58963. set type(value: NodeMaterialBlockConnectionPointTypes);
  58964. /**
  58965. * Gets or sets the connection point name
  58966. */
  58967. name: string;
  58968. /**
  58969. * Gets or sets a boolean indicating that this connection point can be omitted
  58970. */
  58971. isOptional: boolean;
  58972. /**
  58973. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58974. */
  58975. define: string;
  58976. /** @hidden */
  58977. _prioritizeVertex: boolean;
  58978. private _target;
  58979. /** Gets or sets the target of that connection point */
  58980. get target(): NodeMaterialBlockTargets;
  58981. set target(value: NodeMaterialBlockTargets);
  58982. /**
  58983. * Gets a boolean indicating that the current point is connected
  58984. */
  58985. get isConnected(): boolean;
  58986. /**
  58987. * Gets a boolean indicating that the current point is connected to an input block
  58988. */
  58989. get isConnectedToInputBlock(): boolean;
  58990. /**
  58991. * Gets a the connected input block (if any)
  58992. */
  58993. get connectInputBlock(): Nullable<InputBlock>;
  58994. /** Get the other side of the connection (if any) */
  58995. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58996. /** Get the block that owns this connection point */
  58997. get ownerBlock(): NodeMaterialBlock;
  58998. /** Get the block connected on the other side of this connection (if any) */
  58999. get sourceBlock(): Nullable<NodeMaterialBlock>;
  59000. /** Get the block connected on the endpoints of this connection (if any) */
  59001. get connectedBlocks(): Array<NodeMaterialBlock>;
  59002. /** Gets the list of connected endpoints */
  59003. get endpoints(): NodeMaterialConnectionPoint[];
  59004. /** Gets a boolean indicating if that output point is connected to at least one input */
  59005. get hasEndpoints(): boolean;
  59006. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  59007. get isConnectedInVertexShader(): boolean;
  59008. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  59009. get isConnectedInFragmentShader(): boolean;
  59010. /**
  59011. * Creates a new connection point
  59012. * @param name defines the connection point name
  59013. * @param ownerBlock defines the block hosting this connection point
  59014. * @param direction defines the direction of the connection point
  59015. */
  59016. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  59017. /**
  59018. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  59019. * @returns the class name
  59020. */
  59021. getClassName(): string;
  59022. /**
  59023. * Gets a boolean indicating if the current point can be connected to another point
  59024. * @param connectionPoint defines the other connection point
  59025. * @returns a boolean
  59026. */
  59027. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  59028. /**
  59029. * Gets a number indicating if the current point can be connected to another point
  59030. * @param connectionPoint defines the other connection point
  59031. * @returns a number defining the compatibility state
  59032. */
  59033. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  59034. /**
  59035. * Connect this point to another connection point
  59036. * @param connectionPoint defines the other connection point
  59037. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  59038. * @returns the current connection point
  59039. */
  59040. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  59041. /**
  59042. * Disconnect this point from one of his endpoint
  59043. * @param endpoint defines the other connection point
  59044. * @returns the current connection point
  59045. */
  59046. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  59047. /**
  59048. * Serializes this point in a JSON representation
  59049. * @returns the serialized point object
  59050. */
  59051. serialize(): any;
  59052. /**
  59053. * Release resources
  59054. */
  59055. dispose(): void;
  59056. }
  59057. }
  59058. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  59059. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59060. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59061. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59062. import { Mesh } from "babylonjs/Meshes/mesh";
  59063. import { Effect } from "babylonjs/Materials/effect";
  59064. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59065. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59066. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59067. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59068. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  59069. /**
  59070. * Block used to add support for vertex skinning (bones)
  59071. */
  59072. export class BonesBlock extends NodeMaterialBlock {
  59073. /**
  59074. * Creates a new BonesBlock
  59075. * @param name defines the block name
  59076. */
  59077. constructor(name: string);
  59078. /**
  59079. * Initialize the block and prepare the context for build
  59080. * @param state defines the state that will be used for the build
  59081. */
  59082. initialize(state: NodeMaterialBuildState): void;
  59083. /**
  59084. * Gets the current class name
  59085. * @returns the class name
  59086. */
  59087. getClassName(): string;
  59088. /**
  59089. * Gets the matrix indices input component
  59090. */
  59091. get matricesIndices(): NodeMaterialConnectionPoint;
  59092. /**
  59093. * Gets the matrix weights input component
  59094. */
  59095. get matricesWeights(): NodeMaterialConnectionPoint;
  59096. /**
  59097. * Gets the extra matrix indices input component
  59098. */
  59099. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  59100. /**
  59101. * Gets the extra matrix weights input component
  59102. */
  59103. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  59104. /**
  59105. * Gets the world input component
  59106. */
  59107. get world(): NodeMaterialConnectionPoint;
  59108. /**
  59109. * Gets the output component
  59110. */
  59111. get output(): NodeMaterialConnectionPoint;
  59112. autoConfigure(material: NodeMaterial): void;
  59113. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  59114. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59115. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59116. protected _buildBlock(state: NodeMaterialBuildState): this;
  59117. }
  59118. }
  59119. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  59120. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59121. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59122. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59123. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59124. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59125. /**
  59126. * Block used to add support for instances
  59127. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  59128. */
  59129. export class InstancesBlock extends NodeMaterialBlock {
  59130. /**
  59131. * Creates a new InstancesBlock
  59132. * @param name defines the block name
  59133. */
  59134. constructor(name: string);
  59135. /**
  59136. * Gets the current class name
  59137. * @returns the class name
  59138. */
  59139. getClassName(): string;
  59140. /**
  59141. * Gets the first world row input component
  59142. */
  59143. get world0(): NodeMaterialConnectionPoint;
  59144. /**
  59145. * Gets the second world row input component
  59146. */
  59147. get world1(): NodeMaterialConnectionPoint;
  59148. /**
  59149. * Gets the third world row input component
  59150. */
  59151. get world2(): NodeMaterialConnectionPoint;
  59152. /**
  59153. * Gets the forth world row input component
  59154. */
  59155. get world3(): NodeMaterialConnectionPoint;
  59156. /**
  59157. * Gets the world input component
  59158. */
  59159. get world(): NodeMaterialConnectionPoint;
  59160. /**
  59161. * Gets the output component
  59162. */
  59163. get output(): NodeMaterialConnectionPoint;
  59164. autoConfigure(material: NodeMaterial): void;
  59165. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59166. protected _buildBlock(state: NodeMaterialBuildState): this;
  59167. }
  59168. }
  59169. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  59170. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59171. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59172. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59174. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59175. import { Effect } from "babylonjs/Materials/effect";
  59176. import { Mesh } from "babylonjs/Meshes/mesh";
  59177. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59178. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59179. /**
  59180. * Block used to add morph targets support to vertex shader
  59181. */
  59182. export class MorphTargetsBlock extends NodeMaterialBlock {
  59183. private _repeatableContentAnchor;
  59184. private _repeatebleContentGenerated;
  59185. /**
  59186. * Create a new MorphTargetsBlock
  59187. * @param name defines the block name
  59188. */
  59189. constructor(name: string);
  59190. /**
  59191. * Gets the current class name
  59192. * @returns the class name
  59193. */
  59194. getClassName(): string;
  59195. /**
  59196. * Gets the position input component
  59197. */
  59198. get position(): NodeMaterialConnectionPoint;
  59199. /**
  59200. * Gets the normal input component
  59201. */
  59202. get normal(): NodeMaterialConnectionPoint;
  59203. /**
  59204. * Gets the tangent input component
  59205. */
  59206. get tangent(): NodeMaterialConnectionPoint;
  59207. /**
  59208. * Gets the tangent input component
  59209. */
  59210. get uv(): NodeMaterialConnectionPoint;
  59211. /**
  59212. * Gets the position output component
  59213. */
  59214. get positionOutput(): NodeMaterialConnectionPoint;
  59215. /**
  59216. * Gets the normal output component
  59217. */
  59218. get normalOutput(): NodeMaterialConnectionPoint;
  59219. /**
  59220. * Gets the tangent output component
  59221. */
  59222. get tangentOutput(): NodeMaterialConnectionPoint;
  59223. /**
  59224. * Gets the tangent output component
  59225. */
  59226. get uvOutput(): NodeMaterialConnectionPoint;
  59227. initialize(state: NodeMaterialBuildState): void;
  59228. autoConfigure(material: NodeMaterial): void;
  59229. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59230. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59231. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  59232. protected _buildBlock(state: NodeMaterialBuildState): this;
  59233. }
  59234. }
  59235. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  59236. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59237. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59238. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59239. import { Nullable } from "babylonjs/types";
  59240. import { Scene } from "babylonjs/scene";
  59241. import { Effect } from "babylonjs/Materials/effect";
  59242. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59243. import { Mesh } from "babylonjs/Meshes/mesh";
  59244. import { Light } from "babylonjs/Lights/light";
  59245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59246. /**
  59247. * Block used to get data information from a light
  59248. */
  59249. export class LightInformationBlock extends NodeMaterialBlock {
  59250. private _lightDataUniformName;
  59251. private _lightColorUniformName;
  59252. private _lightTypeDefineName;
  59253. /**
  59254. * Gets or sets the light associated with this block
  59255. */
  59256. light: Nullable<Light>;
  59257. /**
  59258. * Creates a new LightInformationBlock
  59259. * @param name defines the block name
  59260. */
  59261. constructor(name: string);
  59262. /**
  59263. * Gets the current class name
  59264. * @returns the class name
  59265. */
  59266. getClassName(): string;
  59267. /**
  59268. * Gets the world position input component
  59269. */
  59270. get worldPosition(): NodeMaterialConnectionPoint;
  59271. /**
  59272. * Gets the direction output component
  59273. */
  59274. get direction(): NodeMaterialConnectionPoint;
  59275. /**
  59276. * Gets the direction output component
  59277. */
  59278. get color(): NodeMaterialConnectionPoint;
  59279. /**
  59280. * Gets the direction output component
  59281. */
  59282. get intensity(): NodeMaterialConnectionPoint;
  59283. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59284. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59285. protected _buildBlock(state: NodeMaterialBuildState): this;
  59286. serialize(): any;
  59287. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59288. }
  59289. }
  59290. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  59291. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  59292. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  59293. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  59294. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  59295. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  59296. }
  59297. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  59298. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59299. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59300. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59301. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59302. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59303. import { Effect } from "babylonjs/Materials/effect";
  59304. import { Mesh } from "babylonjs/Meshes/mesh";
  59305. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59306. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59307. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59308. /**
  59309. * Block used to add image processing support to fragment shader
  59310. */
  59311. export class ImageProcessingBlock extends NodeMaterialBlock {
  59312. /**
  59313. * Create a new ImageProcessingBlock
  59314. * @param name defines the block name
  59315. */
  59316. constructor(name: string);
  59317. /**
  59318. * Gets the current class name
  59319. * @returns the class name
  59320. */
  59321. getClassName(): string;
  59322. /**
  59323. * Gets the color input component
  59324. */
  59325. get color(): NodeMaterialConnectionPoint;
  59326. /**
  59327. * Gets the output component
  59328. */
  59329. get output(): NodeMaterialConnectionPoint;
  59330. /**
  59331. * Initialize the block and prepare the context for build
  59332. * @param state defines the state that will be used for the build
  59333. */
  59334. initialize(state: NodeMaterialBuildState): void;
  59335. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  59336. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59337. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59338. protected _buildBlock(state: NodeMaterialBuildState): this;
  59339. }
  59340. }
  59341. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  59342. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59343. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59344. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59345. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59346. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59347. import { Effect } from "babylonjs/Materials/effect";
  59348. import { Mesh } from "babylonjs/Meshes/mesh";
  59349. import { Scene } from "babylonjs/scene";
  59350. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  59351. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  59352. /**
  59353. * Block used to pertub normals based on a normal map
  59354. */
  59355. export class PerturbNormalBlock extends NodeMaterialBlock {
  59356. private _tangentSpaceParameterName;
  59357. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59358. invertX: boolean;
  59359. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  59360. invertY: boolean;
  59361. /**
  59362. * Create a new PerturbNormalBlock
  59363. * @param name defines the block name
  59364. */
  59365. constructor(name: string);
  59366. /**
  59367. * Gets the current class name
  59368. * @returns the class name
  59369. */
  59370. getClassName(): string;
  59371. /**
  59372. * Gets the world position input component
  59373. */
  59374. get worldPosition(): NodeMaterialConnectionPoint;
  59375. /**
  59376. * Gets the world normal input component
  59377. */
  59378. get worldNormal(): NodeMaterialConnectionPoint;
  59379. /**
  59380. * Gets the uv input component
  59381. */
  59382. get uv(): NodeMaterialConnectionPoint;
  59383. /**
  59384. * Gets the normal map color input component
  59385. */
  59386. get normalMapColor(): NodeMaterialConnectionPoint;
  59387. /**
  59388. * Gets the strength input component
  59389. */
  59390. get strength(): NodeMaterialConnectionPoint;
  59391. /**
  59392. * Gets the output component
  59393. */
  59394. get output(): NodeMaterialConnectionPoint;
  59395. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59396. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59397. autoConfigure(material: NodeMaterial): void;
  59398. protected _buildBlock(state: NodeMaterialBuildState): this;
  59399. protected _dumpPropertiesCode(): string;
  59400. serialize(): any;
  59401. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59402. }
  59403. }
  59404. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  59405. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59406. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59407. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59408. /**
  59409. * Block used to discard a pixel if a value is smaller than a cutoff
  59410. */
  59411. export class DiscardBlock extends NodeMaterialBlock {
  59412. /**
  59413. * Create a new DiscardBlock
  59414. * @param name defines the block name
  59415. */
  59416. constructor(name: string);
  59417. /**
  59418. * Gets the current class name
  59419. * @returns the class name
  59420. */
  59421. getClassName(): string;
  59422. /**
  59423. * Gets the color input component
  59424. */
  59425. get value(): NodeMaterialConnectionPoint;
  59426. /**
  59427. * Gets the cutoff input component
  59428. */
  59429. get cutoff(): NodeMaterialConnectionPoint;
  59430. protected _buildBlock(state: NodeMaterialBuildState): this;
  59431. }
  59432. }
  59433. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  59434. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59435. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59436. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59437. /**
  59438. * Block used to test if the fragment shader is front facing
  59439. */
  59440. export class FrontFacingBlock extends NodeMaterialBlock {
  59441. /**
  59442. * Creates a new FrontFacingBlock
  59443. * @param name defines the block name
  59444. */
  59445. constructor(name: string);
  59446. /**
  59447. * Gets the current class name
  59448. * @returns the class name
  59449. */
  59450. getClassName(): string;
  59451. /**
  59452. * Gets the output component
  59453. */
  59454. get output(): NodeMaterialConnectionPoint;
  59455. protected _buildBlock(state: NodeMaterialBuildState): this;
  59456. }
  59457. }
  59458. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  59459. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59460. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59461. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59462. /**
  59463. * Block used to get the derivative value on x and y of a given input
  59464. */
  59465. export class DerivativeBlock extends NodeMaterialBlock {
  59466. /**
  59467. * Create a new DerivativeBlock
  59468. * @param name defines the block name
  59469. */
  59470. constructor(name: string);
  59471. /**
  59472. * Gets the current class name
  59473. * @returns the class name
  59474. */
  59475. getClassName(): string;
  59476. /**
  59477. * Gets the input component
  59478. */
  59479. get input(): NodeMaterialConnectionPoint;
  59480. /**
  59481. * Gets the derivative output on x
  59482. */
  59483. get dx(): NodeMaterialConnectionPoint;
  59484. /**
  59485. * Gets the derivative output on y
  59486. */
  59487. get dy(): NodeMaterialConnectionPoint;
  59488. protected _buildBlock(state: NodeMaterialBuildState): this;
  59489. }
  59490. }
  59491. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  59492. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  59493. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  59494. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  59495. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  59496. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  59497. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  59498. }
  59499. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  59500. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59501. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59502. import { Mesh } from "babylonjs/Meshes/mesh";
  59503. import { Effect } from "babylonjs/Materials/effect";
  59504. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59505. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59506. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59507. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  59508. /**
  59509. * Block used to add support for scene fog
  59510. */
  59511. export class FogBlock extends NodeMaterialBlock {
  59512. private _fogDistanceName;
  59513. private _fogParameters;
  59514. /**
  59515. * Create a new FogBlock
  59516. * @param name defines the block name
  59517. */
  59518. constructor(name: string);
  59519. /**
  59520. * Gets the current class name
  59521. * @returns the class name
  59522. */
  59523. getClassName(): string;
  59524. /**
  59525. * Gets the world position input component
  59526. */
  59527. get worldPosition(): NodeMaterialConnectionPoint;
  59528. /**
  59529. * Gets the view input component
  59530. */
  59531. get view(): NodeMaterialConnectionPoint;
  59532. /**
  59533. * Gets the color input component
  59534. */
  59535. get input(): NodeMaterialConnectionPoint;
  59536. /**
  59537. * Gets the fog color input component
  59538. */
  59539. get fogColor(): NodeMaterialConnectionPoint;
  59540. /**
  59541. * Gets the output component
  59542. */
  59543. get output(): NodeMaterialConnectionPoint;
  59544. autoConfigure(material: NodeMaterial): void;
  59545. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59546. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59547. protected _buildBlock(state: NodeMaterialBuildState): this;
  59548. }
  59549. }
  59550. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  59551. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59552. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59553. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59555. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59556. import { Effect } from "babylonjs/Materials/effect";
  59557. import { Mesh } from "babylonjs/Meshes/mesh";
  59558. import { Light } from "babylonjs/Lights/light";
  59559. import { Nullable } from "babylonjs/types";
  59560. import { Scene } from "babylonjs/scene";
  59561. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59562. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59563. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  59564. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59565. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  59566. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  59567. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  59568. /**
  59569. * Block used to add light in the fragment shader
  59570. */
  59571. export class LightBlock extends NodeMaterialBlock {
  59572. private _lightId;
  59573. /**
  59574. * Gets or sets the light associated with this block
  59575. */
  59576. light: Nullable<Light>;
  59577. /**
  59578. * Create a new LightBlock
  59579. * @param name defines the block name
  59580. */
  59581. constructor(name: string);
  59582. /**
  59583. * Gets the current class name
  59584. * @returns the class name
  59585. */
  59586. getClassName(): string;
  59587. /**
  59588. * Gets the world position input component
  59589. */
  59590. get worldPosition(): NodeMaterialConnectionPoint;
  59591. /**
  59592. * Gets the world normal input component
  59593. */
  59594. get worldNormal(): NodeMaterialConnectionPoint;
  59595. /**
  59596. * Gets the camera (or eye) position component
  59597. */
  59598. get cameraPosition(): NodeMaterialConnectionPoint;
  59599. /**
  59600. * Gets the glossiness component
  59601. */
  59602. get glossiness(): NodeMaterialConnectionPoint;
  59603. /**
  59604. * Gets the glossinness power component
  59605. */
  59606. get glossPower(): NodeMaterialConnectionPoint;
  59607. /**
  59608. * Gets the diffuse color component
  59609. */
  59610. get diffuseColor(): NodeMaterialConnectionPoint;
  59611. /**
  59612. * Gets the specular color component
  59613. */
  59614. get specularColor(): NodeMaterialConnectionPoint;
  59615. /**
  59616. * Gets the diffuse output component
  59617. */
  59618. get diffuseOutput(): NodeMaterialConnectionPoint;
  59619. /**
  59620. * Gets the specular output component
  59621. */
  59622. get specularOutput(): NodeMaterialConnectionPoint;
  59623. /**
  59624. * Gets the shadow output component
  59625. */
  59626. get shadow(): NodeMaterialConnectionPoint;
  59627. autoConfigure(material: NodeMaterial): void;
  59628. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59629. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59630. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59631. private _injectVertexCode;
  59632. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59633. serialize(): any;
  59634. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59635. }
  59636. }
  59637. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  59638. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  59639. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  59640. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59641. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59642. }
  59643. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  59644. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59645. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  59646. }
  59647. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  59648. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59649. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59650. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59651. /**
  59652. * Block used to multiply 2 values
  59653. */
  59654. export class MultiplyBlock extends NodeMaterialBlock {
  59655. /**
  59656. * Creates a new MultiplyBlock
  59657. * @param name defines the block name
  59658. */
  59659. constructor(name: string);
  59660. /**
  59661. * Gets the current class name
  59662. * @returns the class name
  59663. */
  59664. getClassName(): string;
  59665. /**
  59666. * Gets the left operand input component
  59667. */
  59668. get left(): NodeMaterialConnectionPoint;
  59669. /**
  59670. * Gets the right operand input component
  59671. */
  59672. get right(): NodeMaterialConnectionPoint;
  59673. /**
  59674. * Gets the output component
  59675. */
  59676. get output(): NodeMaterialConnectionPoint;
  59677. protected _buildBlock(state: NodeMaterialBuildState): this;
  59678. }
  59679. }
  59680. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  59681. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59682. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59683. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59684. /**
  59685. * Block used to add 2 vectors
  59686. */
  59687. export class AddBlock extends NodeMaterialBlock {
  59688. /**
  59689. * Creates a new AddBlock
  59690. * @param name defines the block name
  59691. */
  59692. constructor(name: string);
  59693. /**
  59694. * Gets the current class name
  59695. * @returns the class name
  59696. */
  59697. getClassName(): string;
  59698. /**
  59699. * Gets the left operand input component
  59700. */
  59701. get left(): NodeMaterialConnectionPoint;
  59702. /**
  59703. * Gets the right operand input component
  59704. */
  59705. get right(): NodeMaterialConnectionPoint;
  59706. /**
  59707. * Gets the output component
  59708. */
  59709. get output(): NodeMaterialConnectionPoint;
  59710. protected _buildBlock(state: NodeMaterialBuildState): this;
  59711. }
  59712. }
  59713. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  59714. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59715. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59716. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59717. /**
  59718. * Block used to scale a vector by a float
  59719. */
  59720. export class ScaleBlock extends NodeMaterialBlock {
  59721. /**
  59722. * Creates a new ScaleBlock
  59723. * @param name defines the block name
  59724. */
  59725. constructor(name: string);
  59726. /**
  59727. * Gets the current class name
  59728. * @returns the class name
  59729. */
  59730. getClassName(): string;
  59731. /**
  59732. * Gets the input component
  59733. */
  59734. get input(): NodeMaterialConnectionPoint;
  59735. /**
  59736. * Gets the factor input component
  59737. */
  59738. get factor(): NodeMaterialConnectionPoint;
  59739. /**
  59740. * Gets the output component
  59741. */
  59742. get output(): NodeMaterialConnectionPoint;
  59743. protected _buildBlock(state: NodeMaterialBuildState): this;
  59744. }
  59745. }
  59746. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  59747. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59748. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59749. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59750. import { Scene } from "babylonjs/scene";
  59751. /**
  59752. * Block used to clamp a float
  59753. */
  59754. export class ClampBlock extends NodeMaterialBlock {
  59755. /** Gets or sets the minimum range */
  59756. minimum: number;
  59757. /** Gets or sets the maximum range */
  59758. maximum: number;
  59759. /**
  59760. * Creates a new ClampBlock
  59761. * @param name defines the block name
  59762. */
  59763. constructor(name: string);
  59764. /**
  59765. * Gets the current class name
  59766. * @returns the class name
  59767. */
  59768. getClassName(): string;
  59769. /**
  59770. * Gets the value input component
  59771. */
  59772. get value(): NodeMaterialConnectionPoint;
  59773. /**
  59774. * Gets the output component
  59775. */
  59776. get output(): NodeMaterialConnectionPoint;
  59777. protected _buildBlock(state: NodeMaterialBuildState): this;
  59778. protected _dumpPropertiesCode(): string;
  59779. serialize(): any;
  59780. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59781. }
  59782. }
  59783. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  59784. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59785. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59786. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59787. /**
  59788. * Block used to apply a cross product between 2 vectors
  59789. */
  59790. export class CrossBlock extends NodeMaterialBlock {
  59791. /**
  59792. * Creates a new CrossBlock
  59793. * @param name defines the block name
  59794. */
  59795. constructor(name: string);
  59796. /**
  59797. * Gets the current class name
  59798. * @returns the class name
  59799. */
  59800. getClassName(): string;
  59801. /**
  59802. * Gets the left operand input component
  59803. */
  59804. get left(): NodeMaterialConnectionPoint;
  59805. /**
  59806. * Gets the right operand input component
  59807. */
  59808. get right(): NodeMaterialConnectionPoint;
  59809. /**
  59810. * Gets the output component
  59811. */
  59812. get output(): NodeMaterialConnectionPoint;
  59813. protected _buildBlock(state: NodeMaterialBuildState): this;
  59814. }
  59815. }
  59816. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  59817. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59818. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59819. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59820. /**
  59821. * Block used to apply a dot product between 2 vectors
  59822. */
  59823. export class DotBlock extends NodeMaterialBlock {
  59824. /**
  59825. * Creates a new DotBlock
  59826. * @param name defines the block name
  59827. */
  59828. constructor(name: string);
  59829. /**
  59830. * Gets the current class name
  59831. * @returns the class name
  59832. */
  59833. getClassName(): string;
  59834. /**
  59835. * Gets the left operand input component
  59836. */
  59837. get left(): NodeMaterialConnectionPoint;
  59838. /**
  59839. * Gets the right operand input component
  59840. */
  59841. get right(): NodeMaterialConnectionPoint;
  59842. /**
  59843. * Gets the output component
  59844. */
  59845. get output(): NodeMaterialConnectionPoint;
  59846. protected _buildBlock(state: NodeMaterialBuildState): this;
  59847. }
  59848. }
  59849. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  59850. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59851. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59852. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59853. import { Vector2 } from "babylonjs/Maths/math.vector";
  59854. import { Scene } from "babylonjs/scene";
  59855. /**
  59856. * Block used to remap a float from a range to a new one
  59857. */
  59858. export class RemapBlock extends NodeMaterialBlock {
  59859. /**
  59860. * Gets or sets the source range
  59861. */
  59862. sourceRange: Vector2;
  59863. /**
  59864. * Gets or sets the target range
  59865. */
  59866. targetRange: Vector2;
  59867. /**
  59868. * Creates a new RemapBlock
  59869. * @param name defines the block name
  59870. */
  59871. constructor(name: string);
  59872. /**
  59873. * Gets the current class name
  59874. * @returns the class name
  59875. */
  59876. getClassName(): string;
  59877. /**
  59878. * Gets the input component
  59879. */
  59880. get input(): NodeMaterialConnectionPoint;
  59881. /**
  59882. * Gets the source min input component
  59883. */
  59884. get sourceMin(): NodeMaterialConnectionPoint;
  59885. /**
  59886. * Gets the source max input component
  59887. */
  59888. get sourceMax(): NodeMaterialConnectionPoint;
  59889. /**
  59890. * Gets the target min input component
  59891. */
  59892. get targetMin(): NodeMaterialConnectionPoint;
  59893. /**
  59894. * Gets the target max input component
  59895. */
  59896. get targetMax(): NodeMaterialConnectionPoint;
  59897. /**
  59898. * Gets the output component
  59899. */
  59900. get output(): NodeMaterialConnectionPoint;
  59901. protected _buildBlock(state: NodeMaterialBuildState): this;
  59902. protected _dumpPropertiesCode(): string;
  59903. serialize(): any;
  59904. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59905. }
  59906. }
  59907. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  59908. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59909. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59910. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59911. /**
  59912. * Block used to normalize a vector
  59913. */
  59914. export class NormalizeBlock extends NodeMaterialBlock {
  59915. /**
  59916. * Creates a new NormalizeBlock
  59917. * @param name defines the block name
  59918. */
  59919. constructor(name: string);
  59920. /**
  59921. * Gets the current class name
  59922. * @returns the class name
  59923. */
  59924. getClassName(): string;
  59925. /**
  59926. * Gets the input component
  59927. */
  59928. get input(): NodeMaterialConnectionPoint;
  59929. /**
  59930. * Gets the output component
  59931. */
  59932. get output(): NodeMaterialConnectionPoint;
  59933. protected _buildBlock(state: NodeMaterialBuildState): this;
  59934. }
  59935. }
  59936. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  59937. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59938. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59939. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59940. import { Scene } from "babylonjs/scene";
  59941. /**
  59942. * Operations supported by the Trigonometry block
  59943. */
  59944. export enum TrigonometryBlockOperations {
  59945. /** Cos */
  59946. Cos = 0,
  59947. /** Sin */
  59948. Sin = 1,
  59949. /** Abs */
  59950. Abs = 2,
  59951. /** Exp */
  59952. Exp = 3,
  59953. /** Exp2 */
  59954. Exp2 = 4,
  59955. /** Round */
  59956. Round = 5,
  59957. /** Floor */
  59958. Floor = 6,
  59959. /** Ceiling */
  59960. Ceiling = 7,
  59961. /** Square root */
  59962. Sqrt = 8,
  59963. /** Log */
  59964. Log = 9,
  59965. /** Tangent */
  59966. Tan = 10,
  59967. /** Arc tangent */
  59968. ArcTan = 11,
  59969. /** Arc cosinus */
  59970. ArcCos = 12,
  59971. /** Arc sinus */
  59972. ArcSin = 13,
  59973. /** Fraction */
  59974. Fract = 14,
  59975. /** Sign */
  59976. Sign = 15,
  59977. /** To radians (from degrees) */
  59978. Radians = 16,
  59979. /** To degrees (from radians) */
  59980. Degrees = 17
  59981. }
  59982. /**
  59983. * Block used to apply trigonometry operation to floats
  59984. */
  59985. export class TrigonometryBlock extends NodeMaterialBlock {
  59986. /**
  59987. * Gets or sets the operation applied by the block
  59988. */
  59989. operation: TrigonometryBlockOperations;
  59990. /**
  59991. * Creates a new TrigonometryBlock
  59992. * @param name defines the block name
  59993. */
  59994. constructor(name: string);
  59995. /**
  59996. * Gets the current class name
  59997. * @returns the class name
  59998. */
  59999. getClassName(): string;
  60000. /**
  60001. * Gets the input component
  60002. */
  60003. get input(): NodeMaterialConnectionPoint;
  60004. /**
  60005. * Gets the output component
  60006. */
  60007. get output(): NodeMaterialConnectionPoint;
  60008. protected _buildBlock(state: NodeMaterialBuildState): this;
  60009. serialize(): any;
  60010. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60011. protected _dumpPropertiesCode(): string;
  60012. }
  60013. }
  60014. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  60015. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60016. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60017. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60018. /**
  60019. * Block used to create a Color3/4 out of individual inputs (one for each component)
  60020. */
  60021. export class ColorMergerBlock extends NodeMaterialBlock {
  60022. /**
  60023. * Create a new ColorMergerBlock
  60024. * @param name defines the block name
  60025. */
  60026. constructor(name: string);
  60027. /**
  60028. * Gets the current class name
  60029. * @returns the class name
  60030. */
  60031. getClassName(): string;
  60032. /**
  60033. * Gets the rgb component (input)
  60034. */
  60035. get rgbIn(): NodeMaterialConnectionPoint;
  60036. /**
  60037. * Gets the r component (input)
  60038. */
  60039. get r(): NodeMaterialConnectionPoint;
  60040. /**
  60041. * Gets the g component (input)
  60042. */
  60043. get g(): NodeMaterialConnectionPoint;
  60044. /**
  60045. * Gets the b component (input)
  60046. */
  60047. get b(): NodeMaterialConnectionPoint;
  60048. /**
  60049. * Gets the a component (input)
  60050. */
  60051. get a(): NodeMaterialConnectionPoint;
  60052. /**
  60053. * Gets the rgba component (output)
  60054. */
  60055. get rgba(): NodeMaterialConnectionPoint;
  60056. /**
  60057. * Gets the rgb component (output)
  60058. */
  60059. get rgbOut(): NodeMaterialConnectionPoint;
  60060. /**
  60061. * Gets the rgb component (output)
  60062. * @deprecated Please use rgbOut instead.
  60063. */
  60064. get rgb(): NodeMaterialConnectionPoint;
  60065. protected _buildBlock(state: NodeMaterialBuildState): this;
  60066. }
  60067. }
  60068. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  60069. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60070. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60071. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60072. /**
  60073. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  60074. */
  60075. export class VectorMergerBlock extends NodeMaterialBlock {
  60076. /**
  60077. * Create a new VectorMergerBlock
  60078. * @param name defines the block name
  60079. */
  60080. constructor(name: string);
  60081. /**
  60082. * Gets the current class name
  60083. * @returns the class name
  60084. */
  60085. getClassName(): string;
  60086. /**
  60087. * Gets the xyz component (input)
  60088. */
  60089. get xyzIn(): NodeMaterialConnectionPoint;
  60090. /**
  60091. * Gets the xy component (input)
  60092. */
  60093. get xyIn(): NodeMaterialConnectionPoint;
  60094. /**
  60095. * Gets the x component (input)
  60096. */
  60097. get x(): NodeMaterialConnectionPoint;
  60098. /**
  60099. * Gets the y component (input)
  60100. */
  60101. get y(): NodeMaterialConnectionPoint;
  60102. /**
  60103. * Gets the z component (input)
  60104. */
  60105. get z(): NodeMaterialConnectionPoint;
  60106. /**
  60107. * Gets the w component (input)
  60108. */
  60109. get w(): NodeMaterialConnectionPoint;
  60110. /**
  60111. * Gets the xyzw component (output)
  60112. */
  60113. get xyzw(): NodeMaterialConnectionPoint;
  60114. /**
  60115. * Gets the xyz component (output)
  60116. */
  60117. get xyzOut(): NodeMaterialConnectionPoint;
  60118. /**
  60119. * Gets the xy component (output)
  60120. */
  60121. get xyOut(): NodeMaterialConnectionPoint;
  60122. /**
  60123. * Gets the xy component (output)
  60124. * @deprecated Please use xyOut instead.
  60125. */
  60126. get xy(): NodeMaterialConnectionPoint;
  60127. /**
  60128. * Gets the xyz component (output)
  60129. * @deprecated Please use xyzOut instead.
  60130. */
  60131. get xyz(): NodeMaterialConnectionPoint;
  60132. protected _buildBlock(state: NodeMaterialBuildState): this;
  60133. }
  60134. }
  60135. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  60136. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60137. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60138. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60139. /**
  60140. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  60141. */
  60142. export class ColorSplitterBlock extends NodeMaterialBlock {
  60143. /**
  60144. * Create a new ColorSplitterBlock
  60145. * @param name defines the block name
  60146. */
  60147. constructor(name: string);
  60148. /**
  60149. * Gets the current class name
  60150. * @returns the class name
  60151. */
  60152. getClassName(): string;
  60153. /**
  60154. * Gets the rgba component (input)
  60155. */
  60156. get rgba(): NodeMaterialConnectionPoint;
  60157. /**
  60158. * Gets the rgb component (input)
  60159. */
  60160. get rgbIn(): NodeMaterialConnectionPoint;
  60161. /**
  60162. * Gets the rgb component (output)
  60163. */
  60164. get rgbOut(): NodeMaterialConnectionPoint;
  60165. /**
  60166. * Gets the r component (output)
  60167. */
  60168. get r(): NodeMaterialConnectionPoint;
  60169. /**
  60170. * Gets the g component (output)
  60171. */
  60172. get g(): NodeMaterialConnectionPoint;
  60173. /**
  60174. * Gets the b component (output)
  60175. */
  60176. get b(): NodeMaterialConnectionPoint;
  60177. /**
  60178. * Gets the a component (output)
  60179. */
  60180. get a(): NodeMaterialConnectionPoint;
  60181. protected _inputRename(name: string): string;
  60182. protected _outputRename(name: string): string;
  60183. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60184. }
  60185. }
  60186. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  60187. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60188. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60189. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60190. /**
  60191. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  60192. */
  60193. export class VectorSplitterBlock extends NodeMaterialBlock {
  60194. /**
  60195. * Create a new VectorSplitterBlock
  60196. * @param name defines the block name
  60197. */
  60198. constructor(name: string);
  60199. /**
  60200. * Gets the current class name
  60201. * @returns the class name
  60202. */
  60203. getClassName(): string;
  60204. /**
  60205. * Gets the xyzw component (input)
  60206. */
  60207. get xyzw(): NodeMaterialConnectionPoint;
  60208. /**
  60209. * Gets the xyz component (input)
  60210. */
  60211. get xyzIn(): NodeMaterialConnectionPoint;
  60212. /**
  60213. * Gets the xy component (input)
  60214. */
  60215. get xyIn(): NodeMaterialConnectionPoint;
  60216. /**
  60217. * Gets the xyz component (output)
  60218. */
  60219. get xyzOut(): NodeMaterialConnectionPoint;
  60220. /**
  60221. * Gets the xy component (output)
  60222. */
  60223. get xyOut(): NodeMaterialConnectionPoint;
  60224. /**
  60225. * Gets the x component (output)
  60226. */
  60227. get x(): NodeMaterialConnectionPoint;
  60228. /**
  60229. * Gets the y component (output)
  60230. */
  60231. get y(): NodeMaterialConnectionPoint;
  60232. /**
  60233. * Gets the z component (output)
  60234. */
  60235. get z(): NodeMaterialConnectionPoint;
  60236. /**
  60237. * Gets the w component (output)
  60238. */
  60239. get w(): NodeMaterialConnectionPoint;
  60240. protected _inputRename(name: string): string;
  60241. protected _outputRename(name: string): string;
  60242. protected _buildBlock(state: NodeMaterialBuildState): this;
  60243. }
  60244. }
  60245. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  60246. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60247. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60248. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60249. /**
  60250. * Block used to lerp between 2 values
  60251. */
  60252. export class LerpBlock extends NodeMaterialBlock {
  60253. /**
  60254. * Creates a new LerpBlock
  60255. * @param name defines the block name
  60256. */
  60257. constructor(name: string);
  60258. /**
  60259. * Gets the current class name
  60260. * @returns the class name
  60261. */
  60262. getClassName(): string;
  60263. /**
  60264. * Gets the left operand input component
  60265. */
  60266. get left(): NodeMaterialConnectionPoint;
  60267. /**
  60268. * Gets the right operand input component
  60269. */
  60270. get right(): NodeMaterialConnectionPoint;
  60271. /**
  60272. * Gets the gradient operand input component
  60273. */
  60274. get gradient(): NodeMaterialConnectionPoint;
  60275. /**
  60276. * Gets the output component
  60277. */
  60278. get output(): NodeMaterialConnectionPoint;
  60279. protected _buildBlock(state: NodeMaterialBuildState): this;
  60280. }
  60281. }
  60282. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  60283. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60284. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60285. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60286. /**
  60287. * Block used to divide 2 vectors
  60288. */
  60289. export class DivideBlock extends NodeMaterialBlock {
  60290. /**
  60291. * Creates a new DivideBlock
  60292. * @param name defines the block name
  60293. */
  60294. constructor(name: string);
  60295. /**
  60296. * Gets the current class name
  60297. * @returns the class name
  60298. */
  60299. getClassName(): string;
  60300. /**
  60301. * Gets the left operand input component
  60302. */
  60303. get left(): NodeMaterialConnectionPoint;
  60304. /**
  60305. * Gets the right operand input component
  60306. */
  60307. get right(): NodeMaterialConnectionPoint;
  60308. /**
  60309. * Gets the output component
  60310. */
  60311. get output(): NodeMaterialConnectionPoint;
  60312. protected _buildBlock(state: NodeMaterialBuildState): this;
  60313. }
  60314. }
  60315. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  60316. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60317. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60318. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60319. /**
  60320. * Block used to subtract 2 vectors
  60321. */
  60322. export class SubtractBlock extends NodeMaterialBlock {
  60323. /**
  60324. * Creates a new SubtractBlock
  60325. * @param name defines the block name
  60326. */
  60327. constructor(name: string);
  60328. /**
  60329. * Gets the current class name
  60330. * @returns the class name
  60331. */
  60332. getClassName(): string;
  60333. /**
  60334. * Gets the left operand input component
  60335. */
  60336. get left(): NodeMaterialConnectionPoint;
  60337. /**
  60338. * Gets the right operand input component
  60339. */
  60340. get right(): NodeMaterialConnectionPoint;
  60341. /**
  60342. * Gets the output component
  60343. */
  60344. get output(): NodeMaterialConnectionPoint;
  60345. protected _buildBlock(state: NodeMaterialBuildState): this;
  60346. }
  60347. }
  60348. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  60349. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60350. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60351. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60352. /**
  60353. * Block used to step a value
  60354. */
  60355. export class StepBlock extends NodeMaterialBlock {
  60356. /**
  60357. * Creates a new StepBlock
  60358. * @param name defines the block name
  60359. */
  60360. constructor(name: string);
  60361. /**
  60362. * Gets the current class name
  60363. * @returns the class name
  60364. */
  60365. getClassName(): string;
  60366. /**
  60367. * Gets the value operand input component
  60368. */
  60369. get value(): NodeMaterialConnectionPoint;
  60370. /**
  60371. * Gets the edge operand input component
  60372. */
  60373. get edge(): NodeMaterialConnectionPoint;
  60374. /**
  60375. * Gets the output component
  60376. */
  60377. get output(): NodeMaterialConnectionPoint;
  60378. protected _buildBlock(state: NodeMaterialBuildState): this;
  60379. }
  60380. }
  60381. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  60382. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60383. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60384. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60385. /**
  60386. * Block used to get the opposite (1 - x) of a value
  60387. */
  60388. export class OneMinusBlock extends NodeMaterialBlock {
  60389. /**
  60390. * Creates a new OneMinusBlock
  60391. * @param name defines the block name
  60392. */
  60393. constructor(name: string);
  60394. /**
  60395. * Gets the current class name
  60396. * @returns the class name
  60397. */
  60398. getClassName(): string;
  60399. /**
  60400. * Gets the input component
  60401. */
  60402. get input(): NodeMaterialConnectionPoint;
  60403. /**
  60404. * Gets the output component
  60405. */
  60406. get output(): NodeMaterialConnectionPoint;
  60407. protected _buildBlock(state: NodeMaterialBuildState): this;
  60408. }
  60409. }
  60410. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  60411. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60412. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60413. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60414. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  60415. /**
  60416. * Block used to get the view direction
  60417. */
  60418. export class ViewDirectionBlock extends NodeMaterialBlock {
  60419. /**
  60420. * Creates a new ViewDirectionBlock
  60421. * @param name defines the block name
  60422. */
  60423. constructor(name: string);
  60424. /**
  60425. * Gets the current class name
  60426. * @returns the class name
  60427. */
  60428. getClassName(): string;
  60429. /**
  60430. * Gets the world position component
  60431. */
  60432. get worldPosition(): NodeMaterialConnectionPoint;
  60433. /**
  60434. * Gets the camera position component
  60435. */
  60436. get cameraPosition(): NodeMaterialConnectionPoint;
  60437. /**
  60438. * Gets the output component
  60439. */
  60440. get output(): NodeMaterialConnectionPoint;
  60441. autoConfigure(material: NodeMaterial): void;
  60442. protected _buildBlock(state: NodeMaterialBuildState): this;
  60443. }
  60444. }
  60445. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  60446. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60447. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60448. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60449. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  60450. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  60451. /**
  60452. * Block used to compute fresnel value
  60453. */
  60454. export class FresnelBlock extends NodeMaterialBlock {
  60455. /**
  60456. * Create a new FresnelBlock
  60457. * @param name defines the block name
  60458. */
  60459. constructor(name: string);
  60460. /**
  60461. * Gets the current class name
  60462. * @returns the class name
  60463. */
  60464. getClassName(): string;
  60465. /**
  60466. * Gets the world normal input component
  60467. */
  60468. get worldNormal(): NodeMaterialConnectionPoint;
  60469. /**
  60470. * Gets the view direction input component
  60471. */
  60472. get viewDirection(): NodeMaterialConnectionPoint;
  60473. /**
  60474. * Gets the bias input component
  60475. */
  60476. get bias(): NodeMaterialConnectionPoint;
  60477. /**
  60478. * Gets the camera (or eye) position component
  60479. */
  60480. get power(): NodeMaterialConnectionPoint;
  60481. /**
  60482. * Gets the fresnel output component
  60483. */
  60484. get fresnel(): NodeMaterialConnectionPoint;
  60485. autoConfigure(material: NodeMaterial): void;
  60486. protected _buildBlock(state: NodeMaterialBuildState): this;
  60487. }
  60488. }
  60489. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  60490. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60491. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60492. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60493. /**
  60494. * Block used to get the max of 2 values
  60495. */
  60496. export class MaxBlock extends NodeMaterialBlock {
  60497. /**
  60498. * Creates a new MaxBlock
  60499. * @param name defines the block name
  60500. */
  60501. constructor(name: string);
  60502. /**
  60503. * Gets the current class name
  60504. * @returns the class name
  60505. */
  60506. getClassName(): string;
  60507. /**
  60508. * Gets the left operand input component
  60509. */
  60510. get left(): NodeMaterialConnectionPoint;
  60511. /**
  60512. * Gets the right operand input component
  60513. */
  60514. get right(): NodeMaterialConnectionPoint;
  60515. /**
  60516. * Gets the output component
  60517. */
  60518. get output(): NodeMaterialConnectionPoint;
  60519. protected _buildBlock(state: NodeMaterialBuildState): this;
  60520. }
  60521. }
  60522. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  60523. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60524. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60525. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60526. /**
  60527. * Block used to get the min of 2 values
  60528. */
  60529. export class MinBlock extends NodeMaterialBlock {
  60530. /**
  60531. * Creates a new MinBlock
  60532. * @param name defines the block name
  60533. */
  60534. constructor(name: string);
  60535. /**
  60536. * Gets the current class name
  60537. * @returns the class name
  60538. */
  60539. getClassName(): string;
  60540. /**
  60541. * Gets the left operand input component
  60542. */
  60543. get left(): NodeMaterialConnectionPoint;
  60544. /**
  60545. * Gets the right operand input component
  60546. */
  60547. get right(): NodeMaterialConnectionPoint;
  60548. /**
  60549. * Gets the output component
  60550. */
  60551. get output(): NodeMaterialConnectionPoint;
  60552. protected _buildBlock(state: NodeMaterialBuildState): this;
  60553. }
  60554. }
  60555. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  60556. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60557. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60558. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60559. /**
  60560. * Block used to get the distance between 2 values
  60561. */
  60562. export class DistanceBlock extends NodeMaterialBlock {
  60563. /**
  60564. * Creates a new DistanceBlock
  60565. * @param name defines the block name
  60566. */
  60567. constructor(name: string);
  60568. /**
  60569. * Gets the current class name
  60570. * @returns the class name
  60571. */
  60572. getClassName(): string;
  60573. /**
  60574. * Gets the left operand input component
  60575. */
  60576. get left(): NodeMaterialConnectionPoint;
  60577. /**
  60578. * Gets the right operand input component
  60579. */
  60580. get right(): NodeMaterialConnectionPoint;
  60581. /**
  60582. * Gets the output component
  60583. */
  60584. get output(): NodeMaterialConnectionPoint;
  60585. protected _buildBlock(state: NodeMaterialBuildState): this;
  60586. }
  60587. }
  60588. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  60589. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60590. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60591. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60592. /**
  60593. * Block used to get the length of a vector
  60594. */
  60595. export class LengthBlock extends NodeMaterialBlock {
  60596. /**
  60597. * Creates a new LengthBlock
  60598. * @param name defines the block name
  60599. */
  60600. constructor(name: string);
  60601. /**
  60602. * Gets the current class name
  60603. * @returns the class name
  60604. */
  60605. getClassName(): string;
  60606. /**
  60607. * Gets the value input component
  60608. */
  60609. get value(): NodeMaterialConnectionPoint;
  60610. /**
  60611. * Gets the output component
  60612. */
  60613. get output(): NodeMaterialConnectionPoint;
  60614. protected _buildBlock(state: NodeMaterialBuildState): this;
  60615. }
  60616. }
  60617. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  60618. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60619. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60620. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60621. /**
  60622. * Block used to get negative version of a value (i.e. x * -1)
  60623. */
  60624. export class NegateBlock extends NodeMaterialBlock {
  60625. /**
  60626. * Creates a new NegateBlock
  60627. * @param name defines the block name
  60628. */
  60629. constructor(name: string);
  60630. /**
  60631. * Gets the current class name
  60632. * @returns the class name
  60633. */
  60634. getClassName(): string;
  60635. /**
  60636. * Gets the value input component
  60637. */
  60638. get value(): NodeMaterialConnectionPoint;
  60639. /**
  60640. * Gets the output component
  60641. */
  60642. get output(): NodeMaterialConnectionPoint;
  60643. protected _buildBlock(state: NodeMaterialBuildState): this;
  60644. }
  60645. }
  60646. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  60647. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60648. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60649. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60650. /**
  60651. * Block used to get the value of the first parameter raised to the power of the second
  60652. */
  60653. export class PowBlock extends NodeMaterialBlock {
  60654. /**
  60655. * Creates a new PowBlock
  60656. * @param name defines the block name
  60657. */
  60658. constructor(name: string);
  60659. /**
  60660. * Gets the current class name
  60661. * @returns the class name
  60662. */
  60663. getClassName(): string;
  60664. /**
  60665. * Gets the value operand input component
  60666. */
  60667. get value(): NodeMaterialConnectionPoint;
  60668. /**
  60669. * Gets the power operand input component
  60670. */
  60671. get power(): NodeMaterialConnectionPoint;
  60672. /**
  60673. * Gets the output component
  60674. */
  60675. get output(): NodeMaterialConnectionPoint;
  60676. protected _buildBlock(state: NodeMaterialBuildState): this;
  60677. }
  60678. }
  60679. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  60680. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60681. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60682. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60683. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60684. /**
  60685. * Block used to get a random number
  60686. */
  60687. export class RandomNumberBlock extends NodeMaterialBlock {
  60688. /**
  60689. * Creates a new RandomNumberBlock
  60690. * @param name defines the block name
  60691. */
  60692. constructor(name: string);
  60693. /**
  60694. * Gets the current class name
  60695. * @returns the class name
  60696. */
  60697. getClassName(): string;
  60698. /**
  60699. * Gets the seed input component
  60700. */
  60701. get seed(): NodeMaterialConnectionPoint;
  60702. /**
  60703. * Gets the output component
  60704. */
  60705. get output(): NodeMaterialConnectionPoint;
  60706. protected _buildBlock(state: NodeMaterialBuildState): this;
  60707. }
  60708. }
  60709. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  60710. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60711. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60712. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60713. /**
  60714. * Block used to compute arc tangent of 2 values
  60715. */
  60716. export class ArcTan2Block extends NodeMaterialBlock {
  60717. /**
  60718. * Creates a new ArcTan2Block
  60719. * @param name defines the block name
  60720. */
  60721. constructor(name: string);
  60722. /**
  60723. * Gets the current class name
  60724. * @returns the class name
  60725. */
  60726. getClassName(): string;
  60727. /**
  60728. * Gets the x operand input component
  60729. */
  60730. get x(): NodeMaterialConnectionPoint;
  60731. /**
  60732. * Gets the y operand input component
  60733. */
  60734. get y(): NodeMaterialConnectionPoint;
  60735. /**
  60736. * Gets the output component
  60737. */
  60738. get output(): NodeMaterialConnectionPoint;
  60739. protected _buildBlock(state: NodeMaterialBuildState): this;
  60740. }
  60741. }
  60742. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  60743. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60744. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60745. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60746. /**
  60747. * Block used to smooth step a value
  60748. */
  60749. export class SmoothStepBlock extends NodeMaterialBlock {
  60750. /**
  60751. * Creates a new SmoothStepBlock
  60752. * @param name defines the block name
  60753. */
  60754. constructor(name: string);
  60755. /**
  60756. * Gets the current class name
  60757. * @returns the class name
  60758. */
  60759. getClassName(): string;
  60760. /**
  60761. * Gets the value operand input component
  60762. */
  60763. get value(): NodeMaterialConnectionPoint;
  60764. /**
  60765. * Gets the first edge operand input component
  60766. */
  60767. get edge0(): NodeMaterialConnectionPoint;
  60768. /**
  60769. * Gets the second edge operand input component
  60770. */
  60771. get edge1(): NodeMaterialConnectionPoint;
  60772. /**
  60773. * Gets the output component
  60774. */
  60775. get output(): NodeMaterialConnectionPoint;
  60776. protected _buildBlock(state: NodeMaterialBuildState): this;
  60777. }
  60778. }
  60779. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  60780. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60781. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60782. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60783. /**
  60784. * Block used to get the reciprocal (1 / x) of a value
  60785. */
  60786. export class ReciprocalBlock extends NodeMaterialBlock {
  60787. /**
  60788. * Creates a new ReciprocalBlock
  60789. * @param name defines the block name
  60790. */
  60791. constructor(name: string);
  60792. /**
  60793. * Gets the current class name
  60794. * @returns the class name
  60795. */
  60796. getClassName(): string;
  60797. /**
  60798. * Gets the input component
  60799. */
  60800. get input(): NodeMaterialConnectionPoint;
  60801. /**
  60802. * Gets the output component
  60803. */
  60804. get output(): NodeMaterialConnectionPoint;
  60805. protected _buildBlock(state: NodeMaterialBuildState): this;
  60806. }
  60807. }
  60808. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  60809. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60810. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60811. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60812. /**
  60813. * Block used to replace a color by another one
  60814. */
  60815. export class ReplaceColorBlock extends NodeMaterialBlock {
  60816. /**
  60817. * Creates a new ReplaceColorBlock
  60818. * @param name defines the block name
  60819. */
  60820. constructor(name: string);
  60821. /**
  60822. * Gets the current class name
  60823. * @returns the class name
  60824. */
  60825. getClassName(): string;
  60826. /**
  60827. * Gets the value input component
  60828. */
  60829. get value(): NodeMaterialConnectionPoint;
  60830. /**
  60831. * Gets the reference input component
  60832. */
  60833. get reference(): NodeMaterialConnectionPoint;
  60834. /**
  60835. * Gets the distance input component
  60836. */
  60837. get distance(): NodeMaterialConnectionPoint;
  60838. /**
  60839. * Gets the replacement input component
  60840. */
  60841. get replacement(): NodeMaterialConnectionPoint;
  60842. /**
  60843. * Gets the output component
  60844. */
  60845. get output(): NodeMaterialConnectionPoint;
  60846. protected _buildBlock(state: NodeMaterialBuildState): this;
  60847. }
  60848. }
  60849. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  60850. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60851. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60852. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60853. /**
  60854. * Block used to posterize a value
  60855. * @see https://en.wikipedia.org/wiki/Posterization
  60856. */
  60857. export class PosterizeBlock extends NodeMaterialBlock {
  60858. /**
  60859. * Creates a new PosterizeBlock
  60860. * @param name defines the block name
  60861. */
  60862. constructor(name: string);
  60863. /**
  60864. * Gets the current class name
  60865. * @returns the class name
  60866. */
  60867. getClassName(): string;
  60868. /**
  60869. * Gets the value input component
  60870. */
  60871. get value(): NodeMaterialConnectionPoint;
  60872. /**
  60873. * Gets the steps input component
  60874. */
  60875. get steps(): NodeMaterialConnectionPoint;
  60876. /**
  60877. * Gets the output component
  60878. */
  60879. get output(): NodeMaterialConnectionPoint;
  60880. protected _buildBlock(state: NodeMaterialBuildState): this;
  60881. }
  60882. }
  60883. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  60884. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60885. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60886. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60887. import { Scene } from "babylonjs/scene";
  60888. /**
  60889. * Operations supported by the Wave block
  60890. */
  60891. export enum WaveBlockKind {
  60892. /** SawTooth */
  60893. SawTooth = 0,
  60894. /** Square */
  60895. Square = 1,
  60896. /** Triangle */
  60897. Triangle = 2
  60898. }
  60899. /**
  60900. * Block used to apply wave operation to floats
  60901. */
  60902. export class WaveBlock extends NodeMaterialBlock {
  60903. /**
  60904. * Gets or sets the kibnd of wave to be applied by the block
  60905. */
  60906. kind: WaveBlockKind;
  60907. /**
  60908. * Creates a new WaveBlock
  60909. * @param name defines the block name
  60910. */
  60911. constructor(name: string);
  60912. /**
  60913. * Gets the current class name
  60914. * @returns the class name
  60915. */
  60916. getClassName(): string;
  60917. /**
  60918. * Gets the input component
  60919. */
  60920. get input(): NodeMaterialConnectionPoint;
  60921. /**
  60922. * Gets the output component
  60923. */
  60924. get output(): NodeMaterialConnectionPoint;
  60925. protected _buildBlock(state: NodeMaterialBuildState): this;
  60926. serialize(): any;
  60927. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60928. }
  60929. }
  60930. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  60931. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60932. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60933. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60934. import { Color3 } from "babylonjs/Maths/math.color";
  60935. import { Scene } from "babylonjs/scene";
  60936. /**
  60937. * Class used to store a color step for the GradientBlock
  60938. */
  60939. export class GradientBlockColorStep {
  60940. /**
  60941. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60942. */
  60943. step: number;
  60944. /**
  60945. * Gets or sets the color associated with this step
  60946. */
  60947. color: Color3;
  60948. /**
  60949. * Creates a new GradientBlockColorStep
  60950. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  60951. * @param color defines the color associated with this step
  60952. */
  60953. constructor(
  60954. /**
  60955. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60956. */
  60957. step: number,
  60958. /**
  60959. * Gets or sets the color associated with this step
  60960. */
  60961. color: Color3);
  60962. }
  60963. /**
  60964. * Block used to return a color from a gradient based on an input value between 0 and 1
  60965. */
  60966. export class GradientBlock extends NodeMaterialBlock {
  60967. /**
  60968. * Gets or sets the list of color steps
  60969. */
  60970. colorSteps: GradientBlockColorStep[];
  60971. /**
  60972. * Creates a new GradientBlock
  60973. * @param name defines the block name
  60974. */
  60975. constructor(name: string);
  60976. /**
  60977. * Gets the current class name
  60978. * @returns the class name
  60979. */
  60980. getClassName(): string;
  60981. /**
  60982. * Gets the gradient input component
  60983. */
  60984. get gradient(): NodeMaterialConnectionPoint;
  60985. /**
  60986. * Gets the output component
  60987. */
  60988. get output(): NodeMaterialConnectionPoint;
  60989. private _writeColorConstant;
  60990. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60991. serialize(): any;
  60992. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60993. protected _dumpPropertiesCode(): string;
  60994. }
  60995. }
  60996. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  60997. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60998. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60999. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61000. /**
  61001. * Block used to normalize lerp between 2 values
  61002. */
  61003. export class NLerpBlock extends NodeMaterialBlock {
  61004. /**
  61005. * Creates a new NLerpBlock
  61006. * @param name defines the block name
  61007. */
  61008. constructor(name: string);
  61009. /**
  61010. * Gets the current class name
  61011. * @returns the class name
  61012. */
  61013. getClassName(): string;
  61014. /**
  61015. * Gets the left operand input component
  61016. */
  61017. get left(): NodeMaterialConnectionPoint;
  61018. /**
  61019. * Gets the right operand input component
  61020. */
  61021. get right(): NodeMaterialConnectionPoint;
  61022. /**
  61023. * Gets the gradient operand input component
  61024. */
  61025. get gradient(): NodeMaterialConnectionPoint;
  61026. /**
  61027. * Gets the output component
  61028. */
  61029. get output(): NodeMaterialConnectionPoint;
  61030. protected _buildBlock(state: NodeMaterialBuildState): this;
  61031. }
  61032. }
  61033. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  61034. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61035. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61036. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61037. import { Scene } from "babylonjs/scene";
  61038. /**
  61039. * block used to Generate a Worley Noise 3D Noise Pattern
  61040. */
  61041. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  61042. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61043. manhattanDistance: boolean;
  61044. /**
  61045. * Creates a new WorleyNoise3DBlock
  61046. * @param name defines the block name
  61047. */
  61048. constructor(name: string);
  61049. /**
  61050. * Gets the current class name
  61051. * @returns the class name
  61052. */
  61053. getClassName(): string;
  61054. /**
  61055. * Gets the seed input component
  61056. */
  61057. get seed(): NodeMaterialConnectionPoint;
  61058. /**
  61059. * Gets the jitter input component
  61060. */
  61061. get jitter(): NodeMaterialConnectionPoint;
  61062. /**
  61063. * Gets the output component
  61064. */
  61065. get output(): NodeMaterialConnectionPoint;
  61066. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61067. /**
  61068. * Exposes the properties to the UI?
  61069. */
  61070. protected _dumpPropertiesCode(): string;
  61071. /**
  61072. * Exposes the properties to the Seralize?
  61073. */
  61074. serialize(): any;
  61075. /**
  61076. * Exposes the properties to the deseralize?
  61077. */
  61078. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61079. }
  61080. }
  61081. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  61082. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61083. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61084. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61085. /**
  61086. * block used to Generate a Simplex Perlin 3d Noise Pattern
  61087. */
  61088. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  61089. /**
  61090. * Creates a new SimplexPerlin3DBlock
  61091. * @param name defines the block name
  61092. */
  61093. constructor(name: string);
  61094. /**
  61095. * Gets the current class name
  61096. * @returns the class name
  61097. */
  61098. getClassName(): string;
  61099. /**
  61100. * Gets the seed operand input component
  61101. */
  61102. get seed(): NodeMaterialConnectionPoint;
  61103. /**
  61104. * Gets the output component
  61105. */
  61106. get output(): NodeMaterialConnectionPoint;
  61107. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61108. }
  61109. }
  61110. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  61111. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61112. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61113. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61114. /**
  61115. * Block used to blend normals
  61116. */
  61117. export class NormalBlendBlock extends NodeMaterialBlock {
  61118. /**
  61119. * Creates a new NormalBlendBlock
  61120. * @param name defines the block name
  61121. */
  61122. constructor(name: string);
  61123. /**
  61124. * Gets the current class name
  61125. * @returns the class name
  61126. */
  61127. getClassName(): string;
  61128. /**
  61129. * Gets the first input component
  61130. */
  61131. get normalMap0(): NodeMaterialConnectionPoint;
  61132. /**
  61133. * Gets the second input component
  61134. */
  61135. get normalMap1(): NodeMaterialConnectionPoint;
  61136. /**
  61137. * Gets the output component
  61138. */
  61139. get output(): NodeMaterialConnectionPoint;
  61140. protected _buildBlock(state: NodeMaterialBuildState): this;
  61141. }
  61142. }
  61143. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  61144. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61145. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61146. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61147. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  61148. /**
  61149. * Block used to rotate a 2d vector by a given angle
  61150. */
  61151. export class Rotate2dBlock extends NodeMaterialBlock {
  61152. /**
  61153. * Creates a new Rotate2dBlock
  61154. * @param name defines the block name
  61155. */
  61156. constructor(name: string);
  61157. /**
  61158. * Gets the current class name
  61159. * @returns the class name
  61160. */
  61161. getClassName(): string;
  61162. /**
  61163. * Gets the input vector
  61164. */
  61165. get input(): NodeMaterialConnectionPoint;
  61166. /**
  61167. * Gets the input angle
  61168. */
  61169. get angle(): NodeMaterialConnectionPoint;
  61170. /**
  61171. * Gets the output component
  61172. */
  61173. get output(): NodeMaterialConnectionPoint;
  61174. autoConfigure(material: NodeMaterial): void;
  61175. protected _buildBlock(state: NodeMaterialBuildState): this;
  61176. }
  61177. }
  61178. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  61179. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61180. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61181. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61182. /**
  61183. * Block used to get the reflected vector from a direction and a normal
  61184. */
  61185. export class ReflectBlock extends NodeMaterialBlock {
  61186. /**
  61187. * Creates a new ReflectBlock
  61188. * @param name defines the block name
  61189. */
  61190. constructor(name: string);
  61191. /**
  61192. * Gets the current class name
  61193. * @returns the class name
  61194. */
  61195. getClassName(): string;
  61196. /**
  61197. * Gets the incident component
  61198. */
  61199. get incident(): NodeMaterialConnectionPoint;
  61200. /**
  61201. * Gets the normal component
  61202. */
  61203. get normal(): NodeMaterialConnectionPoint;
  61204. /**
  61205. * Gets the output component
  61206. */
  61207. get output(): NodeMaterialConnectionPoint;
  61208. protected _buildBlock(state: NodeMaterialBuildState): this;
  61209. }
  61210. }
  61211. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  61212. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61213. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61214. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61215. /**
  61216. * Block used to get the refracted vector from a direction and a normal
  61217. */
  61218. export class RefractBlock extends NodeMaterialBlock {
  61219. /**
  61220. * Creates a new RefractBlock
  61221. * @param name defines the block name
  61222. */
  61223. constructor(name: string);
  61224. /**
  61225. * Gets the current class name
  61226. * @returns the class name
  61227. */
  61228. getClassName(): string;
  61229. /**
  61230. * Gets the incident component
  61231. */
  61232. get incident(): NodeMaterialConnectionPoint;
  61233. /**
  61234. * Gets the normal component
  61235. */
  61236. get normal(): NodeMaterialConnectionPoint;
  61237. /**
  61238. * Gets the index of refraction component
  61239. */
  61240. get ior(): NodeMaterialConnectionPoint;
  61241. /**
  61242. * Gets the output component
  61243. */
  61244. get output(): NodeMaterialConnectionPoint;
  61245. protected _buildBlock(state: NodeMaterialBuildState): this;
  61246. }
  61247. }
  61248. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  61249. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61250. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61251. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61252. /**
  61253. * Block used to desaturate a color
  61254. */
  61255. export class DesaturateBlock extends NodeMaterialBlock {
  61256. /**
  61257. * Creates a new DesaturateBlock
  61258. * @param name defines the block name
  61259. */
  61260. constructor(name: string);
  61261. /**
  61262. * Gets the current class name
  61263. * @returns the class name
  61264. */
  61265. getClassName(): string;
  61266. /**
  61267. * Gets the color operand input component
  61268. */
  61269. get color(): NodeMaterialConnectionPoint;
  61270. /**
  61271. * Gets the level operand input component
  61272. */
  61273. get level(): NodeMaterialConnectionPoint;
  61274. /**
  61275. * Gets the output component
  61276. */
  61277. get output(): NodeMaterialConnectionPoint;
  61278. protected _buildBlock(state: NodeMaterialBuildState): this;
  61279. }
  61280. }
  61281. declare module "babylonjs/Materials/Node/Blocks/index" {
  61282. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  61283. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  61284. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  61285. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  61286. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  61287. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  61288. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  61289. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  61290. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  61291. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  61292. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  61293. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  61294. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  61295. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  61296. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  61297. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  61298. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  61299. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  61300. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  61301. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  61302. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  61303. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  61304. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  61305. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  61306. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  61307. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  61308. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  61309. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  61310. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  61311. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  61312. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  61313. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  61314. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  61315. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  61316. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  61317. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  61318. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  61319. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  61320. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  61321. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  61322. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  61323. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  61324. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  61325. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  61326. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  61327. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  61328. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  61329. }
  61330. declare module "babylonjs/Materials/Node/Optimizers/index" {
  61331. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  61332. }
  61333. declare module "babylonjs/Materials/Node/index" {
  61334. export * from "babylonjs/Materials/Node/Enums/index";
  61335. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61336. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  61337. export * from "babylonjs/Materials/Node/nodeMaterial";
  61338. export * from "babylonjs/Materials/Node/Blocks/index";
  61339. export * from "babylonjs/Materials/Node/Optimizers/index";
  61340. }
  61341. declare module "babylonjs/Materials/effectRenderer" {
  61342. import { Nullable } from "babylonjs/types";
  61343. import { Texture } from "babylonjs/Materials/Textures/texture";
  61344. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61345. import { Viewport } from "babylonjs/Maths/math.viewport";
  61346. import { Observable } from "babylonjs/Misc/observable";
  61347. import { Effect } from "babylonjs/Materials/effect";
  61348. import "babylonjs/Engines/Extensions/engine.renderTarget";
  61349. import "babylonjs/Shaders/postprocess.vertex";
  61350. /**
  61351. * Effect Render Options
  61352. */
  61353. export interface IEffectRendererOptions {
  61354. /**
  61355. * Defines the vertices positions.
  61356. */
  61357. positions?: number[];
  61358. /**
  61359. * Defines the indices.
  61360. */
  61361. indices?: number[];
  61362. }
  61363. /**
  61364. * Helper class to render one or more effects
  61365. */
  61366. export class EffectRenderer {
  61367. private engine;
  61368. private static _DefaultOptions;
  61369. private _vertexBuffers;
  61370. private _indexBuffer;
  61371. private _ringBufferIndex;
  61372. private _ringScreenBuffer;
  61373. private _fullscreenViewport;
  61374. private _getNextFrameBuffer;
  61375. /**
  61376. * Creates an effect renderer
  61377. * @param engine the engine to use for rendering
  61378. * @param options defines the options of the effect renderer
  61379. */
  61380. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61381. /**
  61382. * Sets the current viewport in normalized coordinates 0-1
  61383. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61384. */
  61385. setViewport(viewport?: Viewport): void;
  61386. /**
  61387. * Binds the embedded attributes buffer to the effect.
  61388. * @param effect Defines the effect to bind the attributes for
  61389. */
  61390. bindBuffers(effect: Effect): void;
  61391. /**
  61392. * Sets the current effect wrapper to use during draw.
  61393. * The effect needs to be ready before calling this api.
  61394. * This also sets the default full screen position attribute.
  61395. * @param effectWrapper Defines the effect to draw with
  61396. */
  61397. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61398. /**
  61399. * Draws a full screen quad.
  61400. */
  61401. draw(): void;
  61402. /**
  61403. * renders one or more effects to a specified texture
  61404. * @param effectWrappers list of effects to renderer
  61405. * @param outputTexture texture to draw to, if null it will render to the screen
  61406. */
  61407. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  61408. /**
  61409. * Disposes of the effect renderer
  61410. */
  61411. dispose(): void;
  61412. }
  61413. /**
  61414. * Options to create an EffectWrapper
  61415. */
  61416. interface EffectWrapperCreationOptions {
  61417. /**
  61418. * Engine to use to create the effect
  61419. */
  61420. engine: ThinEngine;
  61421. /**
  61422. * Fragment shader for the effect
  61423. */
  61424. fragmentShader: string;
  61425. /**
  61426. * Vertex shader for the effect
  61427. */
  61428. vertexShader?: string;
  61429. /**
  61430. * Attributes to use in the shader
  61431. */
  61432. attributeNames?: Array<string>;
  61433. /**
  61434. * Uniforms to use in the shader
  61435. */
  61436. uniformNames?: Array<string>;
  61437. /**
  61438. * Texture sampler names to use in the shader
  61439. */
  61440. samplerNames?: Array<string>;
  61441. /**
  61442. * The friendly name of the effect displayed in Spector.
  61443. */
  61444. name?: string;
  61445. }
  61446. /**
  61447. * Wraps an effect to be used for rendering
  61448. */
  61449. export class EffectWrapper {
  61450. /**
  61451. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61452. */
  61453. onApplyObservable: Observable<{}>;
  61454. /**
  61455. * The underlying effect
  61456. */
  61457. effect: Effect;
  61458. /**
  61459. * Creates an effect to be renderer
  61460. * @param creationOptions options to create the effect
  61461. */
  61462. constructor(creationOptions: EffectWrapperCreationOptions);
  61463. /**
  61464. * Disposes of the effect wrapper
  61465. */
  61466. dispose(): void;
  61467. }
  61468. }
  61469. declare module "babylonjs/Materials/index" {
  61470. export * from "babylonjs/Materials/Background/index";
  61471. export * from "babylonjs/Materials/colorCurves";
  61472. export * from "babylonjs/Materials/iEffectFallbacks";
  61473. export * from "babylonjs/Materials/effectFallbacks";
  61474. export * from "babylonjs/Materials/effect";
  61475. export * from "babylonjs/Materials/fresnelParameters";
  61476. export * from "babylonjs/Materials/imageProcessingConfiguration";
  61477. export * from "babylonjs/Materials/material";
  61478. export * from "babylonjs/Materials/materialDefines";
  61479. export * from "babylonjs/Materials/materialHelper";
  61480. export * from "babylonjs/Materials/multiMaterial";
  61481. export * from "babylonjs/Materials/PBR/index";
  61482. export * from "babylonjs/Materials/pushMaterial";
  61483. export * from "babylonjs/Materials/shaderMaterial";
  61484. export * from "babylonjs/Materials/standardMaterial";
  61485. export * from "babylonjs/Materials/Textures/index";
  61486. export * from "babylonjs/Materials/uniformBuffer";
  61487. export * from "babylonjs/Materials/materialFlags";
  61488. export * from "babylonjs/Materials/Node/index";
  61489. export * from "babylonjs/Materials/effectRenderer";
  61490. }
  61491. declare module "babylonjs/Maths/index" {
  61492. export * from "babylonjs/Maths/math.scalar";
  61493. export * from "babylonjs/Maths/math";
  61494. export * from "babylonjs/Maths/sphericalPolynomial";
  61495. }
  61496. declare module "babylonjs/Misc/workerPool" {
  61497. import { IDisposable } from "babylonjs/scene";
  61498. /**
  61499. * Helper class to push actions to a pool of workers.
  61500. */
  61501. export class WorkerPool implements IDisposable {
  61502. private _workerInfos;
  61503. private _pendingActions;
  61504. /**
  61505. * Constructor
  61506. * @param workers Array of workers to use for actions
  61507. */
  61508. constructor(workers: Array<Worker>);
  61509. /**
  61510. * Terminates all workers and clears any pending actions.
  61511. */
  61512. dispose(): void;
  61513. /**
  61514. * Pushes an action to the worker pool. If all the workers are active, the action will be
  61515. * pended until a worker has completed its action.
  61516. * @param action The action to perform. Call onComplete when the action is complete.
  61517. */
  61518. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61519. private _execute;
  61520. }
  61521. }
  61522. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  61523. import { IDisposable } from "babylonjs/scene";
  61524. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  61525. /**
  61526. * Configuration for Draco compression
  61527. */
  61528. export interface IDracoCompressionConfiguration {
  61529. /**
  61530. * Configuration for the decoder.
  61531. */
  61532. decoder: {
  61533. /**
  61534. * The url to the WebAssembly module.
  61535. */
  61536. wasmUrl?: string;
  61537. /**
  61538. * The url to the WebAssembly binary.
  61539. */
  61540. wasmBinaryUrl?: string;
  61541. /**
  61542. * The url to the fallback JavaScript module.
  61543. */
  61544. fallbackUrl?: string;
  61545. };
  61546. }
  61547. /**
  61548. * Draco compression (https://google.github.io/draco/)
  61549. *
  61550. * This class wraps the Draco module.
  61551. *
  61552. * **Encoder**
  61553. *
  61554. * The encoder is not currently implemented.
  61555. *
  61556. * **Decoder**
  61557. *
  61558. * 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.
  61559. *
  61560. * To update the configuration, use the following code:
  61561. * ```javascript
  61562. * DracoCompression.Configuration = {
  61563. * decoder: {
  61564. * wasmUrl: "<url to the WebAssembly library>",
  61565. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  61566. * fallbackUrl: "<url to the fallback JavaScript library>",
  61567. * }
  61568. * };
  61569. * ```
  61570. *
  61571. * 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.
  61572. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  61573. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  61574. *
  61575. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  61576. * ```javascript
  61577. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  61578. * ```
  61579. *
  61580. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  61581. */
  61582. export class DracoCompression implements IDisposable {
  61583. private _workerPoolPromise?;
  61584. private _decoderModulePromise?;
  61585. /**
  61586. * The configuration. Defaults to the following urls:
  61587. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  61588. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  61589. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  61590. */
  61591. static Configuration: IDracoCompressionConfiguration;
  61592. /**
  61593. * Returns true if the decoder configuration is available.
  61594. */
  61595. static get DecoderAvailable(): boolean;
  61596. /**
  61597. * Default number of workers to create when creating the draco compression object.
  61598. */
  61599. static DefaultNumWorkers: number;
  61600. private static GetDefaultNumWorkers;
  61601. private static _Default;
  61602. /**
  61603. * Default instance for the draco compression object.
  61604. */
  61605. static get Default(): DracoCompression;
  61606. /**
  61607. * Constructor
  61608. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  61609. */
  61610. constructor(numWorkers?: number);
  61611. /**
  61612. * Stop all async operations and release resources.
  61613. */
  61614. dispose(): void;
  61615. /**
  61616. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  61617. * @returns a promise that resolves when ready
  61618. */
  61619. whenReadyAsync(): Promise<void>;
  61620. /**
  61621. * Decode Draco compressed mesh data to vertex data.
  61622. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  61623. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  61624. * @returns A promise that resolves with the decoded vertex data
  61625. */
  61626. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  61627. [kind: string]: number;
  61628. }): Promise<VertexData>;
  61629. }
  61630. }
  61631. declare module "babylonjs/Meshes/Compression/index" {
  61632. export * from "babylonjs/Meshes/Compression/dracoCompression";
  61633. }
  61634. declare module "babylonjs/Meshes/csg" {
  61635. import { Nullable } from "babylonjs/types";
  61636. import { Scene } from "babylonjs/scene";
  61637. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61638. import { Mesh } from "babylonjs/Meshes/mesh";
  61639. import { Material } from "babylonjs/Materials/material";
  61640. /**
  61641. * Class for building Constructive Solid Geometry
  61642. */
  61643. export class CSG {
  61644. private polygons;
  61645. /**
  61646. * The world matrix
  61647. */
  61648. matrix: Matrix;
  61649. /**
  61650. * Stores the position
  61651. */
  61652. position: Vector3;
  61653. /**
  61654. * Stores the rotation
  61655. */
  61656. rotation: Vector3;
  61657. /**
  61658. * Stores the rotation quaternion
  61659. */
  61660. rotationQuaternion: Nullable<Quaternion>;
  61661. /**
  61662. * Stores the scaling vector
  61663. */
  61664. scaling: Vector3;
  61665. /**
  61666. * Convert the Mesh to CSG
  61667. * @param mesh The Mesh to convert to CSG
  61668. * @returns A new CSG from the Mesh
  61669. */
  61670. static FromMesh(mesh: Mesh): CSG;
  61671. /**
  61672. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  61673. * @param polygons Polygons used to construct a CSG solid
  61674. */
  61675. private static FromPolygons;
  61676. /**
  61677. * Clones, or makes a deep copy, of the CSG
  61678. * @returns A new CSG
  61679. */
  61680. clone(): CSG;
  61681. /**
  61682. * Unions this CSG with another CSG
  61683. * @param csg The CSG to union against this CSG
  61684. * @returns The unioned CSG
  61685. */
  61686. union(csg: CSG): CSG;
  61687. /**
  61688. * Unions this CSG with another CSG in place
  61689. * @param csg The CSG to union against this CSG
  61690. */
  61691. unionInPlace(csg: CSG): void;
  61692. /**
  61693. * Subtracts this CSG with another CSG
  61694. * @param csg The CSG to subtract against this CSG
  61695. * @returns A new CSG
  61696. */
  61697. subtract(csg: CSG): CSG;
  61698. /**
  61699. * Subtracts this CSG with another CSG in place
  61700. * @param csg The CSG to subtact against this CSG
  61701. */
  61702. subtractInPlace(csg: CSG): void;
  61703. /**
  61704. * Intersect this CSG with another CSG
  61705. * @param csg The CSG to intersect against this CSG
  61706. * @returns A new CSG
  61707. */
  61708. intersect(csg: CSG): CSG;
  61709. /**
  61710. * Intersects this CSG with another CSG in place
  61711. * @param csg The CSG to intersect against this CSG
  61712. */
  61713. intersectInPlace(csg: CSG): void;
  61714. /**
  61715. * Return a new CSG solid with solid and empty space switched. This solid is
  61716. * not modified.
  61717. * @returns A new CSG solid with solid and empty space switched
  61718. */
  61719. inverse(): CSG;
  61720. /**
  61721. * Inverses the CSG in place
  61722. */
  61723. inverseInPlace(): void;
  61724. /**
  61725. * This is used to keep meshes transformations so they can be restored
  61726. * when we build back a Babylon Mesh
  61727. * NB : All CSG operations are performed in world coordinates
  61728. * @param csg The CSG to copy the transform attributes from
  61729. * @returns This CSG
  61730. */
  61731. copyTransformAttributes(csg: CSG): CSG;
  61732. /**
  61733. * Build Raw mesh from CSG
  61734. * Coordinates here are in world space
  61735. * @param name The name of the mesh geometry
  61736. * @param scene The Scene
  61737. * @param keepSubMeshes Specifies if the submeshes should be kept
  61738. * @returns A new Mesh
  61739. */
  61740. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61741. /**
  61742. * Build Mesh from CSG taking material and transforms into account
  61743. * @param name The name of the Mesh
  61744. * @param material The material of the Mesh
  61745. * @param scene The Scene
  61746. * @param keepSubMeshes Specifies if submeshes should be kept
  61747. * @returns The new Mesh
  61748. */
  61749. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61750. }
  61751. }
  61752. declare module "babylonjs/Meshes/trailMesh" {
  61753. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61754. import { Mesh } from "babylonjs/Meshes/mesh";
  61755. import { Scene } from "babylonjs/scene";
  61756. /**
  61757. * Class used to create a trail following a mesh
  61758. */
  61759. export class TrailMesh extends Mesh {
  61760. private _generator;
  61761. private _autoStart;
  61762. private _running;
  61763. private _diameter;
  61764. private _length;
  61765. private _sectionPolygonPointsCount;
  61766. private _sectionVectors;
  61767. private _sectionNormalVectors;
  61768. private _beforeRenderObserver;
  61769. /**
  61770. * @constructor
  61771. * @param name The value used by scene.getMeshByName() to do a lookup.
  61772. * @param generator The mesh to generate a trail.
  61773. * @param scene The scene to add this mesh to.
  61774. * @param diameter Diameter of trailing mesh. Default is 1.
  61775. * @param length Length of trailing mesh. Default is 60.
  61776. * @param autoStart Automatically start trailing mesh. Default true.
  61777. */
  61778. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  61779. /**
  61780. * "TrailMesh"
  61781. * @returns "TrailMesh"
  61782. */
  61783. getClassName(): string;
  61784. private _createMesh;
  61785. /**
  61786. * Start trailing mesh.
  61787. */
  61788. start(): void;
  61789. /**
  61790. * Stop trailing mesh.
  61791. */
  61792. stop(): void;
  61793. /**
  61794. * Update trailing mesh geometry.
  61795. */
  61796. update(): void;
  61797. /**
  61798. * Returns a new TrailMesh object.
  61799. * @param name is a string, the name given to the new mesh
  61800. * @param newGenerator use new generator object for cloned trail mesh
  61801. * @returns a new mesh
  61802. */
  61803. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  61804. /**
  61805. * Serializes this trail mesh
  61806. * @param serializationObject object to write serialization to
  61807. */
  61808. serialize(serializationObject: any): void;
  61809. /**
  61810. * Parses a serialized trail mesh
  61811. * @param parsedMesh the serialized mesh
  61812. * @param scene the scene to create the trail mesh in
  61813. * @returns the created trail mesh
  61814. */
  61815. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  61816. }
  61817. }
  61818. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  61819. import { Nullable } from "babylonjs/types";
  61820. import { Scene } from "babylonjs/scene";
  61821. import { Vector4 } from "babylonjs/Maths/math.vector";
  61822. import { Color4 } from "babylonjs/Maths/math.color";
  61823. import { Mesh } from "babylonjs/Meshes/mesh";
  61824. /**
  61825. * Class containing static functions to help procedurally build meshes
  61826. */
  61827. export class TiledBoxBuilder {
  61828. /**
  61829. * Creates a box mesh
  61830. * 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)
  61831. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61832. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61833. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61834. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61835. * @param name defines the name of the mesh
  61836. * @param options defines the options used to create the mesh
  61837. * @param scene defines the hosting scene
  61838. * @returns the box mesh
  61839. */
  61840. static CreateTiledBox(name: string, options: {
  61841. pattern?: number;
  61842. width?: number;
  61843. height?: number;
  61844. depth?: number;
  61845. tileSize?: number;
  61846. tileWidth?: number;
  61847. tileHeight?: number;
  61848. alignHorizontal?: number;
  61849. alignVertical?: number;
  61850. faceUV?: Vector4[];
  61851. faceColors?: Color4[];
  61852. sideOrientation?: number;
  61853. updatable?: boolean;
  61854. }, scene?: Nullable<Scene>): Mesh;
  61855. }
  61856. }
  61857. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  61858. import { Vector4 } from "babylonjs/Maths/math.vector";
  61859. import { Mesh } from "babylonjs/Meshes/mesh";
  61860. /**
  61861. * Class containing static functions to help procedurally build meshes
  61862. */
  61863. export class TorusKnotBuilder {
  61864. /**
  61865. * Creates a torus knot mesh
  61866. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61867. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61868. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61869. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61870. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61871. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61873. * @param name defines the name of the mesh
  61874. * @param options defines the options used to create the mesh
  61875. * @param scene defines the hosting scene
  61876. * @returns the torus knot mesh
  61877. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61878. */
  61879. static CreateTorusKnot(name: string, options: {
  61880. radius?: number;
  61881. tube?: number;
  61882. radialSegments?: number;
  61883. tubularSegments?: number;
  61884. p?: number;
  61885. q?: number;
  61886. updatable?: boolean;
  61887. sideOrientation?: number;
  61888. frontUVs?: Vector4;
  61889. backUVs?: Vector4;
  61890. }, scene: any): Mesh;
  61891. }
  61892. }
  61893. declare module "babylonjs/Meshes/polygonMesh" {
  61894. import { Scene } from "babylonjs/scene";
  61895. import { Vector2 } from "babylonjs/Maths/math.vector";
  61896. import { Mesh } from "babylonjs/Meshes/mesh";
  61897. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  61898. import { Path2 } from "babylonjs/Maths/math.path";
  61899. /**
  61900. * Polygon
  61901. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  61902. */
  61903. export class Polygon {
  61904. /**
  61905. * Creates a rectangle
  61906. * @param xmin bottom X coord
  61907. * @param ymin bottom Y coord
  61908. * @param xmax top X coord
  61909. * @param ymax top Y coord
  61910. * @returns points that make the resulting rectation
  61911. */
  61912. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  61913. /**
  61914. * Creates a circle
  61915. * @param radius radius of circle
  61916. * @param cx scale in x
  61917. * @param cy scale in y
  61918. * @param numberOfSides number of sides that make up the circle
  61919. * @returns points that make the resulting circle
  61920. */
  61921. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  61922. /**
  61923. * Creates a polygon from input string
  61924. * @param input Input polygon data
  61925. * @returns the parsed points
  61926. */
  61927. static Parse(input: string): Vector2[];
  61928. /**
  61929. * Starts building a polygon from x and y coordinates
  61930. * @param x x coordinate
  61931. * @param y y coordinate
  61932. * @returns the started path2
  61933. */
  61934. static StartingAt(x: number, y: number): Path2;
  61935. }
  61936. /**
  61937. * Builds a polygon
  61938. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  61939. */
  61940. export class PolygonMeshBuilder {
  61941. private _points;
  61942. private _outlinepoints;
  61943. private _holes;
  61944. private _name;
  61945. private _scene;
  61946. private _epoints;
  61947. private _eholes;
  61948. private _addToepoint;
  61949. /**
  61950. * Babylon reference to the earcut plugin.
  61951. */
  61952. bjsEarcut: any;
  61953. /**
  61954. * Creates a PolygonMeshBuilder
  61955. * @param name name of the builder
  61956. * @param contours Path of the polygon
  61957. * @param scene scene to add to when creating the mesh
  61958. * @param earcutInjection can be used to inject your own earcut reference
  61959. */
  61960. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  61961. /**
  61962. * Adds a whole within the polygon
  61963. * @param hole Array of points defining the hole
  61964. * @returns this
  61965. */
  61966. addHole(hole: Vector2[]): PolygonMeshBuilder;
  61967. /**
  61968. * Creates the polygon
  61969. * @param updatable If the mesh should be updatable
  61970. * @param depth The depth of the mesh created
  61971. * @returns the created mesh
  61972. */
  61973. build(updatable?: boolean, depth?: number): Mesh;
  61974. /**
  61975. * Creates the polygon
  61976. * @param depth The depth of the mesh created
  61977. * @returns the created VertexData
  61978. */
  61979. buildVertexData(depth?: number): VertexData;
  61980. /**
  61981. * Adds a side to the polygon
  61982. * @param positions points that make the polygon
  61983. * @param normals normals of the polygon
  61984. * @param uvs uvs of the polygon
  61985. * @param indices indices of the polygon
  61986. * @param bounds bounds of the polygon
  61987. * @param points points of the polygon
  61988. * @param depth depth of the polygon
  61989. * @param flip flip of the polygon
  61990. */
  61991. private addSide;
  61992. }
  61993. }
  61994. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  61995. import { Scene } from "babylonjs/scene";
  61996. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  61997. import { Color4 } from "babylonjs/Maths/math.color";
  61998. import { Mesh } from "babylonjs/Meshes/mesh";
  61999. import { Nullable } from "babylonjs/types";
  62000. /**
  62001. * Class containing static functions to help procedurally build meshes
  62002. */
  62003. export class PolygonBuilder {
  62004. /**
  62005. * Creates a polygon mesh
  62006. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62007. * * 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
  62008. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62009. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62010. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  62011. * * Remember you can only change the shape positions, not their number when updating a polygon
  62012. * @param name defines the name of the mesh
  62013. * @param options defines the options used to create the mesh
  62014. * @param scene defines the hosting scene
  62015. * @param earcutInjection can be used to inject your own earcut reference
  62016. * @returns the polygon mesh
  62017. */
  62018. static CreatePolygon(name: string, options: {
  62019. shape: Vector3[];
  62020. holes?: Vector3[][];
  62021. depth?: number;
  62022. faceUV?: Vector4[];
  62023. faceColors?: Color4[];
  62024. updatable?: boolean;
  62025. sideOrientation?: number;
  62026. frontUVs?: Vector4;
  62027. backUVs?: Vector4;
  62028. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62029. /**
  62030. * Creates an extruded polygon mesh, with depth in the Y direction.
  62031. * * 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)
  62032. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62033. * @param name defines the name of the mesh
  62034. * @param options defines the options used to create the mesh
  62035. * @param scene defines the hosting scene
  62036. * @param earcutInjection can be used to inject your own earcut reference
  62037. * @returns the polygon mesh
  62038. */
  62039. static ExtrudePolygon(name: string, options: {
  62040. shape: Vector3[];
  62041. holes?: Vector3[][];
  62042. depth?: number;
  62043. faceUV?: Vector4[];
  62044. faceColors?: Color4[];
  62045. updatable?: boolean;
  62046. sideOrientation?: number;
  62047. frontUVs?: Vector4;
  62048. backUVs?: Vector4;
  62049. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62050. }
  62051. }
  62052. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  62053. import { Scene } from "babylonjs/scene";
  62054. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62055. import { Mesh } from "babylonjs/Meshes/mesh";
  62056. import { Nullable } from "babylonjs/types";
  62057. /**
  62058. * Class containing static functions to help procedurally build meshes
  62059. */
  62060. export class LatheBuilder {
  62061. /**
  62062. * Creates lathe mesh.
  62063. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  62064. * * 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
  62065. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  62066. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  62067. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  62068. * * 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
  62069. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  62070. * * 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
  62071. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62072. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62073. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62075. * @param name defines the name of the mesh
  62076. * @param options defines the options used to create the mesh
  62077. * @param scene defines the hosting scene
  62078. * @returns the lathe mesh
  62079. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  62080. */
  62081. static CreateLathe(name: string, options: {
  62082. shape: Vector3[];
  62083. radius?: number;
  62084. tessellation?: number;
  62085. clip?: number;
  62086. arc?: number;
  62087. closed?: boolean;
  62088. updatable?: boolean;
  62089. sideOrientation?: number;
  62090. frontUVs?: Vector4;
  62091. backUVs?: Vector4;
  62092. cap?: number;
  62093. invertUV?: boolean;
  62094. }, scene?: Nullable<Scene>): Mesh;
  62095. }
  62096. }
  62097. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  62098. import { Nullable } from "babylonjs/types";
  62099. import { Scene } from "babylonjs/scene";
  62100. import { Vector4 } from "babylonjs/Maths/math.vector";
  62101. import { Mesh } from "babylonjs/Meshes/mesh";
  62102. /**
  62103. * Class containing static functions to help procedurally build meshes
  62104. */
  62105. export class TiledPlaneBuilder {
  62106. /**
  62107. * Creates a tiled plane mesh
  62108. * * The parameter `pattern` will, depending on value, do nothing or
  62109. * * * flip (reflect about central vertical) alternate tiles across and up
  62110. * * * flip every tile on alternate rows
  62111. * * * rotate (180 degs) alternate tiles across and up
  62112. * * * rotate every tile on alternate rows
  62113. * * * flip and rotate alternate tiles across and up
  62114. * * * flip and rotate every tile on alternate rows
  62115. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  62116. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  62117. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62118. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62119. * * 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)
  62120. * * 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)
  62121. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  62122. * @param name defines the name of the mesh
  62123. * @param options defines the options used to create the mesh
  62124. * @param scene defines the hosting scene
  62125. * @returns the box mesh
  62126. */
  62127. static CreateTiledPlane(name: string, options: {
  62128. pattern?: number;
  62129. tileSize?: number;
  62130. tileWidth?: number;
  62131. tileHeight?: number;
  62132. size?: number;
  62133. width?: number;
  62134. height?: number;
  62135. alignHorizontal?: number;
  62136. alignVertical?: number;
  62137. sideOrientation?: number;
  62138. frontUVs?: Vector4;
  62139. backUVs?: Vector4;
  62140. updatable?: boolean;
  62141. }, scene?: Nullable<Scene>): Mesh;
  62142. }
  62143. }
  62144. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  62145. import { Nullable } from "babylonjs/types";
  62146. import { Scene } from "babylonjs/scene";
  62147. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62148. import { Mesh } from "babylonjs/Meshes/mesh";
  62149. /**
  62150. * Class containing static functions to help procedurally build meshes
  62151. */
  62152. export class TubeBuilder {
  62153. /**
  62154. * Creates a tube mesh.
  62155. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62156. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62157. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62158. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62159. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62160. * * 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)
  62161. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62162. * * 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
  62163. * * 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
  62164. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62165. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62166. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62168. * @param name defines the name of the mesh
  62169. * @param options defines the options used to create the mesh
  62170. * @param scene defines the hosting scene
  62171. * @returns the tube mesh
  62172. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62173. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62174. */
  62175. static CreateTube(name: string, options: {
  62176. path: Vector3[];
  62177. radius?: number;
  62178. tessellation?: number;
  62179. radiusFunction?: {
  62180. (i: number, distance: number): number;
  62181. };
  62182. cap?: number;
  62183. arc?: number;
  62184. updatable?: boolean;
  62185. sideOrientation?: number;
  62186. frontUVs?: Vector4;
  62187. backUVs?: Vector4;
  62188. instance?: Mesh;
  62189. invertUV?: boolean;
  62190. }, scene?: Nullable<Scene>): Mesh;
  62191. }
  62192. }
  62193. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  62194. import { Scene } from "babylonjs/scene";
  62195. import { Vector4 } from "babylonjs/Maths/math.vector";
  62196. import { Mesh } from "babylonjs/Meshes/mesh";
  62197. import { Nullable } from "babylonjs/types";
  62198. /**
  62199. * Class containing static functions to help procedurally build meshes
  62200. */
  62201. export class IcoSphereBuilder {
  62202. /**
  62203. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  62204. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  62205. * * 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`)
  62206. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  62207. * * 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
  62208. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62209. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62211. * @param name defines the name of the mesh
  62212. * @param options defines the options used to create the mesh
  62213. * @param scene defines the hosting scene
  62214. * @returns the icosahedron mesh
  62215. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  62216. */
  62217. static CreateIcoSphere(name: string, options: {
  62218. radius?: number;
  62219. radiusX?: number;
  62220. radiusY?: number;
  62221. radiusZ?: number;
  62222. flat?: boolean;
  62223. subdivisions?: number;
  62224. sideOrientation?: number;
  62225. frontUVs?: Vector4;
  62226. backUVs?: Vector4;
  62227. updatable?: boolean;
  62228. }, scene?: Nullable<Scene>): Mesh;
  62229. }
  62230. }
  62231. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  62232. import { Vector3 } from "babylonjs/Maths/math.vector";
  62233. import { Mesh } from "babylonjs/Meshes/mesh";
  62234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62235. /**
  62236. * Class containing static functions to help procedurally build meshes
  62237. */
  62238. export class DecalBuilder {
  62239. /**
  62240. * Creates a decal mesh.
  62241. * 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
  62242. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62243. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62244. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62245. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62246. * @param name defines the name of the mesh
  62247. * @param sourceMesh defines the mesh where the decal must be applied
  62248. * @param options defines the options used to create the mesh
  62249. * @param scene defines the hosting scene
  62250. * @returns the decal mesh
  62251. * @see https://doc.babylonjs.com/how_to/decals
  62252. */
  62253. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62254. position?: Vector3;
  62255. normal?: Vector3;
  62256. size?: Vector3;
  62257. angle?: number;
  62258. }): Mesh;
  62259. }
  62260. }
  62261. declare module "babylonjs/Meshes/meshBuilder" {
  62262. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  62263. import { Nullable } from "babylonjs/types";
  62264. import { Scene } from "babylonjs/scene";
  62265. import { Mesh } from "babylonjs/Meshes/mesh";
  62266. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  62267. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  62268. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62269. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  62270. import { Plane } from "babylonjs/Maths/math.plane";
  62271. /**
  62272. * Class containing static functions to help procedurally build meshes
  62273. */
  62274. export class MeshBuilder {
  62275. /**
  62276. * Creates a box mesh
  62277. * * The parameter `size` sets the size (float) of each box side (default 1)
  62278. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  62279. * * 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)
  62280. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62281. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62282. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62284. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  62285. * @param name defines the name of the mesh
  62286. * @param options defines the options used to create the mesh
  62287. * @param scene defines the hosting scene
  62288. * @returns the box mesh
  62289. */
  62290. static CreateBox(name: string, options: {
  62291. size?: number;
  62292. width?: number;
  62293. height?: number;
  62294. depth?: number;
  62295. faceUV?: Vector4[];
  62296. faceColors?: Color4[];
  62297. sideOrientation?: number;
  62298. frontUVs?: Vector4;
  62299. backUVs?: Vector4;
  62300. updatable?: boolean;
  62301. }, scene?: Nullable<Scene>): Mesh;
  62302. /**
  62303. * Creates a tiled box mesh
  62304. * * faceTiles sets the pattern, tile size and number of tiles for a face
  62305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62306. * @param name defines the name of the mesh
  62307. * @param options defines the options used to create the mesh
  62308. * @param scene defines the hosting scene
  62309. * @returns the tiled box mesh
  62310. */
  62311. static CreateTiledBox(name: string, options: {
  62312. pattern?: number;
  62313. size?: number;
  62314. width?: number;
  62315. height?: number;
  62316. depth: number;
  62317. tileSize?: number;
  62318. tileWidth?: number;
  62319. tileHeight?: number;
  62320. faceUV?: Vector4[];
  62321. faceColors?: Color4[];
  62322. alignHorizontal?: number;
  62323. alignVertical?: number;
  62324. sideOrientation?: number;
  62325. updatable?: boolean;
  62326. }, scene?: Nullable<Scene>): Mesh;
  62327. /**
  62328. * Creates a sphere mesh
  62329. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  62330. * * 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`)
  62331. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  62332. * * 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
  62333. * * 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)
  62334. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62335. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62337. * @param name defines the name of the mesh
  62338. * @param options defines the options used to create the mesh
  62339. * @param scene defines the hosting scene
  62340. * @returns the sphere mesh
  62341. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  62342. */
  62343. static CreateSphere(name: string, options: {
  62344. segments?: number;
  62345. diameter?: number;
  62346. diameterX?: number;
  62347. diameterY?: number;
  62348. diameterZ?: number;
  62349. arc?: number;
  62350. slice?: number;
  62351. sideOrientation?: number;
  62352. frontUVs?: Vector4;
  62353. backUVs?: Vector4;
  62354. updatable?: boolean;
  62355. }, scene?: Nullable<Scene>): Mesh;
  62356. /**
  62357. * Creates a plane polygonal mesh. By default, this is a disc
  62358. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  62359. * * 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
  62360. * * 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
  62361. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62362. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62364. * @param name defines the name of the mesh
  62365. * @param options defines the options used to create the mesh
  62366. * @param scene defines the hosting scene
  62367. * @returns the plane polygonal mesh
  62368. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  62369. */
  62370. static CreateDisc(name: string, options: {
  62371. radius?: number;
  62372. tessellation?: number;
  62373. arc?: number;
  62374. updatable?: boolean;
  62375. sideOrientation?: number;
  62376. frontUVs?: Vector4;
  62377. backUVs?: Vector4;
  62378. }, scene?: Nullable<Scene>): Mesh;
  62379. /**
  62380. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  62381. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  62382. * * 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`)
  62383. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  62384. * * 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
  62385. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62386. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62388. * @param name defines the name of the mesh
  62389. * @param options defines the options used to create the mesh
  62390. * @param scene defines the hosting scene
  62391. * @returns the icosahedron mesh
  62392. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  62393. */
  62394. static CreateIcoSphere(name: string, options: {
  62395. radius?: number;
  62396. radiusX?: number;
  62397. radiusY?: number;
  62398. radiusZ?: number;
  62399. flat?: boolean;
  62400. subdivisions?: number;
  62401. sideOrientation?: number;
  62402. frontUVs?: Vector4;
  62403. backUVs?: Vector4;
  62404. updatable?: boolean;
  62405. }, scene?: Nullable<Scene>): Mesh;
  62406. /**
  62407. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62408. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  62409. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  62410. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  62411. * * 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
  62412. * * 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
  62413. * * 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
  62414. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62415. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62416. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62417. * * 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
  62418. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  62419. * * 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
  62420. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  62421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62422. * @param name defines the name of the mesh
  62423. * @param options defines the options used to create the mesh
  62424. * @param scene defines the hosting scene
  62425. * @returns the ribbon mesh
  62426. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  62427. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62428. */
  62429. static CreateRibbon(name: string, options: {
  62430. pathArray: Vector3[][];
  62431. closeArray?: boolean;
  62432. closePath?: boolean;
  62433. offset?: number;
  62434. updatable?: boolean;
  62435. sideOrientation?: number;
  62436. frontUVs?: Vector4;
  62437. backUVs?: Vector4;
  62438. instance?: Mesh;
  62439. invertUV?: boolean;
  62440. uvs?: Vector2[];
  62441. colors?: Color4[];
  62442. }, scene?: Nullable<Scene>): Mesh;
  62443. /**
  62444. * Creates a cylinder or a cone mesh
  62445. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  62446. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  62447. * * 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.
  62448. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  62449. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  62450. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  62451. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  62452. * * 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).
  62453. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  62454. * * 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).
  62455. * * 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
  62456. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  62457. * * 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
  62458. * * 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.
  62459. * * If `enclose` is false, a ring surface is one element.
  62460. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  62461. * * 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
  62462. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62463. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62464. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62465. * @param name defines the name of the mesh
  62466. * @param options defines the options used to create the mesh
  62467. * @param scene defines the hosting scene
  62468. * @returns the cylinder mesh
  62469. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  62470. */
  62471. static CreateCylinder(name: string, options: {
  62472. height?: number;
  62473. diameterTop?: number;
  62474. diameterBottom?: number;
  62475. diameter?: number;
  62476. tessellation?: number;
  62477. subdivisions?: number;
  62478. arc?: number;
  62479. faceColors?: Color4[];
  62480. faceUV?: Vector4[];
  62481. updatable?: boolean;
  62482. hasRings?: boolean;
  62483. enclose?: boolean;
  62484. cap?: number;
  62485. sideOrientation?: number;
  62486. frontUVs?: Vector4;
  62487. backUVs?: Vector4;
  62488. }, scene?: Nullable<Scene>): Mesh;
  62489. /**
  62490. * Creates a torus mesh
  62491. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  62492. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  62493. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  62494. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62495. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62497. * @param name defines the name of the mesh
  62498. * @param options defines the options used to create the mesh
  62499. * @param scene defines the hosting scene
  62500. * @returns the torus mesh
  62501. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  62502. */
  62503. static CreateTorus(name: string, options: {
  62504. diameter?: number;
  62505. thickness?: number;
  62506. tessellation?: number;
  62507. updatable?: boolean;
  62508. sideOrientation?: number;
  62509. frontUVs?: Vector4;
  62510. backUVs?: Vector4;
  62511. }, scene?: Nullable<Scene>): Mesh;
  62512. /**
  62513. * Creates a torus knot mesh
  62514. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  62515. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  62516. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  62517. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  62518. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62519. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62521. * @param name defines the name of the mesh
  62522. * @param options defines the options used to create the mesh
  62523. * @param scene defines the hosting scene
  62524. * @returns the torus knot mesh
  62525. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  62526. */
  62527. static CreateTorusKnot(name: string, options: {
  62528. radius?: number;
  62529. tube?: number;
  62530. radialSegments?: number;
  62531. tubularSegments?: number;
  62532. p?: number;
  62533. q?: number;
  62534. updatable?: boolean;
  62535. sideOrientation?: number;
  62536. frontUVs?: Vector4;
  62537. backUVs?: Vector4;
  62538. }, scene?: Nullable<Scene>): Mesh;
  62539. /**
  62540. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  62541. * * 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
  62542. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  62543. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  62544. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  62545. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  62546. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  62547. * * 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
  62548. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  62549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62550. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  62551. * @param name defines the name of the new line system
  62552. * @param options defines the options used to create the line system
  62553. * @param scene defines the hosting scene
  62554. * @returns a new line system mesh
  62555. */
  62556. static CreateLineSystem(name: string, options: {
  62557. lines: Vector3[][];
  62558. updatable?: boolean;
  62559. instance?: Nullable<LinesMesh>;
  62560. colors?: Nullable<Color4[][]>;
  62561. useVertexAlpha?: boolean;
  62562. }, scene: Nullable<Scene>): LinesMesh;
  62563. /**
  62564. * Creates a line mesh
  62565. * 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
  62566. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  62567. * * The parameter `points` is an array successive Vector3
  62568. * * 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
  62569. * * The optional parameter `colors` is an array of successive Color4, one per line point
  62570. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  62571. * * When updating an instance, remember that only point positions can change, not the number of points
  62572. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62573. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  62574. * @param name defines the name of the new line system
  62575. * @param options defines the options used to create the line system
  62576. * @param scene defines the hosting scene
  62577. * @returns a new line mesh
  62578. */
  62579. static CreateLines(name: string, options: {
  62580. points: Vector3[];
  62581. updatable?: boolean;
  62582. instance?: Nullable<LinesMesh>;
  62583. colors?: Color4[];
  62584. useVertexAlpha?: boolean;
  62585. }, scene?: Nullable<Scene>): LinesMesh;
  62586. /**
  62587. * Creates a dashed line mesh
  62588. * * 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
  62589. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  62590. * * The parameter `points` is an array successive Vector3
  62591. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  62592. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  62593. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  62594. * * 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
  62595. * * When updating an instance, remember that only point positions can change, not the number of points
  62596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62597. * @param name defines the name of the mesh
  62598. * @param options defines the options used to create the mesh
  62599. * @param scene defines the hosting scene
  62600. * @returns the dashed line mesh
  62601. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  62602. */
  62603. static CreateDashedLines(name: string, options: {
  62604. points: Vector3[];
  62605. dashSize?: number;
  62606. gapSize?: number;
  62607. dashNb?: number;
  62608. updatable?: boolean;
  62609. instance?: LinesMesh;
  62610. }, scene?: Nullable<Scene>): LinesMesh;
  62611. /**
  62612. * 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.
  62613. * * 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.
  62614. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62615. * * 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.
  62616. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  62617. * * 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
  62618. * * 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
  62619. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  62620. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62621. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62622. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  62623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62624. * @param name defines the name of the mesh
  62625. * @param options defines the options used to create the mesh
  62626. * @param scene defines the hosting scene
  62627. * @returns the extruded shape mesh
  62628. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62629. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62630. */
  62631. static ExtrudeShape(name: string, options: {
  62632. shape: Vector3[];
  62633. path: Vector3[];
  62634. scale?: number;
  62635. rotation?: number;
  62636. cap?: number;
  62637. updatable?: boolean;
  62638. sideOrientation?: number;
  62639. frontUVs?: Vector4;
  62640. backUVs?: Vector4;
  62641. instance?: Mesh;
  62642. invertUV?: boolean;
  62643. }, scene?: Nullable<Scene>): Mesh;
  62644. /**
  62645. * Creates an custom extruded shape mesh.
  62646. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  62647. * * 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.
  62648. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62649. * * 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
  62650. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  62651. * * 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
  62652. * * It must returns a float value that will be the scale value applied to the shape on each path point
  62653. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  62654. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  62655. * * 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
  62656. * * 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
  62657. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  62658. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62659. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62660. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62662. * @param name defines the name of the mesh
  62663. * @param options defines the options used to create the mesh
  62664. * @param scene defines the hosting scene
  62665. * @returns the custom extruded shape mesh
  62666. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  62667. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62668. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62669. */
  62670. static ExtrudeShapeCustom(name: string, options: {
  62671. shape: Vector3[];
  62672. path: Vector3[];
  62673. scaleFunction?: any;
  62674. rotationFunction?: any;
  62675. ribbonCloseArray?: boolean;
  62676. ribbonClosePath?: boolean;
  62677. cap?: number;
  62678. updatable?: boolean;
  62679. sideOrientation?: number;
  62680. frontUVs?: Vector4;
  62681. backUVs?: Vector4;
  62682. instance?: Mesh;
  62683. invertUV?: boolean;
  62684. }, scene?: Nullable<Scene>): Mesh;
  62685. /**
  62686. * Creates lathe mesh.
  62687. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  62688. * * 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
  62689. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  62690. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  62691. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  62692. * * 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
  62693. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  62694. * * 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
  62695. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62696. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62697. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62699. * @param name defines the name of the mesh
  62700. * @param options defines the options used to create the mesh
  62701. * @param scene defines the hosting scene
  62702. * @returns the lathe mesh
  62703. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  62704. */
  62705. static CreateLathe(name: string, options: {
  62706. shape: Vector3[];
  62707. radius?: number;
  62708. tessellation?: number;
  62709. clip?: number;
  62710. arc?: number;
  62711. closed?: boolean;
  62712. updatable?: boolean;
  62713. sideOrientation?: number;
  62714. frontUVs?: Vector4;
  62715. backUVs?: Vector4;
  62716. cap?: number;
  62717. invertUV?: boolean;
  62718. }, scene?: Nullable<Scene>): Mesh;
  62719. /**
  62720. * Creates a tiled plane mesh
  62721. * * You can set a limited pattern arrangement with the tiles
  62722. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62723. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62725. * @param name defines the name of the mesh
  62726. * @param options defines the options used to create the mesh
  62727. * @param scene defines the hosting scene
  62728. * @returns the plane mesh
  62729. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62730. */
  62731. static CreateTiledPlane(name: string, options: {
  62732. pattern?: number;
  62733. tileSize?: number;
  62734. tileWidth?: number;
  62735. tileHeight?: number;
  62736. size?: number;
  62737. width?: number;
  62738. height?: number;
  62739. alignHorizontal?: number;
  62740. alignVertical?: number;
  62741. sideOrientation?: number;
  62742. frontUVs?: Vector4;
  62743. backUVs?: Vector4;
  62744. updatable?: boolean;
  62745. }, scene?: Nullable<Scene>): Mesh;
  62746. /**
  62747. * Creates a plane mesh
  62748. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  62749. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  62750. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  62751. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62752. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62754. * @param name defines the name of the mesh
  62755. * @param options defines the options used to create the mesh
  62756. * @param scene defines the hosting scene
  62757. * @returns the plane mesh
  62758. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62759. */
  62760. static CreatePlane(name: string, options: {
  62761. size?: number;
  62762. width?: number;
  62763. height?: number;
  62764. sideOrientation?: number;
  62765. frontUVs?: Vector4;
  62766. backUVs?: Vector4;
  62767. updatable?: boolean;
  62768. sourcePlane?: Plane;
  62769. }, scene?: Nullable<Scene>): Mesh;
  62770. /**
  62771. * Creates a ground mesh
  62772. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  62773. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  62774. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62775. * @param name defines the name of the mesh
  62776. * @param options defines the options used to create the mesh
  62777. * @param scene defines the hosting scene
  62778. * @returns the ground mesh
  62779. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  62780. */
  62781. static CreateGround(name: string, options: {
  62782. width?: number;
  62783. height?: number;
  62784. subdivisions?: number;
  62785. subdivisionsX?: number;
  62786. subdivisionsY?: number;
  62787. updatable?: boolean;
  62788. }, scene?: Nullable<Scene>): Mesh;
  62789. /**
  62790. * Creates a tiled ground mesh
  62791. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  62792. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  62793. * * 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
  62794. * * 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
  62795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62796. * @param name defines the name of the mesh
  62797. * @param options defines the options used to create the mesh
  62798. * @param scene defines the hosting scene
  62799. * @returns the tiled ground mesh
  62800. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  62801. */
  62802. static CreateTiledGround(name: string, options: {
  62803. xmin: number;
  62804. zmin: number;
  62805. xmax: number;
  62806. zmax: number;
  62807. subdivisions?: {
  62808. w: number;
  62809. h: number;
  62810. };
  62811. precision?: {
  62812. w: number;
  62813. h: number;
  62814. };
  62815. updatable?: boolean;
  62816. }, scene?: Nullable<Scene>): Mesh;
  62817. /**
  62818. * Creates a ground mesh from a height map
  62819. * * The parameter `url` sets the URL of the height map image resource.
  62820. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  62821. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  62822. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  62823. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  62824. * * 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.
  62825. * * 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).
  62826. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  62827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62828. * @param name defines the name of the mesh
  62829. * @param url defines the url to the height map
  62830. * @param options defines the options used to create the mesh
  62831. * @param scene defines the hosting scene
  62832. * @returns the ground mesh
  62833. * @see https://doc.babylonjs.com/babylon101/height_map
  62834. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  62835. */
  62836. static CreateGroundFromHeightMap(name: string, url: string, options: {
  62837. width?: number;
  62838. height?: number;
  62839. subdivisions?: number;
  62840. minHeight?: number;
  62841. maxHeight?: number;
  62842. colorFilter?: Color3;
  62843. alphaFilter?: number;
  62844. updatable?: boolean;
  62845. onReady?: (mesh: GroundMesh) => void;
  62846. }, scene?: Nullable<Scene>): GroundMesh;
  62847. /**
  62848. * Creates a polygon mesh
  62849. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62850. * * 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
  62851. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62853. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  62854. * * Remember you can only change the shape positions, not their number when updating a polygon
  62855. * @param name defines the name of the mesh
  62856. * @param options defines the options used to create the mesh
  62857. * @param scene defines the hosting scene
  62858. * @param earcutInjection can be used to inject your own earcut reference
  62859. * @returns the polygon mesh
  62860. */
  62861. static CreatePolygon(name: string, options: {
  62862. shape: Vector3[];
  62863. holes?: Vector3[][];
  62864. depth?: number;
  62865. faceUV?: Vector4[];
  62866. faceColors?: Color4[];
  62867. updatable?: boolean;
  62868. sideOrientation?: number;
  62869. frontUVs?: Vector4;
  62870. backUVs?: Vector4;
  62871. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62872. /**
  62873. * Creates an extruded polygon mesh, with depth in the Y direction.
  62874. * * 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)
  62875. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62876. * @param name defines the name of the mesh
  62877. * @param options defines the options used to create the mesh
  62878. * @param scene defines the hosting scene
  62879. * @param earcutInjection can be used to inject your own earcut reference
  62880. * @returns the polygon mesh
  62881. */
  62882. static ExtrudePolygon(name: string, options: {
  62883. shape: Vector3[];
  62884. holes?: Vector3[][];
  62885. depth?: number;
  62886. faceUV?: Vector4[];
  62887. faceColors?: Color4[];
  62888. updatable?: boolean;
  62889. sideOrientation?: number;
  62890. frontUVs?: Vector4;
  62891. backUVs?: Vector4;
  62892. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62893. /**
  62894. * Creates a tube mesh.
  62895. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62896. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62897. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62898. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62899. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62900. * * 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)
  62901. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62902. * * 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
  62903. * * 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
  62904. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62905. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62906. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62908. * @param name defines the name of the mesh
  62909. * @param options defines the options used to create the mesh
  62910. * @param scene defines the hosting scene
  62911. * @returns the tube mesh
  62912. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62913. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62914. */
  62915. static CreateTube(name: string, options: {
  62916. path: Vector3[];
  62917. radius?: number;
  62918. tessellation?: number;
  62919. radiusFunction?: {
  62920. (i: number, distance: number): number;
  62921. };
  62922. cap?: number;
  62923. arc?: number;
  62924. updatable?: boolean;
  62925. sideOrientation?: number;
  62926. frontUVs?: Vector4;
  62927. backUVs?: Vector4;
  62928. instance?: Mesh;
  62929. invertUV?: boolean;
  62930. }, scene?: Nullable<Scene>): Mesh;
  62931. /**
  62932. * Creates a polyhedron mesh
  62933. * * 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
  62934. * * The parameter `size` (positive float, default 1) sets the polygon size
  62935. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  62936. * * 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`
  62937. * * 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
  62938. * * 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)`)
  62939. * * 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
  62940. * * 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
  62941. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62942. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62944. * @param name defines the name of the mesh
  62945. * @param options defines the options used to create the mesh
  62946. * @param scene defines the hosting scene
  62947. * @returns the polyhedron mesh
  62948. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  62949. */
  62950. static CreatePolyhedron(name: string, options: {
  62951. type?: number;
  62952. size?: number;
  62953. sizeX?: number;
  62954. sizeY?: number;
  62955. sizeZ?: number;
  62956. custom?: any;
  62957. faceUV?: Vector4[];
  62958. faceColors?: Color4[];
  62959. flat?: boolean;
  62960. updatable?: boolean;
  62961. sideOrientation?: number;
  62962. frontUVs?: Vector4;
  62963. backUVs?: Vector4;
  62964. }, scene?: Nullable<Scene>): Mesh;
  62965. /**
  62966. * Creates a decal mesh.
  62967. * 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
  62968. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62969. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62970. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62971. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62972. * @param name defines the name of the mesh
  62973. * @param sourceMesh defines the mesh where the decal must be applied
  62974. * @param options defines the options used to create the mesh
  62975. * @param scene defines the hosting scene
  62976. * @returns the decal mesh
  62977. * @see https://doc.babylonjs.com/how_to/decals
  62978. */
  62979. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62980. position?: Vector3;
  62981. normal?: Vector3;
  62982. size?: Vector3;
  62983. angle?: number;
  62984. }): Mesh;
  62985. }
  62986. }
  62987. declare module "babylonjs/Meshes/meshSimplification" {
  62988. import { Mesh } from "babylonjs/Meshes/mesh";
  62989. /**
  62990. * A simplifier interface for future simplification implementations
  62991. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62992. */
  62993. export interface ISimplifier {
  62994. /**
  62995. * Simplification of a given mesh according to the given settings.
  62996. * Since this requires computation, it is assumed that the function runs async.
  62997. * @param settings The settings of the simplification, including quality and distance
  62998. * @param successCallback A callback that will be called after the mesh was simplified.
  62999. * @param errorCallback in case of an error, this callback will be called. optional.
  63000. */
  63001. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  63002. }
  63003. /**
  63004. * Expected simplification settings.
  63005. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  63006. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63007. */
  63008. export interface ISimplificationSettings {
  63009. /**
  63010. * Gets or sets the expected quality
  63011. */
  63012. quality: number;
  63013. /**
  63014. * Gets or sets the distance when this optimized version should be used
  63015. */
  63016. distance: number;
  63017. /**
  63018. * Gets an already optimized mesh
  63019. */
  63020. optimizeMesh?: boolean;
  63021. }
  63022. /**
  63023. * Class used to specify simplification options
  63024. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63025. */
  63026. export class SimplificationSettings implements ISimplificationSettings {
  63027. /** expected quality */
  63028. quality: number;
  63029. /** distance when this optimized version should be used */
  63030. distance: number;
  63031. /** already optimized mesh */
  63032. optimizeMesh?: boolean | undefined;
  63033. /**
  63034. * Creates a SimplificationSettings
  63035. * @param quality expected quality
  63036. * @param distance distance when this optimized version should be used
  63037. * @param optimizeMesh already optimized mesh
  63038. */
  63039. constructor(
  63040. /** expected quality */
  63041. quality: number,
  63042. /** distance when this optimized version should be used */
  63043. distance: number,
  63044. /** already optimized mesh */
  63045. optimizeMesh?: boolean | undefined);
  63046. }
  63047. /**
  63048. * Interface used to define a simplification task
  63049. */
  63050. export interface ISimplificationTask {
  63051. /**
  63052. * Array of settings
  63053. */
  63054. settings: Array<ISimplificationSettings>;
  63055. /**
  63056. * Simplification type
  63057. */
  63058. simplificationType: SimplificationType;
  63059. /**
  63060. * Mesh to simplify
  63061. */
  63062. mesh: Mesh;
  63063. /**
  63064. * Callback called on success
  63065. */
  63066. successCallback?: () => void;
  63067. /**
  63068. * Defines if parallel processing can be used
  63069. */
  63070. parallelProcessing: boolean;
  63071. }
  63072. /**
  63073. * Queue used to order the simplification tasks
  63074. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63075. */
  63076. export class SimplificationQueue {
  63077. private _simplificationArray;
  63078. /**
  63079. * Gets a boolean indicating that the process is still running
  63080. */
  63081. running: boolean;
  63082. /**
  63083. * Creates a new queue
  63084. */
  63085. constructor();
  63086. /**
  63087. * Adds a new simplification task
  63088. * @param task defines a task to add
  63089. */
  63090. addTask(task: ISimplificationTask): void;
  63091. /**
  63092. * Execute next task
  63093. */
  63094. executeNext(): void;
  63095. /**
  63096. * Execute a simplification task
  63097. * @param task defines the task to run
  63098. */
  63099. runSimplification(task: ISimplificationTask): void;
  63100. private getSimplifier;
  63101. }
  63102. /**
  63103. * The implemented types of simplification
  63104. * At the moment only Quadratic Error Decimation is implemented
  63105. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63106. */
  63107. export enum SimplificationType {
  63108. /** Quadratic error decimation */
  63109. QUADRATIC = 0
  63110. }
  63111. }
  63112. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  63113. import { Scene } from "babylonjs/scene";
  63114. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  63115. import { ISceneComponent } from "babylonjs/sceneComponent";
  63116. module "babylonjs/scene" {
  63117. interface Scene {
  63118. /** @hidden (Backing field) */
  63119. _simplificationQueue: SimplificationQueue;
  63120. /**
  63121. * Gets or sets the simplification queue attached to the scene
  63122. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63123. */
  63124. simplificationQueue: SimplificationQueue;
  63125. }
  63126. }
  63127. module "babylonjs/Meshes/mesh" {
  63128. interface Mesh {
  63129. /**
  63130. * Simplify the mesh according to the given array of settings.
  63131. * Function will return immediately and will simplify async
  63132. * @param settings a collection of simplification settings
  63133. * @param parallelProcessing should all levels calculate parallel or one after the other
  63134. * @param simplificationType the type of simplification to run
  63135. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  63136. * @returns the current mesh
  63137. */
  63138. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  63139. }
  63140. }
  63141. /**
  63142. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  63143. * created in a scene
  63144. */
  63145. export class SimplicationQueueSceneComponent implements ISceneComponent {
  63146. /**
  63147. * The component name helpfull to identify the component in the list of scene components.
  63148. */
  63149. readonly name: string;
  63150. /**
  63151. * The scene the component belongs to.
  63152. */
  63153. scene: Scene;
  63154. /**
  63155. * Creates a new instance of the component for the given scene
  63156. * @param scene Defines the scene to register the component in
  63157. */
  63158. constructor(scene: Scene);
  63159. /**
  63160. * Registers the component in a given scene
  63161. */
  63162. register(): void;
  63163. /**
  63164. * Rebuilds the elements related to this component in case of
  63165. * context lost for instance.
  63166. */
  63167. rebuild(): void;
  63168. /**
  63169. * Disposes the component and the associated ressources
  63170. */
  63171. dispose(): void;
  63172. private _beforeCameraUpdate;
  63173. }
  63174. }
  63175. declare module "babylonjs/Meshes/Builders/index" {
  63176. export * from "babylonjs/Meshes/Builders/boxBuilder";
  63177. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  63178. export * from "babylonjs/Meshes/Builders/discBuilder";
  63179. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  63180. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  63181. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  63182. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  63183. export * from "babylonjs/Meshes/Builders/torusBuilder";
  63184. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  63185. export * from "babylonjs/Meshes/Builders/linesBuilder";
  63186. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  63187. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  63188. export * from "babylonjs/Meshes/Builders/latheBuilder";
  63189. export * from "babylonjs/Meshes/Builders/planeBuilder";
  63190. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  63191. export * from "babylonjs/Meshes/Builders/groundBuilder";
  63192. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  63193. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  63194. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  63195. export * from "babylonjs/Meshes/Builders/decalBuilder";
  63196. }
  63197. declare module "babylonjs/Meshes/index" {
  63198. export * from "babylonjs/Meshes/abstractMesh";
  63199. export * from "babylonjs/Meshes/buffer";
  63200. export * from "babylonjs/Meshes/Compression/index";
  63201. export * from "babylonjs/Meshes/csg";
  63202. export * from "babylonjs/Meshes/geometry";
  63203. export * from "babylonjs/Meshes/groundMesh";
  63204. export * from "babylonjs/Meshes/trailMesh";
  63205. export * from "babylonjs/Meshes/instancedMesh";
  63206. export * from "babylonjs/Meshes/linesMesh";
  63207. export * from "babylonjs/Meshes/mesh";
  63208. export * from "babylonjs/Meshes/mesh.vertexData";
  63209. export * from "babylonjs/Meshes/meshBuilder";
  63210. export * from "babylonjs/Meshes/meshSimplification";
  63211. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  63212. export * from "babylonjs/Meshes/polygonMesh";
  63213. export * from "babylonjs/Meshes/subMesh";
  63214. export * from "babylonjs/Meshes/meshLODLevel";
  63215. export * from "babylonjs/Meshes/transformNode";
  63216. export * from "babylonjs/Meshes/Builders/index";
  63217. export * from "babylonjs/Meshes/dataBuffer";
  63218. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  63219. }
  63220. declare module "babylonjs/Morph/index" {
  63221. export * from "babylonjs/Morph/morphTarget";
  63222. export * from "babylonjs/Morph/morphTargetManager";
  63223. }
  63224. declare module "babylonjs/Navigation/INavigationEngine" {
  63225. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63226. import { Vector3 } from "babylonjs/Maths/math";
  63227. import { Mesh } from "babylonjs/Meshes/mesh";
  63228. import { Scene } from "babylonjs/scene";
  63229. /**
  63230. * Navigation plugin interface to add navigation constrained by a navigation mesh
  63231. */
  63232. export interface INavigationEnginePlugin {
  63233. /**
  63234. * plugin name
  63235. */
  63236. name: string;
  63237. /**
  63238. * Creates a navigation mesh
  63239. * @param meshes array of all the geometry used to compute the navigatio mesh
  63240. * @param parameters bunch of parameters used to filter geometry
  63241. */
  63242. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  63243. /**
  63244. * Create a navigation mesh debug mesh
  63245. * @param scene is where the mesh will be added
  63246. * @returns debug display mesh
  63247. */
  63248. createDebugNavMesh(scene: Scene): Mesh;
  63249. /**
  63250. * Get a navigation mesh constrained position, closest to the parameter position
  63251. * @param position world position
  63252. * @returns the closest point to position constrained by the navigation mesh
  63253. */
  63254. getClosestPoint(position: Vector3): Vector3;
  63255. /**
  63256. * Get a navigation mesh constrained position, within a particular radius
  63257. * @param position world position
  63258. * @param maxRadius the maximum distance to the constrained world position
  63259. * @returns the closest point to position constrained by the navigation mesh
  63260. */
  63261. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  63262. /**
  63263. * Compute the final position from a segment made of destination-position
  63264. * @param position world position
  63265. * @param destination world position
  63266. * @returns the resulting point along the navmesh
  63267. */
  63268. moveAlong(position: Vector3, destination: Vector3): Vector3;
  63269. /**
  63270. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  63271. * @param start world position
  63272. * @param end world position
  63273. * @returns array containing world position composing the path
  63274. */
  63275. computePath(start: Vector3, end: Vector3): Vector3[];
  63276. /**
  63277. * If this plugin is supported
  63278. * @returns true if plugin is supported
  63279. */
  63280. isSupported(): boolean;
  63281. /**
  63282. * Create a new Crowd so you can add agents
  63283. * @param maxAgents the maximum agent count in the crowd
  63284. * @param maxAgentRadius the maximum radius an agent can have
  63285. * @param scene to attach the crowd to
  63286. * @returns the crowd you can add agents to
  63287. */
  63288. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  63289. /**
  63290. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63291. * The queries will try to find a solution within those bounds
  63292. * default is (1,1,1)
  63293. * @param extent x,y,z value that define the extent around the queries point of reference
  63294. */
  63295. setDefaultQueryExtent(extent: Vector3): void;
  63296. /**
  63297. * Get the Bounding box extent specified by setDefaultQueryExtent
  63298. * @returns the box extent values
  63299. */
  63300. getDefaultQueryExtent(): Vector3;
  63301. /**
  63302. * Release all resources
  63303. */
  63304. dispose(): void;
  63305. }
  63306. /**
  63307. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  63308. */
  63309. export interface ICrowd {
  63310. /**
  63311. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  63312. * You can attach anything to that node. The node position is updated in the scene update tick.
  63313. * @param pos world position that will be constrained by the navigation mesh
  63314. * @param parameters agent parameters
  63315. * @param transform hooked to the agent that will be update by the scene
  63316. * @returns agent index
  63317. */
  63318. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  63319. /**
  63320. * Returns the agent position in world space
  63321. * @param index agent index returned by addAgent
  63322. * @returns world space position
  63323. */
  63324. getAgentPosition(index: number): Vector3;
  63325. /**
  63326. * Gets the agent velocity in world space
  63327. * @param index agent index returned by addAgent
  63328. * @returns world space velocity
  63329. */
  63330. getAgentVelocity(index: number): Vector3;
  63331. /**
  63332. * remove a particular agent previously created
  63333. * @param index agent index returned by addAgent
  63334. */
  63335. removeAgent(index: number): void;
  63336. /**
  63337. * get the list of all agents attached to this crowd
  63338. * @returns list of agent indices
  63339. */
  63340. getAgents(): number[];
  63341. /**
  63342. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  63343. * @param deltaTime in seconds
  63344. */
  63345. update(deltaTime: number): void;
  63346. /**
  63347. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  63348. * @param index agent index returned by addAgent
  63349. * @param destination targeted world position
  63350. */
  63351. agentGoto(index: number, destination: Vector3): void;
  63352. /**
  63353. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63354. * The queries will try to find a solution within those bounds
  63355. * default is (1,1,1)
  63356. * @param extent x,y,z value that define the extent around the queries point of reference
  63357. */
  63358. setDefaultQueryExtent(extent: Vector3): void;
  63359. /**
  63360. * Get the Bounding box extent specified by setDefaultQueryExtent
  63361. * @returns the box extent values
  63362. */
  63363. getDefaultQueryExtent(): Vector3;
  63364. /**
  63365. * Release all resources
  63366. */
  63367. dispose(): void;
  63368. }
  63369. /**
  63370. * Configures an agent
  63371. */
  63372. export interface IAgentParameters {
  63373. /**
  63374. * Agent radius. [Limit: >= 0]
  63375. */
  63376. radius: number;
  63377. /**
  63378. * Agent height. [Limit: > 0]
  63379. */
  63380. height: number;
  63381. /**
  63382. * Maximum allowed acceleration. [Limit: >= 0]
  63383. */
  63384. maxAcceleration: number;
  63385. /**
  63386. * Maximum allowed speed. [Limit: >= 0]
  63387. */
  63388. maxSpeed: number;
  63389. /**
  63390. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  63391. */
  63392. collisionQueryRange: number;
  63393. /**
  63394. * The path visibility optimization range. [Limit: > 0]
  63395. */
  63396. pathOptimizationRange: number;
  63397. /**
  63398. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  63399. */
  63400. separationWeight: number;
  63401. }
  63402. /**
  63403. * Configures the navigation mesh creation
  63404. */
  63405. export interface INavMeshParameters {
  63406. /**
  63407. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  63408. */
  63409. cs: number;
  63410. /**
  63411. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  63412. */
  63413. ch: number;
  63414. /**
  63415. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  63416. */
  63417. walkableSlopeAngle: number;
  63418. /**
  63419. * Minimum floor to 'ceiling' height that will still allow the floor area to
  63420. * be considered walkable. [Limit: >= 3] [Units: vx]
  63421. */
  63422. walkableHeight: number;
  63423. /**
  63424. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  63425. */
  63426. walkableClimb: number;
  63427. /**
  63428. * The distance to erode/shrink the walkable area of the heightfield away from
  63429. * obstructions. [Limit: >=0] [Units: vx]
  63430. */
  63431. walkableRadius: number;
  63432. /**
  63433. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  63434. */
  63435. maxEdgeLen: number;
  63436. /**
  63437. * The maximum distance a simplfied contour's border edges should deviate
  63438. * the original raw contour. [Limit: >=0] [Units: vx]
  63439. */
  63440. maxSimplificationError: number;
  63441. /**
  63442. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  63443. */
  63444. minRegionArea: number;
  63445. /**
  63446. * Any regions with a span count smaller than this value will, if possible,
  63447. * be merged with larger regions. [Limit: >=0] [Units: vx]
  63448. */
  63449. mergeRegionArea: number;
  63450. /**
  63451. * The maximum number of vertices allowed for polygons generated during the
  63452. * contour to polygon conversion process. [Limit: >= 3]
  63453. */
  63454. maxVertsPerPoly: number;
  63455. /**
  63456. * Sets the sampling distance to use when generating the detail mesh.
  63457. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  63458. */
  63459. detailSampleDist: number;
  63460. /**
  63461. * The maximum distance the detail mesh surface should deviate from heightfield
  63462. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  63463. */
  63464. detailSampleMaxError: number;
  63465. }
  63466. }
  63467. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  63468. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  63469. import { Mesh } from "babylonjs/Meshes/mesh";
  63470. import { Scene } from "babylonjs/scene";
  63471. import { Vector3 } from "babylonjs/Maths/math";
  63472. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63473. /**
  63474. * RecastJS navigation plugin
  63475. */
  63476. export class RecastJSPlugin implements INavigationEnginePlugin {
  63477. /**
  63478. * Reference to the Recast library
  63479. */
  63480. bjsRECAST: any;
  63481. /**
  63482. * plugin name
  63483. */
  63484. name: string;
  63485. /**
  63486. * the first navmesh created. We might extend this to support multiple navmeshes
  63487. */
  63488. navMesh: any;
  63489. /**
  63490. * Initializes the recastJS plugin
  63491. * @param recastInjection can be used to inject your own recast reference
  63492. */
  63493. constructor(recastInjection?: any);
  63494. /**
  63495. * Creates a navigation mesh
  63496. * @param meshes array of all the geometry used to compute the navigatio mesh
  63497. * @param parameters bunch of parameters used to filter geometry
  63498. */
  63499. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  63500. /**
  63501. * Create a navigation mesh debug mesh
  63502. * @param scene is where the mesh will be added
  63503. * @returns debug display mesh
  63504. */
  63505. createDebugNavMesh(scene: Scene): Mesh;
  63506. /**
  63507. * Get a navigation mesh constrained position, closest to the parameter position
  63508. * @param position world position
  63509. * @returns the closest point to position constrained by the navigation mesh
  63510. */
  63511. getClosestPoint(position: Vector3): Vector3;
  63512. /**
  63513. * Get a navigation mesh constrained position, within a particular radius
  63514. * @param position world position
  63515. * @param maxRadius the maximum distance to the constrained world position
  63516. * @returns the closest point to position constrained by the navigation mesh
  63517. */
  63518. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  63519. /**
  63520. * Compute the final position from a segment made of destination-position
  63521. * @param position world position
  63522. * @param destination world position
  63523. * @returns the resulting point along the navmesh
  63524. */
  63525. moveAlong(position: Vector3, destination: Vector3): Vector3;
  63526. /**
  63527. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  63528. * @param start world position
  63529. * @param end world position
  63530. * @returns array containing world position composing the path
  63531. */
  63532. computePath(start: Vector3, end: Vector3): Vector3[];
  63533. /**
  63534. * Create a new Crowd so you can add agents
  63535. * @param maxAgents the maximum agent count in the crowd
  63536. * @param maxAgentRadius the maximum radius an agent can have
  63537. * @param scene to attach the crowd to
  63538. * @returns the crowd you can add agents to
  63539. */
  63540. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  63541. /**
  63542. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63543. * The queries will try to find a solution within those bounds
  63544. * default is (1,1,1)
  63545. * @param extent x,y,z value that define the extent around the queries point of reference
  63546. */
  63547. setDefaultQueryExtent(extent: Vector3): void;
  63548. /**
  63549. * Get the Bounding box extent specified by setDefaultQueryExtent
  63550. * @returns the box extent values
  63551. */
  63552. getDefaultQueryExtent(): Vector3;
  63553. /**
  63554. * Disposes
  63555. */
  63556. dispose(): void;
  63557. /**
  63558. * If this plugin is supported
  63559. * @returns true if plugin is supported
  63560. */
  63561. isSupported(): boolean;
  63562. }
  63563. /**
  63564. * Recast detour crowd implementation
  63565. */
  63566. export class RecastJSCrowd implements ICrowd {
  63567. /**
  63568. * Recast/detour plugin
  63569. */
  63570. bjsRECASTPlugin: RecastJSPlugin;
  63571. /**
  63572. * Link to the detour crowd
  63573. */
  63574. recastCrowd: any;
  63575. /**
  63576. * One transform per agent
  63577. */
  63578. transforms: TransformNode[];
  63579. /**
  63580. * All agents created
  63581. */
  63582. agents: number[];
  63583. /**
  63584. * Link to the scene is kept to unregister the crowd from the scene
  63585. */
  63586. private _scene;
  63587. /**
  63588. * Observer for crowd updates
  63589. */
  63590. private _onBeforeAnimationsObserver;
  63591. /**
  63592. * Constructor
  63593. * @param plugin recastJS plugin
  63594. * @param maxAgents the maximum agent count in the crowd
  63595. * @param maxAgentRadius the maximum radius an agent can have
  63596. * @param scene to attach the crowd to
  63597. * @returns the crowd you can add agents to
  63598. */
  63599. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  63600. /**
  63601. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  63602. * You can attach anything to that node. The node position is updated in the scene update tick.
  63603. * @param pos world position that will be constrained by the navigation mesh
  63604. * @param parameters agent parameters
  63605. * @param transform hooked to the agent that will be update by the scene
  63606. * @returns agent index
  63607. */
  63608. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  63609. /**
  63610. * Returns the agent position in world space
  63611. * @param index agent index returned by addAgent
  63612. * @returns world space position
  63613. */
  63614. getAgentPosition(index: number): Vector3;
  63615. /**
  63616. * Returns the agent velocity in world space
  63617. * @param index agent index returned by addAgent
  63618. * @returns world space velocity
  63619. */
  63620. getAgentVelocity(index: number): Vector3;
  63621. /**
  63622. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  63623. * @param index agent index returned by addAgent
  63624. * @param destination targeted world position
  63625. */
  63626. agentGoto(index: number, destination: Vector3): void;
  63627. /**
  63628. * remove a particular agent previously created
  63629. * @param index agent index returned by addAgent
  63630. */
  63631. removeAgent(index: number): void;
  63632. /**
  63633. * get the list of all agents attached to this crowd
  63634. * @returns list of agent indices
  63635. */
  63636. getAgents(): number[];
  63637. /**
  63638. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  63639. * @param deltaTime in seconds
  63640. */
  63641. update(deltaTime: number): void;
  63642. /**
  63643. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63644. * The queries will try to find a solution within those bounds
  63645. * default is (1,1,1)
  63646. * @param extent x,y,z value that define the extent around the queries point of reference
  63647. */
  63648. setDefaultQueryExtent(extent: Vector3): void;
  63649. /**
  63650. * Get the Bounding box extent specified by setDefaultQueryExtent
  63651. * @returns the box extent values
  63652. */
  63653. getDefaultQueryExtent(): Vector3;
  63654. /**
  63655. * Release all resources
  63656. */
  63657. dispose(): void;
  63658. }
  63659. }
  63660. declare module "babylonjs/Navigation/Plugins/index" {
  63661. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  63662. }
  63663. declare module "babylonjs/Navigation/index" {
  63664. export * from "babylonjs/Navigation/INavigationEngine";
  63665. export * from "babylonjs/Navigation/Plugins/index";
  63666. }
  63667. declare module "babylonjs/Offline/database" {
  63668. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  63669. /**
  63670. * Class used to enable access to IndexedDB
  63671. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63672. */
  63673. export class Database implements IOfflineProvider {
  63674. private _callbackManifestChecked;
  63675. private _currentSceneUrl;
  63676. private _db;
  63677. private _enableSceneOffline;
  63678. private _enableTexturesOffline;
  63679. private _manifestVersionFound;
  63680. private _mustUpdateRessources;
  63681. private _hasReachedQuota;
  63682. private _isSupported;
  63683. private _idbFactory;
  63684. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  63685. private static IsUASupportingBlobStorage;
  63686. /**
  63687. * Gets a boolean indicating if Database storate is enabled (off by default)
  63688. */
  63689. static IDBStorageEnabled: boolean;
  63690. /**
  63691. * Gets a boolean indicating if scene must be saved in the database
  63692. */
  63693. get enableSceneOffline(): boolean;
  63694. /**
  63695. * Gets a boolean indicating if textures must be saved in the database
  63696. */
  63697. get enableTexturesOffline(): boolean;
  63698. /**
  63699. * Creates a new Database
  63700. * @param urlToScene defines the url to load the scene
  63701. * @param callbackManifestChecked defines the callback to use when manifest is checked
  63702. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  63703. */
  63704. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  63705. private static _ParseURL;
  63706. private static _ReturnFullUrlLocation;
  63707. private _checkManifestFile;
  63708. /**
  63709. * Open the database and make it available
  63710. * @param successCallback defines the callback to call on success
  63711. * @param errorCallback defines the callback to call on error
  63712. */
  63713. open(successCallback: () => void, errorCallback: () => void): void;
  63714. /**
  63715. * Loads an image from the database
  63716. * @param url defines the url to load from
  63717. * @param image defines the target DOM image
  63718. */
  63719. loadImage(url: string, image: HTMLImageElement): void;
  63720. private _loadImageFromDBAsync;
  63721. private _saveImageIntoDBAsync;
  63722. private _checkVersionFromDB;
  63723. private _loadVersionFromDBAsync;
  63724. private _saveVersionIntoDBAsync;
  63725. /**
  63726. * Loads a file from database
  63727. * @param url defines the URL to load from
  63728. * @param sceneLoaded defines a callback to call on success
  63729. * @param progressCallBack defines a callback to call when progress changed
  63730. * @param errorCallback defines a callback to call on error
  63731. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63732. */
  63733. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63734. private _loadFileAsync;
  63735. private _saveFileAsync;
  63736. /**
  63737. * Validates if xhr data is correct
  63738. * @param xhr defines the request to validate
  63739. * @param dataType defines the expected data type
  63740. * @returns true if data is correct
  63741. */
  63742. private static _ValidateXHRData;
  63743. }
  63744. }
  63745. declare module "babylonjs/Offline/index" {
  63746. export * from "babylonjs/Offline/database";
  63747. export * from "babylonjs/Offline/IOfflineProvider";
  63748. }
  63749. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  63750. /** @hidden */
  63751. export var gpuUpdateParticlesPixelShader: {
  63752. name: string;
  63753. shader: string;
  63754. };
  63755. }
  63756. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  63757. /** @hidden */
  63758. export var gpuUpdateParticlesVertexShader: {
  63759. name: string;
  63760. shader: string;
  63761. };
  63762. }
  63763. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  63764. /** @hidden */
  63765. export var clipPlaneFragmentDeclaration2: {
  63766. name: string;
  63767. shader: string;
  63768. };
  63769. }
  63770. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  63771. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  63772. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  63773. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63774. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  63775. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  63776. /** @hidden */
  63777. export var gpuRenderParticlesPixelShader: {
  63778. name: string;
  63779. shader: string;
  63780. };
  63781. }
  63782. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  63783. /** @hidden */
  63784. export var clipPlaneVertexDeclaration2: {
  63785. name: string;
  63786. shader: string;
  63787. };
  63788. }
  63789. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  63790. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  63791. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  63792. /** @hidden */
  63793. export var gpuRenderParticlesVertexShader: {
  63794. name: string;
  63795. shader: string;
  63796. };
  63797. }
  63798. declare module "babylonjs/Particles/gpuParticleSystem" {
  63799. import { Nullable } from "babylonjs/types";
  63800. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  63801. import { Observable } from "babylonjs/Misc/observable";
  63802. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  63803. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  63804. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  63805. import { Scene, IDisposable } from "babylonjs/scene";
  63806. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  63807. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63808. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  63809. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  63810. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  63811. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  63812. /**
  63813. * This represents a GPU particle system in Babylon
  63814. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  63815. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  63816. */
  63817. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  63818. /**
  63819. * The layer mask we are rendering the particles through.
  63820. */
  63821. layerMask: number;
  63822. private _capacity;
  63823. private _activeCount;
  63824. private _currentActiveCount;
  63825. private _accumulatedCount;
  63826. private _renderEffect;
  63827. private _updateEffect;
  63828. private _buffer0;
  63829. private _buffer1;
  63830. private _spriteBuffer;
  63831. private _updateVAO;
  63832. private _renderVAO;
  63833. private _targetIndex;
  63834. private _sourceBuffer;
  63835. private _targetBuffer;
  63836. private _engine;
  63837. private _currentRenderId;
  63838. private _started;
  63839. private _stopped;
  63840. private _timeDelta;
  63841. private _randomTexture;
  63842. private _randomTexture2;
  63843. private _attributesStrideSize;
  63844. private _updateEffectOptions;
  63845. private _randomTextureSize;
  63846. private _actualFrame;
  63847. private readonly _rawTextureWidth;
  63848. /**
  63849. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  63850. */
  63851. static get IsSupported(): boolean;
  63852. /**
  63853. * An event triggered when the system is disposed.
  63854. */
  63855. onDisposeObservable: Observable<GPUParticleSystem>;
  63856. /**
  63857. * Gets the maximum number of particles active at the same time.
  63858. * @returns The max number of active particles.
  63859. */
  63860. getCapacity(): number;
  63861. /**
  63862. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  63863. * to override the particles.
  63864. */
  63865. forceDepthWrite: boolean;
  63866. /**
  63867. * Gets or set the number of active particles
  63868. */
  63869. get activeParticleCount(): number;
  63870. set activeParticleCount(value: number);
  63871. private _preWarmDone;
  63872. /**
  63873. * Is this system ready to be used/rendered
  63874. * @return true if the system is ready
  63875. */
  63876. isReady(): boolean;
  63877. /**
  63878. * Gets if the system has been started. (Note: this will still be true after stop is called)
  63879. * @returns True if it has been started, otherwise false.
  63880. */
  63881. isStarted(): boolean;
  63882. /**
  63883. * Starts the particle system and begins to emit
  63884. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  63885. */
  63886. start(delay?: number): void;
  63887. /**
  63888. * Stops the particle system.
  63889. */
  63890. stop(): void;
  63891. /**
  63892. * Remove all active particles
  63893. */
  63894. reset(): void;
  63895. /**
  63896. * Returns the string "GPUParticleSystem"
  63897. * @returns a string containing the class name
  63898. */
  63899. getClassName(): string;
  63900. private _colorGradientsTexture;
  63901. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  63902. /**
  63903. * Adds a new color gradient
  63904. * @param gradient defines the gradient to use (between 0 and 1)
  63905. * @param color1 defines the color to affect to the specified gradient
  63906. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  63907. * @returns the current particle system
  63908. */
  63909. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  63910. /**
  63911. * Remove a specific color gradient
  63912. * @param gradient defines the gradient to remove
  63913. * @returns the current particle system
  63914. */
  63915. removeColorGradient(gradient: number): GPUParticleSystem;
  63916. private _angularSpeedGradientsTexture;
  63917. private _sizeGradientsTexture;
  63918. private _velocityGradientsTexture;
  63919. private _limitVelocityGradientsTexture;
  63920. private _dragGradientsTexture;
  63921. private _addFactorGradient;
  63922. /**
  63923. * Adds a new size gradient
  63924. * @param gradient defines the gradient to use (between 0 and 1)
  63925. * @param factor defines the size factor to affect to the specified gradient
  63926. * @returns the current particle system
  63927. */
  63928. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  63929. /**
  63930. * Remove a specific size gradient
  63931. * @param gradient defines the gradient to remove
  63932. * @returns the current particle system
  63933. */
  63934. removeSizeGradient(gradient: number): GPUParticleSystem;
  63935. /**
  63936. * Adds a new angular speed gradient
  63937. * @param gradient defines the gradient to use (between 0 and 1)
  63938. * @param factor defines the angular speed to affect to the specified gradient
  63939. * @returns the current particle system
  63940. */
  63941. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  63942. /**
  63943. * Remove a specific angular speed gradient
  63944. * @param gradient defines the gradient to remove
  63945. * @returns the current particle system
  63946. */
  63947. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  63948. /**
  63949. * Adds a new velocity gradient
  63950. * @param gradient defines the gradient to use (between 0 and 1)
  63951. * @param factor defines the velocity to affect to the specified gradient
  63952. * @returns the current particle system
  63953. */
  63954. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63955. /**
  63956. * Remove a specific velocity gradient
  63957. * @param gradient defines the gradient to remove
  63958. * @returns the current particle system
  63959. */
  63960. removeVelocityGradient(gradient: number): GPUParticleSystem;
  63961. /**
  63962. * Adds a new limit velocity gradient
  63963. * @param gradient defines the gradient to use (between 0 and 1)
  63964. * @param factor defines the limit velocity value to affect to the specified gradient
  63965. * @returns the current particle system
  63966. */
  63967. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63968. /**
  63969. * Remove a specific limit velocity gradient
  63970. * @param gradient defines the gradient to remove
  63971. * @returns the current particle system
  63972. */
  63973. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  63974. /**
  63975. * Adds a new drag gradient
  63976. * @param gradient defines the gradient to use (between 0 and 1)
  63977. * @param factor defines the drag value to affect to the specified gradient
  63978. * @returns the current particle system
  63979. */
  63980. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  63981. /**
  63982. * Remove a specific drag gradient
  63983. * @param gradient defines the gradient to remove
  63984. * @returns the current particle system
  63985. */
  63986. removeDragGradient(gradient: number): GPUParticleSystem;
  63987. /**
  63988. * Not supported by GPUParticleSystem
  63989. * @param gradient defines the gradient to use (between 0 and 1)
  63990. * @param factor defines the emit rate value to affect to the specified gradient
  63991. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63992. * @returns the current particle system
  63993. */
  63994. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63995. /**
  63996. * Not supported by GPUParticleSystem
  63997. * @param gradient defines the gradient to remove
  63998. * @returns the current particle system
  63999. */
  64000. removeEmitRateGradient(gradient: number): IParticleSystem;
  64001. /**
  64002. * Not supported by GPUParticleSystem
  64003. * @param gradient defines the gradient to use (between 0 and 1)
  64004. * @param factor defines the start size value to affect to the specified gradient
  64005. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64006. * @returns the current particle system
  64007. */
  64008. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64009. /**
  64010. * Not supported by GPUParticleSystem
  64011. * @param gradient defines the gradient to remove
  64012. * @returns the current particle system
  64013. */
  64014. removeStartSizeGradient(gradient: number): IParticleSystem;
  64015. /**
  64016. * Not supported by GPUParticleSystem
  64017. * @param gradient defines the gradient to use (between 0 and 1)
  64018. * @param min defines the color remap minimal range
  64019. * @param max defines the color remap maximal range
  64020. * @returns the current particle system
  64021. */
  64022. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  64023. /**
  64024. * Not supported by GPUParticleSystem
  64025. * @param gradient defines the gradient to remove
  64026. * @returns the current particle system
  64027. */
  64028. removeColorRemapGradient(): IParticleSystem;
  64029. /**
  64030. * Not supported by GPUParticleSystem
  64031. * @param gradient defines the gradient to use (between 0 and 1)
  64032. * @param min defines the alpha remap minimal range
  64033. * @param max defines the alpha remap maximal range
  64034. * @returns the current particle system
  64035. */
  64036. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  64037. /**
  64038. * Not supported by GPUParticleSystem
  64039. * @param gradient defines the gradient to remove
  64040. * @returns the current particle system
  64041. */
  64042. removeAlphaRemapGradient(): IParticleSystem;
  64043. /**
  64044. * Not supported by GPUParticleSystem
  64045. * @param gradient defines the gradient to use (between 0 and 1)
  64046. * @param color defines the color to affect to the specified gradient
  64047. * @returns the current particle system
  64048. */
  64049. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  64050. /**
  64051. * Not supported by GPUParticleSystem
  64052. * @param gradient defines the gradient to remove
  64053. * @returns the current particle system
  64054. */
  64055. removeRampGradient(): IParticleSystem;
  64056. /**
  64057. * Not supported by GPUParticleSystem
  64058. * @returns the list of ramp gradients
  64059. */
  64060. getRampGradients(): Nullable<Array<Color3Gradient>>;
  64061. /**
  64062. * Not supported by GPUParticleSystem
  64063. * Gets or sets a boolean indicating that ramp gradients must be used
  64064. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  64065. */
  64066. get useRampGradients(): boolean;
  64067. set useRampGradients(value: boolean);
  64068. /**
  64069. * Not supported by GPUParticleSystem
  64070. * @param gradient defines the gradient to use (between 0 and 1)
  64071. * @param factor defines the life time factor to affect to the specified gradient
  64072. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64073. * @returns the current particle system
  64074. */
  64075. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64076. /**
  64077. * Not supported by GPUParticleSystem
  64078. * @param gradient defines the gradient to remove
  64079. * @returns the current particle system
  64080. */
  64081. removeLifeTimeGradient(gradient: number): IParticleSystem;
  64082. /**
  64083. * Instantiates a GPU particle system.
  64084. * 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.
  64085. * @param name The name of the particle system
  64086. * @param options The options used to create the system
  64087. * @param scene The scene the particle system belongs to
  64088. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  64089. */
  64090. constructor(name: string, options: Partial<{
  64091. capacity: number;
  64092. randomTextureSize: number;
  64093. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  64094. protected _reset(): void;
  64095. private _createUpdateVAO;
  64096. private _createRenderVAO;
  64097. private _initialize;
  64098. /** @hidden */
  64099. _recreateUpdateEffect(): void;
  64100. /** @hidden */
  64101. _recreateRenderEffect(): void;
  64102. /**
  64103. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  64104. * @param preWarm defines if we are in the pre-warmimg phase
  64105. */
  64106. animate(preWarm?: boolean): void;
  64107. private _createFactorGradientTexture;
  64108. private _createSizeGradientTexture;
  64109. private _createAngularSpeedGradientTexture;
  64110. private _createVelocityGradientTexture;
  64111. private _createLimitVelocityGradientTexture;
  64112. private _createDragGradientTexture;
  64113. private _createColorGradientTexture;
  64114. /**
  64115. * Renders the particle system in its current state
  64116. * @param preWarm defines if the system should only update the particles but not render them
  64117. * @returns the current number of particles
  64118. */
  64119. render(preWarm?: boolean): number;
  64120. /**
  64121. * Rebuilds the particle system
  64122. */
  64123. rebuild(): void;
  64124. private _releaseBuffers;
  64125. private _releaseVAOs;
  64126. /**
  64127. * Disposes the particle system and free the associated resources
  64128. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  64129. */
  64130. dispose(disposeTexture?: boolean): void;
  64131. /**
  64132. * Clones the particle system.
  64133. * @param name The name of the cloned object
  64134. * @param newEmitter The new emitter to use
  64135. * @returns the cloned particle system
  64136. */
  64137. clone(name: string, newEmitter: any): GPUParticleSystem;
  64138. /**
  64139. * Serializes the particle system to a JSON object.
  64140. * @returns the JSON object
  64141. */
  64142. serialize(): any;
  64143. /**
  64144. * Parses a JSON object to create a GPU particle system.
  64145. * @param parsedParticleSystem The JSON object to parse
  64146. * @param scene The scene to create the particle system in
  64147. * @param rootUrl The root url to use to load external dependencies like texture
  64148. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  64149. * @returns the parsed GPU particle system
  64150. */
  64151. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  64152. }
  64153. }
  64154. declare module "babylonjs/Particles/particleSystemSet" {
  64155. import { Nullable } from "babylonjs/types";
  64156. import { Color3 } from "babylonjs/Maths/math.color";
  64157. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64159. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64160. import { Scene, IDisposable } from "babylonjs/scene";
  64161. /**
  64162. * Represents a set of particle systems working together to create a specific effect
  64163. */
  64164. export class ParticleSystemSet implements IDisposable {
  64165. /**
  64166. * Gets or sets base Assets URL
  64167. */
  64168. static BaseAssetsUrl: string;
  64169. private _emitterCreationOptions;
  64170. private _emitterNode;
  64171. /**
  64172. * Gets the particle system list
  64173. */
  64174. systems: IParticleSystem[];
  64175. /**
  64176. * Gets the emitter node used with this set
  64177. */
  64178. get emitterNode(): Nullable<TransformNode>;
  64179. /**
  64180. * Creates a new emitter mesh as a sphere
  64181. * @param options defines the options used to create the sphere
  64182. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  64183. * @param scene defines the hosting scene
  64184. */
  64185. setEmitterAsSphere(options: {
  64186. diameter: number;
  64187. segments: number;
  64188. color: Color3;
  64189. }, renderingGroupId: number, scene: Scene): void;
  64190. /**
  64191. * Starts all particle systems of the set
  64192. * @param emitter defines an optional mesh to use as emitter for the particle systems
  64193. */
  64194. start(emitter?: AbstractMesh): void;
  64195. /**
  64196. * Release all associated resources
  64197. */
  64198. dispose(): void;
  64199. /**
  64200. * Serialize the set into a JSON compatible object
  64201. * @returns a JSON compatible representation of the set
  64202. */
  64203. serialize(): any;
  64204. /**
  64205. * Parse a new ParticleSystemSet from a serialized source
  64206. * @param data defines a JSON compatible representation of the set
  64207. * @param scene defines the hosting scene
  64208. * @param gpu defines if we want GPU particles or CPU particles
  64209. * @returns a new ParticleSystemSet
  64210. */
  64211. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  64212. }
  64213. }
  64214. declare module "babylonjs/Particles/particleHelper" {
  64215. import { Nullable } from "babylonjs/types";
  64216. import { Scene } from "babylonjs/scene";
  64217. import { Vector3 } from "babylonjs/Maths/math.vector";
  64218. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64219. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64220. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  64221. /**
  64222. * This class is made for on one-liner static method to help creating particle system set.
  64223. */
  64224. export class ParticleHelper {
  64225. /**
  64226. * Gets or sets base Assets URL
  64227. */
  64228. static BaseAssetsUrl: string;
  64229. /**
  64230. * Create a default particle system that you can tweak
  64231. * @param emitter defines the emitter to use
  64232. * @param capacity defines the system capacity (default is 500 particles)
  64233. * @param scene defines the hosting scene
  64234. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  64235. * @returns the new Particle system
  64236. */
  64237. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  64238. /**
  64239. * This is the main static method (one-liner) of this helper to create different particle systems
  64240. * @param type This string represents the type to the particle system to create
  64241. * @param scene The scene where the particle system should live
  64242. * @param gpu If the system will use gpu
  64243. * @returns the ParticleSystemSet created
  64244. */
  64245. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  64246. /**
  64247. * Static function used to export a particle system to a ParticleSystemSet variable.
  64248. * Please note that the emitter shape is not exported
  64249. * @param systems defines the particle systems to export
  64250. * @returns the created particle system set
  64251. */
  64252. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  64253. }
  64254. }
  64255. declare module "babylonjs/Particles/particleSystemComponent" {
  64256. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64257. import { Effect } from "babylonjs/Materials/effect";
  64258. import "babylonjs/Shaders/particles.vertex";
  64259. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  64260. module "babylonjs/Engines/engine" {
  64261. interface Engine {
  64262. /**
  64263. * Create an effect to use with particle systems.
  64264. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  64265. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  64266. * @param uniformsNames defines a list of attribute names
  64267. * @param samplers defines an array of string used to represent textures
  64268. * @param defines defines the string containing the defines to use to compile the shaders
  64269. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  64270. * @param onCompiled defines a function to call when the effect creation is successful
  64271. * @param onError defines a function to call when the effect creation has failed
  64272. * @returns the new Effect
  64273. */
  64274. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  64275. }
  64276. }
  64277. module "babylonjs/Meshes/mesh" {
  64278. interface Mesh {
  64279. /**
  64280. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  64281. * @returns an array of IParticleSystem
  64282. */
  64283. getEmittedParticleSystems(): IParticleSystem[];
  64284. /**
  64285. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  64286. * @returns an array of IParticleSystem
  64287. */
  64288. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  64289. }
  64290. }
  64291. /**
  64292. * @hidden
  64293. */
  64294. export var _IDoNeedToBeInTheBuild: number;
  64295. }
  64296. declare module "babylonjs/Particles/pointsCloudSystem" {
  64297. import { Color4 } from "babylonjs/Maths/math";
  64298. import { Mesh } from "babylonjs/Meshes/mesh";
  64299. import { Scene, IDisposable } from "babylonjs/scene";
  64300. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  64301. /** Defines the 4 color options */
  64302. export enum PointColor {
  64303. /** color value */
  64304. Color = 2,
  64305. /** uv value */
  64306. UV = 1,
  64307. /** random value */
  64308. Random = 0,
  64309. /** stated value */
  64310. Stated = 3
  64311. }
  64312. /**
  64313. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  64314. * 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.
  64315. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  64316. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  64317. *
  64318. * Full documentation here : TO BE ENTERED
  64319. */
  64320. export class PointsCloudSystem implements IDisposable {
  64321. /**
  64322. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  64323. * Example : var p = SPS.particles[i];
  64324. */
  64325. particles: CloudPoint[];
  64326. /**
  64327. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  64328. */
  64329. nbParticles: number;
  64330. /**
  64331. * This a counter for your own usage. It's not set by any SPS functions.
  64332. */
  64333. counter: number;
  64334. /**
  64335. * The PCS name. This name is also given to the underlying mesh.
  64336. */
  64337. name: string;
  64338. /**
  64339. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  64340. */
  64341. mesh: Mesh;
  64342. /**
  64343. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  64344. * Please read :
  64345. */
  64346. vars: any;
  64347. /**
  64348. * @hidden
  64349. */
  64350. _size: number;
  64351. private _scene;
  64352. private _promises;
  64353. private _positions;
  64354. private _indices;
  64355. private _normals;
  64356. private _colors;
  64357. private _uvs;
  64358. private _indices32;
  64359. private _positions32;
  64360. private _colors32;
  64361. private _uvs32;
  64362. private _updatable;
  64363. private _isVisibilityBoxLocked;
  64364. private _alwaysVisible;
  64365. private _groups;
  64366. private _groupCounter;
  64367. private _computeParticleColor;
  64368. private _computeParticleTexture;
  64369. private _computeParticleRotation;
  64370. private _computeBoundingBox;
  64371. private _isReady;
  64372. /**
  64373. * Creates a PCS (Points Cloud System) object
  64374. * @param name (String) is the PCS name, this will be the underlying mesh name
  64375. * @param pointSize (number) is the size for each point
  64376. * @param scene (Scene) is the scene in which the PCS is added
  64377. * @param options defines the options of the PCS e.g.
  64378. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  64379. */
  64380. constructor(name: string, pointSize: number, scene: Scene, options?: {
  64381. updatable?: boolean;
  64382. });
  64383. /**
  64384. * Builds the PCS underlying mesh. Returns a standard Mesh.
  64385. * If no points were added to the PCS, the returned mesh is just a single point.
  64386. * @returns a promise for the created mesh
  64387. */
  64388. buildMeshAsync(): Promise<Mesh>;
  64389. /**
  64390. * @hidden
  64391. */
  64392. private _buildMesh;
  64393. private _addParticle;
  64394. private _randomUnitVector;
  64395. private _getColorIndicesForCoord;
  64396. private _setPointsColorOrUV;
  64397. private _colorFromTexture;
  64398. private _calculateDensity;
  64399. /**
  64400. * Adds points to the PCS in random positions within a unit sphere
  64401. * @param nb (positive integer) the number of particles to be created from this model
  64402. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  64403. * @returns the number of groups in the system
  64404. */
  64405. addPoints(nb: number, pointFunction?: any): number;
  64406. /**
  64407. * Adds points to the PCS from the surface of the model shape
  64408. * @param mesh is any Mesh object that will be used as a surface model for the points
  64409. * @param nb (positive integer) the number of particles to be created from this model
  64410. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  64411. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  64412. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  64413. * @returns the number of groups in the system
  64414. */
  64415. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  64416. /**
  64417. * Adds points to the PCS inside the model shape
  64418. * @param mesh is any Mesh object that will be used as a surface model for the points
  64419. * @param nb (positive integer) the number of particles to be created from this model
  64420. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  64421. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  64422. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  64423. * @returns the number of groups in the system
  64424. */
  64425. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  64426. /**
  64427. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  64428. * This method calls `updateParticle()` for each particle of the SPS.
  64429. * For an animated SPS, it is usually called within the render loop.
  64430. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  64431. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  64432. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  64433. * @returns the PCS.
  64434. */
  64435. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  64436. /**
  64437. * Disposes the PCS.
  64438. */
  64439. dispose(): void;
  64440. /**
  64441. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  64442. * doc :
  64443. * @returns the PCS.
  64444. */
  64445. refreshVisibleSize(): PointsCloudSystem;
  64446. /**
  64447. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  64448. * @param size the size (float) of the visibility box
  64449. * note : this doesn't lock the PCS mesh bounding box.
  64450. * doc :
  64451. */
  64452. setVisibilityBox(size: number): void;
  64453. /**
  64454. * Gets whether the PCS is always visible or not
  64455. * doc :
  64456. */
  64457. get isAlwaysVisible(): boolean;
  64458. /**
  64459. * Sets the PCS as always visible or not
  64460. * doc :
  64461. */
  64462. set isAlwaysVisible(val: boolean);
  64463. /**
  64464. * Tells to `setParticles()` to compute the particle rotations or not
  64465. * Default value : false. The PCS is faster when it's set to false
  64466. * Note : particle rotations are only applied to parent particles
  64467. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  64468. */
  64469. set computeParticleRotation(val: boolean);
  64470. /**
  64471. * Tells to `setParticles()` to compute the particle colors or not.
  64472. * Default value : true. The PCS is faster when it's set to false.
  64473. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  64474. */
  64475. set computeParticleColor(val: boolean);
  64476. set computeParticleTexture(val: boolean);
  64477. /**
  64478. * Gets if `setParticles()` computes the particle colors or not.
  64479. * Default value : false. The PCS is faster when it's set to false.
  64480. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  64481. */
  64482. get computeParticleColor(): boolean;
  64483. /**
  64484. * Gets if `setParticles()` computes the particle textures or not.
  64485. * Default value : false. The PCS is faster when it's set to false.
  64486. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  64487. */
  64488. get computeParticleTexture(): boolean;
  64489. /**
  64490. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  64491. */
  64492. set computeBoundingBox(val: boolean);
  64493. /**
  64494. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  64495. */
  64496. get computeBoundingBox(): boolean;
  64497. /**
  64498. * This function does nothing. It may be overwritten to set all the particle first values.
  64499. * The PCS doesn't call this function, you may have to call it by your own.
  64500. * doc :
  64501. */
  64502. initParticles(): void;
  64503. /**
  64504. * This function does nothing. It may be overwritten to recycle a particle
  64505. * The PCS doesn't call this function, you can to call it
  64506. * doc :
  64507. * @param particle The particle to recycle
  64508. * @returns the recycled particle
  64509. */
  64510. recycleParticle(particle: CloudPoint): CloudPoint;
  64511. /**
  64512. * Updates a particle : this function should be overwritten by the user.
  64513. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  64514. * doc :
  64515. * @example : just set a particle position or velocity and recycle conditions
  64516. * @param particle The particle to update
  64517. * @returns the updated particle
  64518. */
  64519. updateParticle(particle: CloudPoint): CloudPoint;
  64520. /**
  64521. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  64522. * This does nothing and may be overwritten by the user.
  64523. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  64524. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  64525. * @param update the boolean update value actually passed to setParticles()
  64526. */
  64527. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  64528. /**
  64529. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  64530. * This will be passed three parameters.
  64531. * This does nothing and may be overwritten by the user.
  64532. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  64533. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  64534. * @param update the boolean update value actually passed to setParticles()
  64535. */
  64536. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  64537. }
  64538. }
  64539. declare module "babylonjs/Particles/cloudPoint" {
  64540. import { Nullable } from "babylonjs/types";
  64541. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  64542. import { Mesh } from "babylonjs/Meshes/mesh";
  64543. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  64544. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  64545. /**
  64546. * Represents one particle of a points cloud system.
  64547. */
  64548. export class CloudPoint {
  64549. /**
  64550. * particle global index
  64551. */
  64552. idx: number;
  64553. /**
  64554. * The color of the particle
  64555. */
  64556. color: Nullable<Color4>;
  64557. /**
  64558. * The world space position of the particle.
  64559. */
  64560. position: Vector3;
  64561. /**
  64562. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  64563. */
  64564. rotation: Vector3;
  64565. /**
  64566. * The world space rotation quaternion of the particle.
  64567. */
  64568. rotationQuaternion: Nullable<Quaternion>;
  64569. /**
  64570. * The uv of the particle.
  64571. */
  64572. uv: Nullable<Vector2>;
  64573. /**
  64574. * The current speed of the particle.
  64575. */
  64576. velocity: Vector3;
  64577. /**
  64578. * The pivot point in the particle local space.
  64579. */
  64580. pivot: Vector3;
  64581. /**
  64582. * Must the particle be translated from its pivot point in its local space ?
  64583. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  64584. * Default : false
  64585. */
  64586. translateFromPivot: boolean;
  64587. /**
  64588. * Index of this particle in the global "positions" array (Internal use)
  64589. * @hidden
  64590. */
  64591. _pos: number;
  64592. /**
  64593. * @hidden Index of this particle in the global "indices" array (Internal use)
  64594. */
  64595. _ind: number;
  64596. /**
  64597. * Group this particle belongs to
  64598. */
  64599. _group: PointsGroup;
  64600. /**
  64601. * Group id of this particle
  64602. */
  64603. groupId: number;
  64604. /**
  64605. * Index of the particle in its group id (Internal use)
  64606. */
  64607. idxInGroup: number;
  64608. /**
  64609. * @hidden Particle BoundingInfo object (Internal use)
  64610. */
  64611. _boundingInfo: BoundingInfo;
  64612. /**
  64613. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  64614. */
  64615. _pcs: PointsCloudSystem;
  64616. /**
  64617. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  64618. */
  64619. _stillInvisible: boolean;
  64620. /**
  64621. * @hidden Last computed particle rotation matrix
  64622. */
  64623. _rotationMatrix: number[];
  64624. /**
  64625. * Parent particle Id, if any.
  64626. * Default null.
  64627. */
  64628. parentId: Nullable<number>;
  64629. /**
  64630. * @hidden Internal global position in the PCS.
  64631. */
  64632. _globalPosition: Vector3;
  64633. /**
  64634. * Creates a Point Cloud object.
  64635. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  64636. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  64637. * @param group (PointsGroup) is the group the particle belongs to
  64638. * @param groupId (integer) is the group identifier in the PCS.
  64639. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  64640. * @param pcs defines the PCS it is associated to
  64641. */
  64642. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  64643. /**
  64644. * get point size
  64645. */
  64646. get size(): Vector3;
  64647. /**
  64648. * Set point size
  64649. */
  64650. set size(scale: Vector3);
  64651. /**
  64652. * Legacy support, changed quaternion to rotationQuaternion
  64653. */
  64654. get quaternion(): Nullable<Quaternion>;
  64655. /**
  64656. * Legacy support, changed quaternion to rotationQuaternion
  64657. */
  64658. set quaternion(q: Nullable<Quaternion>);
  64659. /**
  64660. * Returns a boolean. True if the particle intersects a mesh, else false
  64661. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  64662. * @param target is the object (point or mesh) what the intersection is computed against
  64663. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  64664. * @returns true if it intersects
  64665. */
  64666. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  64667. /**
  64668. * get the rotation matrix of the particle
  64669. * @hidden
  64670. */
  64671. getRotationMatrix(m: Matrix): void;
  64672. }
  64673. /**
  64674. * Represents a group of points in a points cloud system
  64675. * * PCS internal tool, don't use it manually.
  64676. */
  64677. export class PointsGroup {
  64678. /**
  64679. * The group id
  64680. * @hidden
  64681. */
  64682. groupID: number;
  64683. /**
  64684. * image data for group (internal use)
  64685. * @hidden
  64686. */
  64687. _groupImageData: Nullable<ArrayBufferView>;
  64688. /**
  64689. * Image Width (internal use)
  64690. * @hidden
  64691. */
  64692. _groupImgWidth: number;
  64693. /**
  64694. * Image Height (internal use)
  64695. * @hidden
  64696. */
  64697. _groupImgHeight: number;
  64698. /**
  64699. * Custom position function (internal use)
  64700. * @hidden
  64701. */
  64702. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  64703. /**
  64704. * density per facet for surface points
  64705. * @hidden
  64706. */
  64707. _groupDensity: number[];
  64708. /**
  64709. * Only when points are colored by texture carries pointer to texture list array
  64710. * @hidden
  64711. */
  64712. _textureNb: number;
  64713. /**
  64714. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  64715. * PCS internal tool, don't use it manually.
  64716. * @hidden
  64717. */
  64718. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  64719. }
  64720. }
  64721. declare module "babylonjs/Particles/index" {
  64722. export * from "babylonjs/Particles/baseParticleSystem";
  64723. export * from "babylonjs/Particles/EmitterTypes/index";
  64724. export * from "babylonjs/Particles/gpuParticleSystem";
  64725. export * from "babylonjs/Particles/IParticleSystem";
  64726. export * from "babylonjs/Particles/particle";
  64727. export * from "babylonjs/Particles/particleHelper";
  64728. export * from "babylonjs/Particles/particleSystem";
  64729. export * from "babylonjs/Particles/particleSystemComponent";
  64730. export * from "babylonjs/Particles/particleSystemSet";
  64731. export * from "babylonjs/Particles/solidParticle";
  64732. export * from "babylonjs/Particles/solidParticleSystem";
  64733. export * from "babylonjs/Particles/cloudPoint";
  64734. export * from "babylonjs/Particles/pointsCloudSystem";
  64735. export * from "babylonjs/Particles/subEmitter";
  64736. }
  64737. declare module "babylonjs/Physics/physicsEngineComponent" {
  64738. import { Nullable } from "babylonjs/types";
  64739. import { Observable, Observer } from "babylonjs/Misc/observable";
  64740. import { Vector3 } from "babylonjs/Maths/math.vector";
  64741. import { Mesh } from "babylonjs/Meshes/mesh";
  64742. import { ISceneComponent } from "babylonjs/sceneComponent";
  64743. import { Scene } from "babylonjs/scene";
  64744. import { Node } from "babylonjs/node";
  64745. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  64746. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64747. module "babylonjs/scene" {
  64748. interface Scene {
  64749. /** @hidden (Backing field) */
  64750. _physicsEngine: Nullable<IPhysicsEngine>;
  64751. /** @hidden */
  64752. _physicsTimeAccumulator: number;
  64753. /**
  64754. * Gets the current physics engine
  64755. * @returns a IPhysicsEngine or null if none attached
  64756. */
  64757. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  64758. /**
  64759. * Enables physics to the current scene
  64760. * @param gravity defines the scene's gravity for the physics engine
  64761. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  64762. * @return a boolean indicating if the physics engine was initialized
  64763. */
  64764. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  64765. /**
  64766. * Disables and disposes the physics engine associated with the scene
  64767. */
  64768. disablePhysicsEngine(): void;
  64769. /**
  64770. * Gets a boolean indicating if there is an active physics engine
  64771. * @returns a boolean indicating if there is an active physics engine
  64772. */
  64773. isPhysicsEnabled(): boolean;
  64774. /**
  64775. * Deletes a physics compound impostor
  64776. * @param compound defines the compound to delete
  64777. */
  64778. deleteCompoundImpostor(compound: any): void;
  64779. /**
  64780. * An event triggered when physic simulation is about to be run
  64781. */
  64782. onBeforePhysicsObservable: Observable<Scene>;
  64783. /**
  64784. * An event triggered when physic simulation has been done
  64785. */
  64786. onAfterPhysicsObservable: Observable<Scene>;
  64787. }
  64788. }
  64789. module "babylonjs/Meshes/abstractMesh" {
  64790. interface AbstractMesh {
  64791. /** @hidden */
  64792. _physicsImpostor: Nullable<PhysicsImpostor>;
  64793. /**
  64794. * Gets or sets impostor used for physic simulation
  64795. * @see http://doc.babylonjs.com/features/physics_engine
  64796. */
  64797. physicsImpostor: Nullable<PhysicsImpostor>;
  64798. /**
  64799. * Gets the current physics impostor
  64800. * @see http://doc.babylonjs.com/features/physics_engine
  64801. * @returns a physics impostor or null
  64802. */
  64803. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  64804. /** Apply a physic impulse to the mesh
  64805. * @param force defines the force to apply
  64806. * @param contactPoint defines where to apply the force
  64807. * @returns the current mesh
  64808. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  64809. */
  64810. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  64811. /**
  64812. * Creates a physic joint between two meshes
  64813. * @param otherMesh defines the other mesh to use
  64814. * @param pivot1 defines the pivot to use on this mesh
  64815. * @param pivot2 defines the pivot to use on the other mesh
  64816. * @param options defines additional options (can be plugin dependent)
  64817. * @returns the current mesh
  64818. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  64819. */
  64820. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  64821. /** @hidden */
  64822. _disposePhysicsObserver: Nullable<Observer<Node>>;
  64823. }
  64824. }
  64825. /**
  64826. * Defines the physics engine scene component responsible to manage a physics engine
  64827. */
  64828. export class PhysicsEngineSceneComponent implements ISceneComponent {
  64829. /**
  64830. * The component name helpful to identify the component in the list of scene components.
  64831. */
  64832. readonly name: string;
  64833. /**
  64834. * The scene the component belongs to.
  64835. */
  64836. scene: Scene;
  64837. /**
  64838. * Creates a new instance of the component for the given scene
  64839. * @param scene Defines the scene to register the component in
  64840. */
  64841. constructor(scene: Scene);
  64842. /**
  64843. * Registers the component in a given scene
  64844. */
  64845. register(): void;
  64846. /**
  64847. * Rebuilds the elements related to this component in case of
  64848. * context lost for instance.
  64849. */
  64850. rebuild(): void;
  64851. /**
  64852. * Disposes the component and the associated ressources
  64853. */
  64854. dispose(): void;
  64855. }
  64856. }
  64857. declare module "babylonjs/Physics/physicsHelper" {
  64858. import { Nullable } from "babylonjs/types";
  64859. import { Vector3 } from "babylonjs/Maths/math.vector";
  64860. import { Mesh } from "babylonjs/Meshes/mesh";
  64861. import { Scene } from "babylonjs/scene";
  64862. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64863. /**
  64864. * A helper for physics simulations
  64865. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64866. */
  64867. export class PhysicsHelper {
  64868. private _scene;
  64869. private _physicsEngine;
  64870. /**
  64871. * Initializes the Physics helper
  64872. * @param scene Babylon.js scene
  64873. */
  64874. constructor(scene: Scene);
  64875. /**
  64876. * Applies a radial explosion impulse
  64877. * @param origin the origin of the explosion
  64878. * @param radiusOrEventOptions the radius or the options of radial explosion
  64879. * @param strength the explosion strength
  64880. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64881. * @returns A physics radial explosion event, or null
  64882. */
  64883. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64884. /**
  64885. * Applies a radial explosion force
  64886. * @param origin the origin of the explosion
  64887. * @param radiusOrEventOptions the radius or the options of radial explosion
  64888. * @param strength the explosion strength
  64889. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64890. * @returns A physics radial explosion event, or null
  64891. */
  64892. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64893. /**
  64894. * Creates a gravitational field
  64895. * @param origin the origin of the explosion
  64896. * @param radiusOrEventOptions the radius or the options of radial explosion
  64897. * @param strength the explosion strength
  64898. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64899. * @returns A physics gravitational field event, or null
  64900. */
  64901. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  64902. /**
  64903. * Creates a physics updraft event
  64904. * @param origin the origin of the updraft
  64905. * @param radiusOrEventOptions the radius or the options of the updraft
  64906. * @param strength the strength of the updraft
  64907. * @param height the height of the updraft
  64908. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  64909. * @returns A physics updraft event, or null
  64910. */
  64911. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  64912. /**
  64913. * Creates a physics vortex event
  64914. * @param origin the of the vortex
  64915. * @param radiusOrEventOptions the radius or the options of the vortex
  64916. * @param strength the strength of the vortex
  64917. * @param height the height of the vortex
  64918. * @returns a Physics vortex event, or null
  64919. * A physics vortex event or null
  64920. */
  64921. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  64922. }
  64923. /**
  64924. * Represents a physics radial explosion event
  64925. */
  64926. class PhysicsRadialExplosionEvent {
  64927. private _scene;
  64928. private _options;
  64929. private _sphere;
  64930. private _dataFetched;
  64931. /**
  64932. * Initializes a radial explosioin event
  64933. * @param _scene BabylonJS scene
  64934. * @param _options The options for the vortex event
  64935. */
  64936. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  64937. /**
  64938. * Returns the data related to the radial explosion event (sphere).
  64939. * @returns The radial explosion event data
  64940. */
  64941. getData(): PhysicsRadialExplosionEventData;
  64942. /**
  64943. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  64944. * @param impostor A physics imposter
  64945. * @param origin the origin of the explosion
  64946. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  64947. */
  64948. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  64949. /**
  64950. * Triggers affecterd impostors callbacks
  64951. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  64952. */
  64953. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  64954. /**
  64955. * Disposes the sphere.
  64956. * @param force Specifies if the sphere should be disposed by force
  64957. */
  64958. dispose(force?: boolean): void;
  64959. /*** Helpers ***/
  64960. private _prepareSphere;
  64961. private _intersectsWithSphere;
  64962. }
  64963. /**
  64964. * Represents a gravitational field event
  64965. */
  64966. class PhysicsGravitationalFieldEvent {
  64967. private _physicsHelper;
  64968. private _scene;
  64969. private _origin;
  64970. private _options;
  64971. private _tickCallback;
  64972. private _sphere;
  64973. private _dataFetched;
  64974. /**
  64975. * Initializes the physics gravitational field event
  64976. * @param _physicsHelper A physics helper
  64977. * @param _scene BabylonJS scene
  64978. * @param _origin The origin position of the gravitational field event
  64979. * @param _options The options for the vortex event
  64980. */
  64981. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  64982. /**
  64983. * Returns the data related to the gravitational field event (sphere).
  64984. * @returns A gravitational field event
  64985. */
  64986. getData(): PhysicsGravitationalFieldEventData;
  64987. /**
  64988. * Enables the gravitational field.
  64989. */
  64990. enable(): void;
  64991. /**
  64992. * Disables the gravitational field.
  64993. */
  64994. disable(): void;
  64995. /**
  64996. * Disposes the sphere.
  64997. * @param force The force to dispose from the gravitational field event
  64998. */
  64999. dispose(force?: boolean): void;
  65000. private _tick;
  65001. }
  65002. /**
  65003. * Represents a physics updraft event
  65004. */
  65005. class PhysicsUpdraftEvent {
  65006. private _scene;
  65007. private _origin;
  65008. private _options;
  65009. private _physicsEngine;
  65010. private _originTop;
  65011. private _originDirection;
  65012. private _tickCallback;
  65013. private _cylinder;
  65014. private _cylinderPosition;
  65015. private _dataFetched;
  65016. /**
  65017. * Initializes the physics updraft event
  65018. * @param _scene BabylonJS scene
  65019. * @param _origin The origin position of the updraft
  65020. * @param _options The options for the updraft event
  65021. */
  65022. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  65023. /**
  65024. * Returns the data related to the updraft event (cylinder).
  65025. * @returns A physics updraft event
  65026. */
  65027. getData(): PhysicsUpdraftEventData;
  65028. /**
  65029. * Enables the updraft.
  65030. */
  65031. enable(): void;
  65032. /**
  65033. * Disables the updraft.
  65034. */
  65035. disable(): void;
  65036. /**
  65037. * Disposes the cylinder.
  65038. * @param force Specifies if the updraft should be disposed by force
  65039. */
  65040. dispose(force?: boolean): void;
  65041. private getImpostorHitData;
  65042. private _tick;
  65043. /*** Helpers ***/
  65044. private _prepareCylinder;
  65045. private _intersectsWithCylinder;
  65046. }
  65047. /**
  65048. * Represents a physics vortex event
  65049. */
  65050. class PhysicsVortexEvent {
  65051. private _scene;
  65052. private _origin;
  65053. private _options;
  65054. private _physicsEngine;
  65055. private _originTop;
  65056. private _tickCallback;
  65057. private _cylinder;
  65058. private _cylinderPosition;
  65059. private _dataFetched;
  65060. /**
  65061. * Initializes the physics vortex event
  65062. * @param _scene The BabylonJS scene
  65063. * @param _origin The origin position of the vortex
  65064. * @param _options The options for the vortex event
  65065. */
  65066. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  65067. /**
  65068. * Returns the data related to the vortex event (cylinder).
  65069. * @returns The physics vortex event data
  65070. */
  65071. getData(): PhysicsVortexEventData;
  65072. /**
  65073. * Enables the vortex.
  65074. */
  65075. enable(): void;
  65076. /**
  65077. * Disables the cortex.
  65078. */
  65079. disable(): void;
  65080. /**
  65081. * Disposes the sphere.
  65082. * @param force
  65083. */
  65084. dispose(force?: boolean): void;
  65085. private getImpostorHitData;
  65086. private _tick;
  65087. /*** Helpers ***/
  65088. private _prepareCylinder;
  65089. private _intersectsWithCylinder;
  65090. }
  65091. /**
  65092. * Options fot the radial explosion event
  65093. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65094. */
  65095. export class PhysicsRadialExplosionEventOptions {
  65096. /**
  65097. * The radius of the sphere for the radial explosion.
  65098. */
  65099. radius: number;
  65100. /**
  65101. * The strenth of the explosion.
  65102. */
  65103. strength: number;
  65104. /**
  65105. * The strenght of the force in correspondence to the distance of the affected object
  65106. */
  65107. falloff: PhysicsRadialImpulseFalloff;
  65108. /**
  65109. * Sphere options for the radial explosion.
  65110. */
  65111. sphere: {
  65112. segments: number;
  65113. diameter: number;
  65114. };
  65115. /**
  65116. * Sphere options for the radial explosion.
  65117. */
  65118. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  65119. }
  65120. /**
  65121. * Options fot the updraft event
  65122. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65123. */
  65124. export class PhysicsUpdraftEventOptions {
  65125. /**
  65126. * The radius of the cylinder for the vortex
  65127. */
  65128. radius: number;
  65129. /**
  65130. * The strenth of the updraft.
  65131. */
  65132. strength: number;
  65133. /**
  65134. * The height of the cylinder for the updraft.
  65135. */
  65136. height: number;
  65137. /**
  65138. * The mode for the the updraft.
  65139. */
  65140. updraftMode: PhysicsUpdraftMode;
  65141. }
  65142. /**
  65143. * Options fot the vortex event
  65144. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65145. */
  65146. export class PhysicsVortexEventOptions {
  65147. /**
  65148. * The radius of the cylinder for the vortex
  65149. */
  65150. radius: number;
  65151. /**
  65152. * The strenth of the vortex.
  65153. */
  65154. strength: number;
  65155. /**
  65156. * The height of the cylinder for the vortex.
  65157. */
  65158. height: number;
  65159. /**
  65160. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  65161. */
  65162. centripetalForceThreshold: number;
  65163. /**
  65164. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  65165. */
  65166. centripetalForceMultiplier: number;
  65167. /**
  65168. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  65169. */
  65170. centrifugalForceMultiplier: number;
  65171. /**
  65172. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  65173. */
  65174. updraftForceMultiplier: number;
  65175. }
  65176. /**
  65177. * The strenght of the force in correspondence to the distance of the affected object
  65178. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65179. */
  65180. export enum PhysicsRadialImpulseFalloff {
  65181. /** Defines that impulse is constant in strength across it's whole radius */
  65182. Constant = 0,
  65183. /** Defines that impulse gets weaker if it's further from the origin */
  65184. Linear = 1
  65185. }
  65186. /**
  65187. * The strength of the force in correspondence to the distance of the affected object
  65188. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65189. */
  65190. export enum PhysicsUpdraftMode {
  65191. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  65192. Center = 0,
  65193. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  65194. Perpendicular = 1
  65195. }
  65196. /**
  65197. * Interface for a physics hit data
  65198. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65199. */
  65200. export interface PhysicsHitData {
  65201. /**
  65202. * The force applied at the contact point
  65203. */
  65204. force: Vector3;
  65205. /**
  65206. * The contact point
  65207. */
  65208. contactPoint: Vector3;
  65209. /**
  65210. * The distance from the origin to the contact point
  65211. */
  65212. distanceFromOrigin: number;
  65213. }
  65214. /**
  65215. * Interface for radial explosion event data
  65216. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65217. */
  65218. export interface PhysicsRadialExplosionEventData {
  65219. /**
  65220. * A sphere used for the radial explosion event
  65221. */
  65222. sphere: Mesh;
  65223. }
  65224. /**
  65225. * Interface for gravitational field event data
  65226. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65227. */
  65228. export interface PhysicsGravitationalFieldEventData {
  65229. /**
  65230. * A sphere mesh used for the gravitational field event
  65231. */
  65232. sphere: Mesh;
  65233. }
  65234. /**
  65235. * Interface for updraft event data
  65236. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65237. */
  65238. export interface PhysicsUpdraftEventData {
  65239. /**
  65240. * A cylinder used for the updraft event
  65241. */
  65242. cylinder: Mesh;
  65243. }
  65244. /**
  65245. * Interface for vortex event data
  65246. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65247. */
  65248. export interface PhysicsVortexEventData {
  65249. /**
  65250. * A cylinder used for the vortex event
  65251. */
  65252. cylinder: Mesh;
  65253. }
  65254. /**
  65255. * Interface for an affected physics impostor
  65256. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65257. */
  65258. export interface PhysicsAffectedImpostorWithData {
  65259. /**
  65260. * The impostor affected by the effect
  65261. */
  65262. impostor: PhysicsImpostor;
  65263. /**
  65264. * The data about the hit/horce from the explosion
  65265. */
  65266. hitData: PhysicsHitData;
  65267. }
  65268. }
  65269. declare module "babylonjs/Physics/Plugins/index" {
  65270. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  65271. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  65272. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  65273. }
  65274. declare module "babylonjs/Physics/index" {
  65275. export * from "babylonjs/Physics/IPhysicsEngine";
  65276. export * from "babylonjs/Physics/physicsEngine";
  65277. export * from "babylonjs/Physics/physicsEngineComponent";
  65278. export * from "babylonjs/Physics/physicsHelper";
  65279. export * from "babylonjs/Physics/physicsImpostor";
  65280. export * from "babylonjs/Physics/physicsJoint";
  65281. export * from "babylonjs/Physics/Plugins/index";
  65282. }
  65283. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  65284. /** @hidden */
  65285. export var blackAndWhitePixelShader: {
  65286. name: string;
  65287. shader: string;
  65288. };
  65289. }
  65290. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  65291. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65292. import { Camera } from "babylonjs/Cameras/camera";
  65293. import { Engine } from "babylonjs/Engines/engine";
  65294. import "babylonjs/Shaders/blackAndWhite.fragment";
  65295. /**
  65296. * Post process used to render in black and white
  65297. */
  65298. export class BlackAndWhitePostProcess extends PostProcess {
  65299. /**
  65300. * Linear about to convert he result to black and white (default: 1)
  65301. */
  65302. degree: number;
  65303. /**
  65304. * Creates a black and white post process
  65305. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  65306. * @param name The name of the effect.
  65307. * @param options The required width/height ratio to downsize to before computing the render pass.
  65308. * @param camera The camera to apply the render pass to.
  65309. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65310. * @param engine The engine which the post process will be applied. (default: current engine)
  65311. * @param reusable If the post process can be reused on the same frame. (default: false)
  65312. */
  65313. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65314. }
  65315. }
  65316. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  65317. import { Nullable } from "babylonjs/types";
  65318. import { Camera } from "babylonjs/Cameras/camera";
  65319. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65320. import { Engine } from "babylonjs/Engines/engine";
  65321. /**
  65322. * This represents a set of one or more post processes in Babylon.
  65323. * A post process can be used to apply a shader to a texture after it is rendered.
  65324. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65325. */
  65326. export class PostProcessRenderEffect {
  65327. private _postProcesses;
  65328. private _getPostProcesses;
  65329. private _singleInstance;
  65330. private _cameras;
  65331. private _indicesForCamera;
  65332. /**
  65333. * Name of the effect
  65334. * @hidden
  65335. */
  65336. _name: string;
  65337. /**
  65338. * Instantiates a post process render effect.
  65339. * A post process can be used to apply a shader to a texture after it is rendered.
  65340. * @param engine The engine the effect is tied to
  65341. * @param name The name of the effect
  65342. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  65343. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  65344. */
  65345. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  65346. /**
  65347. * Checks if all the post processes in the effect are supported.
  65348. */
  65349. get isSupported(): boolean;
  65350. /**
  65351. * Updates the current state of the effect
  65352. * @hidden
  65353. */
  65354. _update(): void;
  65355. /**
  65356. * Attaches the effect on cameras
  65357. * @param cameras The camera to attach to.
  65358. * @hidden
  65359. */
  65360. _attachCameras(cameras: Camera): void;
  65361. /**
  65362. * Attaches the effect on cameras
  65363. * @param cameras The camera to attach to.
  65364. * @hidden
  65365. */
  65366. _attachCameras(cameras: Camera[]): void;
  65367. /**
  65368. * Detaches the effect on cameras
  65369. * @param cameras The camera to detatch from.
  65370. * @hidden
  65371. */
  65372. _detachCameras(cameras: Camera): void;
  65373. /**
  65374. * Detatches the effect on cameras
  65375. * @param cameras The camera to detatch from.
  65376. * @hidden
  65377. */
  65378. _detachCameras(cameras: Camera[]): void;
  65379. /**
  65380. * Enables the effect on given cameras
  65381. * @param cameras The camera to enable.
  65382. * @hidden
  65383. */
  65384. _enable(cameras: Camera): void;
  65385. /**
  65386. * Enables the effect on given cameras
  65387. * @param cameras The camera to enable.
  65388. * @hidden
  65389. */
  65390. _enable(cameras: Nullable<Camera[]>): void;
  65391. /**
  65392. * Disables the effect on the given cameras
  65393. * @param cameras The camera to disable.
  65394. * @hidden
  65395. */
  65396. _disable(cameras: Camera): void;
  65397. /**
  65398. * Disables the effect on the given cameras
  65399. * @param cameras The camera to disable.
  65400. * @hidden
  65401. */
  65402. _disable(cameras: Nullable<Camera[]>): void;
  65403. /**
  65404. * Gets a list of the post processes contained in the effect.
  65405. * @param camera The camera to get the post processes on.
  65406. * @returns The list of the post processes in the effect.
  65407. */
  65408. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  65409. }
  65410. }
  65411. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  65412. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65413. /** @hidden */
  65414. export var extractHighlightsPixelShader: {
  65415. name: string;
  65416. shader: string;
  65417. };
  65418. }
  65419. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  65420. import { Nullable } from "babylonjs/types";
  65421. import { Camera } from "babylonjs/Cameras/camera";
  65422. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65423. import { Engine } from "babylonjs/Engines/engine";
  65424. import "babylonjs/Shaders/extractHighlights.fragment";
  65425. /**
  65426. * 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.
  65427. */
  65428. export class ExtractHighlightsPostProcess extends PostProcess {
  65429. /**
  65430. * The luminance threshold, pixels below this value will be set to black.
  65431. */
  65432. threshold: number;
  65433. /** @hidden */
  65434. _exposure: number;
  65435. /**
  65436. * Post process which has the input texture to be used when performing highlight extraction
  65437. * @hidden
  65438. */
  65439. _inputPostProcess: Nullable<PostProcess>;
  65440. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65441. }
  65442. }
  65443. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  65444. /** @hidden */
  65445. export var bloomMergePixelShader: {
  65446. name: string;
  65447. shader: string;
  65448. };
  65449. }
  65450. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  65451. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65452. import { Nullable } from "babylonjs/types";
  65453. import { Engine } from "babylonjs/Engines/engine";
  65454. import { Camera } from "babylonjs/Cameras/camera";
  65455. import "babylonjs/Shaders/bloomMerge.fragment";
  65456. /**
  65457. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  65458. */
  65459. export class BloomMergePostProcess extends PostProcess {
  65460. /** Weight of the bloom to be added to the original input. */
  65461. weight: number;
  65462. /**
  65463. * Creates a new instance of @see BloomMergePostProcess
  65464. * @param name The name of the effect.
  65465. * @param originalFromInput Post process which's input will be used for the merge.
  65466. * @param blurred Blurred highlights post process which's output will be used.
  65467. * @param weight Weight of the bloom to be added to the original input.
  65468. * @param options The required width/height ratio to downsize to before computing the render pass.
  65469. * @param camera The camera to apply the render pass to.
  65470. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65471. * @param engine The engine which the post process will be applied. (default: current engine)
  65472. * @param reusable If the post process can be reused on the same frame. (default: false)
  65473. * @param textureType Type of textures used when performing the post process. (default: 0)
  65474. * @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)
  65475. */
  65476. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  65477. /** Weight of the bloom to be added to the original input. */
  65478. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65479. }
  65480. }
  65481. declare module "babylonjs/PostProcesses/bloomEffect" {
  65482. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65483. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65484. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  65485. import { Camera } from "babylonjs/Cameras/camera";
  65486. import { Scene } from "babylonjs/scene";
  65487. /**
  65488. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  65489. */
  65490. export class BloomEffect extends PostProcessRenderEffect {
  65491. private bloomScale;
  65492. /**
  65493. * @hidden Internal
  65494. */
  65495. _effects: Array<PostProcess>;
  65496. /**
  65497. * @hidden Internal
  65498. */
  65499. _downscale: ExtractHighlightsPostProcess;
  65500. private _blurX;
  65501. private _blurY;
  65502. private _merge;
  65503. /**
  65504. * The luminance threshold to find bright areas of the image to bloom.
  65505. */
  65506. get threshold(): number;
  65507. set threshold(value: number);
  65508. /**
  65509. * The strength of the bloom.
  65510. */
  65511. get weight(): number;
  65512. set weight(value: number);
  65513. /**
  65514. * Specifies the size of the bloom blur kernel, relative to the final output size
  65515. */
  65516. get kernel(): number;
  65517. set kernel(value: number);
  65518. /**
  65519. * Creates a new instance of @see BloomEffect
  65520. * @param scene The scene the effect belongs to.
  65521. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  65522. * @param bloomKernel The size of the kernel to be used when applying the blur.
  65523. * @param bloomWeight The the strength of bloom.
  65524. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65525. * @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)
  65526. */
  65527. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  65528. /**
  65529. * Disposes each of the internal effects for a given camera.
  65530. * @param camera The camera to dispose the effect on.
  65531. */
  65532. disposeEffects(camera: Camera): void;
  65533. /**
  65534. * @hidden Internal
  65535. */
  65536. _updateEffects(): void;
  65537. /**
  65538. * Internal
  65539. * @returns if all the contained post processes are ready.
  65540. * @hidden
  65541. */
  65542. _isReady(): boolean;
  65543. }
  65544. }
  65545. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  65546. /** @hidden */
  65547. export var chromaticAberrationPixelShader: {
  65548. name: string;
  65549. shader: string;
  65550. };
  65551. }
  65552. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  65553. import { Vector2 } from "babylonjs/Maths/math.vector";
  65554. import { Nullable } from "babylonjs/types";
  65555. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65556. import { Camera } from "babylonjs/Cameras/camera";
  65557. import { Engine } from "babylonjs/Engines/engine";
  65558. import "babylonjs/Shaders/chromaticAberration.fragment";
  65559. /**
  65560. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  65561. */
  65562. export class ChromaticAberrationPostProcess extends PostProcess {
  65563. /**
  65564. * The amount of seperation of rgb channels (default: 30)
  65565. */
  65566. aberrationAmount: number;
  65567. /**
  65568. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  65569. */
  65570. radialIntensity: number;
  65571. /**
  65572. * 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))
  65573. */
  65574. direction: Vector2;
  65575. /**
  65576. * 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))
  65577. */
  65578. centerPosition: Vector2;
  65579. /**
  65580. * Creates a new instance ChromaticAberrationPostProcess
  65581. * @param name The name of the effect.
  65582. * @param screenWidth The width of the screen to apply the effect on.
  65583. * @param screenHeight The height of the screen to apply the effect on.
  65584. * @param options The required width/height ratio to downsize to before computing the render pass.
  65585. * @param camera The camera to apply the render pass to.
  65586. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65587. * @param engine The engine which the post process will be applied. (default: current engine)
  65588. * @param reusable If the post process can be reused on the same frame. (default: false)
  65589. * @param textureType Type of textures used when performing the post process. (default: 0)
  65590. * @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)
  65591. */
  65592. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65593. }
  65594. }
  65595. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  65596. /** @hidden */
  65597. export var circleOfConfusionPixelShader: {
  65598. name: string;
  65599. shader: string;
  65600. };
  65601. }
  65602. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  65603. import { Nullable } from "babylonjs/types";
  65604. import { Engine } from "babylonjs/Engines/engine";
  65605. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65606. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65607. import { Camera } from "babylonjs/Cameras/camera";
  65608. import "babylonjs/Shaders/circleOfConfusion.fragment";
  65609. /**
  65610. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  65611. */
  65612. export class CircleOfConfusionPostProcess extends PostProcess {
  65613. /**
  65614. * 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.
  65615. */
  65616. lensSize: number;
  65617. /**
  65618. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65619. */
  65620. fStop: number;
  65621. /**
  65622. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65623. */
  65624. focusDistance: number;
  65625. /**
  65626. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  65627. */
  65628. focalLength: number;
  65629. private _depthTexture;
  65630. /**
  65631. * Creates a new instance CircleOfConfusionPostProcess
  65632. * @param name The name of the effect.
  65633. * @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.
  65634. * @param options The required width/height ratio to downsize to before computing the render pass.
  65635. * @param camera The camera to apply the render pass to.
  65636. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65637. * @param engine The engine which the post process will be applied. (default: current engine)
  65638. * @param reusable If the post process can be reused on the same frame. (default: false)
  65639. * @param textureType Type of textures used when performing the post process. (default: 0)
  65640. * @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)
  65641. */
  65642. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65643. /**
  65644. * 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.
  65645. */
  65646. set depthTexture(value: RenderTargetTexture);
  65647. }
  65648. }
  65649. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  65650. /** @hidden */
  65651. export var colorCorrectionPixelShader: {
  65652. name: string;
  65653. shader: string;
  65654. };
  65655. }
  65656. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  65657. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65658. import { Engine } from "babylonjs/Engines/engine";
  65659. import { Camera } from "babylonjs/Cameras/camera";
  65660. import "babylonjs/Shaders/colorCorrection.fragment";
  65661. /**
  65662. *
  65663. * This post-process allows the modification of rendered colors by using
  65664. * a 'look-up table' (LUT). This effect is also called Color Grading.
  65665. *
  65666. * The object needs to be provided an url to a texture containing the color
  65667. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  65668. * Use an image editing software to tweak the LUT to match your needs.
  65669. *
  65670. * For an example of a color LUT, see here:
  65671. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  65672. * For explanations on color grading, see here:
  65673. * @see http://udn.epicgames.com/Three/ColorGrading.html
  65674. *
  65675. */
  65676. export class ColorCorrectionPostProcess extends PostProcess {
  65677. private _colorTableTexture;
  65678. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65679. }
  65680. }
  65681. declare module "babylonjs/Shaders/convolution.fragment" {
  65682. /** @hidden */
  65683. export var convolutionPixelShader: {
  65684. name: string;
  65685. shader: string;
  65686. };
  65687. }
  65688. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  65689. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65690. import { Nullable } from "babylonjs/types";
  65691. import { Camera } from "babylonjs/Cameras/camera";
  65692. import { Engine } from "babylonjs/Engines/engine";
  65693. import "babylonjs/Shaders/convolution.fragment";
  65694. /**
  65695. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  65696. * input texture to perform effects such as edge detection or sharpening
  65697. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65698. */
  65699. export class ConvolutionPostProcess extends PostProcess {
  65700. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65701. kernel: number[];
  65702. /**
  65703. * Creates a new instance ConvolutionPostProcess
  65704. * @param name The name of the effect.
  65705. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  65706. * @param options The required width/height ratio to downsize to before computing the render pass.
  65707. * @param camera The camera to apply the render pass to.
  65708. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65709. * @param engine The engine which the post process will be applied. (default: current engine)
  65710. * @param reusable If the post process can be reused on the same frame. (default: false)
  65711. * @param textureType Type of textures used when performing the post process. (default: 0)
  65712. */
  65713. constructor(name: string,
  65714. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65715. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65716. /**
  65717. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65718. */
  65719. static EdgeDetect0Kernel: number[];
  65720. /**
  65721. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65722. */
  65723. static EdgeDetect1Kernel: number[];
  65724. /**
  65725. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65726. */
  65727. static EdgeDetect2Kernel: number[];
  65728. /**
  65729. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65730. */
  65731. static SharpenKernel: number[];
  65732. /**
  65733. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65734. */
  65735. static EmbossKernel: number[];
  65736. /**
  65737. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65738. */
  65739. static GaussianKernel: number[];
  65740. }
  65741. }
  65742. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  65743. import { Nullable } from "babylonjs/types";
  65744. import { Vector2 } from "babylonjs/Maths/math.vector";
  65745. import { Camera } from "babylonjs/Cameras/camera";
  65746. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65747. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  65748. import { Engine } from "babylonjs/Engines/engine";
  65749. import { Scene } from "babylonjs/scene";
  65750. /**
  65751. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  65752. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  65753. * based on samples that have a large difference in distance than the center pixel.
  65754. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  65755. */
  65756. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  65757. direction: Vector2;
  65758. /**
  65759. * Creates a new instance CircleOfConfusionPostProcess
  65760. * @param name The name of the effect.
  65761. * @param scene The scene the effect belongs to.
  65762. * @param direction The direction the blur should be applied.
  65763. * @param kernel The size of the kernel used to blur.
  65764. * @param options The required width/height ratio to downsize to before computing the render pass.
  65765. * @param camera The camera to apply the render pass to.
  65766. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  65767. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  65768. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65769. * @param engine The engine which the post process will be applied. (default: current engine)
  65770. * @param reusable If the post process can be reused on the same frame. (default: false)
  65771. * @param textureType Type of textures used when performing the post process. (default: 0)
  65772. * @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)
  65773. */
  65774. 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);
  65775. }
  65776. }
  65777. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  65778. /** @hidden */
  65779. export var depthOfFieldMergePixelShader: {
  65780. name: string;
  65781. shader: string;
  65782. };
  65783. }
  65784. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  65785. import { Nullable } from "babylonjs/types";
  65786. import { Camera } from "babylonjs/Cameras/camera";
  65787. import { Effect } from "babylonjs/Materials/effect";
  65788. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65789. import { Engine } from "babylonjs/Engines/engine";
  65790. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  65791. /**
  65792. * Options to be set when merging outputs from the default pipeline.
  65793. */
  65794. export class DepthOfFieldMergePostProcessOptions {
  65795. /**
  65796. * The original image to merge on top of
  65797. */
  65798. originalFromInput: PostProcess;
  65799. /**
  65800. * Parameters to perform the merge of the depth of field effect
  65801. */
  65802. depthOfField?: {
  65803. circleOfConfusion: PostProcess;
  65804. blurSteps: Array<PostProcess>;
  65805. };
  65806. /**
  65807. * Parameters to perform the merge of bloom effect
  65808. */
  65809. bloom?: {
  65810. blurred: PostProcess;
  65811. weight: number;
  65812. };
  65813. }
  65814. /**
  65815. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  65816. */
  65817. export class DepthOfFieldMergePostProcess extends PostProcess {
  65818. private blurSteps;
  65819. /**
  65820. * Creates a new instance of DepthOfFieldMergePostProcess
  65821. * @param name The name of the effect.
  65822. * @param originalFromInput Post process which's input will be used for the merge.
  65823. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  65824. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  65825. * @param options The required width/height ratio to downsize to before computing the render pass.
  65826. * @param camera The camera to apply the render pass to.
  65827. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65828. * @param engine The engine which the post process will be applied. (default: current engine)
  65829. * @param reusable If the post process can be reused on the same frame. (default: false)
  65830. * @param textureType Type of textures used when performing the post process. (default: 0)
  65831. * @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)
  65832. */
  65833. 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);
  65834. /**
  65835. * Updates the effect with the current post process compile time values and recompiles the shader.
  65836. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  65837. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  65838. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  65839. * @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
  65840. * @param onCompiled Called when the shader has been compiled.
  65841. * @param onError Called if there is an error when compiling a shader.
  65842. */
  65843. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  65844. }
  65845. }
  65846. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  65847. import { Nullable } from "babylonjs/types";
  65848. import { Camera } from "babylonjs/Cameras/camera";
  65849. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65850. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65851. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65852. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  65853. import { Scene } from "babylonjs/scene";
  65854. /**
  65855. * Specifies the level of max blur that should be applied when using the depth of field effect
  65856. */
  65857. export enum DepthOfFieldEffectBlurLevel {
  65858. /**
  65859. * Subtle blur
  65860. */
  65861. Low = 0,
  65862. /**
  65863. * Medium blur
  65864. */
  65865. Medium = 1,
  65866. /**
  65867. * Large blur
  65868. */
  65869. High = 2
  65870. }
  65871. /**
  65872. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  65873. */
  65874. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  65875. private _circleOfConfusion;
  65876. /**
  65877. * @hidden Internal, blurs from high to low
  65878. */
  65879. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  65880. private _depthOfFieldBlurY;
  65881. private _dofMerge;
  65882. /**
  65883. * @hidden Internal post processes in depth of field effect
  65884. */
  65885. _effects: Array<PostProcess>;
  65886. /**
  65887. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  65888. */
  65889. set focalLength(value: number);
  65890. get focalLength(): number;
  65891. /**
  65892. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65893. */
  65894. set fStop(value: number);
  65895. get fStop(): number;
  65896. /**
  65897. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65898. */
  65899. set focusDistance(value: number);
  65900. get focusDistance(): number;
  65901. /**
  65902. * 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.
  65903. */
  65904. set lensSize(value: number);
  65905. get lensSize(): number;
  65906. /**
  65907. * Creates a new instance DepthOfFieldEffect
  65908. * @param scene The scene the effect belongs to.
  65909. * @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.
  65910. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65911. * @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)
  65912. */
  65913. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  65914. /**
  65915. * Get the current class name of the current effet
  65916. * @returns "DepthOfFieldEffect"
  65917. */
  65918. getClassName(): string;
  65919. /**
  65920. * 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.
  65921. */
  65922. set depthTexture(value: RenderTargetTexture);
  65923. /**
  65924. * Disposes each of the internal effects for a given camera.
  65925. * @param camera The camera to dispose the effect on.
  65926. */
  65927. disposeEffects(camera: Camera): void;
  65928. /**
  65929. * @hidden Internal
  65930. */
  65931. _updateEffects(): void;
  65932. /**
  65933. * Internal
  65934. * @returns if all the contained post processes are ready.
  65935. * @hidden
  65936. */
  65937. _isReady(): boolean;
  65938. }
  65939. }
  65940. declare module "babylonjs/Shaders/displayPass.fragment" {
  65941. /** @hidden */
  65942. export var displayPassPixelShader: {
  65943. name: string;
  65944. shader: string;
  65945. };
  65946. }
  65947. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  65948. import { Nullable } from "babylonjs/types";
  65949. import { Camera } from "babylonjs/Cameras/camera";
  65950. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65951. import { Engine } from "babylonjs/Engines/engine";
  65952. import "babylonjs/Shaders/displayPass.fragment";
  65953. /**
  65954. * DisplayPassPostProcess which produces an output the same as it's input
  65955. */
  65956. export class DisplayPassPostProcess extends PostProcess {
  65957. /**
  65958. * Creates the DisplayPassPostProcess
  65959. * @param name The name of the effect.
  65960. * @param options The required width/height ratio to downsize to before computing the render pass.
  65961. * @param camera The camera to apply the render pass to.
  65962. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65963. * @param engine The engine which the post process will be applied. (default: current engine)
  65964. * @param reusable If the post process can be reused on the same frame. (default: false)
  65965. */
  65966. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65967. }
  65968. }
  65969. declare module "babylonjs/Shaders/filter.fragment" {
  65970. /** @hidden */
  65971. export var filterPixelShader: {
  65972. name: string;
  65973. shader: string;
  65974. };
  65975. }
  65976. declare module "babylonjs/PostProcesses/filterPostProcess" {
  65977. import { Nullable } from "babylonjs/types";
  65978. import { Matrix } from "babylonjs/Maths/math.vector";
  65979. import { Camera } from "babylonjs/Cameras/camera";
  65980. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65981. import { Engine } from "babylonjs/Engines/engine";
  65982. import "babylonjs/Shaders/filter.fragment";
  65983. /**
  65984. * Applies a kernel filter to the image
  65985. */
  65986. export class FilterPostProcess extends PostProcess {
  65987. /** The matrix to be applied to the image */
  65988. kernelMatrix: Matrix;
  65989. /**
  65990. *
  65991. * @param name The name of the effect.
  65992. * @param kernelMatrix The matrix to be applied to the image
  65993. * @param options The required width/height ratio to downsize to before computing the render pass.
  65994. * @param camera The camera to apply the render pass to.
  65995. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65996. * @param engine The engine which the post process will be applied. (default: current engine)
  65997. * @param reusable If the post process can be reused on the same frame. (default: false)
  65998. */
  65999. constructor(name: string,
  66000. /** The matrix to be applied to the image */
  66001. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66002. }
  66003. }
  66004. declare module "babylonjs/Shaders/fxaa.fragment" {
  66005. /** @hidden */
  66006. export var fxaaPixelShader: {
  66007. name: string;
  66008. shader: string;
  66009. };
  66010. }
  66011. declare module "babylonjs/Shaders/fxaa.vertex" {
  66012. /** @hidden */
  66013. export var fxaaVertexShader: {
  66014. name: string;
  66015. shader: string;
  66016. };
  66017. }
  66018. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  66019. import { Nullable } from "babylonjs/types";
  66020. import { Camera } from "babylonjs/Cameras/camera";
  66021. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66022. import { Engine } from "babylonjs/Engines/engine";
  66023. import "babylonjs/Shaders/fxaa.fragment";
  66024. import "babylonjs/Shaders/fxaa.vertex";
  66025. /**
  66026. * Fxaa post process
  66027. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  66028. */
  66029. export class FxaaPostProcess extends PostProcess {
  66030. /** @hidden */
  66031. texelWidth: number;
  66032. /** @hidden */
  66033. texelHeight: number;
  66034. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66035. private _getDefines;
  66036. }
  66037. }
  66038. declare module "babylonjs/Shaders/grain.fragment" {
  66039. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66040. /** @hidden */
  66041. export var grainPixelShader: {
  66042. name: string;
  66043. shader: string;
  66044. };
  66045. }
  66046. declare module "babylonjs/PostProcesses/grainPostProcess" {
  66047. import { Nullable } from "babylonjs/types";
  66048. import { Camera } from "babylonjs/Cameras/camera";
  66049. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66050. import { Engine } from "babylonjs/Engines/engine";
  66051. import "babylonjs/Shaders/grain.fragment";
  66052. /**
  66053. * The GrainPostProcess adds noise to the image at mid luminance levels
  66054. */
  66055. export class GrainPostProcess extends PostProcess {
  66056. /**
  66057. * The intensity of the grain added (default: 30)
  66058. */
  66059. intensity: number;
  66060. /**
  66061. * If the grain should be randomized on every frame
  66062. */
  66063. animated: boolean;
  66064. /**
  66065. * Creates a new instance of @see GrainPostProcess
  66066. * @param name The name of the effect.
  66067. * @param options The required width/height ratio to downsize to before computing the render pass.
  66068. * @param camera The camera to apply the render pass to.
  66069. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66070. * @param engine The engine which the post process will be applied. (default: current engine)
  66071. * @param reusable If the post process can be reused on the same frame. (default: false)
  66072. * @param textureType Type of textures used when performing the post process. (default: 0)
  66073. * @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)
  66074. */
  66075. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66076. }
  66077. }
  66078. declare module "babylonjs/Shaders/highlights.fragment" {
  66079. /** @hidden */
  66080. export var highlightsPixelShader: {
  66081. name: string;
  66082. shader: string;
  66083. };
  66084. }
  66085. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  66086. import { Nullable } from "babylonjs/types";
  66087. import { Camera } from "babylonjs/Cameras/camera";
  66088. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66089. import { Engine } from "babylonjs/Engines/engine";
  66090. import "babylonjs/Shaders/highlights.fragment";
  66091. /**
  66092. * Extracts highlights from the image
  66093. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  66094. */
  66095. export class HighlightsPostProcess extends PostProcess {
  66096. /**
  66097. * Extracts highlights from the image
  66098. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  66099. * @param name The name of the effect.
  66100. * @param options The required width/height ratio to downsize to before computing the render pass.
  66101. * @param camera The camera to apply the render pass to.
  66102. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66103. * @param engine The engine which the post process will be applied. (default: current engine)
  66104. * @param reusable If the post process can be reused on the same frame. (default: false)
  66105. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  66106. */
  66107. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66108. }
  66109. }
  66110. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  66111. /** @hidden */
  66112. export var mrtFragmentDeclaration: {
  66113. name: string;
  66114. shader: string;
  66115. };
  66116. }
  66117. declare module "babylonjs/Shaders/geometry.fragment" {
  66118. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  66119. /** @hidden */
  66120. export var geometryPixelShader: {
  66121. name: string;
  66122. shader: string;
  66123. };
  66124. }
  66125. declare module "babylonjs/Shaders/geometry.vertex" {
  66126. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66127. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66128. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66129. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66130. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66131. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66132. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66133. /** @hidden */
  66134. export var geometryVertexShader: {
  66135. name: string;
  66136. shader: string;
  66137. };
  66138. }
  66139. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  66140. import { Matrix } from "babylonjs/Maths/math.vector";
  66141. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66142. import { Mesh } from "babylonjs/Meshes/mesh";
  66143. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  66144. import { Effect } from "babylonjs/Materials/effect";
  66145. import { Scene } from "babylonjs/scene";
  66146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66147. import "babylonjs/Shaders/geometry.fragment";
  66148. import "babylonjs/Shaders/geometry.vertex";
  66149. /** @hidden */
  66150. interface ISavedTransformationMatrix {
  66151. world: Matrix;
  66152. viewProjection: Matrix;
  66153. }
  66154. /**
  66155. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  66156. */
  66157. export class GeometryBufferRenderer {
  66158. /**
  66159. * Constant used to retrieve the position texture index in the G-Buffer textures array
  66160. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  66161. */
  66162. static readonly POSITION_TEXTURE_TYPE: number;
  66163. /**
  66164. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  66165. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  66166. */
  66167. static readonly VELOCITY_TEXTURE_TYPE: number;
  66168. /**
  66169. * Dictionary used to store the previous transformation matrices of each rendered mesh
  66170. * in order to compute objects velocities when enableVelocity is set to "true"
  66171. * @hidden
  66172. */
  66173. _previousTransformationMatrices: {
  66174. [index: number]: ISavedTransformationMatrix;
  66175. };
  66176. /**
  66177. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  66178. * in order to compute objects velocities when enableVelocity is set to "true"
  66179. * @hidden
  66180. */
  66181. _previousBonesTransformationMatrices: {
  66182. [index: number]: Float32Array;
  66183. };
  66184. /**
  66185. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  66186. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  66187. */
  66188. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  66189. private _scene;
  66190. private _multiRenderTarget;
  66191. private _ratio;
  66192. private _enablePosition;
  66193. private _enableVelocity;
  66194. private _positionIndex;
  66195. private _velocityIndex;
  66196. protected _effect: Effect;
  66197. protected _cachedDefines: string;
  66198. /**
  66199. * Set the render list (meshes to be rendered) used in the G buffer.
  66200. */
  66201. set renderList(meshes: Mesh[]);
  66202. /**
  66203. * Gets wether or not G buffer are supported by the running hardware.
  66204. * This requires draw buffer supports
  66205. */
  66206. get isSupported(): boolean;
  66207. /**
  66208. * Returns the index of the given texture type in the G-Buffer textures array
  66209. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  66210. * @returns the index of the given texture type in the G-Buffer textures array
  66211. */
  66212. getTextureIndex(textureType: number): number;
  66213. /**
  66214. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  66215. */
  66216. get enablePosition(): boolean;
  66217. /**
  66218. * Sets whether or not objects positions are enabled for the G buffer.
  66219. */
  66220. set enablePosition(enable: boolean);
  66221. /**
  66222. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  66223. */
  66224. get enableVelocity(): boolean;
  66225. /**
  66226. * Sets wether or not objects velocities are enabled for the G buffer.
  66227. */
  66228. set enableVelocity(enable: boolean);
  66229. /**
  66230. * Gets the scene associated with the buffer.
  66231. */
  66232. get scene(): Scene;
  66233. /**
  66234. * Gets the ratio used by the buffer during its creation.
  66235. * How big is the buffer related to the main canvas.
  66236. */
  66237. get ratio(): number;
  66238. /** @hidden */
  66239. static _SceneComponentInitialization: (scene: Scene) => void;
  66240. /**
  66241. * Creates a new G Buffer for the scene
  66242. * @param scene The scene the buffer belongs to
  66243. * @param ratio How big is the buffer related to the main canvas.
  66244. */
  66245. constructor(scene: Scene, ratio?: number);
  66246. /**
  66247. * Checks wether everything is ready to render a submesh to the G buffer.
  66248. * @param subMesh the submesh to check readiness for
  66249. * @param useInstances is the mesh drawn using instance or not
  66250. * @returns true if ready otherwise false
  66251. */
  66252. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66253. /**
  66254. * Gets the current underlying G Buffer.
  66255. * @returns the buffer
  66256. */
  66257. getGBuffer(): MultiRenderTarget;
  66258. /**
  66259. * Gets the number of samples used to render the buffer (anti aliasing).
  66260. */
  66261. get samples(): number;
  66262. /**
  66263. * Sets the number of samples used to render the buffer (anti aliasing).
  66264. */
  66265. set samples(value: number);
  66266. /**
  66267. * Disposes the renderer and frees up associated resources.
  66268. */
  66269. dispose(): void;
  66270. protected _createRenderTargets(): void;
  66271. private _copyBonesTransformationMatrices;
  66272. }
  66273. }
  66274. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  66275. import { Nullable } from "babylonjs/types";
  66276. import { Scene } from "babylonjs/scene";
  66277. import { ISceneComponent } from "babylonjs/sceneComponent";
  66278. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  66279. module "babylonjs/scene" {
  66280. interface Scene {
  66281. /** @hidden (Backing field) */
  66282. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  66283. /**
  66284. * Gets or Sets the current geometry buffer associated to the scene.
  66285. */
  66286. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  66287. /**
  66288. * Enables a GeometryBufferRender and associates it with the scene
  66289. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  66290. * @returns the GeometryBufferRenderer
  66291. */
  66292. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  66293. /**
  66294. * Disables the GeometryBufferRender associated with the scene
  66295. */
  66296. disableGeometryBufferRenderer(): void;
  66297. }
  66298. }
  66299. /**
  66300. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  66301. * in several rendering techniques.
  66302. */
  66303. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  66304. /**
  66305. * The component name helpful to identify the component in the list of scene components.
  66306. */
  66307. readonly name: string;
  66308. /**
  66309. * The scene the component belongs to.
  66310. */
  66311. scene: Scene;
  66312. /**
  66313. * Creates a new instance of the component for the given scene
  66314. * @param scene Defines the scene to register the component in
  66315. */
  66316. constructor(scene: Scene);
  66317. /**
  66318. * Registers the component in a given scene
  66319. */
  66320. register(): void;
  66321. /**
  66322. * Rebuilds the elements related to this component in case of
  66323. * context lost for instance.
  66324. */
  66325. rebuild(): void;
  66326. /**
  66327. * Disposes the component and the associated ressources
  66328. */
  66329. dispose(): void;
  66330. private _gatherRenderTargets;
  66331. }
  66332. }
  66333. declare module "babylonjs/Shaders/motionBlur.fragment" {
  66334. /** @hidden */
  66335. export var motionBlurPixelShader: {
  66336. name: string;
  66337. shader: string;
  66338. };
  66339. }
  66340. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  66341. import { Nullable } from "babylonjs/types";
  66342. import { Camera } from "babylonjs/Cameras/camera";
  66343. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66344. import { Scene } from "babylonjs/scene";
  66345. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66346. import "babylonjs/Animations/animatable";
  66347. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  66348. import "babylonjs/Shaders/motionBlur.fragment";
  66349. import { Engine } from "babylonjs/Engines/engine";
  66350. /**
  66351. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  66352. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  66353. * As an example, all you have to do is to create the post-process:
  66354. * var mb = new BABYLON.MotionBlurPostProcess(
  66355. * 'mb', // The name of the effect.
  66356. * scene, // The scene containing the objects to blur according to their velocity.
  66357. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  66358. * camera // The camera to apply the render pass to.
  66359. * );
  66360. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  66361. */
  66362. export class MotionBlurPostProcess extends PostProcess {
  66363. /**
  66364. * Defines how much the image is blurred by the movement. Default value is equal to 1
  66365. */
  66366. motionStrength: number;
  66367. /**
  66368. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  66369. */
  66370. get motionBlurSamples(): number;
  66371. /**
  66372. * Sets the number of iterations to be used for motion blur quality
  66373. */
  66374. set motionBlurSamples(samples: number);
  66375. private _motionBlurSamples;
  66376. private _geometryBufferRenderer;
  66377. /**
  66378. * Creates a new instance MotionBlurPostProcess
  66379. * @param name The name of the effect.
  66380. * @param scene The scene containing the objects to blur according to their velocity.
  66381. * @param options The required width/height ratio to downsize to before computing the render pass.
  66382. * @param camera The camera to apply the render pass to.
  66383. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66384. * @param engine The engine which the post process will be applied. (default: current engine)
  66385. * @param reusable If the post process can be reused on the same frame. (default: false)
  66386. * @param textureType Type of textures used when performing the post process. (default: 0)
  66387. * @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)
  66388. */
  66389. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66390. /**
  66391. * Excludes the given skinned mesh from computing bones velocities.
  66392. * 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.
  66393. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  66394. */
  66395. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  66396. /**
  66397. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  66398. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  66399. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  66400. */
  66401. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  66402. /**
  66403. * Disposes the post process.
  66404. * @param camera The camera to dispose the post process on.
  66405. */
  66406. dispose(camera?: Camera): void;
  66407. }
  66408. }
  66409. declare module "babylonjs/Shaders/refraction.fragment" {
  66410. /** @hidden */
  66411. export var refractionPixelShader: {
  66412. name: string;
  66413. shader: string;
  66414. };
  66415. }
  66416. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  66417. import { Color3 } from "babylonjs/Maths/math.color";
  66418. import { Camera } from "babylonjs/Cameras/camera";
  66419. import { Texture } from "babylonjs/Materials/Textures/texture";
  66420. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66421. import { Engine } from "babylonjs/Engines/engine";
  66422. import "babylonjs/Shaders/refraction.fragment";
  66423. /**
  66424. * Post process which applies a refractin texture
  66425. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  66426. */
  66427. export class RefractionPostProcess extends PostProcess {
  66428. /** the base color of the refraction (used to taint the rendering) */
  66429. color: Color3;
  66430. /** simulated refraction depth */
  66431. depth: number;
  66432. /** the coefficient of the base color (0 to remove base color tainting) */
  66433. colorLevel: number;
  66434. private _refTexture;
  66435. private _ownRefractionTexture;
  66436. /**
  66437. * Gets or sets the refraction texture
  66438. * Please note that you are responsible for disposing the texture if you set it manually
  66439. */
  66440. get refractionTexture(): Texture;
  66441. set refractionTexture(value: Texture);
  66442. /**
  66443. * Initializes the RefractionPostProcess
  66444. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  66445. * @param name The name of the effect.
  66446. * @param refractionTextureUrl Url of the refraction texture to use
  66447. * @param color the base color of the refraction (used to taint the rendering)
  66448. * @param depth simulated refraction depth
  66449. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  66450. * @param camera The camera to apply the render pass to.
  66451. * @param options The required width/height ratio to downsize to before computing the render pass.
  66452. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66453. * @param engine The engine which the post process will be applied. (default: current engine)
  66454. * @param reusable If the post process can be reused on the same frame. (default: false)
  66455. */
  66456. constructor(name: string, refractionTextureUrl: string,
  66457. /** the base color of the refraction (used to taint the rendering) */
  66458. color: Color3,
  66459. /** simulated refraction depth */
  66460. depth: number,
  66461. /** the coefficient of the base color (0 to remove base color tainting) */
  66462. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66463. /**
  66464. * Disposes of the post process
  66465. * @param camera Camera to dispose post process on
  66466. */
  66467. dispose(camera: Camera): void;
  66468. }
  66469. }
  66470. declare module "babylonjs/Shaders/sharpen.fragment" {
  66471. /** @hidden */
  66472. export var sharpenPixelShader: {
  66473. name: string;
  66474. shader: string;
  66475. };
  66476. }
  66477. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  66478. import { Nullable } from "babylonjs/types";
  66479. import { Camera } from "babylonjs/Cameras/camera";
  66480. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66481. import "babylonjs/Shaders/sharpen.fragment";
  66482. import { Engine } from "babylonjs/Engines/engine";
  66483. /**
  66484. * The SharpenPostProcess applies a sharpen kernel to every pixel
  66485. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  66486. */
  66487. export class SharpenPostProcess extends PostProcess {
  66488. /**
  66489. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  66490. */
  66491. colorAmount: number;
  66492. /**
  66493. * How much sharpness should be applied (default: 0.3)
  66494. */
  66495. edgeAmount: number;
  66496. /**
  66497. * Creates a new instance ConvolutionPostProcess
  66498. * @param name The name of the effect.
  66499. * @param options The required width/height ratio to downsize to before computing the render pass.
  66500. * @param camera The camera to apply the render pass to.
  66501. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66502. * @param engine The engine which the post process will be applied. (default: current engine)
  66503. * @param reusable If the post process can be reused on the same frame. (default: false)
  66504. * @param textureType Type of textures used when performing the post process. (default: 0)
  66505. * @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)
  66506. */
  66507. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66508. }
  66509. }
  66510. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  66511. import { Nullable } from "babylonjs/types";
  66512. import { Camera } from "babylonjs/Cameras/camera";
  66513. import { Engine } from "babylonjs/Engines/engine";
  66514. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  66515. import { IInspectable } from "babylonjs/Misc/iInspectable";
  66516. /**
  66517. * PostProcessRenderPipeline
  66518. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66519. */
  66520. export class PostProcessRenderPipeline {
  66521. private engine;
  66522. private _renderEffects;
  66523. private _renderEffectsForIsolatedPass;
  66524. /**
  66525. * List of inspectable custom properties (used by the Inspector)
  66526. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  66527. */
  66528. inspectableCustomProperties: IInspectable[];
  66529. /**
  66530. * @hidden
  66531. */
  66532. protected _cameras: Camera[];
  66533. /** @hidden */
  66534. _name: string;
  66535. /**
  66536. * Gets pipeline name
  66537. */
  66538. get name(): string;
  66539. /** Gets the list of attached cameras */
  66540. get cameras(): Camera[];
  66541. /**
  66542. * Initializes a PostProcessRenderPipeline
  66543. * @param engine engine to add the pipeline to
  66544. * @param name name of the pipeline
  66545. */
  66546. constructor(engine: Engine, name: string);
  66547. /**
  66548. * Gets the class name
  66549. * @returns "PostProcessRenderPipeline"
  66550. */
  66551. getClassName(): string;
  66552. /**
  66553. * If all the render effects in the pipeline are supported
  66554. */
  66555. get isSupported(): boolean;
  66556. /**
  66557. * Adds an effect to the pipeline
  66558. * @param renderEffect the effect to add
  66559. */
  66560. addEffect(renderEffect: PostProcessRenderEffect): void;
  66561. /** @hidden */
  66562. _rebuild(): void;
  66563. /** @hidden */
  66564. _enableEffect(renderEffectName: string, cameras: Camera): void;
  66565. /** @hidden */
  66566. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  66567. /** @hidden */
  66568. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  66569. /** @hidden */
  66570. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  66571. /** @hidden */
  66572. _attachCameras(cameras: Camera, unique: boolean): void;
  66573. /** @hidden */
  66574. _attachCameras(cameras: Camera[], unique: boolean): void;
  66575. /** @hidden */
  66576. _detachCameras(cameras: Camera): void;
  66577. /** @hidden */
  66578. _detachCameras(cameras: Nullable<Camera[]>): void;
  66579. /** @hidden */
  66580. _update(): void;
  66581. /** @hidden */
  66582. _reset(): void;
  66583. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  66584. /**
  66585. * Disposes of the pipeline
  66586. */
  66587. dispose(): void;
  66588. }
  66589. }
  66590. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  66591. import { Camera } from "babylonjs/Cameras/camera";
  66592. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66593. /**
  66594. * PostProcessRenderPipelineManager class
  66595. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66596. */
  66597. export class PostProcessRenderPipelineManager {
  66598. private _renderPipelines;
  66599. /**
  66600. * Initializes a PostProcessRenderPipelineManager
  66601. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66602. */
  66603. constructor();
  66604. /**
  66605. * Gets the list of supported render pipelines
  66606. */
  66607. get supportedPipelines(): PostProcessRenderPipeline[];
  66608. /**
  66609. * Adds a pipeline to the manager
  66610. * @param renderPipeline The pipeline to add
  66611. */
  66612. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  66613. /**
  66614. * Attaches a camera to the pipeline
  66615. * @param renderPipelineName The name of the pipeline to attach to
  66616. * @param cameras the camera to attach
  66617. * @param unique if the camera can be attached multiple times to the pipeline
  66618. */
  66619. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  66620. /**
  66621. * Detaches a camera from the pipeline
  66622. * @param renderPipelineName The name of the pipeline to detach from
  66623. * @param cameras the camera to detach
  66624. */
  66625. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  66626. /**
  66627. * Enables an effect by name on a pipeline
  66628. * @param renderPipelineName the name of the pipeline to enable the effect in
  66629. * @param renderEffectName the name of the effect to enable
  66630. * @param cameras the cameras that the effect should be enabled on
  66631. */
  66632. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  66633. /**
  66634. * Disables an effect by name on a pipeline
  66635. * @param renderPipelineName the name of the pipeline to disable the effect in
  66636. * @param renderEffectName the name of the effect to disable
  66637. * @param cameras the cameras that the effect should be disabled on
  66638. */
  66639. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  66640. /**
  66641. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  66642. */
  66643. update(): void;
  66644. /** @hidden */
  66645. _rebuild(): void;
  66646. /**
  66647. * Disposes of the manager and pipelines
  66648. */
  66649. dispose(): void;
  66650. }
  66651. }
  66652. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  66653. import { ISceneComponent } from "babylonjs/sceneComponent";
  66654. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  66655. import { Scene } from "babylonjs/scene";
  66656. module "babylonjs/scene" {
  66657. interface Scene {
  66658. /** @hidden (Backing field) */
  66659. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  66660. /**
  66661. * Gets the postprocess render pipeline manager
  66662. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66663. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  66664. */
  66665. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  66666. }
  66667. }
  66668. /**
  66669. * Defines the Render Pipeline scene component responsible to rendering pipelines
  66670. */
  66671. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  66672. /**
  66673. * The component name helpfull to identify the component in the list of scene components.
  66674. */
  66675. readonly name: string;
  66676. /**
  66677. * The scene the component belongs to.
  66678. */
  66679. scene: Scene;
  66680. /**
  66681. * Creates a new instance of the component for the given scene
  66682. * @param scene Defines the scene to register the component in
  66683. */
  66684. constructor(scene: Scene);
  66685. /**
  66686. * Registers the component in a given scene
  66687. */
  66688. register(): void;
  66689. /**
  66690. * Rebuilds the elements related to this component in case of
  66691. * context lost for instance.
  66692. */
  66693. rebuild(): void;
  66694. /**
  66695. * Disposes the component and the associated ressources
  66696. */
  66697. dispose(): void;
  66698. private _gatherRenderTargets;
  66699. }
  66700. }
  66701. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  66702. import { Nullable } from "babylonjs/types";
  66703. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  66704. import { Camera } from "babylonjs/Cameras/camera";
  66705. import { IDisposable } from "babylonjs/scene";
  66706. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  66707. import { Scene } from "babylonjs/scene";
  66708. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  66709. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  66710. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  66711. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  66712. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  66713. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66714. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  66715. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66716. import { Animation } from "babylonjs/Animations/animation";
  66717. /**
  66718. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  66719. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  66720. */
  66721. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66722. private _scene;
  66723. private _camerasToBeAttached;
  66724. /**
  66725. * ID of the sharpen post process,
  66726. */
  66727. private readonly SharpenPostProcessId;
  66728. /**
  66729. * @ignore
  66730. * ID of the image processing post process;
  66731. */
  66732. readonly ImageProcessingPostProcessId: string;
  66733. /**
  66734. * @ignore
  66735. * ID of the Fast Approximate Anti-Aliasing post process;
  66736. */
  66737. readonly FxaaPostProcessId: string;
  66738. /**
  66739. * ID of the chromatic aberration post process,
  66740. */
  66741. private readonly ChromaticAberrationPostProcessId;
  66742. /**
  66743. * ID of the grain post process
  66744. */
  66745. private readonly GrainPostProcessId;
  66746. /**
  66747. * Sharpen post process which will apply a sharpen convolution to enhance edges
  66748. */
  66749. sharpen: SharpenPostProcess;
  66750. private _sharpenEffect;
  66751. private bloom;
  66752. /**
  66753. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  66754. */
  66755. depthOfField: DepthOfFieldEffect;
  66756. /**
  66757. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66758. */
  66759. fxaa: FxaaPostProcess;
  66760. /**
  66761. * Image post processing pass used to perform operations such as tone mapping or color grading.
  66762. */
  66763. imageProcessing: ImageProcessingPostProcess;
  66764. /**
  66765. * Chromatic aberration post process which will shift rgb colors in the image
  66766. */
  66767. chromaticAberration: ChromaticAberrationPostProcess;
  66768. private _chromaticAberrationEffect;
  66769. /**
  66770. * Grain post process which add noise to the image
  66771. */
  66772. grain: GrainPostProcess;
  66773. private _grainEffect;
  66774. /**
  66775. * Glow post process which adds a glow to emissive areas of the image
  66776. */
  66777. private _glowLayer;
  66778. /**
  66779. * Animations which can be used to tweak settings over a period of time
  66780. */
  66781. animations: Animation[];
  66782. private _imageProcessingConfigurationObserver;
  66783. private _sharpenEnabled;
  66784. private _bloomEnabled;
  66785. private _depthOfFieldEnabled;
  66786. private _depthOfFieldBlurLevel;
  66787. private _fxaaEnabled;
  66788. private _imageProcessingEnabled;
  66789. private _defaultPipelineTextureType;
  66790. private _bloomScale;
  66791. private _chromaticAberrationEnabled;
  66792. private _grainEnabled;
  66793. private _buildAllowed;
  66794. /**
  66795. * Gets active scene
  66796. */
  66797. get scene(): Scene;
  66798. /**
  66799. * Enable or disable the sharpen process from the pipeline
  66800. */
  66801. set sharpenEnabled(enabled: boolean);
  66802. get sharpenEnabled(): boolean;
  66803. private _resizeObserver;
  66804. private _hardwareScaleLevel;
  66805. private _bloomKernel;
  66806. /**
  66807. * Specifies the size of the bloom blur kernel, relative to the final output size
  66808. */
  66809. get bloomKernel(): number;
  66810. set bloomKernel(value: number);
  66811. /**
  66812. * Specifies the weight of the bloom in the final rendering
  66813. */
  66814. private _bloomWeight;
  66815. /**
  66816. * Specifies the luma threshold for the area that will be blurred by the bloom
  66817. */
  66818. private _bloomThreshold;
  66819. private _hdr;
  66820. /**
  66821. * The strength of the bloom.
  66822. */
  66823. set bloomWeight(value: number);
  66824. get bloomWeight(): number;
  66825. /**
  66826. * The strength of the bloom.
  66827. */
  66828. set bloomThreshold(value: number);
  66829. get bloomThreshold(): number;
  66830. /**
  66831. * The scale of the bloom, lower value will provide better performance.
  66832. */
  66833. set bloomScale(value: number);
  66834. get bloomScale(): number;
  66835. /**
  66836. * Enable or disable the bloom from the pipeline
  66837. */
  66838. set bloomEnabled(enabled: boolean);
  66839. get bloomEnabled(): boolean;
  66840. private _rebuildBloom;
  66841. /**
  66842. * If the depth of field is enabled.
  66843. */
  66844. get depthOfFieldEnabled(): boolean;
  66845. set depthOfFieldEnabled(enabled: boolean);
  66846. /**
  66847. * Blur level of the depth of field effect. (Higher blur will effect performance)
  66848. */
  66849. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  66850. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  66851. /**
  66852. * If the anti aliasing is enabled.
  66853. */
  66854. set fxaaEnabled(enabled: boolean);
  66855. get fxaaEnabled(): boolean;
  66856. private _samples;
  66857. /**
  66858. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66859. */
  66860. set samples(sampleCount: number);
  66861. get samples(): number;
  66862. /**
  66863. * If image processing is enabled.
  66864. */
  66865. set imageProcessingEnabled(enabled: boolean);
  66866. get imageProcessingEnabled(): boolean;
  66867. /**
  66868. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  66869. */
  66870. set glowLayerEnabled(enabled: boolean);
  66871. get glowLayerEnabled(): boolean;
  66872. /**
  66873. * Gets the glow layer (or null if not defined)
  66874. */
  66875. get glowLayer(): Nullable<GlowLayer>;
  66876. /**
  66877. * Enable or disable the chromaticAberration process from the pipeline
  66878. */
  66879. set chromaticAberrationEnabled(enabled: boolean);
  66880. get chromaticAberrationEnabled(): boolean;
  66881. /**
  66882. * Enable or disable the grain process from the pipeline
  66883. */
  66884. set grainEnabled(enabled: boolean);
  66885. get grainEnabled(): boolean;
  66886. /**
  66887. * @constructor
  66888. * @param name - The rendering pipeline name (default: "")
  66889. * @param hdr - If high dynamic range textures should be used (default: true)
  66890. * @param scene - The scene linked to this pipeline (default: the last created scene)
  66891. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  66892. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  66893. */
  66894. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  66895. /**
  66896. * Get the class name
  66897. * @returns "DefaultRenderingPipeline"
  66898. */
  66899. getClassName(): string;
  66900. /**
  66901. * Force the compilation of the entire pipeline.
  66902. */
  66903. prepare(): void;
  66904. private _hasCleared;
  66905. private _prevPostProcess;
  66906. private _prevPrevPostProcess;
  66907. private _setAutoClearAndTextureSharing;
  66908. private _depthOfFieldSceneObserver;
  66909. private _buildPipeline;
  66910. private _disposePostProcesses;
  66911. /**
  66912. * Adds a camera to the pipeline
  66913. * @param camera the camera to be added
  66914. */
  66915. addCamera(camera: Camera): void;
  66916. /**
  66917. * Removes a camera from the pipeline
  66918. * @param camera the camera to remove
  66919. */
  66920. removeCamera(camera: Camera): void;
  66921. /**
  66922. * Dispose of the pipeline and stop all post processes
  66923. */
  66924. dispose(): void;
  66925. /**
  66926. * Serialize the rendering pipeline (Used when exporting)
  66927. * @returns the serialized object
  66928. */
  66929. serialize(): any;
  66930. /**
  66931. * Parse the serialized pipeline
  66932. * @param source Source pipeline.
  66933. * @param scene The scene to load the pipeline to.
  66934. * @param rootUrl The URL of the serialized pipeline.
  66935. * @returns An instantiated pipeline from the serialized object.
  66936. */
  66937. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  66938. }
  66939. }
  66940. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  66941. /** @hidden */
  66942. export var lensHighlightsPixelShader: {
  66943. name: string;
  66944. shader: string;
  66945. };
  66946. }
  66947. declare module "babylonjs/Shaders/depthOfField.fragment" {
  66948. /** @hidden */
  66949. export var depthOfFieldPixelShader: {
  66950. name: string;
  66951. shader: string;
  66952. };
  66953. }
  66954. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  66955. import { Camera } from "babylonjs/Cameras/camera";
  66956. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66957. import { Scene } from "babylonjs/scene";
  66958. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66959. import "babylonjs/Shaders/chromaticAberration.fragment";
  66960. import "babylonjs/Shaders/lensHighlights.fragment";
  66961. import "babylonjs/Shaders/depthOfField.fragment";
  66962. /**
  66963. * BABYLON.JS Chromatic Aberration GLSL Shader
  66964. * Author: Olivier Guyot
  66965. * Separates very slightly R, G and B colors on the edges of the screen
  66966. * Inspired by Francois Tarlier & Martins Upitis
  66967. */
  66968. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  66969. /**
  66970. * @ignore
  66971. * The chromatic aberration PostProcess id in the pipeline
  66972. */
  66973. LensChromaticAberrationEffect: string;
  66974. /**
  66975. * @ignore
  66976. * The highlights enhancing PostProcess id in the pipeline
  66977. */
  66978. HighlightsEnhancingEffect: string;
  66979. /**
  66980. * @ignore
  66981. * The depth-of-field PostProcess id in the pipeline
  66982. */
  66983. LensDepthOfFieldEffect: string;
  66984. private _scene;
  66985. private _depthTexture;
  66986. private _grainTexture;
  66987. private _chromaticAberrationPostProcess;
  66988. private _highlightsPostProcess;
  66989. private _depthOfFieldPostProcess;
  66990. private _edgeBlur;
  66991. private _grainAmount;
  66992. private _chromaticAberration;
  66993. private _distortion;
  66994. private _highlightsGain;
  66995. private _highlightsThreshold;
  66996. private _dofDistance;
  66997. private _dofAperture;
  66998. private _dofDarken;
  66999. private _dofPentagon;
  67000. private _blurNoise;
  67001. /**
  67002. * @constructor
  67003. *
  67004. * Effect parameters are as follow:
  67005. * {
  67006. * chromatic_aberration: number; // from 0 to x (1 for realism)
  67007. * edge_blur: number; // from 0 to x (1 for realism)
  67008. * distortion: number; // from 0 to x (1 for realism)
  67009. * grain_amount: number; // from 0 to 1
  67010. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  67011. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  67012. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  67013. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  67014. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  67015. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  67016. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  67017. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  67018. * }
  67019. * Note: if an effect parameter is unset, effect is disabled
  67020. *
  67021. * @param name The rendering pipeline name
  67022. * @param parameters - An object containing all parameters (see above)
  67023. * @param scene The scene linked to this pipeline
  67024. * @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)
  67025. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67026. */
  67027. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  67028. /**
  67029. * Get the class name
  67030. * @returns "LensRenderingPipeline"
  67031. */
  67032. getClassName(): string;
  67033. /**
  67034. * Gets associated scene
  67035. */
  67036. get scene(): Scene;
  67037. /**
  67038. * Gets or sets the edge blur
  67039. */
  67040. get edgeBlur(): number;
  67041. set edgeBlur(value: number);
  67042. /**
  67043. * Gets or sets the grain amount
  67044. */
  67045. get grainAmount(): number;
  67046. set grainAmount(value: number);
  67047. /**
  67048. * Gets or sets the chromatic aberration amount
  67049. */
  67050. get chromaticAberration(): number;
  67051. set chromaticAberration(value: number);
  67052. /**
  67053. * Gets or sets the depth of field aperture
  67054. */
  67055. get dofAperture(): number;
  67056. set dofAperture(value: number);
  67057. /**
  67058. * Gets or sets the edge distortion
  67059. */
  67060. get edgeDistortion(): number;
  67061. set edgeDistortion(value: number);
  67062. /**
  67063. * Gets or sets the depth of field distortion
  67064. */
  67065. get dofDistortion(): number;
  67066. set dofDistortion(value: number);
  67067. /**
  67068. * Gets or sets the darken out of focus amount
  67069. */
  67070. get darkenOutOfFocus(): number;
  67071. set darkenOutOfFocus(value: number);
  67072. /**
  67073. * Gets or sets a boolean indicating if blur noise is enabled
  67074. */
  67075. get blurNoise(): boolean;
  67076. set blurNoise(value: boolean);
  67077. /**
  67078. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  67079. */
  67080. get pentagonBokeh(): boolean;
  67081. set pentagonBokeh(value: boolean);
  67082. /**
  67083. * Gets or sets the highlight grain amount
  67084. */
  67085. get highlightsGain(): number;
  67086. set highlightsGain(value: number);
  67087. /**
  67088. * Gets or sets the highlight threshold
  67089. */
  67090. get highlightsThreshold(): number;
  67091. set highlightsThreshold(value: number);
  67092. /**
  67093. * Sets the amount of blur at the edges
  67094. * @param amount blur amount
  67095. */
  67096. setEdgeBlur(amount: number): void;
  67097. /**
  67098. * Sets edge blur to 0
  67099. */
  67100. disableEdgeBlur(): void;
  67101. /**
  67102. * Sets the amout of grain
  67103. * @param amount Amount of grain
  67104. */
  67105. setGrainAmount(amount: number): void;
  67106. /**
  67107. * Set grain amount to 0
  67108. */
  67109. disableGrain(): void;
  67110. /**
  67111. * Sets the chromatic aberration amount
  67112. * @param amount amount of chromatic aberration
  67113. */
  67114. setChromaticAberration(amount: number): void;
  67115. /**
  67116. * Sets chromatic aberration amount to 0
  67117. */
  67118. disableChromaticAberration(): void;
  67119. /**
  67120. * Sets the EdgeDistortion amount
  67121. * @param amount amount of EdgeDistortion
  67122. */
  67123. setEdgeDistortion(amount: number): void;
  67124. /**
  67125. * Sets edge distortion to 0
  67126. */
  67127. disableEdgeDistortion(): void;
  67128. /**
  67129. * Sets the FocusDistance amount
  67130. * @param amount amount of FocusDistance
  67131. */
  67132. setFocusDistance(amount: number): void;
  67133. /**
  67134. * Disables depth of field
  67135. */
  67136. disableDepthOfField(): void;
  67137. /**
  67138. * Sets the Aperture amount
  67139. * @param amount amount of Aperture
  67140. */
  67141. setAperture(amount: number): void;
  67142. /**
  67143. * Sets the DarkenOutOfFocus amount
  67144. * @param amount amount of DarkenOutOfFocus
  67145. */
  67146. setDarkenOutOfFocus(amount: number): void;
  67147. private _pentagonBokehIsEnabled;
  67148. /**
  67149. * Creates a pentagon bokeh effect
  67150. */
  67151. enablePentagonBokeh(): void;
  67152. /**
  67153. * Disables the pentagon bokeh effect
  67154. */
  67155. disablePentagonBokeh(): void;
  67156. /**
  67157. * Enables noise blur
  67158. */
  67159. enableNoiseBlur(): void;
  67160. /**
  67161. * Disables noise blur
  67162. */
  67163. disableNoiseBlur(): void;
  67164. /**
  67165. * Sets the HighlightsGain amount
  67166. * @param amount amount of HighlightsGain
  67167. */
  67168. setHighlightsGain(amount: number): void;
  67169. /**
  67170. * Sets the HighlightsThreshold amount
  67171. * @param amount amount of HighlightsThreshold
  67172. */
  67173. setHighlightsThreshold(amount: number): void;
  67174. /**
  67175. * Disables highlights
  67176. */
  67177. disableHighlights(): void;
  67178. /**
  67179. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  67180. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  67181. */
  67182. dispose(disableDepthRender?: boolean): void;
  67183. private _createChromaticAberrationPostProcess;
  67184. private _createHighlightsPostProcess;
  67185. private _createDepthOfFieldPostProcess;
  67186. private _createGrainTexture;
  67187. }
  67188. }
  67189. declare module "babylonjs/Shaders/ssao2.fragment" {
  67190. /** @hidden */
  67191. export var ssao2PixelShader: {
  67192. name: string;
  67193. shader: string;
  67194. };
  67195. }
  67196. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  67197. /** @hidden */
  67198. export var ssaoCombinePixelShader: {
  67199. name: string;
  67200. shader: string;
  67201. };
  67202. }
  67203. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  67204. import { Camera } from "babylonjs/Cameras/camera";
  67205. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67206. import { Scene } from "babylonjs/scene";
  67207. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67208. import "babylonjs/Shaders/ssao2.fragment";
  67209. import "babylonjs/Shaders/ssaoCombine.fragment";
  67210. /**
  67211. * Render pipeline to produce ssao effect
  67212. */
  67213. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  67214. /**
  67215. * @ignore
  67216. * The PassPostProcess id in the pipeline that contains the original scene color
  67217. */
  67218. SSAOOriginalSceneColorEffect: string;
  67219. /**
  67220. * @ignore
  67221. * The SSAO PostProcess id in the pipeline
  67222. */
  67223. SSAORenderEffect: string;
  67224. /**
  67225. * @ignore
  67226. * The horizontal blur PostProcess id in the pipeline
  67227. */
  67228. SSAOBlurHRenderEffect: string;
  67229. /**
  67230. * @ignore
  67231. * The vertical blur PostProcess id in the pipeline
  67232. */
  67233. SSAOBlurVRenderEffect: string;
  67234. /**
  67235. * @ignore
  67236. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  67237. */
  67238. SSAOCombineRenderEffect: string;
  67239. /**
  67240. * The output strength of the SSAO post-process. Default value is 1.0.
  67241. */
  67242. totalStrength: number;
  67243. /**
  67244. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  67245. */
  67246. maxZ: number;
  67247. /**
  67248. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  67249. */
  67250. minZAspect: number;
  67251. private _samples;
  67252. /**
  67253. * Number of samples used for the SSAO calculations. Default value is 8
  67254. */
  67255. set samples(n: number);
  67256. get samples(): number;
  67257. private _textureSamples;
  67258. /**
  67259. * Number of samples to use for antialiasing
  67260. */
  67261. set textureSamples(n: number);
  67262. get textureSamples(): number;
  67263. /**
  67264. * Ratio object used for SSAO ratio and blur ratio
  67265. */
  67266. private _ratio;
  67267. /**
  67268. * Dynamically generated sphere sampler.
  67269. */
  67270. private _sampleSphere;
  67271. /**
  67272. * Blur filter offsets
  67273. */
  67274. private _samplerOffsets;
  67275. private _expensiveBlur;
  67276. /**
  67277. * If bilateral blur should be used
  67278. */
  67279. set expensiveBlur(b: boolean);
  67280. get expensiveBlur(): boolean;
  67281. /**
  67282. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  67283. */
  67284. radius: number;
  67285. /**
  67286. * The base color of the SSAO post-process
  67287. * The final result is "base + ssao" between [0, 1]
  67288. */
  67289. base: number;
  67290. /**
  67291. * Support test.
  67292. */
  67293. static get IsSupported(): boolean;
  67294. private _scene;
  67295. private _depthTexture;
  67296. private _normalTexture;
  67297. private _randomTexture;
  67298. private _originalColorPostProcess;
  67299. private _ssaoPostProcess;
  67300. private _blurHPostProcess;
  67301. private _blurVPostProcess;
  67302. private _ssaoCombinePostProcess;
  67303. /**
  67304. * Gets active scene
  67305. */
  67306. get scene(): Scene;
  67307. /**
  67308. * @constructor
  67309. * @param name The rendering pipeline name
  67310. * @param scene The scene linked to this pipeline
  67311. * @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 }
  67312. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67313. */
  67314. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  67315. /**
  67316. * Get the class name
  67317. * @returns "SSAO2RenderingPipeline"
  67318. */
  67319. getClassName(): string;
  67320. /**
  67321. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  67322. */
  67323. dispose(disableGeometryBufferRenderer?: boolean): void;
  67324. private _createBlurPostProcess;
  67325. /** @hidden */
  67326. _rebuild(): void;
  67327. private _bits;
  67328. private _radicalInverse_VdC;
  67329. private _hammersley;
  67330. private _hemisphereSample_uniform;
  67331. private _generateHemisphere;
  67332. private _createSSAOPostProcess;
  67333. private _createSSAOCombinePostProcess;
  67334. private _createRandomTexture;
  67335. /**
  67336. * Serialize the rendering pipeline (Used when exporting)
  67337. * @returns the serialized object
  67338. */
  67339. serialize(): any;
  67340. /**
  67341. * Parse the serialized pipeline
  67342. * @param source Source pipeline.
  67343. * @param scene The scene to load the pipeline to.
  67344. * @param rootUrl The URL of the serialized pipeline.
  67345. * @returns An instantiated pipeline from the serialized object.
  67346. */
  67347. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  67348. }
  67349. }
  67350. declare module "babylonjs/Shaders/ssao.fragment" {
  67351. /** @hidden */
  67352. export var ssaoPixelShader: {
  67353. name: string;
  67354. shader: string;
  67355. };
  67356. }
  67357. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  67358. import { Camera } from "babylonjs/Cameras/camera";
  67359. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67360. import { Scene } from "babylonjs/scene";
  67361. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67362. import "babylonjs/Shaders/ssao.fragment";
  67363. import "babylonjs/Shaders/ssaoCombine.fragment";
  67364. /**
  67365. * Render pipeline to produce ssao effect
  67366. */
  67367. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  67368. /**
  67369. * @ignore
  67370. * The PassPostProcess id in the pipeline that contains the original scene color
  67371. */
  67372. SSAOOriginalSceneColorEffect: string;
  67373. /**
  67374. * @ignore
  67375. * The SSAO PostProcess id in the pipeline
  67376. */
  67377. SSAORenderEffect: string;
  67378. /**
  67379. * @ignore
  67380. * The horizontal blur PostProcess id in the pipeline
  67381. */
  67382. SSAOBlurHRenderEffect: string;
  67383. /**
  67384. * @ignore
  67385. * The vertical blur PostProcess id in the pipeline
  67386. */
  67387. SSAOBlurVRenderEffect: string;
  67388. /**
  67389. * @ignore
  67390. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  67391. */
  67392. SSAOCombineRenderEffect: string;
  67393. /**
  67394. * The output strength of the SSAO post-process. Default value is 1.0.
  67395. */
  67396. totalStrength: number;
  67397. /**
  67398. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  67399. */
  67400. radius: number;
  67401. /**
  67402. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  67403. * Must not be equal to fallOff and superior to fallOff.
  67404. * Default value is 0.0075
  67405. */
  67406. area: number;
  67407. /**
  67408. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  67409. * Must not be equal to area and inferior to area.
  67410. * Default value is 0.000001
  67411. */
  67412. fallOff: number;
  67413. /**
  67414. * The base color of the SSAO post-process
  67415. * The final result is "base + ssao" between [0, 1]
  67416. */
  67417. base: number;
  67418. private _scene;
  67419. private _depthTexture;
  67420. private _randomTexture;
  67421. private _originalColorPostProcess;
  67422. private _ssaoPostProcess;
  67423. private _blurHPostProcess;
  67424. private _blurVPostProcess;
  67425. private _ssaoCombinePostProcess;
  67426. private _firstUpdate;
  67427. /**
  67428. * Gets active scene
  67429. */
  67430. get scene(): Scene;
  67431. /**
  67432. * @constructor
  67433. * @param name - The rendering pipeline name
  67434. * @param scene - The scene linked to this pipeline
  67435. * @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 }
  67436. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  67437. */
  67438. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  67439. /**
  67440. * Get the class name
  67441. * @returns "SSAORenderingPipeline"
  67442. */
  67443. getClassName(): string;
  67444. /**
  67445. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  67446. */
  67447. dispose(disableDepthRender?: boolean): void;
  67448. private _createBlurPostProcess;
  67449. /** @hidden */
  67450. _rebuild(): void;
  67451. private _createSSAOPostProcess;
  67452. private _createSSAOCombinePostProcess;
  67453. private _createRandomTexture;
  67454. }
  67455. }
  67456. declare module "babylonjs/Shaders/standard.fragment" {
  67457. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  67458. /** @hidden */
  67459. export var standardPixelShader: {
  67460. name: string;
  67461. shader: string;
  67462. };
  67463. }
  67464. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  67465. import { Nullable } from "babylonjs/types";
  67466. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  67467. import { Camera } from "babylonjs/Cameras/camera";
  67468. import { Texture } from "babylonjs/Materials/Textures/texture";
  67469. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67470. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67471. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67472. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  67473. import { IDisposable } from "babylonjs/scene";
  67474. import { SpotLight } from "babylonjs/Lights/spotLight";
  67475. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  67476. import { Scene } from "babylonjs/scene";
  67477. import { Animation } from "babylonjs/Animations/animation";
  67478. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67479. import "babylonjs/Shaders/standard.fragment";
  67480. /**
  67481. * Standard rendering pipeline
  67482. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  67483. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  67484. */
  67485. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  67486. /**
  67487. * Public members
  67488. */
  67489. /**
  67490. * Post-process which contains the original scene color before the pipeline applies all the effects
  67491. */
  67492. originalPostProcess: Nullable<PostProcess>;
  67493. /**
  67494. * Post-process used to down scale an image x4
  67495. */
  67496. downSampleX4PostProcess: Nullable<PostProcess>;
  67497. /**
  67498. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  67499. */
  67500. brightPassPostProcess: Nullable<PostProcess>;
  67501. /**
  67502. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  67503. */
  67504. blurHPostProcesses: PostProcess[];
  67505. /**
  67506. * Post-process array storing all the vertical blur post-processes used by the pipeline
  67507. */
  67508. blurVPostProcesses: PostProcess[];
  67509. /**
  67510. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  67511. */
  67512. textureAdderPostProcess: Nullable<PostProcess>;
  67513. /**
  67514. * Post-process used to create volumetric lighting effect
  67515. */
  67516. volumetricLightPostProcess: Nullable<PostProcess>;
  67517. /**
  67518. * Post-process used to smooth the previous volumetric light post-process on the X axis
  67519. */
  67520. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  67521. /**
  67522. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  67523. */
  67524. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  67525. /**
  67526. * Post-process used to merge the volumetric light effect and the real scene color
  67527. */
  67528. volumetricLightMergePostProces: Nullable<PostProcess>;
  67529. /**
  67530. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  67531. */
  67532. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  67533. /**
  67534. * Base post-process used to calculate the average luminance of the final image for HDR
  67535. */
  67536. luminancePostProcess: Nullable<PostProcess>;
  67537. /**
  67538. * Post-processes used to create down sample post-processes in order to get
  67539. * the average luminance of the final image for HDR
  67540. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  67541. */
  67542. luminanceDownSamplePostProcesses: PostProcess[];
  67543. /**
  67544. * Post-process used to create a HDR effect (light adaptation)
  67545. */
  67546. hdrPostProcess: Nullable<PostProcess>;
  67547. /**
  67548. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  67549. */
  67550. textureAdderFinalPostProcess: Nullable<PostProcess>;
  67551. /**
  67552. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  67553. */
  67554. lensFlareFinalPostProcess: Nullable<PostProcess>;
  67555. /**
  67556. * Post-process used to merge the final HDR post-process and the real scene color
  67557. */
  67558. hdrFinalPostProcess: Nullable<PostProcess>;
  67559. /**
  67560. * Post-process used to create a lens flare effect
  67561. */
  67562. lensFlarePostProcess: Nullable<PostProcess>;
  67563. /**
  67564. * Post-process that merges the result of the lens flare post-process and the real scene color
  67565. */
  67566. lensFlareComposePostProcess: Nullable<PostProcess>;
  67567. /**
  67568. * Post-process used to create a motion blur effect
  67569. */
  67570. motionBlurPostProcess: Nullable<PostProcess>;
  67571. /**
  67572. * Post-process used to create a depth of field effect
  67573. */
  67574. depthOfFieldPostProcess: Nullable<PostProcess>;
  67575. /**
  67576. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  67577. */
  67578. fxaaPostProcess: Nullable<FxaaPostProcess>;
  67579. /**
  67580. * Represents the brightness threshold in order to configure the illuminated surfaces
  67581. */
  67582. brightThreshold: number;
  67583. /**
  67584. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  67585. */
  67586. blurWidth: number;
  67587. /**
  67588. * Sets if the blur for highlighted surfaces must be only horizontal
  67589. */
  67590. horizontalBlur: boolean;
  67591. /**
  67592. * Gets the overall exposure used by the pipeline
  67593. */
  67594. get exposure(): number;
  67595. /**
  67596. * Sets the overall exposure used by the pipeline
  67597. */
  67598. set exposure(value: number);
  67599. /**
  67600. * Texture used typically to simulate "dirty" on camera lens
  67601. */
  67602. lensTexture: Nullable<Texture>;
  67603. /**
  67604. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  67605. */
  67606. volumetricLightCoefficient: number;
  67607. /**
  67608. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  67609. */
  67610. volumetricLightPower: number;
  67611. /**
  67612. * Used the set the blur intensity to smooth the volumetric lights
  67613. */
  67614. volumetricLightBlurScale: number;
  67615. /**
  67616. * Light (spot or directional) used to generate the volumetric lights rays
  67617. * The source light must have a shadow generate so the pipeline can get its
  67618. * depth map
  67619. */
  67620. sourceLight: Nullable<SpotLight | DirectionalLight>;
  67621. /**
  67622. * For eye adaptation, represents the minimum luminance the eye can see
  67623. */
  67624. hdrMinimumLuminance: number;
  67625. /**
  67626. * For eye adaptation, represents the decrease luminance speed
  67627. */
  67628. hdrDecreaseRate: number;
  67629. /**
  67630. * For eye adaptation, represents the increase luminance speed
  67631. */
  67632. hdrIncreaseRate: number;
  67633. /**
  67634. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  67635. */
  67636. get hdrAutoExposure(): boolean;
  67637. /**
  67638. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  67639. */
  67640. set hdrAutoExposure(value: boolean);
  67641. /**
  67642. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  67643. */
  67644. lensColorTexture: Nullable<Texture>;
  67645. /**
  67646. * The overall strengh for the lens flare effect
  67647. */
  67648. lensFlareStrength: number;
  67649. /**
  67650. * Dispersion coefficient for lens flare ghosts
  67651. */
  67652. lensFlareGhostDispersal: number;
  67653. /**
  67654. * Main lens flare halo width
  67655. */
  67656. lensFlareHaloWidth: number;
  67657. /**
  67658. * Based on the lens distortion effect, defines how much the lens flare result
  67659. * is distorted
  67660. */
  67661. lensFlareDistortionStrength: number;
  67662. /**
  67663. * Configures the blur intensity used for for lens flare (halo)
  67664. */
  67665. lensFlareBlurWidth: number;
  67666. /**
  67667. * Lens star texture must be used to simulate rays on the flares and is available
  67668. * in the documentation
  67669. */
  67670. lensStarTexture: Nullable<Texture>;
  67671. /**
  67672. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  67673. * flare effect by taking account of the dirt texture
  67674. */
  67675. lensFlareDirtTexture: Nullable<Texture>;
  67676. /**
  67677. * Represents the focal length for the depth of field effect
  67678. */
  67679. depthOfFieldDistance: number;
  67680. /**
  67681. * Represents the blur intensity for the blurred part of the depth of field effect
  67682. */
  67683. depthOfFieldBlurWidth: number;
  67684. /**
  67685. * Gets how much the image is blurred by the movement while using the motion blur post-process
  67686. */
  67687. get motionStrength(): number;
  67688. /**
  67689. * Sets how much the image is blurred by the movement while using the motion blur post-process
  67690. */
  67691. set motionStrength(strength: number);
  67692. /**
  67693. * Gets wether or not the motion blur post-process is object based or screen based.
  67694. */
  67695. get objectBasedMotionBlur(): boolean;
  67696. /**
  67697. * Sets wether or not the motion blur post-process should be object based or screen based
  67698. */
  67699. set objectBasedMotionBlur(value: boolean);
  67700. /**
  67701. * List of animations for the pipeline (IAnimatable implementation)
  67702. */
  67703. animations: Animation[];
  67704. /**
  67705. * Private members
  67706. */
  67707. private _scene;
  67708. private _currentDepthOfFieldSource;
  67709. private _basePostProcess;
  67710. private _fixedExposure;
  67711. private _currentExposure;
  67712. private _hdrAutoExposure;
  67713. private _hdrCurrentLuminance;
  67714. private _motionStrength;
  67715. private _isObjectBasedMotionBlur;
  67716. private _floatTextureType;
  67717. private _camerasToBeAttached;
  67718. private _ratio;
  67719. private _bloomEnabled;
  67720. private _depthOfFieldEnabled;
  67721. private _vlsEnabled;
  67722. private _lensFlareEnabled;
  67723. private _hdrEnabled;
  67724. private _motionBlurEnabled;
  67725. private _fxaaEnabled;
  67726. private _motionBlurSamples;
  67727. private _volumetricLightStepsCount;
  67728. private _samples;
  67729. /**
  67730. * @ignore
  67731. * Specifies if the bloom pipeline is enabled
  67732. */
  67733. get BloomEnabled(): boolean;
  67734. set BloomEnabled(enabled: boolean);
  67735. /**
  67736. * @ignore
  67737. * Specifies if the depth of field pipeline is enabed
  67738. */
  67739. get DepthOfFieldEnabled(): boolean;
  67740. set DepthOfFieldEnabled(enabled: boolean);
  67741. /**
  67742. * @ignore
  67743. * Specifies if the lens flare pipeline is enabed
  67744. */
  67745. get LensFlareEnabled(): boolean;
  67746. set LensFlareEnabled(enabled: boolean);
  67747. /**
  67748. * @ignore
  67749. * Specifies if the HDR pipeline is enabled
  67750. */
  67751. get HDREnabled(): boolean;
  67752. set HDREnabled(enabled: boolean);
  67753. /**
  67754. * @ignore
  67755. * Specifies if the volumetric lights scattering effect is enabled
  67756. */
  67757. get VLSEnabled(): boolean;
  67758. set VLSEnabled(enabled: boolean);
  67759. /**
  67760. * @ignore
  67761. * Specifies if the motion blur effect is enabled
  67762. */
  67763. get MotionBlurEnabled(): boolean;
  67764. set MotionBlurEnabled(enabled: boolean);
  67765. /**
  67766. * Specifies if anti-aliasing is enabled
  67767. */
  67768. get fxaaEnabled(): boolean;
  67769. set fxaaEnabled(enabled: boolean);
  67770. /**
  67771. * Specifies the number of steps used to calculate the volumetric lights
  67772. * Typically in interval [50, 200]
  67773. */
  67774. get volumetricLightStepsCount(): number;
  67775. set volumetricLightStepsCount(count: number);
  67776. /**
  67777. * Specifies the number of samples used for the motion blur effect
  67778. * Typically in interval [16, 64]
  67779. */
  67780. get motionBlurSamples(): number;
  67781. set motionBlurSamples(samples: number);
  67782. /**
  67783. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  67784. */
  67785. get samples(): number;
  67786. set samples(sampleCount: number);
  67787. /**
  67788. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  67789. * @constructor
  67790. * @param name The rendering pipeline name
  67791. * @param scene The scene linked to this pipeline
  67792. * @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)
  67793. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  67794. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67795. */
  67796. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  67797. private _buildPipeline;
  67798. private _createDownSampleX4PostProcess;
  67799. private _createBrightPassPostProcess;
  67800. private _createBlurPostProcesses;
  67801. private _createTextureAdderPostProcess;
  67802. private _createVolumetricLightPostProcess;
  67803. private _createLuminancePostProcesses;
  67804. private _createHdrPostProcess;
  67805. private _createLensFlarePostProcess;
  67806. private _createDepthOfFieldPostProcess;
  67807. private _createMotionBlurPostProcess;
  67808. private _getDepthTexture;
  67809. private _disposePostProcesses;
  67810. /**
  67811. * Dispose of the pipeline and stop all post processes
  67812. */
  67813. dispose(): void;
  67814. /**
  67815. * Serialize the rendering pipeline (Used when exporting)
  67816. * @returns the serialized object
  67817. */
  67818. serialize(): any;
  67819. /**
  67820. * Parse the serialized pipeline
  67821. * @param source Source pipeline.
  67822. * @param scene The scene to load the pipeline to.
  67823. * @param rootUrl The URL of the serialized pipeline.
  67824. * @returns An instantiated pipeline from the serialized object.
  67825. */
  67826. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  67827. /**
  67828. * Luminance steps
  67829. */
  67830. static LuminanceSteps: number;
  67831. }
  67832. }
  67833. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  67834. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  67835. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  67836. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  67837. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  67838. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  67839. }
  67840. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  67841. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  67842. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67843. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67844. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  67845. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67846. }
  67847. declare module "babylonjs/Shaders/tonemap.fragment" {
  67848. /** @hidden */
  67849. export var tonemapPixelShader: {
  67850. name: string;
  67851. shader: string;
  67852. };
  67853. }
  67854. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  67855. import { Camera } from "babylonjs/Cameras/camera";
  67856. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67857. import "babylonjs/Shaders/tonemap.fragment";
  67858. import { Engine } from "babylonjs/Engines/engine";
  67859. /** Defines operator used for tonemapping */
  67860. export enum TonemappingOperator {
  67861. /** Hable */
  67862. Hable = 0,
  67863. /** Reinhard */
  67864. Reinhard = 1,
  67865. /** HejiDawson */
  67866. HejiDawson = 2,
  67867. /** Photographic */
  67868. Photographic = 3
  67869. }
  67870. /**
  67871. * Defines a post process to apply tone mapping
  67872. */
  67873. export class TonemapPostProcess extends PostProcess {
  67874. private _operator;
  67875. /** Defines the required exposure adjustement */
  67876. exposureAdjustment: number;
  67877. /**
  67878. * Creates a new TonemapPostProcess
  67879. * @param name defines the name of the postprocess
  67880. * @param _operator defines the operator to use
  67881. * @param exposureAdjustment defines the required exposure adjustement
  67882. * @param camera defines the camera to use (can be null)
  67883. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  67884. * @param engine defines the hosting engine (can be ignore if camera is set)
  67885. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  67886. */
  67887. constructor(name: string, _operator: TonemappingOperator,
  67888. /** Defines the required exposure adjustement */
  67889. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  67890. }
  67891. }
  67892. declare module "babylonjs/Shaders/depth.vertex" {
  67893. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67894. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67895. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67896. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67897. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67898. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67899. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67900. /** @hidden */
  67901. export var depthVertexShader: {
  67902. name: string;
  67903. shader: string;
  67904. };
  67905. }
  67906. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  67907. /** @hidden */
  67908. export var volumetricLightScatteringPixelShader: {
  67909. name: string;
  67910. shader: string;
  67911. };
  67912. }
  67913. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  67914. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67915. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67916. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67917. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67918. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67919. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67920. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67921. /** @hidden */
  67922. export var volumetricLightScatteringPassVertexShader: {
  67923. name: string;
  67924. shader: string;
  67925. };
  67926. }
  67927. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  67928. /** @hidden */
  67929. export var volumetricLightScatteringPassPixelShader: {
  67930. name: string;
  67931. shader: string;
  67932. };
  67933. }
  67934. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  67935. import { Vector3 } from "babylonjs/Maths/math.vector";
  67936. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67937. import { Mesh } from "babylonjs/Meshes/mesh";
  67938. import { Camera } from "babylonjs/Cameras/camera";
  67939. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67940. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67941. import { Scene } from "babylonjs/scene";
  67942. import "babylonjs/Meshes/Builders/planeBuilder";
  67943. import "babylonjs/Shaders/depth.vertex";
  67944. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  67945. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  67946. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  67947. import { Engine } from "babylonjs/Engines/engine";
  67948. /**
  67949. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  67950. */
  67951. export class VolumetricLightScatteringPostProcess extends PostProcess {
  67952. private _volumetricLightScatteringPass;
  67953. private _volumetricLightScatteringRTT;
  67954. private _viewPort;
  67955. private _screenCoordinates;
  67956. private _cachedDefines;
  67957. /**
  67958. * If not undefined, the mesh position is computed from the attached node position
  67959. */
  67960. attachedNode: {
  67961. position: Vector3;
  67962. };
  67963. /**
  67964. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  67965. */
  67966. customMeshPosition: Vector3;
  67967. /**
  67968. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  67969. */
  67970. useCustomMeshPosition: boolean;
  67971. /**
  67972. * If the post-process should inverse the light scattering direction
  67973. */
  67974. invert: boolean;
  67975. /**
  67976. * The internal mesh used by the post-process
  67977. */
  67978. mesh: Mesh;
  67979. /**
  67980. * @hidden
  67981. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  67982. */
  67983. get useDiffuseColor(): boolean;
  67984. set useDiffuseColor(useDiffuseColor: boolean);
  67985. /**
  67986. * Array containing the excluded meshes not rendered in the internal pass
  67987. */
  67988. excludedMeshes: AbstractMesh[];
  67989. /**
  67990. * Controls the overall intensity of the post-process
  67991. */
  67992. exposure: number;
  67993. /**
  67994. * Dissipates each sample's contribution in range [0, 1]
  67995. */
  67996. decay: number;
  67997. /**
  67998. * Controls the overall intensity of each sample
  67999. */
  68000. weight: number;
  68001. /**
  68002. * Controls the density of each sample
  68003. */
  68004. density: number;
  68005. /**
  68006. * @constructor
  68007. * @param name The post-process name
  68008. * @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)
  68009. * @param camera The camera that the post-process will be attached to
  68010. * @param mesh The mesh used to create the light scattering
  68011. * @param samples The post-process quality, default 100
  68012. * @param samplingModeThe post-process filtering mode
  68013. * @param engine The babylon engine
  68014. * @param reusable If the post-process is reusable
  68015. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  68016. */
  68017. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  68018. /**
  68019. * Returns the string "VolumetricLightScatteringPostProcess"
  68020. * @returns "VolumetricLightScatteringPostProcess"
  68021. */
  68022. getClassName(): string;
  68023. private _isReady;
  68024. /**
  68025. * Sets the new light position for light scattering effect
  68026. * @param position The new custom light position
  68027. */
  68028. setCustomMeshPosition(position: Vector3): void;
  68029. /**
  68030. * Returns the light position for light scattering effect
  68031. * @return Vector3 The custom light position
  68032. */
  68033. getCustomMeshPosition(): Vector3;
  68034. /**
  68035. * Disposes the internal assets and detaches the post-process from the camera
  68036. */
  68037. dispose(camera: Camera): void;
  68038. /**
  68039. * Returns the render target texture used by the post-process
  68040. * @return the render target texture used by the post-process
  68041. */
  68042. getPass(): RenderTargetTexture;
  68043. private _meshExcluded;
  68044. private _createPass;
  68045. private _updateMeshScreenCoordinates;
  68046. /**
  68047. * Creates a default mesh for the Volumeric Light Scattering post-process
  68048. * @param name The mesh name
  68049. * @param scene The scene where to create the mesh
  68050. * @return the default mesh
  68051. */
  68052. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  68053. }
  68054. }
  68055. declare module "babylonjs/PostProcesses/index" {
  68056. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  68057. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  68058. export * from "babylonjs/PostProcesses/bloomEffect";
  68059. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  68060. export * from "babylonjs/PostProcesses/blurPostProcess";
  68061. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68062. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  68063. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  68064. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  68065. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  68066. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  68067. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  68068. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  68069. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  68070. export * from "babylonjs/PostProcesses/filterPostProcess";
  68071. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  68072. export * from "babylonjs/PostProcesses/grainPostProcess";
  68073. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  68074. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68075. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  68076. export * from "babylonjs/PostProcesses/passPostProcess";
  68077. export * from "babylonjs/PostProcesses/postProcess";
  68078. export * from "babylonjs/PostProcesses/postProcessManager";
  68079. export * from "babylonjs/PostProcesses/refractionPostProcess";
  68080. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  68081. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  68082. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  68083. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  68084. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  68085. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  68086. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  68087. }
  68088. declare module "babylonjs/Probes/index" {
  68089. export * from "babylonjs/Probes/reflectionProbe";
  68090. }
  68091. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  68092. import { Scene } from "babylonjs/scene";
  68093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68094. import { SmartArray } from "babylonjs/Misc/smartArray";
  68095. import { ISceneComponent } from "babylonjs/sceneComponent";
  68096. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  68097. import "babylonjs/Meshes/Builders/boxBuilder";
  68098. import "babylonjs/Shaders/color.fragment";
  68099. import "babylonjs/Shaders/color.vertex";
  68100. import { Color3 } from "babylonjs/Maths/math.color";
  68101. module "babylonjs/scene" {
  68102. interface Scene {
  68103. /** @hidden (Backing field) */
  68104. _boundingBoxRenderer: BoundingBoxRenderer;
  68105. /** @hidden (Backing field) */
  68106. _forceShowBoundingBoxes: boolean;
  68107. /**
  68108. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  68109. */
  68110. forceShowBoundingBoxes: boolean;
  68111. /**
  68112. * Gets the bounding box renderer associated with the scene
  68113. * @returns a BoundingBoxRenderer
  68114. */
  68115. getBoundingBoxRenderer(): BoundingBoxRenderer;
  68116. }
  68117. }
  68118. module "babylonjs/Meshes/abstractMesh" {
  68119. interface AbstractMesh {
  68120. /** @hidden (Backing field) */
  68121. _showBoundingBox: boolean;
  68122. /**
  68123. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  68124. */
  68125. showBoundingBox: boolean;
  68126. }
  68127. }
  68128. /**
  68129. * Component responsible of rendering the bounding box of the meshes in a scene.
  68130. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  68131. */
  68132. export class BoundingBoxRenderer implements ISceneComponent {
  68133. /**
  68134. * The component name helpfull to identify the component in the list of scene components.
  68135. */
  68136. readonly name: string;
  68137. /**
  68138. * The scene the component belongs to.
  68139. */
  68140. scene: Scene;
  68141. /**
  68142. * Color of the bounding box lines placed in front of an object
  68143. */
  68144. frontColor: Color3;
  68145. /**
  68146. * Color of the bounding box lines placed behind an object
  68147. */
  68148. backColor: Color3;
  68149. /**
  68150. * Defines if the renderer should show the back lines or not
  68151. */
  68152. showBackLines: boolean;
  68153. /**
  68154. * @hidden
  68155. */
  68156. renderList: SmartArray<BoundingBox>;
  68157. private _colorShader;
  68158. private _vertexBuffers;
  68159. private _indexBuffer;
  68160. private _fillIndexBuffer;
  68161. private _fillIndexData;
  68162. /**
  68163. * Instantiates a new bounding box renderer in a scene.
  68164. * @param scene the scene the renderer renders in
  68165. */
  68166. constructor(scene: Scene);
  68167. /**
  68168. * Registers the component in a given scene
  68169. */
  68170. register(): void;
  68171. private _evaluateSubMesh;
  68172. private _activeMesh;
  68173. private _prepareRessources;
  68174. private _createIndexBuffer;
  68175. /**
  68176. * Rebuilds the elements related to this component in case of
  68177. * context lost for instance.
  68178. */
  68179. rebuild(): void;
  68180. /**
  68181. * @hidden
  68182. */
  68183. reset(): void;
  68184. /**
  68185. * Render the bounding boxes of a specific rendering group
  68186. * @param renderingGroupId defines the rendering group to render
  68187. */
  68188. render(renderingGroupId: number): void;
  68189. /**
  68190. * In case of occlusion queries, we can render the occlusion bounding box through this method
  68191. * @param mesh Define the mesh to render the occlusion bounding box for
  68192. */
  68193. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  68194. /**
  68195. * Dispose and release the resources attached to this renderer.
  68196. */
  68197. dispose(): void;
  68198. }
  68199. }
  68200. declare module "babylonjs/Shaders/depth.fragment" {
  68201. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  68202. /** @hidden */
  68203. export var depthPixelShader: {
  68204. name: string;
  68205. shader: string;
  68206. };
  68207. }
  68208. declare module "babylonjs/Rendering/depthRenderer" {
  68209. import { Nullable } from "babylonjs/types";
  68210. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68211. import { Scene } from "babylonjs/scene";
  68212. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68213. import { Camera } from "babylonjs/Cameras/camera";
  68214. import "babylonjs/Shaders/depth.fragment";
  68215. import "babylonjs/Shaders/depth.vertex";
  68216. /**
  68217. * This represents a depth renderer in Babylon.
  68218. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  68219. */
  68220. export class DepthRenderer {
  68221. private _scene;
  68222. private _depthMap;
  68223. private _effect;
  68224. private readonly _storeNonLinearDepth;
  68225. private readonly _clearColor;
  68226. /** Get if the depth renderer is using packed depth or not */
  68227. readonly isPacked: boolean;
  68228. private _cachedDefines;
  68229. private _camera;
  68230. /**
  68231. * Specifiess that the depth renderer will only be used within
  68232. * the camera it is created for.
  68233. * This can help forcing its rendering during the camera processing.
  68234. */
  68235. useOnlyInActiveCamera: boolean;
  68236. /** @hidden */
  68237. static _SceneComponentInitialization: (scene: Scene) => void;
  68238. /**
  68239. * Instantiates a depth renderer
  68240. * @param scene The scene the renderer belongs to
  68241. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  68242. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  68243. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  68244. */
  68245. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  68246. /**
  68247. * Creates the depth rendering effect and checks if the effect is ready.
  68248. * @param subMesh The submesh to be used to render the depth map of
  68249. * @param useInstances If multiple world instances should be used
  68250. * @returns if the depth renderer is ready to render the depth map
  68251. */
  68252. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68253. /**
  68254. * Gets the texture which the depth map will be written to.
  68255. * @returns The depth map texture
  68256. */
  68257. getDepthMap(): RenderTargetTexture;
  68258. /**
  68259. * Disposes of the depth renderer.
  68260. */
  68261. dispose(): void;
  68262. }
  68263. }
  68264. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  68265. import { Nullable } from "babylonjs/types";
  68266. import { Scene } from "babylonjs/scene";
  68267. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  68268. import { Camera } from "babylonjs/Cameras/camera";
  68269. import { ISceneComponent } from "babylonjs/sceneComponent";
  68270. module "babylonjs/scene" {
  68271. interface Scene {
  68272. /** @hidden (Backing field) */
  68273. _depthRenderer: {
  68274. [id: string]: DepthRenderer;
  68275. };
  68276. /**
  68277. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  68278. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  68279. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  68280. * @returns the created depth renderer
  68281. */
  68282. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  68283. /**
  68284. * Disables a depth renderer for a given camera
  68285. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  68286. */
  68287. disableDepthRenderer(camera?: Nullable<Camera>): void;
  68288. }
  68289. }
  68290. /**
  68291. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  68292. * in several rendering techniques.
  68293. */
  68294. export class DepthRendererSceneComponent implements ISceneComponent {
  68295. /**
  68296. * The component name helpfull to identify the component in the list of scene components.
  68297. */
  68298. readonly name: string;
  68299. /**
  68300. * The scene the component belongs to.
  68301. */
  68302. scene: Scene;
  68303. /**
  68304. * Creates a new instance of the component for the given scene
  68305. * @param scene Defines the scene to register the component in
  68306. */
  68307. constructor(scene: Scene);
  68308. /**
  68309. * Registers the component in a given scene
  68310. */
  68311. register(): void;
  68312. /**
  68313. * Rebuilds the elements related to this component in case of
  68314. * context lost for instance.
  68315. */
  68316. rebuild(): void;
  68317. /**
  68318. * Disposes the component and the associated ressources
  68319. */
  68320. dispose(): void;
  68321. private _gatherRenderTargets;
  68322. private _gatherActiveCameraRenderTargets;
  68323. }
  68324. }
  68325. declare module "babylonjs/Shaders/outline.fragment" {
  68326. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  68327. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  68328. /** @hidden */
  68329. export var outlinePixelShader: {
  68330. name: string;
  68331. shader: string;
  68332. };
  68333. }
  68334. declare module "babylonjs/Shaders/outline.vertex" {
  68335. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  68336. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  68337. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  68338. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  68339. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  68340. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  68341. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  68342. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  68343. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  68344. /** @hidden */
  68345. export var outlineVertexShader: {
  68346. name: string;
  68347. shader: string;
  68348. };
  68349. }
  68350. declare module "babylonjs/Rendering/outlineRenderer" {
  68351. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68352. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  68353. import { Scene } from "babylonjs/scene";
  68354. import { ISceneComponent } from "babylonjs/sceneComponent";
  68355. import "babylonjs/Shaders/outline.fragment";
  68356. import "babylonjs/Shaders/outline.vertex";
  68357. module "babylonjs/scene" {
  68358. interface Scene {
  68359. /** @hidden */
  68360. _outlineRenderer: OutlineRenderer;
  68361. /**
  68362. * Gets the outline renderer associated with the scene
  68363. * @returns a OutlineRenderer
  68364. */
  68365. getOutlineRenderer(): OutlineRenderer;
  68366. }
  68367. }
  68368. module "babylonjs/Meshes/abstractMesh" {
  68369. interface AbstractMesh {
  68370. /** @hidden (Backing field) */
  68371. _renderOutline: boolean;
  68372. /**
  68373. * Gets or sets a boolean indicating if the outline must be rendered as well
  68374. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  68375. */
  68376. renderOutline: boolean;
  68377. /** @hidden (Backing field) */
  68378. _renderOverlay: boolean;
  68379. /**
  68380. * Gets or sets a boolean indicating if the overlay must be rendered as well
  68381. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  68382. */
  68383. renderOverlay: boolean;
  68384. }
  68385. }
  68386. /**
  68387. * This class is responsible to draw bothe outline/overlay of meshes.
  68388. * It should not be used directly but through the available method on mesh.
  68389. */
  68390. export class OutlineRenderer implements ISceneComponent {
  68391. /**
  68392. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  68393. */
  68394. private static _StencilReference;
  68395. /**
  68396. * The name of the component. Each component must have a unique name.
  68397. */
  68398. name: string;
  68399. /**
  68400. * The scene the component belongs to.
  68401. */
  68402. scene: Scene;
  68403. /**
  68404. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  68405. */
  68406. zOffset: number;
  68407. private _engine;
  68408. private _effect;
  68409. private _cachedDefines;
  68410. private _savedDepthWrite;
  68411. /**
  68412. * Instantiates a new outline renderer. (There could be only one per scene).
  68413. * @param scene Defines the scene it belongs to
  68414. */
  68415. constructor(scene: Scene);
  68416. /**
  68417. * Register the component to one instance of a scene.
  68418. */
  68419. register(): void;
  68420. /**
  68421. * Rebuilds the elements related to this component in case of
  68422. * context lost for instance.
  68423. */
  68424. rebuild(): void;
  68425. /**
  68426. * Disposes the component and the associated ressources.
  68427. */
  68428. dispose(): void;
  68429. /**
  68430. * Renders the outline in the canvas.
  68431. * @param subMesh Defines the sumesh to render
  68432. * @param batch Defines the batch of meshes in case of instances
  68433. * @param useOverlay Defines if the rendering is for the overlay or the outline
  68434. */
  68435. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  68436. /**
  68437. * Returns whether or not the outline renderer is ready for a given submesh.
  68438. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  68439. * @param subMesh Defines the submesh to check readyness for
  68440. * @param useInstances Defines wheter wee are trying to render instances or not
  68441. * @returns true if ready otherwise false
  68442. */
  68443. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68444. private _beforeRenderingMesh;
  68445. private _afterRenderingMesh;
  68446. }
  68447. }
  68448. declare module "babylonjs/Rendering/index" {
  68449. export * from "babylonjs/Rendering/boundingBoxRenderer";
  68450. export * from "babylonjs/Rendering/depthRenderer";
  68451. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  68452. export * from "babylonjs/Rendering/edgesRenderer";
  68453. export * from "babylonjs/Rendering/geometryBufferRenderer";
  68454. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68455. export * from "babylonjs/Rendering/outlineRenderer";
  68456. export * from "babylonjs/Rendering/renderingGroup";
  68457. export * from "babylonjs/Rendering/renderingManager";
  68458. export * from "babylonjs/Rendering/utilityLayerRenderer";
  68459. }
  68460. declare module "babylonjs/Sprites/ISprites" {
  68461. /**
  68462. * Defines the basic options interface of a Sprite Frame Source Size.
  68463. */
  68464. export interface ISpriteJSONSpriteSourceSize {
  68465. /**
  68466. * number of the original width of the Frame
  68467. */
  68468. w: number;
  68469. /**
  68470. * number of the original height of the Frame
  68471. */
  68472. h: number;
  68473. }
  68474. /**
  68475. * Defines the basic options interface of a Sprite Frame Data.
  68476. */
  68477. export interface ISpriteJSONSpriteFrameData {
  68478. /**
  68479. * number of the x offset of the Frame
  68480. */
  68481. x: number;
  68482. /**
  68483. * number of the y offset of the Frame
  68484. */
  68485. y: number;
  68486. /**
  68487. * number of the width of the Frame
  68488. */
  68489. w: number;
  68490. /**
  68491. * number of the height of the Frame
  68492. */
  68493. h: number;
  68494. }
  68495. /**
  68496. * Defines the basic options interface of a JSON Sprite.
  68497. */
  68498. export interface ISpriteJSONSprite {
  68499. /**
  68500. * string name of the Frame
  68501. */
  68502. filename: string;
  68503. /**
  68504. * ISpriteJSONSpriteFrame basic object of the frame data
  68505. */
  68506. frame: ISpriteJSONSpriteFrameData;
  68507. /**
  68508. * boolean to flag is the frame was rotated.
  68509. */
  68510. rotated: boolean;
  68511. /**
  68512. * boolean to flag is the frame was trimmed.
  68513. */
  68514. trimmed: boolean;
  68515. /**
  68516. * ISpriteJSONSpriteFrame basic object of the source data
  68517. */
  68518. spriteSourceSize: ISpriteJSONSpriteFrameData;
  68519. /**
  68520. * ISpriteJSONSpriteFrame basic object of the source data
  68521. */
  68522. sourceSize: ISpriteJSONSpriteSourceSize;
  68523. }
  68524. /**
  68525. * Defines the basic options interface of a JSON atlas.
  68526. */
  68527. export interface ISpriteJSONAtlas {
  68528. /**
  68529. * Array of objects that contain the frame data.
  68530. */
  68531. frames: Array<ISpriteJSONSprite>;
  68532. /**
  68533. * object basic object containing the sprite meta data.
  68534. */
  68535. meta?: object;
  68536. }
  68537. }
  68538. declare module "babylonjs/Shaders/spriteMap.fragment" {
  68539. /** @hidden */
  68540. export var spriteMapPixelShader: {
  68541. name: string;
  68542. shader: string;
  68543. };
  68544. }
  68545. declare module "babylonjs/Shaders/spriteMap.vertex" {
  68546. /** @hidden */
  68547. export var spriteMapVertexShader: {
  68548. name: string;
  68549. shader: string;
  68550. };
  68551. }
  68552. declare module "babylonjs/Sprites/spriteMap" {
  68553. import { IDisposable, Scene } from "babylonjs/scene";
  68554. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  68555. import { Texture } from "babylonjs/Materials/Textures/texture";
  68556. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  68557. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  68558. import "babylonjs/Meshes/Builders/planeBuilder";
  68559. import "babylonjs/Shaders/spriteMap.fragment";
  68560. import "babylonjs/Shaders/spriteMap.vertex";
  68561. /**
  68562. * Defines the basic options interface of a SpriteMap
  68563. */
  68564. export interface ISpriteMapOptions {
  68565. /**
  68566. * Vector2 of the number of cells in the grid.
  68567. */
  68568. stageSize?: Vector2;
  68569. /**
  68570. * Vector2 of the size of the output plane in World Units.
  68571. */
  68572. outputSize?: Vector2;
  68573. /**
  68574. * Vector3 of the position of the output plane in World Units.
  68575. */
  68576. outputPosition?: Vector3;
  68577. /**
  68578. * Vector3 of the rotation of the output plane.
  68579. */
  68580. outputRotation?: Vector3;
  68581. /**
  68582. * number of layers that the system will reserve in resources.
  68583. */
  68584. layerCount?: number;
  68585. /**
  68586. * number of max animation frames a single cell will reserve in resources.
  68587. */
  68588. maxAnimationFrames?: number;
  68589. /**
  68590. * number cell index of the base tile when the system compiles.
  68591. */
  68592. baseTile?: number;
  68593. /**
  68594. * boolean flip the sprite after its been repositioned by the framing data.
  68595. */
  68596. flipU?: boolean;
  68597. /**
  68598. * Vector3 scalar of the global RGB values of the SpriteMap.
  68599. */
  68600. colorMultiply?: Vector3;
  68601. }
  68602. /**
  68603. * Defines the IDisposable interface in order to be cleanable from resources.
  68604. */
  68605. export interface ISpriteMap extends IDisposable {
  68606. /**
  68607. * String name of the SpriteMap.
  68608. */
  68609. name: string;
  68610. /**
  68611. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  68612. */
  68613. atlasJSON: ISpriteJSONAtlas;
  68614. /**
  68615. * Texture of the SpriteMap.
  68616. */
  68617. spriteSheet: Texture;
  68618. /**
  68619. * The parameters to initialize the SpriteMap with.
  68620. */
  68621. options: ISpriteMapOptions;
  68622. }
  68623. /**
  68624. * Class used to manage a grid restricted sprite deployment on an Output plane.
  68625. */
  68626. export class SpriteMap implements ISpriteMap {
  68627. /** The Name of the spriteMap */
  68628. name: string;
  68629. /** The JSON file with the frame and meta data */
  68630. atlasJSON: ISpriteJSONAtlas;
  68631. /** The systems Sprite Sheet Texture */
  68632. spriteSheet: Texture;
  68633. /** Arguments passed with the Constructor */
  68634. options: ISpriteMapOptions;
  68635. /** Public Sprite Storage array, parsed from atlasJSON */
  68636. sprites: Array<ISpriteJSONSprite>;
  68637. /** Returns the Number of Sprites in the System */
  68638. get spriteCount(): number;
  68639. /** Returns the Position of Output Plane*/
  68640. get position(): Vector3;
  68641. /** Returns the Position of Output Plane*/
  68642. set position(v: Vector3);
  68643. /** Returns the Rotation of Output Plane*/
  68644. get rotation(): Vector3;
  68645. /** Returns the Rotation of Output Plane*/
  68646. set rotation(v: Vector3);
  68647. /** Sets the AnimationMap*/
  68648. get animationMap(): RawTexture;
  68649. /** Sets the AnimationMap*/
  68650. set animationMap(v: RawTexture);
  68651. /** Scene that the SpriteMap was created in */
  68652. private _scene;
  68653. /** Texture Buffer of Float32 that holds tile frame data*/
  68654. private _frameMap;
  68655. /** Texture Buffers of Float32 that holds tileMap data*/
  68656. private _tileMaps;
  68657. /** Texture Buffer of Float32 that holds Animation Data*/
  68658. private _animationMap;
  68659. /** Custom ShaderMaterial Central to the System*/
  68660. private _material;
  68661. /** Custom ShaderMaterial Central to the System*/
  68662. private _output;
  68663. /** Systems Time Ticker*/
  68664. private _time;
  68665. /**
  68666. * Creates a new SpriteMap
  68667. * @param name defines the SpriteMaps Name
  68668. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  68669. * @param spriteSheet is the Texture that the Sprites are on.
  68670. * @param options a basic deployment configuration
  68671. * @param scene The Scene that the map is deployed on
  68672. */
  68673. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  68674. /**
  68675. * Returns tileID location
  68676. * @returns Vector2 the cell position ID
  68677. */
  68678. getTileID(): Vector2;
  68679. /**
  68680. * Gets the UV location of the mouse over the SpriteMap.
  68681. * @returns Vector2 the UV position of the mouse interaction
  68682. */
  68683. getMousePosition(): Vector2;
  68684. /**
  68685. * Creates the "frame" texture Buffer
  68686. * -------------------------------------
  68687. * Structure of frames
  68688. * "filename": "Falling-Water-2.png",
  68689. * "frame": {"x":69,"y":103,"w":24,"h":32},
  68690. * "rotated": true,
  68691. * "trimmed": true,
  68692. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  68693. * "sourceSize": {"w":32,"h":32}
  68694. * @returns RawTexture of the frameMap
  68695. */
  68696. private _createFrameBuffer;
  68697. /**
  68698. * Creates the tileMap texture Buffer
  68699. * @param buffer normally and array of numbers, or a false to generate from scratch
  68700. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  68701. * @returns RawTexture of the tileMap
  68702. */
  68703. private _createTileBuffer;
  68704. /**
  68705. * Modifies the data of the tileMaps
  68706. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  68707. * @param pos is the iVector2 Coordinates of the Tile
  68708. * @param tile The SpriteIndex of the new Tile
  68709. */
  68710. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  68711. /**
  68712. * Creates the animationMap texture Buffer
  68713. * @param buffer normally and array of numbers, or a false to generate from scratch
  68714. * @returns RawTexture of the animationMap
  68715. */
  68716. private _createTileAnimationBuffer;
  68717. /**
  68718. * Modifies the data of the animationMap
  68719. * @param cellID is the Index of the Sprite
  68720. * @param _frame is the target Animation frame
  68721. * @param toCell is the Target Index of the next frame of the animation
  68722. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  68723. * @param speed is a global scalar of the time variable on the map.
  68724. */
  68725. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  68726. /**
  68727. * Exports the .tilemaps file
  68728. */
  68729. saveTileMaps(): void;
  68730. /**
  68731. * Imports the .tilemaps file
  68732. * @param url of the .tilemaps file
  68733. */
  68734. loadTileMaps(url: string): void;
  68735. /**
  68736. * Release associated resources
  68737. */
  68738. dispose(): void;
  68739. }
  68740. }
  68741. declare module "babylonjs/Sprites/spritePackedManager" {
  68742. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  68743. import { Scene } from "babylonjs/scene";
  68744. /**
  68745. * Class used to manage multiple sprites of different sizes on the same spritesheet
  68746. * @see http://doc.babylonjs.com/babylon101/sprites
  68747. */
  68748. export class SpritePackedManager extends SpriteManager {
  68749. /** defines the packed manager's name */
  68750. name: string;
  68751. /**
  68752. * Creates a new sprite manager from a packed sprite sheet
  68753. * @param name defines the manager's name
  68754. * @param imgUrl defines the sprite sheet url
  68755. * @param capacity defines the maximum allowed number of sprites
  68756. * @param scene defines the hosting scene
  68757. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  68758. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  68759. * @param samplingMode defines the smapling mode to use with spritesheet
  68760. * @param fromPacked set to true; do not alter
  68761. */
  68762. constructor(
  68763. /** defines the packed manager's name */
  68764. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  68765. }
  68766. }
  68767. declare module "babylonjs/Sprites/index" {
  68768. export * from "babylonjs/Sprites/sprite";
  68769. export * from "babylonjs/Sprites/ISprites";
  68770. export * from "babylonjs/Sprites/spriteManager";
  68771. export * from "babylonjs/Sprites/spriteMap";
  68772. export * from "babylonjs/Sprites/spritePackedManager";
  68773. export * from "babylonjs/Sprites/spriteSceneComponent";
  68774. }
  68775. declare module "babylonjs/States/index" {
  68776. export * from "babylonjs/States/alphaCullingState";
  68777. export * from "babylonjs/States/depthCullingState";
  68778. export * from "babylonjs/States/stencilState";
  68779. }
  68780. declare module "babylonjs/Misc/assetsManager" {
  68781. import { Scene } from "babylonjs/scene";
  68782. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68783. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  68784. import { Skeleton } from "babylonjs/Bones/skeleton";
  68785. import { Observable } from "babylonjs/Misc/observable";
  68786. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68787. import { Texture } from "babylonjs/Materials/Textures/texture";
  68788. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  68789. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  68790. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  68791. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  68792. /**
  68793. * Defines the list of states available for a task inside a AssetsManager
  68794. */
  68795. export enum AssetTaskState {
  68796. /**
  68797. * Initialization
  68798. */
  68799. INIT = 0,
  68800. /**
  68801. * Running
  68802. */
  68803. RUNNING = 1,
  68804. /**
  68805. * Done
  68806. */
  68807. DONE = 2,
  68808. /**
  68809. * Error
  68810. */
  68811. ERROR = 3
  68812. }
  68813. /**
  68814. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  68815. */
  68816. export abstract class AbstractAssetTask {
  68817. /**
  68818. * Task name
  68819. */ name: string;
  68820. /**
  68821. * Callback called when the task is successful
  68822. */
  68823. onSuccess: (task: any) => void;
  68824. /**
  68825. * Callback called when the task is not successful
  68826. */
  68827. onError: (task: any, message?: string, exception?: any) => void;
  68828. /**
  68829. * Creates a new AssetsManager
  68830. * @param name defines the name of the task
  68831. */
  68832. constructor(
  68833. /**
  68834. * Task name
  68835. */ name: string);
  68836. private _isCompleted;
  68837. private _taskState;
  68838. private _errorObject;
  68839. /**
  68840. * Get if the task is completed
  68841. */
  68842. get isCompleted(): boolean;
  68843. /**
  68844. * Gets the current state of the task
  68845. */
  68846. get taskState(): AssetTaskState;
  68847. /**
  68848. * Gets the current error object (if task is in error)
  68849. */
  68850. get errorObject(): {
  68851. message?: string;
  68852. exception?: any;
  68853. };
  68854. /**
  68855. * Internal only
  68856. * @hidden
  68857. */
  68858. _setErrorObject(message?: string, exception?: any): void;
  68859. /**
  68860. * Execute the current task
  68861. * @param scene defines the scene where you want your assets to be loaded
  68862. * @param onSuccess is a callback called when the task is successfully executed
  68863. * @param onError is a callback called if an error occurs
  68864. */
  68865. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68866. /**
  68867. * Execute the current task
  68868. * @param scene defines the scene where you want your assets to be loaded
  68869. * @param onSuccess is a callback called when the task is successfully executed
  68870. * @param onError is a callback called if an error occurs
  68871. */
  68872. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68873. /**
  68874. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  68875. * This can be used with failed tasks that have the reason for failure fixed.
  68876. */
  68877. reset(): void;
  68878. private onErrorCallback;
  68879. private onDoneCallback;
  68880. }
  68881. /**
  68882. * Define the interface used by progress events raised during assets loading
  68883. */
  68884. export interface IAssetsProgressEvent {
  68885. /**
  68886. * Defines the number of remaining tasks to process
  68887. */
  68888. remainingCount: number;
  68889. /**
  68890. * Defines the total number of tasks
  68891. */
  68892. totalCount: number;
  68893. /**
  68894. * Defines the task that was just processed
  68895. */
  68896. task: AbstractAssetTask;
  68897. }
  68898. /**
  68899. * Class used to share progress information about assets loading
  68900. */
  68901. export class AssetsProgressEvent implements IAssetsProgressEvent {
  68902. /**
  68903. * Defines the number of remaining tasks to process
  68904. */
  68905. remainingCount: number;
  68906. /**
  68907. * Defines the total number of tasks
  68908. */
  68909. totalCount: number;
  68910. /**
  68911. * Defines the task that was just processed
  68912. */
  68913. task: AbstractAssetTask;
  68914. /**
  68915. * Creates a AssetsProgressEvent
  68916. * @param remainingCount defines the number of remaining tasks to process
  68917. * @param totalCount defines the total number of tasks
  68918. * @param task defines the task that was just processed
  68919. */
  68920. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  68921. }
  68922. /**
  68923. * Define a task used by AssetsManager to load meshes
  68924. */
  68925. export class MeshAssetTask extends AbstractAssetTask {
  68926. /**
  68927. * Defines the name of the task
  68928. */
  68929. name: string;
  68930. /**
  68931. * Defines the list of mesh's names you want to load
  68932. */
  68933. meshesNames: any;
  68934. /**
  68935. * Defines the root url to use as a base to load your meshes and associated resources
  68936. */
  68937. rootUrl: string;
  68938. /**
  68939. * Defines the filename of the scene to load from
  68940. */
  68941. sceneFilename: string;
  68942. /**
  68943. * Gets the list of loaded meshes
  68944. */
  68945. loadedMeshes: Array<AbstractMesh>;
  68946. /**
  68947. * Gets the list of loaded particle systems
  68948. */
  68949. loadedParticleSystems: Array<IParticleSystem>;
  68950. /**
  68951. * Gets the list of loaded skeletons
  68952. */
  68953. loadedSkeletons: Array<Skeleton>;
  68954. /**
  68955. * Gets the list of loaded animation groups
  68956. */
  68957. loadedAnimationGroups: Array<AnimationGroup>;
  68958. /**
  68959. * Callback called when the task is successful
  68960. */
  68961. onSuccess: (task: MeshAssetTask) => void;
  68962. /**
  68963. * Callback called when the task is successful
  68964. */
  68965. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  68966. /**
  68967. * Creates a new MeshAssetTask
  68968. * @param name defines the name of the task
  68969. * @param meshesNames defines the list of mesh's names you want to load
  68970. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  68971. * @param sceneFilename defines the filename of the scene to load from
  68972. */
  68973. constructor(
  68974. /**
  68975. * Defines the name of the task
  68976. */
  68977. name: string,
  68978. /**
  68979. * Defines the list of mesh's names you want to load
  68980. */
  68981. meshesNames: any,
  68982. /**
  68983. * Defines the root url to use as a base to load your meshes and associated resources
  68984. */
  68985. rootUrl: string,
  68986. /**
  68987. * Defines the filename of the scene to load from
  68988. */
  68989. sceneFilename: string);
  68990. /**
  68991. * Execute the current task
  68992. * @param scene defines the scene where you want your assets to be loaded
  68993. * @param onSuccess is a callback called when the task is successfully executed
  68994. * @param onError is a callback called if an error occurs
  68995. */
  68996. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68997. }
  68998. /**
  68999. * Define a task used by AssetsManager to load text content
  69000. */
  69001. export class TextFileAssetTask extends AbstractAssetTask {
  69002. /**
  69003. * Defines the name of the task
  69004. */
  69005. name: string;
  69006. /**
  69007. * Defines the location of the file to load
  69008. */
  69009. url: string;
  69010. /**
  69011. * Gets the loaded text string
  69012. */
  69013. text: string;
  69014. /**
  69015. * Callback called when the task is successful
  69016. */
  69017. onSuccess: (task: TextFileAssetTask) => void;
  69018. /**
  69019. * Callback called when the task is successful
  69020. */
  69021. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  69022. /**
  69023. * Creates a new TextFileAssetTask object
  69024. * @param name defines the name of the task
  69025. * @param url defines the location of the file to load
  69026. */
  69027. constructor(
  69028. /**
  69029. * Defines the name of the task
  69030. */
  69031. name: string,
  69032. /**
  69033. * Defines the location of the file to load
  69034. */
  69035. url: string);
  69036. /**
  69037. * Execute the current task
  69038. * @param scene defines the scene where you want your assets to be loaded
  69039. * @param onSuccess is a callback called when the task is successfully executed
  69040. * @param onError is a callback called if an error occurs
  69041. */
  69042. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69043. }
  69044. /**
  69045. * Define a task used by AssetsManager to load binary data
  69046. */
  69047. export class BinaryFileAssetTask extends AbstractAssetTask {
  69048. /**
  69049. * Defines the name of the task
  69050. */
  69051. name: string;
  69052. /**
  69053. * Defines the location of the file to load
  69054. */
  69055. url: string;
  69056. /**
  69057. * Gets the lodaded data (as an array buffer)
  69058. */
  69059. data: ArrayBuffer;
  69060. /**
  69061. * Callback called when the task is successful
  69062. */
  69063. onSuccess: (task: BinaryFileAssetTask) => void;
  69064. /**
  69065. * Callback called when the task is successful
  69066. */
  69067. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  69068. /**
  69069. * Creates a new BinaryFileAssetTask object
  69070. * @param name defines the name of the new task
  69071. * @param url defines the location of the file to load
  69072. */
  69073. constructor(
  69074. /**
  69075. * Defines the name of the task
  69076. */
  69077. name: string,
  69078. /**
  69079. * Defines the location of the file to load
  69080. */
  69081. url: string);
  69082. /**
  69083. * Execute the current task
  69084. * @param scene defines the scene where you want your assets to be loaded
  69085. * @param onSuccess is a callback called when the task is successfully executed
  69086. * @param onError is a callback called if an error occurs
  69087. */
  69088. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69089. }
  69090. /**
  69091. * Define a task used by AssetsManager to load images
  69092. */
  69093. export class ImageAssetTask extends AbstractAssetTask {
  69094. /**
  69095. * Defines the name of the task
  69096. */
  69097. name: string;
  69098. /**
  69099. * Defines the location of the image to load
  69100. */
  69101. url: string;
  69102. /**
  69103. * Gets the loaded images
  69104. */
  69105. image: HTMLImageElement;
  69106. /**
  69107. * Callback called when the task is successful
  69108. */
  69109. onSuccess: (task: ImageAssetTask) => void;
  69110. /**
  69111. * Callback called when the task is successful
  69112. */
  69113. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  69114. /**
  69115. * Creates a new ImageAssetTask
  69116. * @param name defines the name of the task
  69117. * @param url defines the location of the image to load
  69118. */
  69119. constructor(
  69120. /**
  69121. * Defines the name of the task
  69122. */
  69123. name: string,
  69124. /**
  69125. * Defines the location of the image to load
  69126. */
  69127. url: string);
  69128. /**
  69129. * Execute the current task
  69130. * @param scene defines the scene where you want your assets to be loaded
  69131. * @param onSuccess is a callback called when the task is successfully executed
  69132. * @param onError is a callback called if an error occurs
  69133. */
  69134. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69135. }
  69136. /**
  69137. * Defines the interface used by texture loading tasks
  69138. */
  69139. export interface ITextureAssetTask<TEX extends BaseTexture> {
  69140. /**
  69141. * Gets the loaded texture
  69142. */
  69143. texture: TEX;
  69144. }
  69145. /**
  69146. * Define a task used by AssetsManager to load 2D textures
  69147. */
  69148. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  69149. /**
  69150. * Defines the name of the task
  69151. */
  69152. name: string;
  69153. /**
  69154. * Defines the location of the file to load
  69155. */
  69156. url: string;
  69157. /**
  69158. * Defines if mipmap should not be generated (default is false)
  69159. */
  69160. noMipmap?: boolean | undefined;
  69161. /**
  69162. * Defines if texture must be inverted on Y axis (default is false)
  69163. */
  69164. invertY?: boolean | undefined;
  69165. /**
  69166. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69167. */
  69168. samplingMode: number;
  69169. /**
  69170. * Gets the loaded texture
  69171. */
  69172. texture: Texture;
  69173. /**
  69174. * Callback called when the task is successful
  69175. */
  69176. onSuccess: (task: TextureAssetTask) => void;
  69177. /**
  69178. * Callback called when the task is successful
  69179. */
  69180. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  69181. /**
  69182. * Creates a new TextureAssetTask object
  69183. * @param name defines the name of the task
  69184. * @param url defines the location of the file to load
  69185. * @param noMipmap defines if mipmap should not be generated (default is false)
  69186. * @param invertY defines if texture must be inverted on Y axis (default is false)
  69187. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69188. */
  69189. constructor(
  69190. /**
  69191. * Defines the name of the task
  69192. */
  69193. name: string,
  69194. /**
  69195. * Defines the location of the file to load
  69196. */
  69197. url: string,
  69198. /**
  69199. * Defines if mipmap should not be generated (default is false)
  69200. */
  69201. noMipmap?: boolean | undefined,
  69202. /**
  69203. * Defines if texture must be inverted on Y axis (default is false)
  69204. */
  69205. invertY?: boolean | undefined,
  69206. /**
  69207. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69208. */
  69209. samplingMode?: number);
  69210. /**
  69211. * Execute the current task
  69212. * @param scene defines the scene where you want your assets to be loaded
  69213. * @param onSuccess is a callback called when the task is successfully executed
  69214. * @param onError is a callback called if an error occurs
  69215. */
  69216. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69217. }
  69218. /**
  69219. * Define a task used by AssetsManager to load cube textures
  69220. */
  69221. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  69222. /**
  69223. * Defines the name of the task
  69224. */
  69225. name: string;
  69226. /**
  69227. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69228. */
  69229. url: string;
  69230. /**
  69231. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69232. */
  69233. extensions?: string[] | undefined;
  69234. /**
  69235. * Defines if mipmaps should not be generated (default is false)
  69236. */
  69237. noMipmap?: boolean | undefined;
  69238. /**
  69239. * Defines the explicit list of files (undefined by default)
  69240. */
  69241. files?: string[] | undefined;
  69242. /**
  69243. * Gets the loaded texture
  69244. */
  69245. texture: CubeTexture;
  69246. /**
  69247. * Callback called when the task is successful
  69248. */
  69249. onSuccess: (task: CubeTextureAssetTask) => void;
  69250. /**
  69251. * Callback called when the task is successful
  69252. */
  69253. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  69254. /**
  69255. * Creates a new CubeTextureAssetTask
  69256. * @param name defines the name of the task
  69257. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69258. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69259. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69260. * @param files defines the explicit list of files (undefined by default)
  69261. */
  69262. constructor(
  69263. /**
  69264. * Defines the name of the task
  69265. */
  69266. name: string,
  69267. /**
  69268. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69269. */
  69270. url: string,
  69271. /**
  69272. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69273. */
  69274. extensions?: string[] | undefined,
  69275. /**
  69276. * Defines if mipmaps should not be generated (default is false)
  69277. */
  69278. noMipmap?: boolean | undefined,
  69279. /**
  69280. * Defines the explicit list of files (undefined by default)
  69281. */
  69282. files?: string[] | undefined);
  69283. /**
  69284. * Execute the current task
  69285. * @param scene defines the scene where you want your assets to be loaded
  69286. * @param onSuccess is a callback called when the task is successfully executed
  69287. * @param onError is a callback called if an error occurs
  69288. */
  69289. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69290. }
  69291. /**
  69292. * Define a task used by AssetsManager to load HDR cube textures
  69293. */
  69294. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  69295. /**
  69296. * Defines the name of the task
  69297. */
  69298. name: string;
  69299. /**
  69300. * Defines the location of the file to load
  69301. */
  69302. url: string;
  69303. /**
  69304. * Defines the desired size (the more it increases the longer the generation will be)
  69305. */
  69306. size: number;
  69307. /**
  69308. * Defines if mipmaps should not be generated (default is false)
  69309. */
  69310. noMipmap: boolean;
  69311. /**
  69312. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69313. */
  69314. generateHarmonics: boolean;
  69315. /**
  69316. * 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)
  69317. */
  69318. gammaSpace: boolean;
  69319. /**
  69320. * Internal Use Only
  69321. */
  69322. reserved: boolean;
  69323. /**
  69324. * Gets the loaded texture
  69325. */
  69326. texture: HDRCubeTexture;
  69327. /**
  69328. * Callback called when the task is successful
  69329. */
  69330. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  69331. /**
  69332. * Callback called when the task is successful
  69333. */
  69334. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  69335. /**
  69336. * Creates a new HDRCubeTextureAssetTask object
  69337. * @param name defines the name of the task
  69338. * @param url defines the location of the file to load
  69339. * @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.
  69340. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69341. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69342. * @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)
  69343. * @param reserved Internal use only
  69344. */
  69345. constructor(
  69346. /**
  69347. * Defines the name of the task
  69348. */
  69349. name: string,
  69350. /**
  69351. * Defines the location of the file to load
  69352. */
  69353. url: string,
  69354. /**
  69355. * Defines the desired size (the more it increases the longer the generation will be)
  69356. */
  69357. size: number,
  69358. /**
  69359. * Defines if mipmaps should not be generated (default is false)
  69360. */
  69361. noMipmap?: boolean,
  69362. /**
  69363. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69364. */
  69365. generateHarmonics?: boolean,
  69366. /**
  69367. * 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)
  69368. */
  69369. gammaSpace?: boolean,
  69370. /**
  69371. * Internal Use Only
  69372. */
  69373. reserved?: boolean);
  69374. /**
  69375. * Execute the current task
  69376. * @param scene defines the scene where you want your assets to be loaded
  69377. * @param onSuccess is a callback called when the task is successfully executed
  69378. * @param onError is a callback called if an error occurs
  69379. */
  69380. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69381. }
  69382. /**
  69383. * Define a task used by AssetsManager to load Equirectangular cube textures
  69384. */
  69385. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  69386. /**
  69387. * Defines the name of the task
  69388. */
  69389. name: string;
  69390. /**
  69391. * Defines the location of the file to load
  69392. */
  69393. url: string;
  69394. /**
  69395. * Defines the desired size (the more it increases the longer the generation will be)
  69396. */
  69397. size: number;
  69398. /**
  69399. * Defines if mipmaps should not be generated (default is false)
  69400. */
  69401. noMipmap: boolean;
  69402. /**
  69403. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  69404. * but the standard material would require them in Gamma space) (default is true)
  69405. */
  69406. gammaSpace: boolean;
  69407. /**
  69408. * Gets the loaded texture
  69409. */
  69410. texture: EquiRectangularCubeTexture;
  69411. /**
  69412. * Callback called when the task is successful
  69413. */
  69414. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  69415. /**
  69416. * Callback called when the task is successful
  69417. */
  69418. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  69419. /**
  69420. * Creates a new EquiRectangularCubeTextureAssetTask object
  69421. * @param name defines the name of the task
  69422. * @param url defines the location of the file to load
  69423. * @param size defines the desired size (the more it increases the longer the generation will be)
  69424. * If the size is omitted this implies you are using a preprocessed cubemap.
  69425. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69426. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  69427. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  69428. * (default is true)
  69429. */
  69430. constructor(
  69431. /**
  69432. * Defines the name of the task
  69433. */
  69434. name: string,
  69435. /**
  69436. * Defines the location of the file to load
  69437. */
  69438. url: string,
  69439. /**
  69440. * Defines the desired size (the more it increases the longer the generation will be)
  69441. */
  69442. size: number,
  69443. /**
  69444. * Defines if mipmaps should not be generated (default is false)
  69445. */
  69446. noMipmap?: boolean,
  69447. /**
  69448. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  69449. * but the standard material would require them in Gamma space) (default is true)
  69450. */
  69451. gammaSpace?: boolean);
  69452. /**
  69453. * Execute the current task
  69454. * @param scene defines the scene where you want your assets to be loaded
  69455. * @param onSuccess is a callback called when the task is successfully executed
  69456. * @param onError is a callback called if an error occurs
  69457. */
  69458. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69459. }
  69460. /**
  69461. * This class can be used to easily import assets into a scene
  69462. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  69463. */
  69464. export class AssetsManager {
  69465. private _scene;
  69466. private _isLoading;
  69467. protected _tasks: AbstractAssetTask[];
  69468. protected _waitingTasksCount: number;
  69469. protected _totalTasksCount: number;
  69470. /**
  69471. * Callback called when all tasks are processed
  69472. */
  69473. onFinish: (tasks: AbstractAssetTask[]) => void;
  69474. /**
  69475. * Callback called when a task is successful
  69476. */
  69477. onTaskSuccess: (task: AbstractAssetTask) => void;
  69478. /**
  69479. * Callback called when a task had an error
  69480. */
  69481. onTaskError: (task: AbstractAssetTask) => void;
  69482. /**
  69483. * Callback called when a task is done (whatever the result is)
  69484. */
  69485. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  69486. /**
  69487. * Observable called when all tasks are processed
  69488. */
  69489. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  69490. /**
  69491. * Observable called when a task had an error
  69492. */
  69493. onTaskErrorObservable: Observable<AbstractAssetTask>;
  69494. /**
  69495. * Observable called when all tasks were executed
  69496. */
  69497. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  69498. /**
  69499. * Observable called when a task is done (whatever the result is)
  69500. */
  69501. onProgressObservable: Observable<IAssetsProgressEvent>;
  69502. /**
  69503. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  69504. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  69505. */
  69506. useDefaultLoadingScreen: boolean;
  69507. /**
  69508. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  69509. * when all assets have been downloaded.
  69510. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  69511. */
  69512. autoHideLoadingUI: boolean;
  69513. /**
  69514. * Creates a new AssetsManager
  69515. * @param scene defines the scene to work on
  69516. */
  69517. constructor(scene: Scene);
  69518. /**
  69519. * Add a MeshAssetTask to the list of active tasks
  69520. * @param taskName defines the name of the new task
  69521. * @param meshesNames defines the name of meshes to load
  69522. * @param rootUrl defines the root url to use to locate files
  69523. * @param sceneFilename defines the filename of the scene file
  69524. * @returns a new MeshAssetTask object
  69525. */
  69526. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  69527. /**
  69528. * Add a TextFileAssetTask to the list of active tasks
  69529. * @param taskName defines the name of the new task
  69530. * @param url defines the url of the file to load
  69531. * @returns a new TextFileAssetTask object
  69532. */
  69533. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  69534. /**
  69535. * Add a BinaryFileAssetTask to the list of active tasks
  69536. * @param taskName defines the name of the new task
  69537. * @param url defines the url of the file to load
  69538. * @returns a new BinaryFileAssetTask object
  69539. */
  69540. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  69541. /**
  69542. * Add a ImageAssetTask to the list of active tasks
  69543. * @param taskName defines the name of the new task
  69544. * @param url defines the url of the file to load
  69545. * @returns a new ImageAssetTask object
  69546. */
  69547. addImageTask(taskName: string, url: string): ImageAssetTask;
  69548. /**
  69549. * Add a TextureAssetTask to the list of active tasks
  69550. * @param taskName defines the name of the new task
  69551. * @param url defines the url of the file to load
  69552. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69553. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  69554. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  69555. * @returns a new TextureAssetTask object
  69556. */
  69557. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  69558. /**
  69559. * Add a CubeTextureAssetTask to the list of active tasks
  69560. * @param taskName defines the name of the new task
  69561. * @param url defines the url of the file to load
  69562. * @param extensions defines the extension to use to load the cube map (can be null)
  69563. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69564. * @param files defines the list of files to load (can be null)
  69565. * @returns a new CubeTextureAssetTask object
  69566. */
  69567. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  69568. /**
  69569. *
  69570. * Add a HDRCubeTextureAssetTask to the list of active tasks
  69571. * @param taskName defines the name of the new task
  69572. * @param url defines the url of the file to load
  69573. * @param size defines the size you want for the cubemap (can be null)
  69574. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69575. * @param generateHarmonics defines if you want to automatically generate (true by default)
  69576. * @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)
  69577. * @param reserved Internal use only
  69578. * @returns a new HDRCubeTextureAssetTask object
  69579. */
  69580. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  69581. /**
  69582. *
  69583. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  69584. * @param taskName defines the name of the new task
  69585. * @param url defines the url of the file to load
  69586. * @param size defines the size you want for the cubemap (can be null)
  69587. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69588. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  69589. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  69590. * @returns a new EquiRectangularCubeTextureAssetTask object
  69591. */
  69592. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  69593. /**
  69594. * Remove a task from the assets manager.
  69595. * @param task the task to remove
  69596. */
  69597. removeTask(task: AbstractAssetTask): void;
  69598. private _decreaseWaitingTasksCount;
  69599. private _runTask;
  69600. /**
  69601. * Reset the AssetsManager and remove all tasks
  69602. * @return the current instance of the AssetsManager
  69603. */
  69604. reset(): AssetsManager;
  69605. /**
  69606. * Start the loading process
  69607. * @return the current instance of the AssetsManager
  69608. */
  69609. load(): AssetsManager;
  69610. /**
  69611. * Start the loading process as an async operation
  69612. * @return a promise returning the list of failed tasks
  69613. */
  69614. loadAsync(): Promise<void>;
  69615. }
  69616. }
  69617. declare module "babylonjs/Misc/deferred" {
  69618. /**
  69619. * Wrapper class for promise with external resolve and reject.
  69620. */
  69621. export class Deferred<T> {
  69622. /**
  69623. * The promise associated with this deferred object.
  69624. */
  69625. readonly promise: Promise<T>;
  69626. private _resolve;
  69627. private _reject;
  69628. /**
  69629. * The resolve method of the promise associated with this deferred object.
  69630. */
  69631. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  69632. /**
  69633. * The reject method of the promise associated with this deferred object.
  69634. */
  69635. get reject(): (reason?: any) => void;
  69636. /**
  69637. * Constructor for this deferred object.
  69638. */
  69639. constructor();
  69640. }
  69641. }
  69642. declare module "babylonjs/Misc/meshExploder" {
  69643. import { Mesh } from "babylonjs/Meshes/mesh";
  69644. /**
  69645. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  69646. */
  69647. export class MeshExploder {
  69648. private _centerMesh;
  69649. private _meshes;
  69650. private _meshesOrigins;
  69651. private _toCenterVectors;
  69652. private _scaledDirection;
  69653. private _newPosition;
  69654. private _centerPosition;
  69655. /**
  69656. * Explodes meshes from a center mesh.
  69657. * @param meshes The meshes to explode.
  69658. * @param centerMesh The mesh to be center of explosion.
  69659. */
  69660. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  69661. private _setCenterMesh;
  69662. /**
  69663. * Get class name
  69664. * @returns "MeshExploder"
  69665. */
  69666. getClassName(): string;
  69667. /**
  69668. * "Exploded meshes"
  69669. * @returns Array of meshes with the centerMesh at index 0.
  69670. */
  69671. getMeshes(): Array<Mesh>;
  69672. /**
  69673. * Explodes meshes giving a specific direction
  69674. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  69675. */
  69676. explode(direction?: number): void;
  69677. }
  69678. }
  69679. declare module "babylonjs/Misc/filesInput" {
  69680. import { Engine } from "babylonjs/Engines/engine";
  69681. import { Scene } from "babylonjs/scene";
  69682. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  69683. /**
  69684. * Class used to help managing file picking and drag'n'drop
  69685. */
  69686. export class FilesInput {
  69687. /**
  69688. * List of files ready to be loaded
  69689. */
  69690. static get FilesToLoad(): {
  69691. [key: string]: File;
  69692. };
  69693. /**
  69694. * Callback called when a file is processed
  69695. */
  69696. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  69697. private _engine;
  69698. private _currentScene;
  69699. private _sceneLoadedCallback;
  69700. private _progressCallback;
  69701. private _additionalRenderLoopLogicCallback;
  69702. private _textureLoadingCallback;
  69703. private _startingProcessingFilesCallback;
  69704. private _onReloadCallback;
  69705. private _errorCallback;
  69706. private _elementToMonitor;
  69707. private _sceneFileToLoad;
  69708. private _filesToLoad;
  69709. /**
  69710. * Creates a new FilesInput
  69711. * @param engine defines the rendering engine
  69712. * @param scene defines the hosting scene
  69713. * @param sceneLoadedCallback callback called when scene is loaded
  69714. * @param progressCallback callback called to track progress
  69715. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  69716. * @param textureLoadingCallback callback called when a texture is loading
  69717. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  69718. * @param onReloadCallback callback called when a reload is requested
  69719. * @param errorCallback callback call if an error occurs
  69720. */
  69721. 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);
  69722. private _dragEnterHandler;
  69723. private _dragOverHandler;
  69724. private _dropHandler;
  69725. /**
  69726. * Calls this function to listen to drag'n'drop events on a specific DOM element
  69727. * @param elementToMonitor defines the DOM element to track
  69728. */
  69729. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  69730. /**
  69731. * Release all associated resources
  69732. */
  69733. dispose(): void;
  69734. private renderFunction;
  69735. private drag;
  69736. private drop;
  69737. private _traverseFolder;
  69738. private _processFiles;
  69739. /**
  69740. * Load files from a drop event
  69741. * @param event defines the drop event to use as source
  69742. */
  69743. loadFiles(event: any): void;
  69744. private _processReload;
  69745. /**
  69746. * Reload the current scene from the loaded files
  69747. */
  69748. reload(): void;
  69749. }
  69750. }
  69751. declare module "babylonjs/Misc/HighDynamicRange/index" {
  69752. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  69753. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  69754. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  69755. }
  69756. declare module "babylonjs/Misc/sceneOptimizer" {
  69757. import { Scene, IDisposable } from "babylonjs/scene";
  69758. import { Observable } from "babylonjs/Misc/observable";
  69759. /**
  69760. * Defines the root class used to create scene optimization to use with SceneOptimizer
  69761. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69762. */
  69763. export class SceneOptimization {
  69764. /**
  69765. * Defines the priority of this optimization (0 by default which means first in the list)
  69766. */
  69767. priority: number;
  69768. /**
  69769. * Gets a string describing the action executed by the current optimization
  69770. * @returns description string
  69771. */
  69772. getDescription(): string;
  69773. /**
  69774. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69775. * @param scene defines the current scene where to apply this optimization
  69776. * @param optimizer defines the current optimizer
  69777. * @returns true if everything that can be done was applied
  69778. */
  69779. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69780. /**
  69781. * Creates the SceneOptimization object
  69782. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69783. * @param desc defines the description associated with the optimization
  69784. */
  69785. constructor(
  69786. /**
  69787. * Defines the priority of this optimization (0 by default which means first in the list)
  69788. */
  69789. priority?: number);
  69790. }
  69791. /**
  69792. * Defines an optimization used to reduce the size of render target textures
  69793. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69794. */
  69795. export class TextureOptimization extends SceneOptimization {
  69796. /**
  69797. * Defines the priority of this optimization (0 by default which means first in the list)
  69798. */
  69799. priority: number;
  69800. /**
  69801. * 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
  69802. */
  69803. maximumSize: number;
  69804. /**
  69805. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69806. */
  69807. step: number;
  69808. /**
  69809. * Gets a string describing the action executed by the current optimization
  69810. * @returns description string
  69811. */
  69812. getDescription(): string;
  69813. /**
  69814. * Creates the TextureOptimization object
  69815. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69816. * @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
  69817. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69818. */
  69819. constructor(
  69820. /**
  69821. * Defines the priority of this optimization (0 by default which means first in the list)
  69822. */
  69823. priority?: number,
  69824. /**
  69825. * 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
  69826. */
  69827. maximumSize?: number,
  69828. /**
  69829. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69830. */
  69831. step?: number);
  69832. /**
  69833. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69834. * @param scene defines the current scene where to apply this optimization
  69835. * @param optimizer defines the current optimizer
  69836. * @returns true if everything that can be done was applied
  69837. */
  69838. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69839. }
  69840. /**
  69841. * Defines an optimization used to increase or decrease the rendering resolution
  69842. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69843. */
  69844. export class HardwareScalingOptimization extends SceneOptimization {
  69845. /**
  69846. * Defines the priority of this optimization (0 by default which means first in the list)
  69847. */
  69848. priority: number;
  69849. /**
  69850. * Defines the maximum scale to use (2 by default)
  69851. */
  69852. maximumScale: number;
  69853. /**
  69854. * Defines the step to use between two passes (0.5 by default)
  69855. */
  69856. step: number;
  69857. private _currentScale;
  69858. private _directionOffset;
  69859. /**
  69860. * Gets a string describing the action executed by the current optimization
  69861. * @return description string
  69862. */
  69863. getDescription(): string;
  69864. /**
  69865. * Creates the HardwareScalingOptimization object
  69866. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69867. * @param maximumScale defines the maximum scale to use (2 by default)
  69868. * @param step defines the step to use between two passes (0.5 by default)
  69869. */
  69870. constructor(
  69871. /**
  69872. * Defines the priority of this optimization (0 by default which means first in the list)
  69873. */
  69874. priority?: number,
  69875. /**
  69876. * Defines the maximum scale to use (2 by default)
  69877. */
  69878. maximumScale?: number,
  69879. /**
  69880. * Defines the step to use between two passes (0.5 by default)
  69881. */
  69882. step?: number);
  69883. /**
  69884. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69885. * @param scene defines the current scene where to apply this optimization
  69886. * @param optimizer defines the current optimizer
  69887. * @returns true if everything that can be done was applied
  69888. */
  69889. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69890. }
  69891. /**
  69892. * Defines an optimization used to remove shadows
  69893. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69894. */
  69895. export class ShadowsOptimization extends SceneOptimization {
  69896. /**
  69897. * Gets a string describing the action executed by the current optimization
  69898. * @return description string
  69899. */
  69900. getDescription(): string;
  69901. /**
  69902. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69903. * @param scene defines the current scene where to apply this optimization
  69904. * @param optimizer defines the current optimizer
  69905. * @returns true if everything that can be done was applied
  69906. */
  69907. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69908. }
  69909. /**
  69910. * Defines an optimization used to turn post-processes off
  69911. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69912. */
  69913. export class PostProcessesOptimization extends SceneOptimization {
  69914. /**
  69915. * Gets a string describing the action executed by the current optimization
  69916. * @return description string
  69917. */
  69918. getDescription(): string;
  69919. /**
  69920. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69921. * @param scene defines the current scene where to apply this optimization
  69922. * @param optimizer defines the current optimizer
  69923. * @returns true if everything that can be done was applied
  69924. */
  69925. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69926. }
  69927. /**
  69928. * Defines an optimization used to turn lens flares off
  69929. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69930. */
  69931. export class LensFlaresOptimization extends SceneOptimization {
  69932. /**
  69933. * Gets a string describing the action executed by the current optimization
  69934. * @return description string
  69935. */
  69936. getDescription(): string;
  69937. /**
  69938. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69939. * @param scene defines the current scene where to apply this optimization
  69940. * @param optimizer defines the current optimizer
  69941. * @returns true if everything that can be done was applied
  69942. */
  69943. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69944. }
  69945. /**
  69946. * Defines an optimization based on user defined callback.
  69947. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69948. */
  69949. export class CustomOptimization extends SceneOptimization {
  69950. /**
  69951. * Callback called to apply the custom optimization.
  69952. */
  69953. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  69954. /**
  69955. * Callback called to get custom description
  69956. */
  69957. onGetDescription: () => string;
  69958. /**
  69959. * Gets a string describing the action executed by the current optimization
  69960. * @returns description string
  69961. */
  69962. getDescription(): string;
  69963. /**
  69964. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69965. * @param scene defines the current scene where to apply this optimization
  69966. * @param optimizer defines the current optimizer
  69967. * @returns true if everything that can be done was applied
  69968. */
  69969. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69970. }
  69971. /**
  69972. * Defines an optimization used to turn particles off
  69973. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69974. */
  69975. export class ParticlesOptimization extends SceneOptimization {
  69976. /**
  69977. * Gets a string describing the action executed by the current optimization
  69978. * @return description string
  69979. */
  69980. getDescription(): string;
  69981. /**
  69982. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69983. * @param scene defines the current scene where to apply this optimization
  69984. * @param optimizer defines the current optimizer
  69985. * @returns true if everything that can be done was applied
  69986. */
  69987. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69988. }
  69989. /**
  69990. * Defines an optimization used to turn render targets off
  69991. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69992. */
  69993. export class RenderTargetsOptimization extends SceneOptimization {
  69994. /**
  69995. * Gets a string describing the action executed by the current optimization
  69996. * @return description string
  69997. */
  69998. getDescription(): string;
  69999. /**
  70000. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70001. * @param scene defines the current scene where to apply this optimization
  70002. * @param optimizer defines the current optimizer
  70003. * @returns true if everything that can be done was applied
  70004. */
  70005. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70006. }
  70007. /**
  70008. * Defines an optimization used to merge meshes with compatible materials
  70009. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70010. */
  70011. export class MergeMeshesOptimization extends SceneOptimization {
  70012. private static _UpdateSelectionTree;
  70013. /**
  70014. * Gets or sets a boolean which defines if optimization octree has to be updated
  70015. */
  70016. static get UpdateSelectionTree(): boolean;
  70017. /**
  70018. * Gets or sets a boolean which defines if optimization octree has to be updated
  70019. */
  70020. static set UpdateSelectionTree(value: boolean);
  70021. /**
  70022. * Gets a string describing the action executed by the current optimization
  70023. * @return description string
  70024. */
  70025. getDescription(): string;
  70026. private _canBeMerged;
  70027. /**
  70028. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70029. * @param scene defines the current scene where to apply this optimization
  70030. * @param optimizer defines the current optimizer
  70031. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  70032. * @returns true if everything that can be done was applied
  70033. */
  70034. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  70035. }
  70036. /**
  70037. * Defines a list of options used by SceneOptimizer
  70038. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70039. */
  70040. export class SceneOptimizerOptions {
  70041. /**
  70042. * Defines the target frame rate to reach (60 by default)
  70043. */
  70044. targetFrameRate: number;
  70045. /**
  70046. * Defines the interval between two checkes (2000ms by default)
  70047. */
  70048. trackerDuration: number;
  70049. /**
  70050. * Gets the list of optimizations to apply
  70051. */
  70052. optimizations: SceneOptimization[];
  70053. /**
  70054. * Creates a new list of options used by SceneOptimizer
  70055. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  70056. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  70057. */
  70058. constructor(
  70059. /**
  70060. * Defines the target frame rate to reach (60 by default)
  70061. */
  70062. targetFrameRate?: number,
  70063. /**
  70064. * Defines the interval between two checkes (2000ms by default)
  70065. */
  70066. trackerDuration?: number);
  70067. /**
  70068. * Add a new optimization
  70069. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  70070. * @returns the current SceneOptimizerOptions
  70071. */
  70072. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  70073. /**
  70074. * Add a new custom optimization
  70075. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  70076. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  70077. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70078. * @returns the current SceneOptimizerOptions
  70079. */
  70080. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  70081. /**
  70082. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  70083. * @param targetFrameRate defines the target frame rate (60 by default)
  70084. * @returns a SceneOptimizerOptions object
  70085. */
  70086. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70087. /**
  70088. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  70089. * @param targetFrameRate defines the target frame rate (60 by default)
  70090. * @returns a SceneOptimizerOptions object
  70091. */
  70092. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70093. /**
  70094. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  70095. * @param targetFrameRate defines the target frame rate (60 by default)
  70096. * @returns a SceneOptimizerOptions object
  70097. */
  70098. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70099. }
  70100. /**
  70101. * Class used to run optimizations in order to reach a target frame rate
  70102. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70103. */
  70104. export class SceneOptimizer implements IDisposable {
  70105. private _isRunning;
  70106. private _options;
  70107. private _scene;
  70108. private _currentPriorityLevel;
  70109. private _targetFrameRate;
  70110. private _trackerDuration;
  70111. private _currentFrameRate;
  70112. private _sceneDisposeObserver;
  70113. private _improvementMode;
  70114. /**
  70115. * Defines an observable called when the optimizer reaches the target frame rate
  70116. */
  70117. onSuccessObservable: Observable<SceneOptimizer>;
  70118. /**
  70119. * Defines an observable called when the optimizer enables an optimization
  70120. */
  70121. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  70122. /**
  70123. * Defines an observable called when the optimizer is not able to reach the target frame rate
  70124. */
  70125. onFailureObservable: Observable<SceneOptimizer>;
  70126. /**
  70127. * Gets a boolean indicating if the optimizer is in improvement mode
  70128. */
  70129. get isInImprovementMode(): boolean;
  70130. /**
  70131. * Gets the current priority level (0 at start)
  70132. */
  70133. get currentPriorityLevel(): number;
  70134. /**
  70135. * Gets the current frame rate checked by the SceneOptimizer
  70136. */
  70137. get currentFrameRate(): number;
  70138. /**
  70139. * Gets or sets the current target frame rate (60 by default)
  70140. */
  70141. get targetFrameRate(): number;
  70142. /**
  70143. * Gets or sets the current target frame rate (60 by default)
  70144. */
  70145. set targetFrameRate(value: number);
  70146. /**
  70147. * Gets or sets the current interval between two checks (every 2000ms by default)
  70148. */
  70149. get trackerDuration(): number;
  70150. /**
  70151. * Gets or sets the current interval between two checks (every 2000ms by default)
  70152. */
  70153. set trackerDuration(value: number);
  70154. /**
  70155. * Gets the list of active optimizations
  70156. */
  70157. get optimizations(): SceneOptimization[];
  70158. /**
  70159. * Creates a new SceneOptimizer
  70160. * @param scene defines the scene to work on
  70161. * @param options defines the options to use with the SceneOptimizer
  70162. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  70163. * @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)
  70164. */
  70165. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  70166. /**
  70167. * Stops the current optimizer
  70168. */
  70169. stop(): void;
  70170. /**
  70171. * Reset the optimizer to initial step (current priority level = 0)
  70172. */
  70173. reset(): void;
  70174. /**
  70175. * Start the optimizer. By default it will try to reach a specific framerate
  70176. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  70177. */
  70178. start(): void;
  70179. private _checkCurrentState;
  70180. /**
  70181. * Release all resources
  70182. */
  70183. dispose(): void;
  70184. /**
  70185. * Helper function to create a SceneOptimizer with one single line of code
  70186. * @param scene defines the scene to work on
  70187. * @param options defines the options to use with the SceneOptimizer
  70188. * @param onSuccess defines a callback to call on success
  70189. * @param onFailure defines a callback to call on failure
  70190. * @returns the new SceneOptimizer object
  70191. */
  70192. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  70193. }
  70194. }
  70195. declare module "babylonjs/Misc/sceneSerializer" {
  70196. import { Scene } from "babylonjs/scene";
  70197. /**
  70198. * Class used to serialize a scene into a string
  70199. */
  70200. export class SceneSerializer {
  70201. /**
  70202. * Clear cache used by a previous serialization
  70203. */
  70204. static ClearCache(): void;
  70205. /**
  70206. * Serialize a scene into a JSON compatible object
  70207. * @param scene defines the scene to serialize
  70208. * @returns a JSON compatible object
  70209. */
  70210. static Serialize(scene: Scene): any;
  70211. /**
  70212. * Serialize a mesh into a JSON compatible object
  70213. * @param toSerialize defines the mesh to serialize
  70214. * @param withParents defines if parents must be serialized as well
  70215. * @param withChildren defines if children must be serialized as well
  70216. * @returns a JSON compatible object
  70217. */
  70218. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  70219. }
  70220. }
  70221. declare module "babylonjs/Misc/textureTools" {
  70222. import { Texture } from "babylonjs/Materials/Textures/texture";
  70223. /**
  70224. * Class used to host texture specific utilities
  70225. */
  70226. export class TextureTools {
  70227. /**
  70228. * Uses the GPU to create a copy texture rescaled at a given size
  70229. * @param texture Texture to copy from
  70230. * @param width defines the desired width
  70231. * @param height defines the desired height
  70232. * @param useBilinearMode defines if bilinear mode has to be used
  70233. * @return the generated texture
  70234. */
  70235. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  70236. }
  70237. }
  70238. declare module "babylonjs/Misc/videoRecorder" {
  70239. import { Nullable } from "babylonjs/types";
  70240. import { Engine } from "babylonjs/Engines/engine";
  70241. /**
  70242. * This represents the different options available for the video capture.
  70243. */
  70244. export interface VideoRecorderOptions {
  70245. /** Defines the mime type of the video. */
  70246. mimeType: string;
  70247. /** Defines the FPS the video should be recorded at. */
  70248. fps: number;
  70249. /** Defines the chunk size for the recording data. */
  70250. recordChunckSize: number;
  70251. /** The audio tracks to attach to the recording. */
  70252. audioTracks?: MediaStreamTrack[];
  70253. }
  70254. /**
  70255. * This can help with recording videos from BabylonJS.
  70256. * This is based on the available WebRTC functionalities of the browser.
  70257. *
  70258. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  70259. */
  70260. export class VideoRecorder {
  70261. private static readonly _defaultOptions;
  70262. /**
  70263. * Returns whether or not the VideoRecorder is available in your browser.
  70264. * @param engine Defines the Babylon Engine.
  70265. * @returns true if supported otherwise false.
  70266. */
  70267. static IsSupported(engine: Engine): boolean;
  70268. private readonly _options;
  70269. private _canvas;
  70270. private _mediaRecorder;
  70271. private _recordedChunks;
  70272. private _fileName;
  70273. private _resolve;
  70274. private _reject;
  70275. /**
  70276. * True when a recording is already in progress.
  70277. */
  70278. get isRecording(): boolean;
  70279. /**
  70280. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  70281. * @param engine Defines the BabylonJS Engine you wish to record.
  70282. * @param options Defines options that can be used to customize the capture.
  70283. */
  70284. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  70285. /**
  70286. * Stops the current recording before the default capture timeout passed in the startRecording function.
  70287. */
  70288. stopRecording(): void;
  70289. /**
  70290. * Starts recording the canvas for a max duration specified in parameters.
  70291. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  70292. * If null no automatic download will start and you can rely on the promise to get the data back.
  70293. * @param maxDuration Defines the maximum recording time in seconds.
  70294. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  70295. * @return A promise callback at the end of the recording with the video data in Blob.
  70296. */
  70297. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  70298. /**
  70299. * Releases internal resources used during the recording.
  70300. */
  70301. dispose(): void;
  70302. private _handleDataAvailable;
  70303. private _handleError;
  70304. private _handleStop;
  70305. }
  70306. }
  70307. declare module "babylonjs/Misc/screenshotTools" {
  70308. import { Camera } from "babylonjs/Cameras/camera";
  70309. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  70310. import { Engine } from "babylonjs/Engines/engine";
  70311. /**
  70312. * Class containing a set of static utilities functions for screenshots
  70313. */
  70314. export class ScreenshotTools {
  70315. /**
  70316. * Captures a screenshot of the current rendering
  70317. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70318. * @param engine defines the rendering engine
  70319. * @param camera defines the source camera
  70320. * @param size This parameter can be set to a single number or to an object with the
  70321. * following (optional) properties: precision, width, height. If a single number is passed,
  70322. * it will be used for both width and height. If an object is passed, the screenshot size
  70323. * will be derived from the parameters. The precision property is a multiplier allowing
  70324. * rendering at a higher or lower resolution
  70325. * @param successCallback defines the callback receives a single parameter which contains the
  70326. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  70327. * src parameter of an <img> to display it
  70328. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  70329. * Check your browser for supported MIME types
  70330. */
  70331. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  70332. /**
  70333. * Captures a screenshot of the current rendering
  70334. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70335. * @param engine defines the rendering engine
  70336. * @param camera defines the source camera
  70337. * @param size This parameter can be set to a single number or to an object with the
  70338. * following (optional) properties: precision, width, height. If a single number is passed,
  70339. * it will be used for both width and height. If an object is passed, the screenshot size
  70340. * will be derived from the parameters. The precision property is a multiplier allowing
  70341. * rendering at a higher or lower resolution
  70342. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  70343. * Check your browser for supported MIME types
  70344. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  70345. * to the src parameter of an <img> to display it
  70346. */
  70347. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  70348. /**
  70349. * Generates an image screenshot from the specified camera.
  70350. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70351. * @param engine The engine to use for rendering
  70352. * @param camera The camera to use for rendering
  70353. * @param size This parameter can be set to a single number or to an object with the
  70354. * following (optional) properties: precision, width, height. If a single number is passed,
  70355. * it will be used for both width and height. If an object is passed, the screenshot size
  70356. * will be derived from the parameters. The precision property is a multiplier allowing
  70357. * rendering at a higher or lower resolution
  70358. * @param successCallback The callback receives a single parameter which contains the
  70359. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  70360. * src parameter of an <img> to display it
  70361. * @param mimeType The MIME type of the screenshot image (default: image/png).
  70362. * Check your browser for supported MIME types
  70363. * @param samples Texture samples (default: 1)
  70364. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  70365. * @param fileName A name for for the downloaded file.
  70366. */
  70367. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  70368. /**
  70369. * Generates an image screenshot from the specified camera.
  70370. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70371. * @param engine The engine to use for rendering
  70372. * @param camera The camera to use for rendering
  70373. * @param size This parameter can be set to a single number or to an object with the
  70374. * following (optional) properties: precision, width, height. If a single number is passed,
  70375. * it will be used for both width and height. If an object is passed, the screenshot size
  70376. * will be derived from the parameters. The precision property is a multiplier allowing
  70377. * rendering at a higher or lower resolution
  70378. * @param mimeType The MIME type of the screenshot image (default: image/png).
  70379. * Check your browser for supported MIME types
  70380. * @param samples Texture samples (default: 1)
  70381. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  70382. * @param fileName A name for for the downloaded file.
  70383. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  70384. * to the src parameter of an <img> to display it
  70385. */
  70386. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  70387. /**
  70388. * Gets height and width for screenshot size
  70389. * @private
  70390. */
  70391. private static _getScreenshotSize;
  70392. }
  70393. }
  70394. declare module "babylonjs/Misc/dataReader" {
  70395. /**
  70396. * Interface for a data buffer
  70397. */
  70398. export interface IDataBuffer {
  70399. /**
  70400. * Reads bytes from the data buffer.
  70401. * @param byteOffset The byte offset to read
  70402. * @param byteLength The byte length to read
  70403. * @returns A promise that resolves when the bytes are read
  70404. */
  70405. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  70406. /**
  70407. * The byte length of the buffer.
  70408. */
  70409. readonly byteLength: number;
  70410. }
  70411. /**
  70412. * Utility class for reading from a data buffer
  70413. */
  70414. export class DataReader {
  70415. /**
  70416. * The data buffer associated with this data reader.
  70417. */
  70418. readonly buffer: IDataBuffer;
  70419. /**
  70420. * The current byte offset from the beginning of the data buffer.
  70421. */
  70422. byteOffset: number;
  70423. private _dataView;
  70424. private _dataByteOffset;
  70425. /**
  70426. * Constructor
  70427. * @param buffer The buffer to read
  70428. */
  70429. constructor(buffer: IDataBuffer);
  70430. /**
  70431. * Loads the given byte length.
  70432. * @param byteLength The byte length to load
  70433. * @returns A promise that resolves when the load is complete
  70434. */
  70435. loadAsync(byteLength: number): Promise<void>;
  70436. /**
  70437. * Read a unsigned 32-bit integer from the currently loaded data range.
  70438. * @returns The 32-bit integer read
  70439. */
  70440. readUint32(): number;
  70441. /**
  70442. * Read a byte array from the currently loaded data range.
  70443. * @param byteLength The byte length to read
  70444. * @returns The byte array read
  70445. */
  70446. readUint8Array(byteLength: number): Uint8Array;
  70447. /**
  70448. * Read a string from the currently loaded data range.
  70449. * @param byteLength The byte length to read
  70450. * @returns The string read
  70451. */
  70452. readString(byteLength: number): string;
  70453. /**
  70454. * Skips the given byte length the currently loaded data range.
  70455. * @param byteLength The byte length to skip
  70456. */
  70457. skipBytes(byteLength: number): void;
  70458. }
  70459. }
  70460. declare module "babylonjs/Misc/index" {
  70461. export * from "babylonjs/Misc/andOrNotEvaluator";
  70462. export * from "babylonjs/Misc/assetsManager";
  70463. export * from "babylonjs/Misc/basis";
  70464. export * from "babylonjs/Misc/dds";
  70465. export * from "babylonjs/Misc/decorators";
  70466. export * from "babylonjs/Misc/deferred";
  70467. export * from "babylonjs/Misc/environmentTextureTools";
  70468. export * from "babylonjs/Misc/meshExploder";
  70469. export * from "babylonjs/Misc/filesInput";
  70470. export * from "babylonjs/Misc/HighDynamicRange/index";
  70471. export * from "babylonjs/Misc/khronosTextureContainer";
  70472. export * from "babylonjs/Misc/observable";
  70473. export * from "babylonjs/Misc/performanceMonitor";
  70474. export * from "babylonjs/Misc/promise";
  70475. export * from "babylonjs/Misc/sceneOptimizer";
  70476. export * from "babylonjs/Misc/sceneSerializer";
  70477. export * from "babylonjs/Misc/smartArray";
  70478. export * from "babylonjs/Misc/stringDictionary";
  70479. export * from "babylonjs/Misc/tags";
  70480. export * from "babylonjs/Misc/textureTools";
  70481. export * from "babylonjs/Misc/tga";
  70482. export * from "babylonjs/Misc/tools";
  70483. export * from "babylonjs/Misc/videoRecorder";
  70484. export * from "babylonjs/Misc/virtualJoystick";
  70485. export * from "babylonjs/Misc/workerPool";
  70486. export * from "babylonjs/Misc/logger";
  70487. export * from "babylonjs/Misc/typeStore";
  70488. export * from "babylonjs/Misc/filesInputStore";
  70489. export * from "babylonjs/Misc/deepCopier";
  70490. export * from "babylonjs/Misc/pivotTools";
  70491. export * from "babylonjs/Misc/precisionDate";
  70492. export * from "babylonjs/Misc/screenshotTools";
  70493. export * from "babylonjs/Misc/typeStore";
  70494. export * from "babylonjs/Misc/webRequest";
  70495. export * from "babylonjs/Misc/iInspectable";
  70496. export * from "babylonjs/Misc/brdfTextureTools";
  70497. export * from "babylonjs/Misc/rgbdTextureTools";
  70498. export * from "babylonjs/Misc/gradients";
  70499. export * from "babylonjs/Misc/perfCounter";
  70500. export * from "babylonjs/Misc/fileRequest";
  70501. export * from "babylonjs/Misc/customAnimationFrameRequester";
  70502. export * from "babylonjs/Misc/retryStrategy";
  70503. export * from "babylonjs/Misc/interfaces/screenshotSize";
  70504. export * from "babylonjs/Misc/canvasGenerator";
  70505. export * from "babylonjs/Misc/fileTools";
  70506. export * from "babylonjs/Misc/stringTools";
  70507. export * from "babylonjs/Misc/dataReader";
  70508. }
  70509. declare module "babylonjs/index" {
  70510. export * from "babylonjs/abstractScene";
  70511. export * from "babylonjs/Actions/index";
  70512. export * from "babylonjs/Animations/index";
  70513. export * from "babylonjs/assetContainer";
  70514. export * from "babylonjs/Audio/index";
  70515. export * from "babylonjs/Behaviors/index";
  70516. export * from "babylonjs/Bones/index";
  70517. export * from "babylonjs/Cameras/index";
  70518. export * from "babylonjs/Collisions/index";
  70519. export * from "babylonjs/Culling/index";
  70520. export * from "babylonjs/Debug/index";
  70521. export * from "babylonjs/Engines/index";
  70522. export * from "babylonjs/Events/index";
  70523. export * from "babylonjs/Gamepads/index";
  70524. export * from "babylonjs/Gizmos/index";
  70525. export * from "babylonjs/Helpers/index";
  70526. export * from "babylonjs/Instrumentation/index";
  70527. export * from "babylonjs/Layers/index";
  70528. export * from "babylonjs/LensFlares/index";
  70529. export * from "babylonjs/Lights/index";
  70530. export * from "babylonjs/Loading/index";
  70531. export * from "babylonjs/Materials/index";
  70532. export * from "babylonjs/Maths/index";
  70533. export * from "babylonjs/Meshes/index";
  70534. export * from "babylonjs/Morph/index";
  70535. export * from "babylonjs/Navigation/index";
  70536. export * from "babylonjs/node";
  70537. export * from "babylonjs/Offline/index";
  70538. export * from "babylonjs/Particles/index";
  70539. export * from "babylonjs/Physics/index";
  70540. export * from "babylonjs/PostProcesses/index";
  70541. export * from "babylonjs/Probes/index";
  70542. export * from "babylonjs/Rendering/index";
  70543. export * from "babylonjs/scene";
  70544. export * from "babylonjs/sceneComponent";
  70545. export * from "babylonjs/Sprites/index";
  70546. export * from "babylonjs/States/index";
  70547. export * from "babylonjs/Misc/index";
  70548. export * from "babylonjs/types";
  70549. }
  70550. declare module "babylonjs/Animations/pathCursor" {
  70551. import { Vector3 } from "babylonjs/Maths/math.vector";
  70552. import { Path2 } from "babylonjs/Maths/math.path";
  70553. /**
  70554. * A cursor which tracks a point on a path
  70555. */
  70556. export class PathCursor {
  70557. private path;
  70558. /**
  70559. * Stores path cursor callbacks for when an onchange event is triggered
  70560. */
  70561. private _onchange;
  70562. /**
  70563. * The value of the path cursor
  70564. */
  70565. value: number;
  70566. /**
  70567. * The animation array of the path cursor
  70568. */
  70569. animations: Animation[];
  70570. /**
  70571. * Initializes the path cursor
  70572. * @param path The path to track
  70573. */
  70574. constructor(path: Path2);
  70575. /**
  70576. * Gets the cursor point on the path
  70577. * @returns A point on the path cursor at the cursor location
  70578. */
  70579. getPoint(): Vector3;
  70580. /**
  70581. * Moves the cursor ahead by the step amount
  70582. * @param step The amount to move the cursor forward
  70583. * @returns This path cursor
  70584. */
  70585. moveAhead(step?: number): PathCursor;
  70586. /**
  70587. * Moves the cursor behind by the step amount
  70588. * @param step The amount to move the cursor back
  70589. * @returns This path cursor
  70590. */
  70591. moveBack(step?: number): PathCursor;
  70592. /**
  70593. * Moves the cursor by the step amount
  70594. * If the step amount is greater than one, an exception is thrown
  70595. * @param step The amount to move the cursor
  70596. * @returns This path cursor
  70597. */
  70598. move(step: number): PathCursor;
  70599. /**
  70600. * Ensures that the value is limited between zero and one
  70601. * @returns This path cursor
  70602. */
  70603. private ensureLimits;
  70604. /**
  70605. * Runs onchange callbacks on change (used by the animation engine)
  70606. * @returns This path cursor
  70607. */
  70608. private raiseOnChange;
  70609. /**
  70610. * Executes a function on change
  70611. * @param f A path cursor onchange callback
  70612. * @returns This path cursor
  70613. */
  70614. onchange(f: (cursor: PathCursor) => void): PathCursor;
  70615. }
  70616. }
  70617. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  70618. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  70619. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  70620. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  70621. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  70622. }
  70623. declare module "babylonjs/Engines/Processors/Expressions/index" {
  70624. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  70625. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  70626. }
  70627. declare module "babylonjs/Engines/Processors/index" {
  70628. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  70629. export * from "babylonjs/Engines/Processors/Expressions/index";
  70630. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  70631. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  70632. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  70633. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  70634. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  70635. export * from "babylonjs/Engines/Processors/shaderProcessor";
  70636. }
  70637. declare module "babylonjs/Legacy/legacy" {
  70638. import * as Babylon from "babylonjs/index";
  70639. export * from "babylonjs/index";
  70640. }
  70641. declare module "babylonjs/Shaders/blur.fragment" {
  70642. /** @hidden */
  70643. export var blurPixelShader: {
  70644. name: string;
  70645. shader: string;
  70646. };
  70647. }
  70648. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  70649. /** @hidden */
  70650. export var pointCloudVertexDeclaration: {
  70651. name: string;
  70652. shader: string;
  70653. };
  70654. }
  70655. declare module "babylonjs" {
  70656. export * from "babylonjs/Legacy/legacy";
  70657. }
  70658. declare module BABYLON {
  70659. /** Alias type for value that can be null */
  70660. export type Nullable<T> = T | null;
  70661. /**
  70662. * Alias type for number that are floats
  70663. * @ignorenaming
  70664. */
  70665. export type float = number;
  70666. /**
  70667. * Alias type for number that are doubles.
  70668. * @ignorenaming
  70669. */
  70670. export type double = number;
  70671. /**
  70672. * Alias type for number that are integer
  70673. * @ignorenaming
  70674. */
  70675. export type int = number;
  70676. /** Alias type for number array or Float32Array */
  70677. export type FloatArray = number[] | Float32Array;
  70678. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  70679. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  70680. /**
  70681. * Alias for types that can be used by a Buffer or VertexBuffer.
  70682. */
  70683. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  70684. /**
  70685. * Alias type for primitive types
  70686. * @ignorenaming
  70687. */
  70688. type Primitive = undefined | null | boolean | string | number | Function;
  70689. /**
  70690. * Type modifier to make all the properties of an object Readonly
  70691. */
  70692. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  70693. /**
  70694. * Type modifier to make all the properties of an object Readonly recursively
  70695. */
  70696. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  70697. /**
  70698. * Type modifier to make object properties readonly.
  70699. */
  70700. export type DeepImmutableObject<T> = {
  70701. readonly [K in keyof T]: DeepImmutable<T[K]>;
  70702. };
  70703. /** @hidden */
  70704. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  70705. }
  70706. }
  70707. declare module BABYLON {
  70708. /**
  70709. * A class serves as a medium between the observable and its observers
  70710. */
  70711. export class EventState {
  70712. /**
  70713. * Create a new EventState
  70714. * @param mask defines the mask associated with this state
  70715. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  70716. * @param target defines the original target of the state
  70717. * @param currentTarget defines the current target of the state
  70718. */
  70719. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  70720. /**
  70721. * Initialize the current event state
  70722. * @param mask defines the mask associated with this state
  70723. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  70724. * @param target defines the original target of the state
  70725. * @param currentTarget defines the current target of the state
  70726. * @returns the current event state
  70727. */
  70728. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  70729. /**
  70730. * An Observer can set this property to true to prevent subsequent observers of being notified
  70731. */
  70732. skipNextObservers: boolean;
  70733. /**
  70734. * Get the mask value that were used to trigger the event corresponding to this EventState object
  70735. */
  70736. mask: number;
  70737. /**
  70738. * The object that originally notified the event
  70739. */
  70740. target?: any;
  70741. /**
  70742. * The current object in the bubbling phase
  70743. */
  70744. currentTarget?: any;
  70745. /**
  70746. * This will be populated with the return value of the last function that was executed.
  70747. * If it is the first function in the callback chain it will be the event data.
  70748. */
  70749. lastReturnValue?: any;
  70750. }
  70751. /**
  70752. * Represent an Observer registered to a given Observable object.
  70753. */
  70754. export class Observer<T> {
  70755. /**
  70756. * Defines the callback to call when the observer is notified
  70757. */
  70758. callback: (eventData: T, eventState: EventState) => void;
  70759. /**
  70760. * Defines the mask of the observer (used to filter notifications)
  70761. */
  70762. mask: number;
  70763. /**
  70764. * Defines the current scope used to restore the JS context
  70765. */
  70766. scope: any;
  70767. /** @hidden */
  70768. _willBeUnregistered: boolean;
  70769. /**
  70770. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  70771. */
  70772. unregisterOnNextCall: boolean;
  70773. /**
  70774. * Creates a new observer
  70775. * @param callback defines the callback to call when the observer is notified
  70776. * @param mask defines the mask of the observer (used to filter notifications)
  70777. * @param scope defines the current scope used to restore the JS context
  70778. */
  70779. constructor(
  70780. /**
  70781. * Defines the callback to call when the observer is notified
  70782. */
  70783. callback: (eventData: T, eventState: EventState) => void,
  70784. /**
  70785. * Defines the mask of the observer (used to filter notifications)
  70786. */
  70787. mask: number,
  70788. /**
  70789. * Defines the current scope used to restore the JS context
  70790. */
  70791. scope?: any);
  70792. }
  70793. /**
  70794. * Represent a list of observers registered to multiple Observables object.
  70795. */
  70796. export class MultiObserver<T> {
  70797. private _observers;
  70798. private _observables;
  70799. /**
  70800. * Release associated resources
  70801. */
  70802. dispose(): void;
  70803. /**
  70804. * Raise a callback when one of the observable will notify
  70805. * @param observables defines a list of observables to watch
  70806. * @param callback defines the callback to call on notification
  70807. * @param mask defines the mask used to filter notifications
  70808. * @param scope defines the current scope used to restore the JS context
  70809. * @returns the new MultiObserver
  70810. */
  70811. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  70812. }
  70813. /**
  70814. * The Observable class is a simple implementation of the Observable pattern.
  70815. *
  70816. * 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.
  70817. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  70818. * 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).
  70819. * 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.
  70820. */
  70821. export class Observable<T> {
  70822. private _observers;
  70823. private _eventState;
  70824. private _onObserverAdded;
  70825. /**
  70826. * Gets the list of observers
  70827. */
  70828. get observers(): Array<Observer<T>>;
  70829. /**
  70830. * Creates a new observable
  70831. * @param onObserverAdded defines a callback to call when a new observer is added
  70832. */
  70833. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  70834. /**
  70835. * Create a new Observer with the specified callback
  70836. * @param callback the callback that will be executed for that Observer
  70837. * @param mask the mask used to filter observers
  70838. * @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.
  70839. * @param scope optional scope for the callback to be called from
  70840. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  70841. * @returns the new observer created for the callback
  70842. */
  70843. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  70844. /**
  70845. * Create a new Observer with the specified callback and unregisters after the next notification
  70846. * @param callback the callback that will be executed for that Observer
  70847. * @returns the new observer created for the callback
  70848. */
  70849. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  70850. /**
  70851. * Remove an Observer from the Observable object
  70852. * @param observer the instance of the Observer to remove
  70853. * @returns false if it doesn't belong to this Observable
  70854. */
  70855. remove(observer: Nullable<Observer<T>>): boolean;
  70856. /**
  70857. * Remove a callback from the Observable object
  70858. * @param callback the callback to remove
  70859. * @param scope optional scope. If used only the callbacks with this scope will be removed
  70860. * @returns false if it doesn't belong to this Observable
  70861. */
  70862. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  70863. private _deferUnregister;
  70864. private _remove;
  70865. /**
  70866. * Moves the observable to the top of the observer list making it get called first when notified
  70867. * @param observer the observer to move
  70868. */
  70869. makeObserverTopPriority(observer: Observer<T>): void;
  70870. /**
  70871. * Moves the observable to the bottom of the observer list making it get called last when notified
  70872. * @param observer the observer to move
  70873. */
  70874. makeObserverBottomPriority(observer: Observer<T>): void;
  70875. /**
  70876. * Notify all Observers by calling their respective callback with the given data
  70877. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  70878. * @param eventData defines the data to send to all observers
  70879. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  70880. * @param target defines the original target of the state
  70881. * @param currentTarget defines the current target of the state
  70882. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  70883. */
  70884. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  70885. /**
  70886. * Calling this will execute each callback, expecting it to be a promise or return a value.
  70887. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  70888. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  70889. * and it is crucial that all callbacks will be executed.
  70890. * The order of the callbacks is kept, callbacks are not executed parallel.
  70891. *
  70892. * @param eventData The data to be sent to each callback
  70893. * @param mask is used to filter observers defaults to -1
  70894. * @param target defines the callback target (see EventState)
  70895. * @param currentTarget defines he current object in the bubbling phase
  70896. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  70897. */
  70898. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  70899. /**
  70900. * Notify a specific observer
  70901. * @param observer defines the observer to notify
  70902. * @param eventData defines the data to be sent to each callback
  70903. * @param mask is used to filter observers defaults to -1
  70904. */
  70905. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  70906. /**
  70907. * Gets a boolean indicating if the observable has at least one observer
  70908. * @returns true is the Observable has at least one Observer registered
  70909. */
  70910. hasObservers(): boolean;
  70911. /**
  70912. * Clear the list of observers
  70913. */
  70914. clear(): void;
  70915. /**
  70916. * Clone the current observable
  70917. * @returns a new observable
  70918. */
  70919. clone(): Observable<T>;
  70920. /**
  70921. * Does this observable handles observer registered with a given mask
  70922. * @param mask defines the mask to be tested
  70923. * @return whether or not one observer registered with the given mask is handeled
  70924. **/
  70925. hasSpecificMask(mask?: number): boolean;
  70926. }
  70927. }
  70928. declare module BABYLON {
  70929. /**
  70930. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  70931. * Babylon.js
  70932. */
  70933. export class DomManagement {
  70934. /**
  70935. * Checks if the window object exists
  70936. * @returns true if the window object exists
  70937. */
  70938. static IsWindowObjectExist(): boolean;
  70939. /**
  70940. * Checks if the navigator object exists
  70941. * @returns true if the navigator object exists
  70942. */
  70943. static IsNavigatorAvailable(): boolean;
  70944. /**
  70945. * Extracts text content from a DOM element hierarchy
  70946. * @param element defines the root element
  70947. * @returns a string
  70948. */
  70949. static GetDOMTextContent(element: HTMLElement): string;
  70950. }
  70951. }
  70952. declare module BABYLON {
  70953. /**
  70954. * Logger used througouht the application to allow configuration of
  70955. * the log level required for the messages.
  70956. */
  70957. export class Logger {
  70958. /**
  70959. * No log
  70960. */
  70961. static readonly NoneLogLevel: number;
  70962. /**
  70963. * Only message logs
  70964. */
  70965. static readonly MessageLogLevel: number;
  70966. /**
  70967. * Only warning logs
  70968. */
  70969. static readonly WarningLogLevel: number;
  70970. /**
  70971. * Only error logs
  70972. */
  70973. static readonly ErrorLogLevel: number;
  70974. /**
  70975. * All logs
  70976. */
  70977. static readonly AllLogLevel: number;
  70978. private static _LogCache;
  70979. /**
  70980. * Gets a value indicating the number of loading errors
  70981. * @ignorenaming
  70982. */
  70983. static errorsCount: number;
  70984. /**
  70985. * Callback called when a new log is added
  70986. */
  70987. static OnNewCacheEntry: (entry: string) => void;
  70988. private static _AddLogEntry;
  70989. private static _FormatMessage;
  70990. private static _LogDisabled;
  70991. private static _LogEnabled;
  70992. private static _WarnDisabled;
  70993. private static _WarnEnabled;
  70994. private static _ErrorDisabled;
  70995. private static _ErrorEnabled;
  70996. /**
  70997. * Log a message to the console
  70998. */
  70999. static Log: (message: string) => void;
  71000. /**
  71001. * Write a warning message to the console
  71002. */
  71003. static Warn: (message: string) => void;
  71004. /**
  71005. * Write an error message to the console
  71006. */
  71007. static Error: (message: string) => void;
  71008. /**
  71009. * Gets current log cache (list of logs)
  71010. */
  71011. static get LogCache(): string;
  71012. /**
  71013. * Clears the log cache
  71014. */
  71015. static ClearLogCache(): void;
  71016. /**
  71017. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  71018. */
  71019. static set LogLevels(level: number);
  71020. }
  71021. }
  71022. declare module BABYLON {
  71023. /** @hidden */
  71024. export class _TypeStore {
  71025. /** @hidden */
  71026. static RegisteredTypes: {
  71027. [key: string]: Object;
  71028. };
  71029. /** @hidden */
  71030. static GetClass(fqdn: string): any;
  71031. }
  71032. }
  71033. declare module BABYLON {
  71034. /**
  71035. * Helper to manipulate strings
  71036. */
  71037. export class StringTools {
  71038. /**
  71039. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  71040. * @param str Source string
  71041. * @param suffix Suffix to search for in the source string
  71042. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71043. */
  71044. static EndsWith(str: string, suffix: string): boolean;
  71045. /**
  71046. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  71047. * @param str Source string
  71048. * @param suffix Suffix to search for in the source string
  71049. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71050. */
  71051. static StartsWith(str: string, suffix: string): boolean;
  71052. /**
  71053. * Decodes a buffer into a string
  71054. * @param buffer The buffer to decode
  71055. * @returns The decoded string
  71056. */
  71057. static Decode(buffer: Uint8Array | Uint16Array): string;
  71058. /**
  71059. * Encode a buffer to a base64 string
  71060. * @param buffer defines the buffer to encode
  71061. * @returns the encoded string
  71062. */
  71063. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  71064. }
  71065. }
  71066. declare module BABYLON {
  71067. /**
  71068. * Class containing a set of static utilities functions for deep copy.
  71069. */
  71070. export class DeepCopier {
  71071. /**
  71072. * Tries to copy an object by duplicating every property
  71073. * @param source defines the source object
  71074. * @param destination defines the target object
  71075. * @param doNotCopyList defines a list of properties to avoid
  71076. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  71077. */
  71078. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  71079. }
  71080. }
  71081. declare module BABYLON {
  71082. /**
  71083. * Class containing a set of static utilities functions for precision date
  71084. */
  71085. export class PrecisionDate {
  71086. /**
  71087. * Gets either window.performance.now() if supported or Date.now() else
  71088. */
  71089. static get Now(): number;
  71090. }
  71091. }
  71092. declare module BABYLON {
  71093. /** @hidden */
  71094. export class _DevTools {
  71095. static WarnImport(name: string): string;
  71096. }
  71097. }
  71098. declare module BABYLON {
  71099. /**
  71100. * Interface used to define the mechanism to get data from the network
  71101. */
  71102. export interface IWebRequest {
  71103. /**
  71104. * Returns client's response url
  71105. */
  71106. responseURL: string;
  71107. /**
  71108. * Returns client's status
  71109. */
  71110. status: number;
  71111. /**
  71112. * Returns client's status as a text
  71113. */
  71114. statusText: string;
  71115. }
  71116. }
  71117. declare module BABYLON {
  71118. /**
  71119. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  71120. */
  71121. export class WebRequest implements IWebRequest {
  71122. private _xhr;
  71123. /**
  71124. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  71125. * i.e. when loading files, where the server/service expects an Authorization header
  71126. */
  71127. static CustomRequestHeaders: {
  71128. [key: string]: string;
  71129. };
  71130. /**
  71131. * Add callback functions in this array to update all the requests before they get sent to the network
  71132. */
  71133. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  71134. private _injectCustomRequestHeaders;
  71135. /**
  71136. * Gets or sets a function to be called when loading progress changes
  71137. */
  71138. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  71139. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  71140. /**
  71141. * Returns client's state
  71142. */
  71143. get readyState(): number;
  71144. /**
  71145. * Returns client's status
  71146. */
  71147. get status(): number;
  71148. /**
  71149. * Returns client's status as a text
  71150. */
  71151. get statusText(): string;
  71152. /**
  71153. * Returns client's response
  71154. */
  71155. get response(): any;
  71156. /**
  71157. * Returns client's response url
  71158. */
  71159. get responseURL(): string;
  71160. /**
  71161. * Returns client's response as text
  71162. */
  71163. get responseText(): string;
  71164. /**
  71165. * Gets or sets the expected response type
  71166. */
  71167. get responseType(): XMLHttpRequestResponseType;
  71168. set responseType(value: XMLHttpRequestResponseType);
  71169. /** @hidden */
  71170. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  71171. /** @hidden */
  71172. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  71173. /**
  71174. * Cancels any network activity
  71175. */
  71176. abort(): void;
  71177. /**
  71178. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  71179. * @param body defines an optional request body
  71180. */
  71181. send(body?: Document | BodyInit | null): void;
  71182. /**
  71183. * Sets the request method, request URL
  71184. * @param method defines the method to use (GET, POST, etc..)
  71185. * @param url defines the url to connect with
  71186. */
  71187. open(method: string, url: string): void;
  71188. /**
  71189. * Sets the value of a request header.
  71190. * @param name The name of the header whose value is to be set
  71191. * @param value The value to set as the body of the header
  71192. */
  71193. setRequestHeader(name: string, value: string): void;
  71194. /**
  71195. * Get the string containing the text of a particular header's value.
  71196. * @param name The name of the header
  71197. * @returns The string containing the text of the given header name
  71198. */
  71199. getResponseHeader(name: string): Nullable<string>;
  71200. }
  71201. }
  71202. declare module BABYLON {
  71203. /**
  71204. * File request interface
  71205. */
  71206. export interface IFileRequest {
  71207. /**
  71208. * Raised when the request is complete (success or error).
  71209. */
  71210. onCompleteObservable: Observable<IFileRequest>;
  71211. /**
  71212. * Aborts the request for a file.
  71213. */
  71214. abort: () => void;
  71215. }
  71216. }
  71217. declare module BABYLON {
  71218. /**
  71219. * Define options used to create a render target texture
  71220. */
  71221. export class RenderTargetCreationOptions {
  71222. /**
  71223. * Specifies is mipmaps must be generated
  71224. */
  71225. generateMipMaps?: boolean;
  71226. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  71227. generateDepthBuffer?: boolean;
  71228. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  71229. generateStencilBuffer?: boolean;
  71230. /** Defines texture type (int by default) */
  71231. type?: number;
  71232. /** Defines sampling mode (trilinear by default) */
  71233. samplingMode?: number;
  71234. /** Defines format (RGBA by default) */
  71235. format?: number;
  71236. }
  71237. }
  71238. declare module BABYLON {
  71239. /**
  71240. * @hidden
  71241. **/
  71242. export class _TimeToken {
  71243. _startTimeQuery: Nullable<WebGLQuery>;
  71244. _endTimeQuery: Nullable<WebGLQuery>;
  71245. _timeElapsedQuery: Nullable<WebGLQuery>;
  71246. _timeElapsedQueryEnded: boolean;
  71247. }
  71248. }
  71249. declare module BABYLON {
  71250. /** Defines the cross module used constants to avoid circular dependncies */
  71251. export class Constants {
  71252. /** Defines that alpha blending is disabled */
  71253. static readonly ALPHA_DISABLE: number;
  71254. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  71255. static readonly ALPHA_ADD: number;
  71256. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  71257. static readonly ALPHA_COMBINE: number;
  71258. /** Defines that alpha blending is DEST - SRC * DEST */
  71259. static readonly ALPHA_SUBTRACT: number;
  71260. /** Defines that alpha blending is SRC * DEST */
  71261. static readonly ALPHA_MULTIPLY: number;
  71262. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  71263. static readonly ALPHA_MAXIMIZED: number;
  71264. /** Defines that alpha blending is SRC + DEST */
  71265. static readonly ALPHA_ONEONE: number;
  71266. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  71267. static readonly ALPHA_PREMULTIPLIED: number;
  71268. /**
  71269. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  71270. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  71271. */
  71272. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  71273. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  71274. static readonly ALPHA_INTERPOLATE: number;
  71275. /**
  71276. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  71277. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  71278. */
  71279. static readonly ALPHA_SCREENMODE: number;
  71280. /**
  71281. * Defines that alpha blending is SRC + DST
  71282. * Alpha will be set to SRC ALPHA + DST ALPHA
  71283. */
  71284. static readonly ALPHA_ONEONE_ONEONE: number;
  71285. /**
  71286. * Defines that alpha blending is SRC * DST ALPHA + DST
  71287. * Alpha will be set to 0
  71288. */
  71289. static readonly ALPHA_ALPHATOCOLOR: number;
  71290. /**
  71291. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  71292. */
  71293. static readonly ALPHA_REVERSEONEMINUS: number;
  71294. /**
  71295. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  71296. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  71297. */
  71298. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  71299. /**
  71300. * Defines that alpha blending is SRC + DST
  71301. * Alpha will be set to SRC ALPHA
  71302. */
  71303. static readonly ALPHA_ONEONE_ONEZERO: number;
  71304. /**
  71305. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  71306. * Alpha will be set to DST ALPHA
  71307. */
  71308. static readonly ALPHA_EXCLUSION: number;
  71309. /** Defines that alpha blending equation a SUM */
  71310. static readonly ALPHA_EQUATION_ADD: number;
  71311. /** Defines that alpha blending equation a SUBSTRACTION */
  71312. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  71313. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  71314. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  71315. /** Defines that alpha blending equation a MAX operation */
  71316. static readonly ALPHA_EQUATION_MAX: number;
  71317. /** Defines that alpha blending equation a MIN operation */
  71318. static readonly ALPHA_EQUATION_MIN: number;
  71319. /**
  71320. * Defines that alpha blending equation a DARKEN operation:
  71321. * It takes the min of the src and sums the alpha channels.
  71322. */
  71323. static readonly ALPHA_EQUATION_DARKEN: number;
  71324. /** Defines that the ressource is not delayed*/
  71325. static readonly DELAYLOADSTATE_NONE: number;
  71326. /** Defines that the ressource was successfully delay loaded */
  71327. static readonly DELAYLOADSTATE_LOADED: number;
  71328. /** Defines that the ressource is currently delay loading */
  71329. static readonly DELAYLOADSTATE_LOADING: number;
  71330. /** Defines that the ressource is delayed and has not started loading */
  71331. static readonly DELAYLOADSTATE_NOTLOADED: number;
  71332. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  71333. static readonly NEVER: number;
  71334. /** 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 */
  71335. static readonly ALWAYS: number;
  71336. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  71337. static readonly LESS: number;
  71338. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  71339. static readonly EQUAL: number;
  71340. /** 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 */
  71341. static readonly LEQUAL: number;
  71342. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  71343. static readonly GREATER: number;
  71344. /** 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 */
  71345. static readonly GEQUAL: number;
  71346. /** 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 */
  71347. static readonly NOTEQUAL: number;
  71348. /** Passed to stencilOperation to specify that stencil value must be kept */
  71349. static readonly KEEP: number;
  71350. /** Passed to stencilOperation to specify that stencil value must be replaced */
  71351. static readonly REPLACE: number;
  71352. /** Passed to stencilOperation to specify that stencil value must be incremented */
  71353. static readonly INCR: number;
  71354. /** Passed to stencilOperation to specify that stencil value must be decremented */
  71355. static readonly DECR: number;
  71356. /** Passed to stencilOperation to specify that stencil value must be inverted */
  71357. static readonly INVERT: number;
  71358. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  71359. static readonly INCR_WRAP: number;
  71360. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  71361. static readonly DECR_WRAP: number;
  71362. /** Texture is not repeating outside of 0..1 UVs */
  71363. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  71364. /** Texture is repeating outside of 0..1 UVs */
  71365. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  71366. /** Texture is repeating and mirrored */
  71367. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  71368. /** ALPHA */
  71369. static readonly TEXTUREFORMAT_ALPHA: number;
  71370. /** LUMINANCE */
  71371. static readonly TEXTUREFORMAT_LUMINANCE: number;
  71372. /** LUMINANCE_ALPHA */
  71373. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  71374. /** RGB */
  71375. static readonly TEXTUREFORMAT_RGB: number;
  71376. /** RGBA */
  71377. static readonly TEXTUREFORMAT_RGBA: number;
  71378. /** RED */
  71379. static readonly TEXTUREFORMAT_RED: number;
  71380. /** RED (2nd reference) */
  71381. static readonly TEXTUREFORMAT_R: number;
  71382. /** RG */
  71383. static readonly TEXTUREFORMAT_RG: number;
  71384. /** RED_INTEGER */
  71385. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  71386. /** RED_INTEGER (2nd reference) */
  71387. static readonly TEXTUREFORMAT_R_INTEGER: number;
  71388. /** RG_INTEGER */
  71389. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  71390. /** RGB_INTEGER */
  71391. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  71392. /** RGBA_INTEGER */
  71393. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  71394. /** UNSIGNED_BYTE */
  71395. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  71396. /** UNSIGNED_BYTE (2nd reference) */
  71397. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  71398. /** FLOAT */
  71399. static readonly TEXTURETYPE_FLOAT: number;
  71400. /** HALF_FLOAT */
  71401. static readonly TEXTURETYPE_HALF_FLOAT: number;
  71402. /** BYTE */
  71403. static readonly TEXTURETYPE_BYTE: number;
  71404. /** SHORT */
  71405. static readonly TEXTURETYPE_SHORT: number;
  71406. /** UNSIGNED_SHORT */
  71407. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  71408. /** INT */
  71409. static readonly TEXTURETYPE_INT: number;
  71410. /** UNSIGNED_INT */
  71411. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  71412. /** UNSIGNED_SHORT_4_4_4_4 */
  71413. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  71414. /** UNSIGNED_SHORT_5_5_5_1 */
  71415. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  71416. /** UNSIGNED_SHORT_5_6_5 */
  71417. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  71418. /** UNSIGNED_INT_2_10_10_10_REV */
  71419. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  71420. /** UNSIGNED_INT_24_8 */
  71421. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  71422. /** UNSIGNED_INT_10F_11F_11F_REV */
  71423. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  71424. /** UNSIGNED_INT_5_9_9_9_REV */
  71425. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  71426. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  71427. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  71428. /** nearest is mag = nearest and min = nearest and mip = nearest */
  71429. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  71430. /** Bilinear is mag = linear and min = linear and mip = nearest */
  71431. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  71432. /** Trilinear is mag = linear and min = linear and mip = linear */
  71433. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  71434. /** nearest is mag = nearest and min = nearest and mip = linear */
  71435. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  71436. /** Bilinear is mag = linear and min = linear and mip = nearest */
  71437. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  71438. /** Trilinear is mag = linear and min = linear and mip = linear */
  71439. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  71440. /** mag = nearest and min = nearest and mip = nearest */
  71441. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  71442. /** mag = nearest and min = linear and mip = nearest */
  71443. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  71444. /** mag = nearest and min = linear and mip = linear */
  71445. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  71446. /** mag = nearest and min = linear and mip = none */
  71447. static readonly TEXTURE_NEAREST_LINEAR: number;
  71448. /** mag = nearest and min = nearest and mip = none */
  71449. static readonly TEXTURE_NEAREST_NEAREST: number;
  71450. /** mag = linear and min = nearest and mip = nearest */
  71451. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  71452. /** mag = linear and min = nearest and mip = linear */
  71453. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  71454. /** mag = linear and min = linear and mip = none */
  71455. static readonly TEXTURE_LINEAR_LINEAR: number;
  71456. /** mag = linear and min = nearest and mip = none */
  71457. static readonly TEXTURE_LINEAR_NEAREST: number;
  71458. /** Explicit coordinates mode */
  71459. static readonly TEXTURE_EXPLICIT_MODE: number;
  71460. /** Spherical coordinates mode */
  71461. static readonly TEXTURE_SPHERICAL_MODE: number;
  71462. /** Planar coordinates mode */
  71463. static readonly TEXTURE_PLANAR_MODE: number;
  71464. /** Cubic coordinates mode */
  71465. static readonly TEXTURE_CUBIC_MODE: number;
  71466. /** Projection coordinates mode */
  71467. static readonly TEXTURE_PROJECTION_MODE: number;
  71468. /** Skybox coordinates mode */
  71469. static readonly TEXTURE_SKYBOX_MODE: number;
  71470. /** Inverse Cubic coordinates mode */
  71471. static readonly TEXTURE_INVCUBIC_MODE: number;
  71472. /** Equirectangular coordinates mode */
  71473. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  71474. /** Equirectangular Fixed coordinates mode */
  71475. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  71476. /** Equirectangular Fixed Mirrored coordinates mode */
  71477. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  71478. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  71479. static readonly SCALEMODE_FLOOR: number;
  71480. /** Defines that texture rescaling will look for the nearest power of 2 size */
  71481. static readonly SCALEMODE_NEAREST: number;
  71482. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  71483. static readonly SCALEMODE_CEILING: number;
  71484. /**
  71485. * The dirty texture flag value
  71486. */
  71487. static readonly MATERIAL_TextureDirtyFlag: number;
  71488. /**
  71489. * The dirty light flag value
  71490. */
  71491. static readonly MATERIAL_LightDirtyFlag: number;
  71492. /**
  71493. * The dirty fresnel flag value
  71494. */
  71495. static readonly MATERIAL_FresnelDirtyFlag: number;
  71496. /**
  71497. * The dirty attribute flag value
  71498. */
  71499. static readonly MATERIAL_AttributesDirtyFlag: number;
  71500. /**
  71501. * The dirty misc flag value
  71502. */
  71503. static readonly MATERIAL_MiscDirtyFlag: number;
  71504. /**
  71505. * The all dirty flag value
  71506. */
  71507. static readonly MATERIAL_AllDirtyFlag: number;
  71508. /**
  71509. * Returns the triangle fill mode
  71510. */
  71511. static readonly MATERIAL_TriangleFillMode: number;
  71512. /**
  71513. * Returns the wireframe mode
  71514. */
  71515. static readonly MATERIAL_WireFrameFillMode: number;
  71516. /**
  71517. * Returns the point fill mode
  71518. */
  71519. static readonly MATERIAL_PointFillMode: number;
  71520. /**
  71521. * Returns the point list draw mode
  71522. */
  71523. static readonly MATERIAL_PointListDrawMode: number;
  71524. /**
  71525. * Returns the line list draw mode
  71526. */
  71527. static readonly MATERIAL_LineListDrawMode: number;
  71528. /**
  71529. * Returns the line loop draw mode
  71530. */
  71531. static readonly MATERIAL_LineLoopDrawMode: number;
  71532. /**
  71533. * Returns the line strip draw mode
  71534. */
  71535. static readonly MATERIAL_LineStripDrawMode: number;
  71536. /**
  71537. * Returns the triangle strip draw mode
  71538. */
  71539. static readonly MATERIAL_TriangleStripDrawMode: number;
  71540. /**
  71541. * Returns the triangle fan draw mode
  71542. */
  71543. static readonly MATERIAL_TriangleFanDrawMode: number;
  71544. /**
  71545. * Stores the clock-wise side orientation
  71546. */
  71547. static readonly MATERIAL_ClockWiseSideOrientation: number;
  71548. /**
  71549. * Stores the counter clock-wise side orientation
  71550. */
  71551. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  71552. /**
  71553. * Nothing
  71554. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71555. */
  71556. static readonly ACTION_NothingTrigger: number;
  71557. /**
  71558. * On pick
  71559. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71560. */
  71561. static readonly ACTION_OnPickTrigger: number;
  71562. /**
  71563. * On left pick
  71564. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71565. */
  71566. static readonly ACTION_OnLeftPickTrigger: number;
  71567. /**
  71568. * On right pick
  71569. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71570. */
  71571. static readonly ACTION_OnRightPickTrigger: number;
  71572. /**
  71573. * On center pick
  71574. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71575. */
  71576. static readonly ACTION_OnCenterPickTrigger: number;
  71577. /**
  71578. * On pick down
  71579. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71580. */
  71581. static readonly ACTION_OnPickDownTrigger: number;
  71582. /**
  71583. * On double pick
  71584. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71585. */
  71586. static readonly ACTION_OnDoublePickTrigger: number;
  71587. /**
  71588. * On pick up
  71589. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71590. */
  71591. static readonly ACTION_OnPickUpTrigger: number;
  71592. /**
  71593. * On pick out.
  71594. * This trigger will only be raised if you also declared a OnPickDown
  71595. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71596. */
  71597. static readonly ACTION_OnPickOutTrigger: number;
  71598. /**
  71599. * On long press
  71600. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71601. */
  71602. static readonly ACTION_OnLongPressTrigger: number;
  71603. /**
  71604. * On pointer over
  71605. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71606. */
  71607. static readonly ACTION_OnPointerOverTrigger: number;
  71608. /**
  71609. * On pointer out
  71610. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71611. */
  71612. static readonly ACTION_OnPointerOutTrigger: number;
  71613. /**
  71614. * On every frame
  71615. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71616. */
  71617. static readonly ACTION_OnEveryFrameTrigger: number;
  71618. /**
  71619. * On intersection enter
  71620. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71621. */
  71622. static readonly ACTION_OnIntersectionEnterTrigger: number;
  71623. /**
  71624. * On intersection exit
  71625. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71626. */
  71627. static readonly ACTION_OnIntersectionExitTrigger: number;
  71628. /**
  71629. * On key down
  71630. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71631. */
  71632. static readonly ACTION_OnKeyDownTrigger: number;
  71633. /**
  71634. * On key up
  71635. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71636. */
  71637. static readonly ACTION_OnKeyUpTrigger: number;
  71638. /**
  71639. * Billboard mode will only apply to Y axis
  71640. */
  71641. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  71642. /**
  71643. * Billboard mode will apply to all axes
  71644. */
  71645. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  71646. /**
  71647. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  71648. */
  71649. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  71650. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  71651. * Test order :
  71652. * Is the bounding sphere outside the frustum ?
  71653. * If not, are the bounding box vertices outside the frustum ?
  71654. * It not, then the cullable object is in the frustum.
  71655. */
  71656. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  71657. /** Culling strategy : Bounding Sphere Only.
  71658. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  71659. * It's also less accurate than the standard because some not visible objects can still be selected.
  71660. * Test : is the bounding sphere outside the frustum ?
  71661. * If not, then the cullable object is in the frustum.
  71662. */
  71663. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  71664. /** Culling strategy : Optimistic Inclusion.
  71665. * This in an inclusion test first, then the standard exclusion test.
  71666. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  71667. * 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.
  71668. * Anyway, it's as accurate as the standard strategy.
  71669. * Test :
  71670. * Is the cullable object bounding sphere center in the frustum ?
  71671. * If not, apply the default culling strategy.
  71672. */
  71673. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  71674. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  71675. * This in an inclusion test first, then the bounding sphere only exclusion test.
  71676. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  71677. * 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.
  71678. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  71679. * Test :
  71680. * Is the cullable object bounding sphere center in the frustum ?
  71681. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  71682. */
  71683. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  71684. /**
  71685. * No logging while loading
  71686. */
  71687. static readonly SCENELOADER_NO_LOGGING: number;
  71688. /**
  71689. * Minimal logging while loading
  71690. */
  71691. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  71692. /**
  71693. * Summary logging while loading
  71694. */
  71695. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  71696. /**
  71697. * Detailled logging while loading
  71698. */
  71699. static readonly SCENELOADER_DETAILED_LOGGING: number;
  71700. }
  71701. }
  71702. declare module BABYLON {
  71703. /**
  71704. * This represents the required contract to create a new type of texture loader.
  71705. */
  71706. export interface IInternalTextureLoader {
  71707. /**
  71708. * Defines wether the loader supports cascade loading the different faces.
  71709. */
  71710. supportCascades: boolean;
  71711. /**
  71712. * This returns if the loader support the current file information.
  71713. * @param extension defines the file extension of the file being loaded
  71714. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71715. * @param fallback defines the fallback internal texture if any
  71716. * @param isBase64 defines whether the texture is encoded as a base64
  71717. * @param isBuffer defines whether the texture data are stored as a buffer
  71718. * @returns true if the loader can load the specified file
  71719. */
  71720. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  71721. /**
  71722. * Transform the url before loading if required.
  71723. * @param rootUrl the url of the texture
  71724. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71725. * @returns the transformed texture
  71726. */
  71727. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  71728. /**
  71729. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  71730. * @param rootUrl the url of the texture
  71731. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71732. * @returns the fallback texture
  71733. */
  71734. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  71735. /**
  71736. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  71737. * @param data contains the texture data
  71738. * @param texture defines the BabylonJS internal texture
  71739. * @param createPolynomials will be true if polynomials have been requested
  71740. * @param onLoad defines the callback to trigger once the texture is ready
  71741. * @param onError defines the callback to trigger in case of error
  71742. */
  71743. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  71744. /**
  71745. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  71746. * @param data contains the texture data
  71747. * @param texture defines the BabylonJS internal texture
  71748. * @param callback defines the method to call once ready to upload
  71749. */
  71750. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  71751. }
  71752. }
  71753. declare module BABYLON {
  71754. /**
  71755. * Class used to store and describe the pipeline context associated with an effect
  71756. */
  71757. export interface IPipelineContext {
  71758. /**
  71759. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  71760. */
  71761. isAsync: boolean;
  71762. /**
  71763. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  71764. */
  71765. isReady: boolean;
  71766. /** @hidden */
  71767. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  71768. }
  71769. }
  71770. declare module BABYLON {
  71771. /**
  71772. * Class used to store gfx data (like WebGLBuffer)
  71773. */
  71774. export class DataBuffer {
  71775. /**
  71776. * Gets or sets the number of objects referencing this buffer
  71777. */
  71778. references: number;
  71779. /** Gets or sets the size of the underlying buffer */
  71780. capacity: number;
  71781. /**
  71782. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  71783. */
  71784. is32Bits: boolean;
  71785. /**
  71786. * Gets the underlying buffer
  71787. */
  71788. get underlyingResource(): any;
  71789. }
  71790. }
  71791. declare module BABYLON {
  71792. /** @hidden */
  71793. export interface IShaderProcessor {
  71794. attributeProcessor?: (attribute: string) => string;
  71795. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  71796. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  71797. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  71798. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  71799. lineProcessor?: (line: string, isFragment: boolean) => string;
  71800. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71801. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71802. }
  71803. }
  71804. declare module BABYLON {
  71805. /** @hidden */
  71806. export interface ProcessingOptions {
  71807. defines: string[];
  71808. indexParameters: any;
  71809. isFragment: boolean;
  71810. shouldUseHighPrecisionShader: boolean;
  71811. supportsUniformBuffers: boolean;
  71812. shadersRepository: string;
  71813. includesShadersStore: {
  71814. [key: string]: string;
  71815. };
  71816. processor?: IShaderProcessor;
  71817. version: string;
  71818. platformName: string;
  71819. lookForClosingBracketForUniformBuffer?: boolean;
  71820. }
  71821. }
  71822. declare module BABYLON {
  71823. /** @hidden */
  71824. export class ShaderCodeNode {
  71825. line: string;
  71826. children: ShaderCodeNode[];
  71827. additionalDefineKey?: string;
  71828. additionalDefineValue?: string;
  71829. isValid(preprocessors: {
  71830. [key: string]: string;
  71831. }): boolean;
  71832. process(preprocessors: {
  71833. [key: string]: string;
  71834. }, options: ProcessingOptions): string;
  71835. }
  71836. }
  71837. declare module BABYLON {
  71838. /** @hidden */
  71839. export class ShaderCodeCursor {
  71840. private _lines;
  71841. lineIndex: number;
  71842. get currentLine(): string;
  71843. get canRead(): boolean;
  71844. set lines(value: string[]);
  71845. }
  71846. }
  71847. declare module BABYLON {
  71848. /** @hidden */
  71849. export class ShaderCodeConditionNode extends ShaderCodeNode {
  71850. process(preprocessors: {
  71851. [key: string]: string;
  71852. }, options: ProcessingOptions): string;
  71853. }
  71854. }
  71855. declare module BABYLON {
  71856. /** @hidden */
  71857. export class ShaderDefineExpression {
  71858. isTrue(preprocessors: {
  71859. [key: string]: string;
  71860. }): boolean;
  71861. }
  71862. }
  71863. declare module BABYLON {
  71864. /** @hidden */
  71865. export class ShaderCodeTestNode extends ShaderCodeNode {
  71866. testExpression: ShaderDefineExpression;
  71867. isValid(preprocessors: {
  71868. [key: string]: string;
  71869. }): boolean;
  71870. }
  71871. }
  71872. declare module BABYLON {
  71873. /** @hidden */
  71874. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  71875. define: string;
  71876. not: boolean;
  71877. constructor(define: string, not?: boolean);
  71878. isTrue(preprocessors: {
  71879. [key: string]: string;
  71880. }): boolean;
  71881. }
  71882. }
  71883. declare module BABYLON {
  71884. /** @hidden */
  71885. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  71886. leftOperand: ShaderDefineExpression;
  71887. rightOperand: ShaderDefineExpression;
  71888. isTrue(preprocessors: {
  71889. [key: string]: string;
  71890. }): boolean;
  71891. }
  71892. }
  71893. declare module BABYLON {
  71894. /** @hidden */
  71895. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  71896. leftOperand: ShaderDefineExpression;
  71897. rightOperand: ShaderDefineExpression;
  71898. isTrue(preprocessors: {
  71899. [key: string]: string;
  71900. }): boolean;
  71901. }
  71902. }
  71903. declare module BABYLON {
  71904. /** @hidden */
  71905. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  71906. define: string;
  71907. operand: string;
  71908. testValue: string;
  71909. constructor(define: string, operand: string, testValue: string);
  71910. isTrue(preprocessors: {
  71911. [key: string]: string;
  71912. }): boolean;
  71913. }
  71914. }
  71915. declare module BABYLON {
  71916. /**
  71917. * Class used to enable access to offline support
  71918. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71919. */
  71920. export interface IOfflineProvider {
  71921. /**
  71922. * Gets a boolean indicating if scene must be saved in the database
  71923. */
  71924. enableSceneOffline: boolean;
  71925. /**
  71926. * Gets a boolean indicating if textures must be saved in the database
  71927. */
  71928. enableTexturesOffline: boolean;
  71929. /**
  71930. * Open the offline support and make it available
  71931. * @param successCallback defines the callback to call on success
  71932. * @param errorCallback defines the callback to call on error
  71933. */
  71934. open(successCallback: () => void, errorCallback: () => void): void;
  71935. /**
  71936. * Loads an image from the offline support
  71937. * @param url defines the url to load from
  71938. * @param image defines the target DOM image
  71939. */
  71940. loadImage(url: string, image: HTMLImageElement): void;
  71941. /**
  71942. * Loads a file from offline support
  71943. * @param url defines the URL to load from
  71944. * @param sceneLoaded defines a callback to call on success
  71945. * @param progressCallBack defines a callback to call when progress changed
  71946. * @param errorCallback defines a callback to call on error
  71947. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71948. */
  71949. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71950. }
  71951. }
  71952. declare module BABYLON {
  71953. /**
  71954. * Class used to help managing file picking and drag'n'drop
  71955. * File Storage
  71956. */
  71957. export class FilesInputStore {
  71958. /**
  71959. * List of files ready to be loaded
  71960. */
  71961. static FilesToLoad: {
  71962. [key: string]: File;
  71963. };
  71964. }
  71965. }
  71966. declare module BABYLON {
  71967. /**
  71968. * Class used to define a retry strategy when error happens while loading assets
  71969. */
  71970. export class RetryStrategy {
  71971. /**
  71972. * Function used to defines an exponential back off strategy
  71973. * @param maxRetries defines the maximum number of retries (3 by default)
  71974. * @param baseInterval defines the interval between retries
  71975. * @returns the strategy function to use
  71976. */
  71977. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  71978. }
  71979. }
  71980. declare module BABYLON {
  71981. /**
  71982. * @ignore
  71983. * Application error to support additional information when loading a file
  71984. */
  71985. export abstract class BaseError extends Error {
  71986. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  71987. }
  71988. }
  71989. declare module BABYLON {
  71990. /** @ignore */
  71991. export class LoadFileError extends BaseError {
  71992. request?: WebRequest;
  71993. file?: File;
  71994. /**
  71995. * Creates a new LoadFileError
  71996. * @param message defines the message of the error
  71997. * @param request defines the optional web request
  71998. * @param file defines the optional file
  71999. */
  72000. constructor(message: string, object?: WebRequest | File);
  72001. }
  72002. /** @ignore */
  72003. export class RequestFileError extends BaseError {
  72004. request: WebRequest;
  72005. /**
  72006. * Creates a new LoadFileError
  72007. * @param message defines the message of the error
  72008. * @param request defines the optional web request
  72009. */
  72010. constructor(message: string, request: WebRequest);
  72011. }
  72012. /** @ignore */
  72013. export class ReadFileError extends BaseError {
  72014. file: File;
  72015. /**
  72016. * Creates a new ReadFileError
  72017. * @param message defines the message of the error
  72018. * @param file defines the optional file
  72019. */
  72020. constructor(message: string, file: File);
  72021. }
  72022. /**
  72023. * @hidden
  72024. */
  72025. export class FileTools {
  72026. /**
  72027. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  72028. */
  72029. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  72030. /**
  72031. * Gets or sets the base URL to use to load assets
  72032. */
  72033. static BaseUrl: string;
  72034. /**
  72035. * Default behaviour for cors in the application.
  72036. * It can be a string if the expected behavior is identical in the entire app.
  72037. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  72038. */
  72039. static CorsBehavior: string | ((url: string | string[]) => string);
  72040. /**
  72041. * Gets or sets a function used to pre-process url before using them to load assets
  72042. */
  72043. static PreprocessUrl: (url: string) => string;
  72044. /**
  72045. * Removes unwanted characters from an url
  72046. * @param url defines the url to clean
  72047. * @returns the cleaned url
  72048. */
  72049. private static _CleanUrl;
  72050. /**
  72051. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  72052. * @param url define the url we are trying
  72053. * @param element define the dom element where to configure the cors policy
  72054. */
  72055. static SetCorsBehavior(url: string | string[], element: {
  72056. crossOrigin: string | null;
  72057. }): void;
  72058. /**
  72059. * Loads an image as an HTMLImageElement.
  72060. * @param input url string, ArrayBuffer, or Blob to load
  72061. * @param onLoad callback called when the image successfully loads
  72062. * @param onError callback called when the image fails to load
  72063. * @param offlineProvider offline provider for caching
  72064. * @param mimeType optional mime type
  72065. * @returns the HTMLImageElement of the loaded image
  72066. */
  72067. 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>;
  72068. /**
  72069. * Reads a file from a File object
  72070. * @param file defines the file to load
  72071. * @param onSuccess defines the callback to call when data is loaded
  72072. * @param onProgress defines the callback to call during loading process
  72073. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  72074. * @param onError defines the callback to call when an error occurs
  72075. * @returns a file request object
  72076. */
  72077. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  72078. /**
  72079. * Loads a file from a url
  72080. * @param url url to load
  72081. * @param onSuccess callback called when the file successfully loads
  72082. * @param onProgress callback called while file is loading (if the server supports this mode)
  72083. * @param offlineProvider defines the offline provider for caching
  72084. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  72085. * @param onError callback called when the file fails to load
  72086. * @returns a file request object
  72087. */
  72088. 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;
  72089. /**
  72090. * Loads a file
  72091. * @param url url to load
  72092. * @param onSuccess callback called when the file successfully loads
  72093. * @param onProgress callback called while file is loading (if the server supports this mode)
  72094. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  72095. * @param onError callback called when the file fails to load
  72096. * @param onOpened callback called when the web request is opened
  72097. * @returns a file request object
  72098. */
  72099. 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;
  72100. /**
  72101. * Checks if the loaded document was accessed via `file:`-Protocol.
  72102. * @returns boolean
  72103. */
  72104. static IsFileURL(): boolean;
  72105. }
  72106. }
  72107. declare module BABYLON {
  72108. /** @hidden */
  72109. export class ShaderProcessor {
  72110. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  72111. private static _ProcessPrecision;
  72112. private static _ExtractOperation;
  72113. private static _BuildSubExpression;
  72114. private static _BuildExpression;
  72115. private static _MoveCursorWithinIf;
  72116. private static _MoveCursor;
  72117. private static _EvaluatePreProcessors;
  72118. private static _PreparePreProcessors;
  72119. private static _ProcessShaderConversion;
  72120. private static _ProcessIncludes;
  72121. /**
  72122. * Loads a file from a url
  72123. * @param url url to load
  72124. * @param onSuccess callback called when the file successfully loads
  72125. * @param onProgress callback called while file is loading (if the server supports this mode)
  72126. * @param offlineProvider defines the offline provider for caching
  72127. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  72128. * @param onError callback called when the file fails to load
  72129. * @returns a file request object
  72130. * @hidden
  72131. */
  72132. 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;
  72133. }
  72134. }
  72135. declare module BABYLON {
  72136. /**
  72137. * @hidden
  72138. */
  72139. export interface IColor4Like {
  72140. r: float;
  72141. g: float;
  72142. b: float;
  72143. a: float;
  72144. }
  72145. /**
  72146. * @hidden
  72147. */
  72148. export interface IColor3Like {
  72149. r: float;
  72150. g: float;
  72151. b: float;
  72152. }
  72153. /**
  72154. * @hidden
  72155. */
  72156. export interface IVector4Like {
  72157. x: float;
  72158. y: float;
  72159. z: float;
  72160. w: float;
  72161. }
  72162. /**
  72163. * @hidden
  72164. */
  72165. export interface IVector3Like {
  72166. x: float;
  72167. y: float;
  72168. z: float;
  72169. }
  72170. /**
  72171. * @hidden
  72172. */
  72173. export interface IVector2Like {
  72174. x: float;
  72175. y: float;
  72176. }
  72177. /**
  72178. * @hidden
  72179. */
  72180. export interface IMatrixLike {
  72181. toArray(): DeepImmutable<Float32Array>;
  72182. updateFlag: int;
  72183. }
  72184. /**
  72185. * @hidden
  72186. */
  72187. export interface IViewportLike {
  72188. x: float;
  72189. y: float;
  72190. width: float;
  72191. height: float;
  72192. }
  72193. /**
  72194. * @hidden
  72195. */
  72196. export interface IPlaneLike {
  72197. normal: IVector3Like;
  72198. d: float;
  72199. normalize(): void;
  72200. }
  72201. }
  72202. declare module BABYLON {
  72203. /**
  72204. * Interface used to define common properties for effect fallbacks
  72205. */
  72206. export interface IEffectFallbacks {
  72207. /**
  72208. * Removes the defines that should be removed when falling back.
  72209. * @param currentDefines defines the current define statements for the shader.
  72210. * @param effect defines the current effect we try to compile
  72211. * @returns The resulting defines with defines of the current rank removed.
  72212. */
  72213. reduce(currentDefines: string, effect: Effect): string;
  72214. /**
  72215. * Removes the fallback from the bound mesh.
  72216. */
  72217. unBindMesh(): void;
  72218. /**
  72219. * Checks to see if more fallbacks are still availible.
  72220. */
  72221. hasMoreFallbacks: boolean;
  72222. }
  72223. }
  72224. declare module BABYLON {
  72225. /**
  72226. * Class used to evalaute queries containing `and` and `or` operators
  72227. */
  72228. export class AndOrNotEvaluator {
  72229. /**
  72230. * Evaluate a query
  72231. * @param query defines the query to evaluate
  72232. * @param evaluateCallback defines the callback used to filter result
  72233. * @returns true if the query matches
  72234. */
  72235. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  72236. private static _HandleParenthesisContent;
  72237. private static _SimplifyNegation;
  72238. }
  72239. }
  72240. declare module BABYLON {
  72241. /**
  72242. * Class used to store custom tags
  72243. */
  72244. export class Tags {
  72245. /**
  72246. * Adds support for tags on the given object
  72247. * @param obj defines the object to use
  72248. */
  72249. static EnableFor(obj: any): void;
  72250. /**
  72251. * Removes tags support
  72252. * @param obj defines the object to use
  72253. */
  72254. static DisableFor(obj: any): void;
  72255. /**
  72256. * Gets a boolean indicating if the given object has tags
  72257. * @param obj defines the object to use
  72258. * @returns a boolean
  72259. */
  72260. static HasTags(obj: any): boolean;
  72261. /**
  72262. * Gets the tags available on a given object
  72263. * @param obj defines the object to use
  72264. * @param asString defines if the tags must be returned as a string instead of an array of strings
  72265. * @returns the tags
  72266. */
  72267. static GetTags(obj: any, asString?: boolean): any;
  72268. /**
  72269. * Adds tags to an object
  72270. * @param obj defines the object to use
  72271. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  72272. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  72273. */
  72274. static AddTagsTo(obj: any, tagsString: string): void;
  72275. /**
  72276. * @hidden
  72277. */
  72278. static _AddTagTo(obj: any, tag: string): void;
  72279. /**
  72280. * Removes specific tags from a specific object
  72281. * @param obj defines the object to use
  72282. * @param tagsString defines the tags to remove
  72283. */
  72284. static RemoveTagsFrom(obj: any, tagsString: string): void;
  72285. /**
  72286. * @hidden
  72287. */
  72288. static _RemoveTagFrom(obj: any, tag: string): void;
  72289. /**
  72290. * Defines if tags hosted on an object match a given query
  72291. * @param obj defines the object to use
  72292. * @param tagsQuery defines the tag query
  72293. * @returns a boolean
  72294. */
  72295. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  72296. }
  72297. }
  72298. declare module BABYLON {
  72299. /**
  72300. * Scalar computation library
  72301. */
  72302. export class Scalar {
  72303. /**
  72304. * Two pi constants convenient for computation.
  72305. */
  72306. static TwoPi: number;
  72307. /**
  72308. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  72309. * @param a number
  72310. * @param b number
  72311. * @param epsilon (default = 1.401298E-45)
  72312. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  72313. */
  72314. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  72315. /**
  72316. * Returns a string : the upper case translation of the number i to hexadecimal.
  72317. * @param i number
  72318. * @returns the upper case translation of the number i to hexadecimal.
  72319. */
  72320. static ToHex(i: number): string;
  72321. /**
  72322. * Returns -1 if value is negative and +1 is value is positive.
  72323. * @param value the value
  72324. * @returns the value itself if it's equal to zero.
  72325. */
  72326. static Sign(value: number): number;
  72327. /**
  72328. * Returns the value itself if it's between min and max.
  72329. * Returns min if the value is lower than min.
  72330. * Returns max if the value is greater than max.
  72331. * @param value the value to clmap
  72332. * @param min the min value to clamp to (default: 0)
  72333. * @param max the max value to clamp to (default: 1)
  72334. * @returns the clamped value
  72335. */
  72336. static Clamp(value: number, min?: number, max?: number): number;
  72337. /**
  72338. * the log2 of value.
  72339. * @param value the value to compute log2 of
  72340. * @returns the log2 of value.
  72341. */
  72342. static Log2(value: number): number;
  72343. /**
  72344. * Loops the value, so that it is never larger than length and never smaller than 0.
  72345. *
  72346. * This is similar to the modulo operator but it works with floating point numbers.
  72347. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  72348. * With t = 5 and length = 2.5, the result would be 0.0.
  72349. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  72350. * @param value the value
  72351. * @param length the length
  72352. * @returns the looped value
  72353. */
  72354. static Repeat(value: number, length: number): number;
  72355. /**
  72356. * Normalize the value between 0.0 and 1.0 using min and max values
  72357. * @param value value to normalize
  72358. * @param min max to normalize between
  72359. * @param max min to normalize between
  72360. * @returns the normalized value
  72361. */
  72362. static Normalize(value: number, min: number, max: number): number;
  72363. /**
  72364. * Denormalize the value from 0.0 and 1.0 using min and max values
  72365. * @param normalized value to denormalize
  72366. * @param min max to denormalize between
  72367. * @param max min to denormalize between
  72368. * @returns the denormalized value
  72369. */
  72370. static Denormalize(normalized: number, min: number, max: number): number;
  72371. /**
  72372. * Calculates the shortest difference between two given angles given in degrees.
  72373. * @param current current angle in degrees
  72374. * @param target target angle in degrees
  72375. * @returns the delta
  72376. */
  72377. static DeltaAngle(current: number, target: number): number;
  72378. /**
  72379. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  72380. * @param tx value
  72381. * @param length length
  72382. * @returns The returned value will move back and forth between 0 and length
  72383. */
  72384. static PingPong(tx: number, length: number): number;
  72385. /**
  72386. * Interpolates between min and max with smoothing at the limits.
  72387. *
  72388. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  72389. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  72390. * @param from from
  72391. * @param to to
  72392. * @param tx value
  72393. * @returns the smooth stepped value
  72394. */
  72395. static SmoothStep(from: number, to: number, tx: number): number;
  72396. /**
  72397. * Moves a value current towards target.
  72398. *
  72399. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  72400. * Negative values of maxDelta pushes the value away from target.
  72401. * @param current current value
  72402. * @param target target value
  72403. * @param maxDelta max distance to move
  72404. * @returns resulting value
  72405. */
  72406. static MoveTowards(current: number, target: number, maxDelta: number): number;
  72407. /**
  72408. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  72409. *
  72410. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  72411. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  72412. * @param current current value
  72413. * @param target target value
  72414. * @param maxDelta max distance to move
  72415. * @returns resulting angle
  72416. */
  72417. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  72418. /**
  72419. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  72420. * @param start start value
  72421. * @param end target value
  72422. * @param amount amount to lerp between
  72423. * @returns the lerped value
  72424. */
  72425. static Lerp(start: number, end: number, amount: number): number;
  72426. /**
  72427. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  72428. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  72429. * @param start start value
  72430. * @param end target value
  72431. * @param amount amount to lerp between
  72432. * @returns the lerped value
  72433. */
  72434. static LerpAngle(start: number, end: number, amount: number): number;
  72435. /**
  72436. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  72437. * @param a start value
  72438. * @param b target value
  72439. * @param value value between a and b
  72440. * @returns the inverseLerp value
  72441. */
  72442. static InverseLerp(a: number, b: number, value: number): number;
  72443. /**
  72444. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  72445. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  72446. * @param value1 spline value
  72447. * @param tangent1 spline value
  72448. * @param value2 spline value
  72449. * @param tangent2 spline value
  72450. * @param amount input value
  72451. * @returns hermite result
  72452. */
  72453. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  72454. /**
  72455. * Returns a random float number between and min and max values
  72456. * @param min min value of random
  72457. * @param max max value of random
  72458. * @returns random value
  72459. */
  72460. static RandomRange(min: number, max: number): number;
  72461. /**
  72462. * This function returns percentage of a number in a given range.
  72463. *
  72464. * RangeToPercent(40,20,60) will return 0.5 (50%)
  72465. * RangeToPercent(34,0,100) will return 0.34 (34%)
  72466. * @param number to convert to percentage
  72467. * @param min min range
  72468. * @param max max range
  72469. * @returns the percentage
  72470. */
  72471. static RangeToPercent(number: number, min: number, max: number): number;
  72472. /**
  72473. * This function returns number that corresponds to the percentage in a given range.
  72474. *
  72475. * PercentToRange(0.34,0,100) will return 34.
  72476. * @param percent to convert to number
  72477. * @param min min range
  72478. * @param max max range
  72479. * @returns the number
  72480. */
  72481. static PercentToRange(percent: number, min: number, max: number): number;
  72482. /**
  72483. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  72484. * @param angle The angle to normalize in radian.
  72485. * @return The converted angle.
  72486. */
  72487. static NormalizeRadians(angle: number): number;
  72488. }
  72489. }
  72490. declare module BABYLON {
  72491. /**
  72492. * Constant used to convert a value to gamma space
  72493. * @ignorenaming
  72494. */
  72495. export const ToGammaSpace: number;
  72496. /**
  72497. * Constant used to convert a value to linear space
  72498. * @ignorenaming
  72499. */
  72500. export const ToLinearSpace = 2.2;
  72501. /**
  72502. * Constant used to define the minimal number value in Babylon.js
  72503. * @ignorenaming
  72504. */
  72505. let Epsilon: number;
  72506. }
  72507. declare module BABYLON {
  72508. /**
  72509. * Class used to represent a viewport on screen
  72510. */
  72511. export class Viewport {
  72512. /** viewport left coordinate */
  72513. x: number;
  72514. /** viewport top coordinate */
  72515. y: number;
  72516. /**viewport width */
  72517. width: number;
  72518. /** viewport height */
  72519. height: number;
  72520. /**
  72521. * Creates a Viewport object located at (x, y) and sized (width, height)
  72522. * @param x defines viewport left coordinate
  72523. * @param y defines viewport top coordinate
  72524. * @param width defines the viewport width
  72525. * @param height defines the viewport height
  72526. */
  72527. constructor(
  72528. /** viewport left coordinate */
  72529. x: number,
  72530. /** viewport top coordinate */
  72531. y: number,
  72532. /**viewport width */
  72533. width: number,
  72534. /** viewport height */
  72535. height: number);
  72536. /**
  72537. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  72538. * @param renderWidth defines the rendering width
  72539. * @param renderHeight defines the rendering height
  72540. * @returns a new Viewport
  72541. */
  72542. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  72543. /**
  72544. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  72545. * @param renderWidth defines the rendering width
  72546. * @param renderHeight defines the rendering height
  72547. * @param ref defines the target viewport
  72548. * @returns the current viewport
  72549. */
  72550. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  72551. /**
  72552. * Returns a new Viewport copied from the current one
  72553. * @returns a new Viewport
  72554. */
  72555. clone(): Viewport;
  72556. }
  72557. }
  72558. declare module BABYLON {
  72559. /**
  72560. * Class containing a set of static utilities functions for arrays.
  72561. */
  72562. export class ArrayTools {
  72563. /**
  72564. * Returns an array of the given size filled with element built from the given constructor and the paramters
  72565. * @param size the number of element to construct and put in the array
  72566. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  72567. * @returns a new array filled with new objects
  72568. */
  72569. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  72570. }
  72571. }
  72572. declare module BABYLON {
  72573. /**
  72574. * Class representing a vector containing 2 coordinates
  72575. */
  72576. export class Vector2 {
  72577. /** defines the first coordinate */
  72578. x: number;
  72579. /** defines the second coordinate */
  72580. y: number;
  72581. /**
  72582. * Creates a new Vector2 from the given x and y coordinates
  72583. * @param x defines the first coordinate
  72584. * @param y defines the second coordinate
  72585. */
  72586. constructor(
  72587. /** defines the first coordinate */
  72588. x?: number,
  72589. /** defines the second coordinate */
  72590. y?: number);
  72591. /**
  72592. * Gets a string with the Vector2 coordinates
  72593. * @returns a string with the Vector2 coordinates
  72594. */
  72595. toString(): string;
  72596. /**
  72597. * Gets class name
  72598. * @returns the string "Vector2"
  72599. */
  72600. getClassName(): string;
  72601. /**
  72602. * Gets current vector hash code
  72603. * @returns the Vector2 hash code as a number
  72604. */
  72605. getHashCode(): number;
  72606. /**
  72607. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  72608. * @param array defines the source array
  72609. * @param index defines the offset in source array
  72610. * @returns the current Vector2
  72611. */
  72612. toArray(array: FloatArray, index?: number): Vector2;
  72613. /**
  72614. * Copy the current vector to an array
  72615. * @returns a new array with 2 elements: the Vector2 coordinates.
  72616. */
  72617. asArray(): number[];
  72618. /**
  72619. * Sets the Vector2 coordinates with the given Vector2 coordinates
  72620. * @param source defines the source Vector2
  72621. * @returns the current updated Vector2
  72622. */
  72623. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  72624. /**
  72625. * Sets the Vector2 coordinates with the given floats
  72626. * @param x defines the first coordinate
  72627. * @param y defines the second coordinate
  72628. * @returns the current updated Vector2
  72629. */
  72630. copyFromFloats(x: number, y: number): Vector2;
  72631. /**
  72632. * Sets the Vector2 coordinates with the given floats
  72633. * @param x defines the first coordinate
  72634. * @param y defines the second coordinate
  72635. * @returns the current updated Vector2
  72636. */
  72637. set(x: number, y: number): Vector2;
  72638. /**
  72639. * Add another vector with the current one
  72640. * @param otherVector defines the other vector
  72641. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  72642. */
  72643. add(otherVector: DeepImmutable<Vector2>): Vector2;
  72644. /**
  72645. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  72646. * @param otherVector defines the other vector
  72647. * @param result defines the target vector
  72648. * @returns the unmodified current Vector2
  72649. */
  72650. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72651. /**
  72652. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  72653. * @param otherVector defines the other vector
  72654. * @returns the current updated Vector2
  72655. */
  72656. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72657. /**
  72658. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  72659. * @param otherVector defines the other vector
  72660. * @returns a new Vector2
  72661. */
  72662. addVector3(otherVector: Vector3): Vector2;
  72663. /**
  72664. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  72665. * @param otherVector defines the other vector
  72666. * @returns a new Vector2
  72667. */
  72668. subtract(otherVector: Vector2): Vector2;
  72669. /**
  72670. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  72671. * @param otherVector defines the other vector
  72672. * @param result defines the target vector
  72673. * @returns the unmodified current Vector2
  72674. */
  72675. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72676. /**
  72677. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  72678. * @param otherVector defines the other vector
  72679. * @returns the current updated Vector2
  72680. */
  72681. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72682. /**
  72683. * Multiplies in place the current Vector2 coordinates by the given ones
  72684. * @param otherVector defines the other vector
  72685. * @returns the current updated Vector2
  72686. */
  72687. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72688. /**
  72689. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  72690. * @param otherVector defines the other vector
  72691. * @returns a new Vector2
  72692. */
  72693. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  72694. /**
  72695. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  72696. * @param otherVector defines the other vector
  72697. * @param result defines the target vector
  72698. * @returns the unmodified current Vector2
  72699. */
  72700. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72701. /**
  72702. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  72703. * @param x defines the first coordinate
  72704. * @param y defines the second coordinate
  72705. * @returns a new Vector2
  72706. */
  72707. multiplyByFloats(x: number, y: number): Vector2;
  72708. /**
  72709. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  72710. * @param otherVector defines the other vector
  72711. * @returns a new Vector2
  72712. */
  72713. divide(otherVector: Vector2): Vector2;
  72714. /**
  72715. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  72716. * @param otherVector defines the other vector
  72717. * @param result defines the target vector
  72718. * @returns the unmodified current Vector2
  72719. */
  72720. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72721. /**
  72722. * Divides the current Vector2 coordinates by the given ones
  72723. * @param otherVector defines the other vector
  72724. * @returns the current updated Vector2
  72725. */
  72726. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72727. /**
  72728. * Gets a new Vector2 with current Vector2 negated coordinates
  72729. * @returns a new Vector2
  72730. */
  72731. negate(): Vector2;
  72732. /**
  72733. * Multiply the Vector2 coordinates by scale
  72734. * @param scale defines the scaling factor
  72735. * @returns the current updated Vector2
  72736. */
  72737. scaleInPlace(scale: number): Vector2;
  72738. /**
  72739. * Returns a new Vector2 scaled by "scale" from the current Vector2
  72740. * @param scale defines the scaling factor
  72741. * @returns a new Vector2
  72742. */
  72743. scale(scale: number): Vector2;
  72744. /**
  72745. * Scale the current Vector2 values by a factor to a given Vector2
  72746. * @param scale defines the scale factor
  72747. * @param result defines the Vector2 object where to store the result
  72748. * @returns the unmodified current Vector2
  72749. */
  72750. scaleToRef(scale: number, result: Vector2): Vector2;
  72751. /**
  72752. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  72753. * @param scale defines the scale factor
  72754. * @param result defines the Vector2 object where to store the result
  72755. * @returns the unmodified current Vector2
  72756. */
  72757. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  72758. /**
  72759. * Gets a boolean if two vectors are equals
  72760. * @param otherVector defines the other vector
  72761. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  72762. */
  72763. equals(otherVector: DeepImmutable<Vector2>): boolean;
  72764. /**
  72765. * Gets a boolean if two vectors are equals (using an epsilon value)
  72766. * @param otherVector defines the other vector
  72767. * @param epsilon defines the minimal distance to consider equality
  72768. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  72769. */
  72770. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  72771. /**
  72772. * Gets a new Vector2 from current Vector2 floored values
  72773. * @returns a new Vector2
  72774. */
  72775. floor(): Vector2;
  72776. /**
  72777. * Gets a new Vector2 from current Vector2 floored values
  72778. * @returns a new Vector2
  72779. */
  72780. fract(): Vector2;
  72781. /**
  72782. * Gets the length of the vector
  72783. * @returns the vector length (float)
  72784. */
  72785. length(): number;
  72786. /**
  72787. * Gets the vector squared length
  72788. * @returns the vector squared length (float)
  72789. */
  72790. lengthSquared(): number;
  72791. /**
  72792. * Normalize the vector
  72793. * @returns the current updated Vector2
  72794. */
  72795. normalize(): Vector2;
  72796. /**
  72797. * Gets a new Vector2 copied from the Vector2
  72798. * @returns a new Vector2
  72799. */
  72800. clone(): Vector2;
  72801. /**
  72802. * Gets a new Vector2(0, 0)
  72803. * @returns a new Vector2
  72804. */
  72805. static Zero(): Vector2;
  72806. /**
  72807. * Gets a new Vector2(1, 1)
  72808. * @returns a new Vector2
  72809. */
  72810. static One(): Vector2;
  72811. /**
  72812. * Gets a new Vector2 set from the given index element of the given array
  72813. * @param array defines the data source
  72814. * @param offset defines the offset in the data source
  72815. * @returns a new Vector2
  72816. */
  72817. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  72818. /**
  72819. * Sets "result" from the given index element of the given array
  72820. * @param array defines the data source
  72821. * @param offset defines the offset in the data source
  72822. * @param result defines the target vector
  72823. */
  72824. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  72825. /**
  72826. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  72827. * @param value1 defines 1st point of control
  72828. * @param value2 defines 2nd point of control
  72829. * @param value3 defines 3rd point of control
  72830. * @param value4 defines 4th point of control
  72831. * @param amount defines the interpolation factor
  72832. * @returns a new Vector2
  72833. */
  72834. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  72835. /**
  72836. * 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".
  72837. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  72838. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  72839. * @param value defines the value to clamp
  72840. * @param min defines the lower limit
  72841. * @param max defines the upper limit
  72842. * @returns a new Vector2
  72843. */
  72844. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  72845. /**
  72846. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  72847. * @param value1 defines the 1st control point
  72848. * @param tangent1 defines the outgoing tangent
  72849. * @param value2 defines the 2nd control point
  72850. * @param tangent2 defines the incoming tangent
  72851. * @param amount defines the interpolation factor
  72852. * @returns a new Vector2
  72853. */
  72854. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  72855. /**
  72856. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  72857. * @param start defines the start vector
  72858. * @param end defines the end vector
  72859. * @param amount defines the interpolation factor
  72860. * @returns a new Vector2
  72861. */
  72862. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  72863. /**
  72864. * Gets the dot product of the vector "left" and the vector "right"
  72865. * @param left defines first vector
  72866. * @param right defines second vector
  72867. * @returns the dot product (float)
  72868. */
  72869. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  72870. /**
  72871. * Returns a new Vector2 equal to the normalized given vector
  72872. * @param vector defines the vector to normalize
  72873. * @returns a new Vector2
  72874. */
  72875. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  72876. /**
  72877. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  72878. * @param left defines 1st vector
  72879. * @param right defines 2nd vector
  72880. * @returns a new Vector2
  72881. */
  72882. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  72883. /**
  72884. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  72885. * @param left defines 1st vector
  72886. * @param right defines 2nd vector
  72887. * @returns a new Vector2
  72888. */
  72889. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  72890. /**
  72891. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  72892. * @param vector defines the vector to transform
  72893. * @param transformation defines the matrix to apply
  72894. * @returns a new Vector2
  72895. */
  72896. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  72897. /**
  72898. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  72899. * @param vector defines the vector to transform
  72900. * @param transformation defines the matrix to apply
  72901. * @param result defines the target vector
  72902. */
  72903. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  72904. /**
  72905. * Determines if a given vector is included in a triangle
  72906. * @param p defines the vector to test
  72907. * @param p0 defines 1st triangle point
  72908. * @param p1 defines 2nd triangle point
  72909. * @param p2 defines 3rd triangle point
  72910. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  72911. */
  72912. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  72913. /**
  72914. * Gets the distance between the vectors "value1" and "value2"
  72915. * @param value1 defines first vector
  72916. * @param value2 defines second vector
  72917. * @returns the distance between vectors
  72918. */
  72919. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  72920. /**
  72921. * Returns the squared distance between the vectors "value1" and "value2"
  72922. * @param value1 defines first vector
  72923. * @param value2 defines second vector
  72924. * @returns the squared distance between vectors
  72925. */
  72926. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  72927. /**
  72928. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  72929. * @param value1 defines first vector
  72930. * @param value2 defines second vector
  72931. * @returns a new Vector2
  72932. */
  72933. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  72934. /**
  72935. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  72936. * @param p defines the middle point
  72937. * @param segA defines one point of the segment
  72938. * @param segB defines the other point of the segment
  72939. * @returns the shortest distance
  72940. */
  72941. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  72942. }
  72943. /**
  72944. * Class used to store (x,y,z) vector representation
  72945. * A Vector3 is the main object used in 3D geometry
  72946. * It can represent etiher the coordinates of a point the space, either a direction
  72947. * Reminder: js uses a left handed forward facing system
  72948. */
  72949. export class Vector3 {
  72950. /**
  72951. * Defines the first coordinates (on X axis)
  72952. */
  72953. x: number;
  72954. /**
  72955. * Defines the second coordinates (on Y axis)
  72956. */
  72957. y: number;
  72958. /**
  72959. * Defines the third coordinates (on Z axis)
  72960. */
  72961. z: number;
  72962. private static _UpReadOnly;
  72963. private static _ZeroReadOnly;
  72964. /**
  72965. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  72966. * @param x defines the first coordinates (on X axis)
  72967. * @param y defines the second coordinates (on Y axis)
  72968. * @param z defines the third coordinates (on Z axis)
  72969. */
  72970. constructor(
  72971. /**
  72972. * Defines the first coordinates (on X axis)
  72973. */
  72974. x?: number,
  72975. /**
  72976. * Defines the second coordinates (on Y axis)
  72977. */
  72978. y?: number,
  72979. /**
  72980. * Defines the third coordinates (on Z axis)
  72981. */
  72982. z?: number);
  72983. /**
  72984. * Creates a string representation of the Vector3
  72985. * @returns a string with the Vector3 coordinates.
  72986. */
  72987. toString(): string;
  72988. /**
  72989. * Gets the class name
  72990. * @returns the string "Vector3"
  72991. */
  72992. getClassName(): string;
  72993. /**
  72994. * Creates the Vector3 hash code
  72995. * @returns a number which tends to be unique between Vector3 instances
  72996. */
  72997. getHashCode(): number;
  72998. /**
  72999. * Creates an array containing three elements : the coordinates of the Vector3
  73000. * @returns a new array of numbers
  73001. */
  73002. asArray(): number[];
  73003. /**
  73004. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  73005. * @param array defines the destination array
  73006. * @param index defines the offset in the destination array
  73007. * @returns the current Vector3
  73008. */
  73009. toArray(array: FloatArray, index?: number): Vector3;
  73010. /**
  73011. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  73012. * @returns a new Quaternion object, computed from the Vector3 coordinates
  73013. */
  73014. toQuaternion(): Quaternion;
  73015. /**
  73016. * Adds the given vector to the current Vector3
  73017. * @param otherVector defines the second operand
  73018. * @returns the current updated Vector3
  73019. */
  73020. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  73021. /**
  73022. * Adds the given coordinates to the current Vector3
  73023. * @param x defines the x coordinate of the operand
  73024. * @param y defines the y coordinate of the operand
  73025. * @param z defines the z coordinate of the operand
  73026. * @returns the current updated Vector3
  73027. */
  73028. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  73029. /**
  73030. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  73031. * @param otherVector defines the second operand
  73032. * @returns the resulting Vector3
  73033. */
  73034. add(otherVector: DeepImmutable<Vector3>): Vector3;
  73035. /**
  73036. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  73037. * @param otherVector defines the second operand
  73038. * @param result defines the Vector3 object where to store the result
  73039. * @returns the current Vector3
  73040. */
  73041. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73042. /**
  73043. * Subtract the given vector from the current Vector3
  73044. * @param otherVector defines the second operand
  73045. * @returns the current updated Vector3
  73046. */
  73047. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  73048. /**
  73049. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  73050. * @param otherVector defines the second operand
  73051. * @returns the resulting Vector3
  73052. */
  73053. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  73054. /**
  73055. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  73056. * @param otherVector defines the second operand
  73057. * @param result defines the Vector3 object where to store the result
  73058. * @returns the current Vector3
  73059. */
  73060. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73061. /**
  73062. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  73063. * @param x defines the x coordinate of the operand
  73064. * @param y defines the y coordinate of the operand
  73065. * @param z defines the z coordinate of the operand
  73066. * @returns the resulting Vector3
  73067. */
  73068. subtractFromFloats(x: number, y: number, z: number): Vector3;
  73069. /**
  73070. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  73071. * @param x defines the x coordinate of the operand
  73072. * @param y defines the y coordinate of the operand
  73073. * @param z defines the z coordinate of the operand
  73074. * @param result defines the Vector3 object where to store the result
  73075. * @returns the current Vector3
  73076. */
  73077. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  73078. /**
  73079. * Gets a new Vector3 set with the current Vector3 negated coordinates
  73080. * @returns a new Vector3
  73081. */
  73082. negate(): Vector3;
  73083. /**
  73084. * Multiplies the Vector3 coordinates by the float "scale"
  73085. * @param scale defines the multiplier factor
  73086. * @returns the current updated Vector3
  73087. */
  73088. scaleInPlace(scale: number): Vector3;
  73089. /**
  73090. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  73091. * @param scale defines the multiplier factor
  73092. * @returns a new Vector3
  73093. */
  73094. scale(scale: number): Vector3;
  73095. /**
  73096. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  73097. * @param scale defines the multiplier factor
  73098. * @param result defines the Vector3 object where to store the result
  73099. * @returns the current Vector3
  73100. */
  73101. scaleToRef(scale: number, result: Vector3): Vector3;
  73102. /**
  73103. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  73104. * @param scale defines the scale factor
  73105. * @param result defines the Vector3 object where to store the result
  73106. * @returns the unmodified current Vector3
  73107. */
  73108. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  73109. /**
  73110. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  73111. * @param otherVector defines the second operand
  73112. * @returns true if both vectors are equals
  73113. */
  73114. equals(otherVector: DeepImmutable<Vector3>): boolean;
  73115. /**
  73116. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  73117. * @param otherVector defines the second operand
  73118. * @param epsilon defines the minimal distance to define values as equals
  73119. * @returns true if both vectors are distant less than epsilon
  73120. */
  73121. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  73122. /**
  73123. * Returns true if the current Vector3 coordinates equals the given floats
  73124. * @param x defines the x coordinate of the operand
  73125. * @param y defines the y coordinate of the operand
  73126. * @param z defines the z coordinate of the operand
  73127. * @returns true if both vectors are equals
  73128. */
  73129. equalsToFloats(x: number, y: number, z: number): boolean;
  73130. /**
  73131. * Multiplies the current Vector3 coordinates by the given ones
  73132. * @param otherVector defines the second operand
  73133. * @returns the current updated Vector3
  73134. */
  73135. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  73136. /**
  73137. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  73138. * @param otherVector defines the second operand
  73139. * @returns the new Vector3
  73140. */
  73141. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  73142. /**
  73143. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  73144. * @param otherVector defines the second operand
  73145. * @param result defines the Vector3 object where to store the result
  73146. * @returns the current Vector3
  73147. */
  73148. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73149. /**
  73150. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  73151. * @param x defines the x coordinate of the operand
  73152. * @param y defines the y coordinate of the operand
  73153. * @param z defines the z coordinate of the operand
  73154. * @returns the new Vector3
  73155. */
  73156. multiplyByFloats(x: number, y: number, z: number): Vector3;
  73157. /**
  73158. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  73159. * @param otherVector defines the second operand
  73160. * @returns the new Vector3
  73161. */
  73162. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  73163. /**
  73164. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  73165. * @param otherVector defines the second operand
  73166. * @param result defines the Vector3 object where to store the result
  73167. * @returns the current Vector3
  73168. */
  73169. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73170. /**
  73171. * Divides the current Vector3 coordinates by the given ones.
  73172. * @param otherVector defines the second operand
  73173. * @returns the current updated Vector3
  73174. */
  73175. divideInPlace(otherVector: Vector3): Vector3;
  73176. /**
  73177. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  73178. * @param other defines the second operand
  73179. * @returns the current updated Vector3
  73180. */
  73181. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  73182. /**
  73183. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  73184. * @param other defines the second operand
  73185. * @returns the current updated Vector3
  73186. */
  73187. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  73188. /**
  73189. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  73190. * @param x defines the x coordinate of the operand
  73191. * @param y defines the y coordinate of the operand
  73192. * @param z defines the z coordinate of the operand
  73193. * @returns the current updated Vector3
  73194. */
  73195. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  73196. /**
  73197. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  73198. * @param x defines the x coordinate of the operand
  73199. * @param y defines the y coordinate of the operand
  73200. * @param z defines the z coordinate of the operand
  73201. * @returns the current updated Vector3
  73202. */
  73203. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  73204. /**
  73205. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  73206. * Check if is non uniform within a certain amount of decimal places to account for this
  73207. * @param epsilon the amount the values can differ
  73208. * @returns if the the vector is non uniform to a certain number of decimal places
  73209. */
  73210. isNonUniformWithinEpsilon(epsilon: number): boolean;
  73211. /**
  73212. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  73213. */
  73214. get isNonUniform(): boolean;
  73215. /**
  73216. * Gets a new Vector3 from current Vector3 floored values
  73217. * @returns a new Vector3
  73218. */
  73219. floor(): Vector3;
  73220. /**
  73221. * Gets a new Vector3 from current Vector3 floored values
  73222. * @returns a new Vector3
  73223. */
  73224. fract(): Vector3;
  73225. /**
  73226. * Gets the length of the Vector3
  73227. * @returns the length of the Vector3
  73228. */
  73229. length(): number;
  73230. /**
  73231. * Gets the squared length of the Vector3
  73232. * @returns squared length of the Vector3
  73233. */
  73234. lengthSquared(): number;
  73235. /**
  73236. * Normalize the current Vector3.
  73237. * Please note that this is an in place operation.
  73238. * @returns the current updated Vector3
  73239. */
  73240. normalize(): Vector3;
  73241. /**
  73242. * Reorders the x y z properties of the vector in place
  73243. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  73244. * @returns the current updated vector
  73245. */
  73246. reorderInPlace(order: string): this;
  73247. /**
  73248. * Rotates the vector around 0,0,0 by a quaternion
  73249. * @param quaternion the rotation quaternion
  73250. * @param result vector to store the result
  73251. * @returns the resulting vector
  73252. */
  73253. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  73254. /**
  73255. * Rotates a vector around a given point
  73256. * @param quaternion the rotation quaternion
  73257. * @param point the point to rotate around
  73258. * @param result vector to store the result
  73259. * @returns the resulting vector
  73260. */
  73261. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  73262. /**
  73263. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  73264. * The cross product is then orthogonal to both current and "other"
  73265. * @param other defines the right operand
  73266. * @returns the cross product
  73267. */
  73268. cross(other: Vector3): Vector3;
  73269. /**
  73270. * Normalize the current Vector3 with the given input length.
  73271. * Please note that this is an in place operation.
  73272. * @param len the length of the vector
  73273. * @returns the current updated Vector3
  73274. */
  73275. normalizeFromLength(len: number): Vector3;
  73276. /**
  73277. * Normalize the current Vector3 to a new vector
  73278. * @returns the new Vector3
  73279. */
  73280. normalizeToNew(): Vector3;
  73281. /**
  73282. * Normalize the current Vector3 to the reference
  73283. * @param reference define the Vector3 to update
  73284. * @returns the updated Vector3
  73285. */
  73286. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  73287. /**
  73288. * Creates a new Vector3 copied from the current Vector3
  73289. * @returns the new Vector3
  73290. */
  73291. clone(): Vector3;
  73292. /**
  73293. * Copies the given vector coordinates to the current Vector3 ones
  73294. * @param source defines the source Vector3
  73295. * @returns the current updated Vector3
  73296. */
  73297. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  73298. /**
  73299. * Copies the given floats to the current Vector3 coordinates
  73300. * @param x defines the x coordinate of the operand
  73301. * @param y defines the y coordinate of the operand
  73302. * @param z defines the z coordinate of the operand
  73303. * @returns the current updated Vector3
  73304. */
  73305. copyFromFloats(x: number, y: number, z: number): Vector3;
  73306. /**
  73307. * Copies the given floats to the current Vector3 coordinates
  73308. * @param x defines the x coordinate of the operand
  73309. * @param y defines the y coordinate of the operand
  73310. * @param z defines the z coordinate of the operand
  73311. * @returns the current updated Vector3
  73312. */
  73313. set(x: number, y: number, z: number): Vector3;
  73314. /**
  73315. * Copies the given float to the current Vector3 coordinates
  73316. * @param v defines the x, y and z coordinates of the operand
  73317. * @returns the current updated Vector3
  73318. */
  73319. setAll(v: number): Vector3;
  73320. /**
  73321. * Get the clip factor between two vectors
  73322. * @param vector0 defines the first operand
  73323. * @param vector1 defines the second operand
  73324. * @param axis defines the axis to use
  73325. * @param size defines the size along the axis
  73326. * @returns the clip factor
  73327. */
  73328. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  73329. /**
  73330. * Get angle between two vectors
  73331. * @param vector0 angle between vector0 and vector1
  73332. * @param vector1 angle between vector0 and vector1
  73333. * @param normal direction of the normal
  73334. * @return the angle between vector0 and vector1
  73335. */
  73336. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  73337. /**
  73338. * Returns a new Vector3 set from the index "offset" of the given array
  73339. * @param array defines the source array
  73340. * @param offset defines the offset in the source array
  73341. * @returns the new Vector3
  73342. */
  73343. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  73344. /**
  73345. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  73346. * @param array defines the source array
  73347. * @param offset defines the offset in the source array
  73348. * @returns the new Vector3
  73349. * @deprecated Please use FromArray instead.
  73350. */
  73351. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  73352. /**
  73353. * Sets the given vector "result" with the element values from the index "offset" of the given array
  73354. * @param array defines the source array
  73355. * @param offset defines the offset in the source array
  73356. * @param result defines the Vector3 where to store the result
  73357. */
  73358. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  73359. /**
  73360. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  73361. * @param array defines the source array
  73362. * @param offset defines the offset in the source array
  73363. * @param result defines the Vector3 where to store the result
  73364. * @deprecated Please use FromArrayToRef instead.
  73365. */
  73366. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  73367. /**
  73368. * Sets the given vector "result" with the given floats.
  73369. * @param x defines the x coordinate of the source
  73370. * @param y defines the y coordinate of the source
  73371. * @param z defines the z coordinate of the source
  73372. * @param result defines the Vector3 where to store the result
  73373. */
  73374. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  73375. /**
  73376. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  73377. * @returns a new empty Vector3
  73378. */
  73379. static Zero(): Vector3;
  73380. /**
  73381. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  73382. * @returns a new unit Vector3
  73383. */
  73384. static One(): Vector3;
  73385. /**
  73386. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  73387. * @returns a new up Vector3
  73388. */
  73389. static Up(): Vector3;
  73390. /**
  73391. * Gets a up Vector3 that must not be updated
  73392. */
  73393. static get UpReadOnly(): DeepImmutable<Vector3>;
  73394. /**
  73395. * Gets a zero Vector3 that must not be updated
  73396. */
  73397. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  73398. /**
  73399. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  73400. * @returns a new down Vector3
  73401. */
  73402. static Down(): Vector3;
  73403. /**
  73404. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  73405. * @returns a new forward Vector3
  73406. */
  73407. static Forward(): Vector3;
  73408. /**
  73409. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  73410. * @returns a new forward Vector3
  73411. */
  73412. static Backward(): Vector3;
  73413. /**
  73414. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  73415. * @returns a new right Vector3
  73416. */
  73417. static Right(): Vector3;
  73418. /**
  73419. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  73420. * @returns a new left Vector3
  73421. */
  73422. static Left(): Vector3;
  73423. /**
  73424. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  73425. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  73426. * @param vector defines the Vector3 to transform
  73427. * @param transformation defines the transformation matrix
  73428. * @returns the transformed Vector3
  73429. */
  73430. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  73431. /**
  73432. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  73433. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  73434. * @param vector defines the Vector3 to transform
  73435. * @param transformation defines the transformation matrix
  73436. * @param result defines the Vector3 where to store the result
  73437. */
  73438. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  73439. /**
  73440. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  73441. * This method computes tranformed coordinates only, not transformed direction vectors
  73442. * @param x define the x coordinate of the source vector
  73443. * @param y define the y coordinate of the source vector
  73444. * @param z define the z coordinate of the source vector
  73445. * @param transformation defines the transformation matrix
  73446. * @param result defines the Vector3 where to store the result
  73447. */
  73448. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  73449. /**
  73450. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  73451. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  73452. * @param vector defines the Vector3 to transform
  73453. * @param transformation defines the transformation matrix
  73454. * @returns the new Vector3
  73455. */
  73456. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  73457. /**
  73458. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  73459. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  73460. * @param vector defines the Vector3 to transform
  73461. * @param transformation defines the transformation matrix
  73462. * @param result defines the Vector3 where to store the result
  73463. */
  73464. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  73465. /**
  73466. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  73467. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  73468. * @param x define the x coordinate of the source vector
  73469. * @param y define the y coordinate of the source vector
  73470. * @param z define the z coordinate of the source vector
  73471. * @param transformation defines the transformation matrix
  73472. * @param result defines the Vector3 where to store the result
  73473. */
  73474. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  73475. /**
  73476. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  73477. * @param value1 defines the first control point
  73478. * @param value2 defines the second control point
  73479. * @param value3 defines the third control point
  73480. * @param value4 defines the fourth control point
  73481. * @param amount defines the amount on the spline to use
  73482. * @returns the new Vector3
  73483. */
  73484. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  73485. /**
  73486. * 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"
  73487. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  73488. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  73489. * @param value defines the current value
  73490. * @param min defines the lower range value
  73491. * @param max defines the upper range value
  73492. * @returns the new Vector3
  73493. */
  73494. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  73495. /**
  73496. * 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"
  73497. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  73498. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  73499. * @param value defines the current value
  73500. * @param min defines the lower range value
  73501. * @param max defines the upper range value
  73502. * @param result defines the Vector3 where to store the result
  73503. */
  73504. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  73505. /**
  73506. * Checks if a given vector is inside a specific range
  73507. * @param v defines the vector to test
  73508. * @param min defines the minimum range
  73509. * @param max defines the maximum range
  73510. */
  73511. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  73512. /**
  73513. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  73514. * @param value1 defines the first control point
  73515. * @param tangent1 defines the first tangent vector
  73516. * @param value2 defines the second control point
  73517. * @param tangent2 defines the second tangent vector
  73518. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  73519. * @returns the new Vector3
  73520. */
  73521. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  73522. /**
  73523. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  73524. * @param start defines the start value
  73525. * @param end defines the end value
  73526. * @param amount max defines amount between both (between 0 and 1)
  73527. * @returns the new Vector3
  73528. */
  73529. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  73530. /**
  73531. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  73532. * @param start defines the start value
  73533. * @param end defines the end value
  73534. * @param amount max defines amount between both (between 0 and 1)
  73535. * @param result defines the Vector3 where to store the result
  73536. */
  73537. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  73538. /**
  73539. * Returns the dot product (float) between the vectors "left" and "right"
  73540. * @param left defines the left operand
  73541. * @param right defines the right operand
  73542. * @returns the dot product
  73543. */
  73544. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  73545. /**
  73546. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  73547. * The cross product is then orthogonal to both "left" and "right"
  73548. * @param left defines the left operand
  73549. * @param right defines the right operand
  73550. * @returns the cross product
  73551. */
  73552. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  73553. /**
  73554. * Sets the given vector "result" with the cross product of "left" and "right"
  73555. * The cross product is then orthogonal to both "left" and "right"
  73556. * @param left defines the left operand
  73557. * @param right defines the right operand
  73558. * @param result defines the Vector3 where to store the result
  73559. */
  73560. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  73561. /**
  73562. * Returns a new Vector3 as the normalization of the given vector
  73563. * @param vector defines the Vector3 to normalize
  73564. * @returns the new Vector3
  73565. */
  73566. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  73567. /**
  73568. * Sets the given vector "result" with the normalization of the given first vector
  73569. * @param vector defines the Vector3 to normalize
  73570. * @param result defines the Vector3 where to store the result
  73571. */
  73572. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  73573. /**
  73574. * Project a Vector3 onto screen space
  73575. * @param vector defines the Vector3 to project
  73576. * @param world defines the world matrix to use
  73577. * @param transform defines the transform (view x projection) matrix to use
  73578. * @param viewport defines the screen viewport to use
  73579. * @returns the new Vector3
  73580. */
  73581. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  73582. /** @hidden */
  73583. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  73584. /**
  73585. * Unproject from screen space to object space
  73586. * @param source defines the screen space Vector3 to use
  73587. * @param viewportWidth defines the current width of the viewport
  73588. * @param viewportHeight defines the current height of the viewport
  73589. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73590. * @param transform defines the transform (view x projection) matrix to use
  73591. * @returns the new Vector3
  73592. */
  73593. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  73594. /**
  73595. * Unproject from screen space to object space
  73596. * @param source defines the screen space Vector3 to use
  73597. * @param viewportWidth defines the current width of the viewport
  73598. * @param viewportHeight defines the current height of the viewport
  73599. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73600. * @param view defines the view matrix to use
  73601. * @param projection defines the projection matrix to use
  73602. * @returns the new Vector3
  73603. */
  73604. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  73605. /**
  73606. * Unproject from screen space to object space
  73607. * @param source defines the screen space Vector3 to use
  73608. * @param viewportWidth defines the current width of the viewport
  73609. * @param viewportHeight defines the current height of the viewport
  73610. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73611. * @param view defines the view matrix to use
  73612. * @param projection defines the projection matrix to use
  73613. * @param result defines the Vector3 where to store the result
  73614. */
  73615. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  73616. /**
  73617. * Unproject from screen space to object space
  73618. * @param sourceX defines the screen space x coordinate to use
  73619. * @param sourceY defines the screen space y coordinate to use
  73620. * @param sourceZ defines the screen space z coordinate to use
  73621. * @param viewportWidth defines the current width of the viewport
  73622. * @param viewportHeight defines the current height of the viewport
  73623. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73624. * @param view defines the view matrix to use
  73625. * @param projection defines the projection matrix to use
  73626. * @param result defines the Vector3 where to store the result
  73627. */
  73628. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  73629. /**
  73630. * Gets the minimal coordinate values between two Vector3
  73631. * @param left defines the first operand
  73632. * @param right defines the second operand
  73633. * @returns the new Vector3
  73634. */
  73635. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  73636. /**
  73637. * Gets the maximal coordinate values between two Vector3
  73638. * @param left defines the first operand
  73639. * @param right defines the second operand
  73640. * @returns the new Vector3
  73641. */
  73642. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  73643. /**
  73644. * Returns the distance between the vectors "value1" and "value2"
  73645. * @param value1 defines the first operand
  73646. * @param value2 defines the second operand
  73647. * @returns the distance
  73648. */
  73649. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  73650. /**
  73651. * Returns the squared distance between the vectors "value1" and "value2"
  73652. * @param value1 defines the first operand
  73653. * @param value2 defines the second operand
  73654. * @returns the squared distance
  73655. */
  73656. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  73657. /**
  73658. * Returns a new Vector3 located at the center between "value1" and "value2"
  73659. * @param value1 defines the first operand
  73660. * @param value2 defines the second operand
  73661. * @returns the new Vector3
  73662. */
  73663. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  73664. /**
  73665. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  73666. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  73667. * to something in order to rotate it from its local system to the given target system
  73668. * Note: axis1, axis2 and axis3 are normalized during this operation
  73669. * @param axis1 defines the first axis
  73670. * @param axis2 defines the second axis
  73671. * @param axis3 defines the third axis
  73672. * @returns a new Vector3
  73673. */
  73674. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  73675. /**
  73676. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  73677. * @param axis1 defines the first axis
  73678. * @param axis2 defines the second axis
  73679. * @param axis3 defines the third axis
  73680. * @param ref defines the Vector3 where to store the result
  73681. */
  73682. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  73683. }
  73684. /**
  73685. * Vector4 class created for EulerAngle class conversion to Quaternion
  73686. */
  73687. export class Vector4 {
  73688. /** x value of the vector */
  73689. x: number;
  73690. /** y value of the vector */
  73691. y: number;
  73692. /** z value of the vector */
  73693. z: number;
  73694. /** w value of the vector */
  73695. w: number;
  73696. /**
  73697. * Creates a Vector4 object from the given floats.
  73698. * @param x x value of the vector
  73699. * @param y y value of the vector
  73700. * @param z z value of the vector
  73701. * @param w w value of the vector
  73702. */
  73703. constructor(
  73704. /** x value of the vector */
  73705. x: number,
  73706. /** y value of the vector */
  73707. y: number,
  73708. /** z value of the vector */
  73709. z: number,
  73710. /** w value of the vector */
  73711. w: number);
  73712. /**
  73713. * Returns the string with the Vector4 coordinates.
  73714. * @returns a string containing all the vector values
  73715. */
  73716. toString(): string;
  73717. /**
  73718. * Returns the string "Vector4".
  73719. * @returns "Vector4"
  73720. */
  73721. getClassName(): string;
  73722. /**
  73723. * Returns the Vector4 hash code.
  73724. * @returns a unique hash code
  73725. */
  73726. getHashCode(): number;
  73727. /**
  73728. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  73729. * @returns the resulting array
  73730. */
  73731. asArray(): number[];
  73732. /**
  73733. * Populates the given array from the given index with the Vector4 coordinates.
  73734. * @param array array to populate
  73735. * @param index index of the array to start at (default: 0)
  73736. * @returns the Vector4.
  73737. */
  73738. toArray(array: FloatArray, index?: number): Vector4;
  73739. /**
  73740. * Adds the given vector to the current Vector4.
  73741. * @param otherVector the vector to add
  73742. * @returns the updated Vector4.
  73743. */
  73744. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  73745. /**
  73746. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  73747. * @param otherVector the vector to add
  73748. * @returns the resulting vector
  73749. */
  73750. add(otherVector: DeepImmutable<Vector4>): Vector4;
  73751. /**
  73752. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  73753. * @param otherVector the vector to add
  73754. * @param result the vector to store the result
  73755. * @returns the current Vector4.
  73756. */
  73757. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73758. /**
  73759. * Subtract in place the given vector from the current Vector4.
  73760. * @param otherVector the vector to subtract
  73761. * @returns the updated Vector4.
  73762. */
  73763. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  73764. /**
  73765. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  73766. * @param otherVector the vector to add
  73767. * @returns the new vector with the result
  73768. */
  73769. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  73770. /**
  73771. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  73772. * @param otherVector the vector to subtract
  73773. * @param result the vector to store the result
  73774. * @returns the current Vector4.
  73775. */
  73776. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73777. /**
  73778. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73779. */
  73780. /**
  73781. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73782. * @param x value to subtract
  73783. * @param y value to subtract
  73784. * @param z value to subtract
  73785. * @param w value to subtract
  73786. * @returns new vector containing the result
  73787. */
  73788. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  73789. /**
  73790. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73791. * @param x value to subtract
  73792. * @param y value to subtract
  73793. * @param z value to subtract
  73794. * @param w value to subtract
  73795. * @param result the vector to store the result in
  73796. * @returns the current Vector4.
  73797. */
  73798. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  73799. /**
  73800. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  73801. * @returns a new vector with the negated values
  73802. */
  73803. negate(): Vector4;
  73804. /**
  73805. * Multiplies the current Vector4 coordinates by scale (float).
  73806. * @param scale the number to scale with
  73807. * @returns the updated Vector4.
  73808. */
  73809. scaleInPlace(scale: number): Vector4;
  73810. /**
  73811. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  73812. * @param scale the number to scale with
  73813. * @returns a new vector with the result
  73814. */
  73815. scale(scale: number): Vector4;
  73816. /**
  73817. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  73818. * @param scale the number to scale with
  73819. * @param result a vector to store the result in
  73820. * @returns the current Vector4.
  73821. */
  73822. scaleToRef(scale: number, result: Vector4): Vector4;
  73823. /**
  73824. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  73825. * @param scale defines the scale factor
  73826. * @param result defines the Vector4 object where to store the result
  73827. * @returns the unmodified current Vector4
  73828. */
  73829. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  73830. /**
  73831. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  73832. * @param otherVector the vector to compare against
  73833. * @returns true if they are equal
  73834. */
  73835. equals(otherVector: DeepImmutable<Vector4>): boolean;
  73836. /**
  73837. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  73838. * @param otherVector vector to compare against
  73839. * @param epsilon (Default: very small number)
  73840. * @returns true if they are equal
  73841. */
  73842. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  73843. /**
  73844. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  73845. * @param x x value to compare against
  73846. * @param y y value to compare against
  73847. * @param z z value to compare against
  73848. * @param w w value to compare against
  73849. * @returns true if equal
  73850. */
  73851. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  73852. /**
  73853. * Multiplies in place the current Vector4 by the given one.
  73854. * @param otherVector vector to multiple with
  73855. * @returns the updated Vector4.
  73856. */
  73857. multiplyInPlace(otherVector: Vector4): Vector4;
  73858. /**
  73859. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  73860. * @param otherVector vector to multiple with
  73861. * @returns resulting new vector
  73862. */
  73863. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  73864. /**
  73865. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  73866. * @param otherVector vector to multiple with
  73867. * @param result vector to store the result
  73868. * @returns the current Vector4.
  73869. */
  73870. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73871. /**
  73872. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  73873. * @param x x value multiply with
  73874. * @param y y value multiply with
  73875. * @param z z value multiply with
  73876. * @param w w value multiply with
  73877. * @returns resulting new vector
  73878. */
  73879. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  73880. /**
  73881. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  73882. * @param otherVector vector to devide with
  73883. * @returns resulting new vector
  73884. */
  73885. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  73886. /**
  73887. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  73888. * @param otherVector vector to devide with
  73889. * @param result vector to store the result
  73890. * @returns the current Vector4.
  73891. */
  73892. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73893. /**
  73894. * Divides the current Vector3 coordinates by the given ones.
  73895. * @param otherVector vector to devide with
  73896. * @returns the updated Vector3.
  73897. */
  73898. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  73899. /**
  73900. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  73901. * @param other defines the second operand
  73902. * @returns the current updated Vector4
  73903. */
  73904. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  73905. /**
  73906. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  73907. * @param other defines the second operand
  73908. * @returns the current updated Vector4
  73909. */
  73910. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  73911. /**
  73912. * Gets a new Vector4 from current Vector4 floored values
  73913. * @returns a new Vector4
  73914. */
  73915. floor(): Vector4;
  73916. /**
  73917. * Gets a new Vector4 from current Vector3 floored values
  73918. * @returns a new Vector4
  73919. */
  73920. fract(): Vector4;
  73921. /**
  73922. * Returns the Vector4 length (float).
  73923. * @returns the length
  73924. */
  73925. length(): number;
  73926. /**
  73927. * Returns the Vector4 squared length (float).
  73928. * @returns the length squared
  73929. */
  73930. lengthSquared(): number;
  73931. /**
  73932. * Normalizes in place the Vector4.
  73933. * @returns the updated Vector4.
  73934. */
  73935. normalize(): Vector4;
  73936. /**
  73937. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  73938. * @returns this converted to a new vector3
  73939. */
  73940. toVector3(): Vector3;
  73941. /**
  73942. * Returns a new Vector4 copied from the current one.
  73943. * @returns the new cloned vector
  73944. */
  73945. clone(): Vector4;
  73946. /**
  73947. * Updates the current Vector4 with the given one coordinates.
  73948. * @param source the source vector to copy from
  73949. * @returns the updated Vector4.
  73950. */
  73951. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  73952. /**
  73953. * Updates the current Vector4 coordinates with the given floats.
  73954. * @param x float to copy from
  73955. * @param y float to copy from
  73956. * @param z float to copy from
  73957. * @param w float to copy from
  73958. * @returns the updated Vector4.
  73959. */
  73960. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  73961. /**
  73962. * Updates the current Vector4 coordinates with the given floats.
  73963. * @param x float to set from
  73964. * @param y float to set from
  73965. * @param z float to set from
  73966. * @param w float to set from
  73967. * @returns the updated Vector4.
  73968. */
  73969. set(x: number, y: number, z: number, w: number): Vector4;
  73970. /**
  73971. * Copies the given float to the current Vector3 coordinates
  73972. * @param v defines the x, y, z and w coordinates of the operand
  73973. * @returns the current updated Vector3
  73974. */
  73975. setAll(v: number): Vector4;
  73976. /**
  73977. * Returns a new Vector4 set from the starting index of the given array.
  73978. * @param array the array to pull values from
  73979. * @param offset the offset into the array to start at
  73980. * @returns the new vector
  73981. */
  73982. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  73983. /**
  73984. * Updates the given vector "result" from the starting index of the given array.
  73985. * @param array the array to pull values from
  73986. * @param offset the offset into the array to start at
  73987. * @param result the vector to store the result in
  73988. */
  73989. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  73990. /**
  73991. * Updates the given vector "result" from the starting index of the given Float32Array.
  73992. * @param array the array to pull values from
  73993. * @param offset the offset into the array to start at
  73994. * @param result the vector to store the result in
  73995. */
  73996. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  73997. /**
  73998. * Updates the given vector "result" coordinates from the given floats.
  73999. * @param x float to set from
  74000. * @param y float to set from
  74001. * @param z float to set from
  74002. * @param w float to set from
  74003. * @param result the vector to the floats in
  74004. */
  74005. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  74006. /**
  74007. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  74008. * @returns the new vector
  74009. */
  74010. static Zero(): Vector4;
  74011. /**
  74012. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  74013. * @returns the new vector
  74014. */
  74015. static One(): Vector4;
  74016. /**
  74017. * Returns a new normalized Vector4 from the given one.
  74018. * @param vector the vector to normalize
  74019. * @returns the vector
  74020. */
  74021. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  74022. /**
  74023. * Updates the given vector "result" from the normalization of the given one.
  74024. * @param vector the vector to normalize
  74025. * @param result the vector to store the result in
  74026. */
  74027. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  74028. /**
  74029. * Returns a vector with the minimum values from the left and right vectors
  74030. * @param left left vector to minimize
  74031. * @param right right vector to minimize
  74032. * @returns a new vector with the minimum of the left and right vector values
  74033. */
  74034. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  74035. /**
  74036. * Returns a vector with the maximum values from the left and right vectors
  74037. * @param left left vector to maximize
  74038. * @param right right vector to maximize
  74039. * @returns a new vector with the maximum of the left and right vector values
  74040. */
  74041. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  74042. /**
  74043. * Returns the distance (float) between the vectors "value1" and "value2".
  74044. * @param value1 value to calulate the distance between
  74045. * @param value2 value to calulate the distance between
  74046. * @return the distance between the two vectors
  74047. */
  74048. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  74049. /**
  74050. * Returns the squared distance (float) between the vectors "value1" and "value2".
  74051. * @param value1 value to calulate the distance between
  74052. * @param value2 value to calulate the distance between
  74053. * @return the distance between the two vectors squared
  74054. */
  74055. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  74056. /**
  74057. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  74058. * @param value1 value to calulate the center between
  74059. * @param value2 value to calulate the center between
  74060. * @return the center between the two vectors
  74061. */
  74062. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  74063. /**
  74064. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  74065. * This methods computes transformed normalized direction vectors only.
  74066. * @param vector the vector to transform
  74067. * @param transformation the transformation matrix to apply
  74068. * @returns the new vector
  74069. */
  74070. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  74071. /**
  74072. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  74073. * This methods computes transformed normalized direction vectors only.
  74074. * @param vector the vector to transform
  74075. * @param transformation the transformation matrix to apply
  74076. * @param result the vector to store the result in
  74077. */
  74078. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  74079. /**
  74080. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  74081. * This methods computes transformed normalized direction vectors only.
  74082. * @param x value to transform
  74083. * @param y value to transform
  74084. * @param z value to transform
  74085. * @param w value to transform
  74086. * @param transformation the transformation matrix to apply
  74087. * @param result the vector to store the results in
  74088. */
  74089. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  74090. /**
  74091. * Creates a new Vector4 from a Vector3
  74092. * @param source defines the source data
  74093. * @param w defines the 4th component (default is 0)
  74094. * @returns a new Vector4
  74095. */
  74096. static FromVector3(source: Vector3, w?: number): Vector4;
  74097. }
  74098. /**
  74099. * Class used to store quaternion data
  74100. * @see https://en.wikipedia.org/wiki/Quaternion
  74101. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  74102. */
  74103. export class Quaternion {
  74104. /** defines the first component (0 by default) */
  74105. x: number;
  74106. /** defines the second component (0 by default) */
  74107. y: number;
  74108. /** defines the third component (0 by default) */
  74109. z: number;
  74110. /** defines the fourth component (1.0 by default) */
  74111. w: number;
  74112. /**
  74113. * Creates a new Quaternion from the given floats
  74114. * @param x defines the first component (0 by default)
  74115. * @param y defines the second component (0 by default)
  74116. * @param z defines the third component (0 by default)
  74117. * @param w defines the fourth component (1.0 by default)
  74118. */
  74119. constructor(
  74120. /** defines the first component (0 by default) */
  74121. x?: number,
  74122. /** defines the second component (0 by default) */
  74123. y?: number,
  74124. /** defines the third component (0 by default) */
  74125. z?: number,
  74126. /** defines the fourth component (1.0 by default) */
  74127. w?: number);
  74128. /**
  74129. * Gets a string representation for the current quaternion
  74130. * @returns a string with the Quaternion coordinates
  74131. */
  74132. toString(): string;
  74133. /**
  74134. * Gets the class name of the quaternion
  74135. * @returns the string "Quaternion"
  74136. */
  74137. getClassName(): string;
  74138. /**
  74139. * Gets a hash code for this quaternion
  74140. * @returns the quaternion hash code
  74141. */
  74142. getHashCode(): number;
  74143. /**
  74144. * Copy the quaternion to an array
  74145. * @returns a new array populated with 4 elements from the quaternion coordinates
  74146. */
  74147. asArray(): number[];
  74148. /**
  74149. * Check if two quaternions are equals
  74150. * @param otherQuaternion defines the second operand
  74151. * @return true if the current quaternion and the given one coordinates are strictly equals
  74152. */
  74153. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  74154. /**
  74155. * Clone the current quaternion
  74156. * @returns a new quaternion copied from the current one
  74157. */
  74158. clone(): Quaternion;
  74159. /**
  74160. * Copy a quaternion to the current one
  74161. * @param other defines the other quaternion
  74162. * @returns the updated current quaternion
  74163. */
  74164. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  74165. /**
  74166. * Updates the current quaternion with the given float coordinates
  74167. * @param x defines the x coordinate
  74168. * @param y defines the y coordinate
  74169. * @param z defines the z coordinate
  74170. * @param w defines the w coordinate
  74171. * @returns the updated current quaternion
  74172. */
  74173. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  74174. /**
  74175. * Updates the current quaternion from the given float coordinates
  74176. * @param x defines the x coordinate
  74177. * @param y defines the y coordinate
  74178. * @param z defines the z coordinate
  74179. * @param w defines the w coordinate
  74180. * @returns the updated current quaternion
  74181. */
  74182. set(x: number, y: number, z: number, w: number): Quaternion;
  74183. /**
  74184. * Adds two quaternions
  74185. * @param other defines the second operand
  74186. * @returns a new quaternion as the addition result of the given one and the current quaternion
  74187. */
  74188. add(other: DeepImmutable<Quaternion>): Quaternion;
  74189. /**
  74190. * Add a quaternion to the current one
  74191. * @param other defines the quaternion to add
  74192. * @returns the current quaternion
  74193. */
  74194. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  74195. /**
  74196. * Subtract two quaternions
  74197. * @param other defines the second operand
  74198. * @returns a new quaternion as the subtraction result of the given one from the current one
  74199. */
  74200. subtract(other: Quaternion): Quaternion;
  74201. /**
  74202. * Multiplies the current quaternion by a scale factor
  74203. * @param value defines the scale factor
  74204. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  74205. */
  74206. scale(value: number): Quaternion;
  74207. /**
  74208. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  74209. * @param scale defines the scale factor
  74210. * @param result defines the Quaternion object where to store the result
  74211. * @returns the unmodified current quaternion
  74212. */
  74213. scaleToRef(scale: number, result: Quaternion): Quaternion;
  74214. /**
  74215. * Multiplies in place the current quaternion by a scale factor
  74216. * @param value defines the scale factor
  74217. * @returns the current modified quaternion
  74218. */
  74219. scaleInPlace(value: number): Quaternion;
  74220. /**
  74221. * Scale the current quaternion values by a factor and add the result to a given quaternion
  74222. * @param scale defines the scale factor
  74223. * @param result defines the Quaternion object where to store the result
  74224. * @returns the unmodified current quaternion
  74225. */
  74226. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  74227. /**
  74228. * Multiplies two quaternions
  74229. * @param q1 defines the second operand
  74230. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  74231. */
  74232. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  74233. /**
  74234. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  74235. * @param q1 defines the second operand
  74236. * @param result defines the target quaternion
  74237. * @returns the current quaternion
  74238. */
  74239. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  74240. /**
  74241. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  74242. * @param q1 defines the second operand
  74243. * @returns the currentupdated quaternion
  74244. */
  74245. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  74246. /**
  74247. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  74248. * @param ref defines the target quaternion
  74249. * @returns the current quaternion
  74250. */
  74251. conjugateToRef(ref: Quaternion): Quaternion;
  74252. /**
  74253. * Conjugates in place (1-q) the current quaternion
  74254. * @returns the current updated quaternion
  74255. */
  74256. conjugateInPlace(): Quaternion;
  74257. /**
  74258. * Conjugates in place (1-q) the current quaternion
  74259. * @returns a new quaternion
  74260. */
  74261. conjugate(): Quaternion;
  74262. /**
  74263. * Gets length of current quaternion
  74264. * @returns the quaternion length (float)
  74265. */
  74266. length(): number;
  74267. /**
  74268. * Normalize in place the current quaternion
  74269. * @returns the current updated quaternion
  74270. */
  74271. normalize(): Quaternion;
  74272. /**
  74273. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  74274. * @param order is a reserved parameter and is ignore for now
  74275. * @returns a new Vector3 containing the Euler angles
  74276. */
  74277. toEulerAngles(order?: string): Vector3;
  74278. /**
  74279. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  74280. * @param result defines the vector which will be filled with the Euler angles
  74281. * @param order is a reserved parameter and is ignore for now
  74282. * @returns the current unchanged quaternion
  74283. */
  74284. toEulerAnglesToRef(result: Vector3): Quaternion;
  74285. /**
  74286. * Updates the given rotation matrix with the current quaternion values
  74287. * @param result defines the target matrix
  74288. * @returns the current unchanged quaternion
  74289. */
  74290. toRotationMatrix(result: Matrix): Quaternion;
  74291. /**
  74292. * Updates the current quaternion from the given rotation matrix values
  74293. * @param matrix defines the source matrix
  74294. * @returns the current updated quaternion
  74295. */
  74296. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  74297. /**
  74298. * Creates a new quaternion from a rotation matrix
  74299. * @param matrix defines the source matrix
  74300. * @returns a new quaternion created from the given rotation matrix values
  74301. */
  74302. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  74303. /**
  74304. * Updates the given quaternion with the given rotation matrix values
  74305. * @param matrix defines the source matrix
  74306. * @param result defines the target quaternion
  74307. */
  74308. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  74309. /**
  74310. * Returns the dot product (float) between the quaternions "left" and "right"
  74311. * @param left defines the left operand
  74312. * @param right defines the right operand
  74313. * @returns the dot product
  74314. */
  74315. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  74316. /**
  74317. * Checks if the two quaternions are close to each other
  74318. * @param quat0 defines the first quaternion to check
  74319. * @param quat1 defines the second quaternion to check
  74320. * @returns true if the two quaternions are close to each other
  74321. */
  74322. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  74323. /**
  74324. * Creates an empty quaternion
  74325. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  74326. */
  74327. static Zero(): Quaternion;
  74328. /**
  74329. * Inverse a given quaternion
  74330. * @param q defines the source quaternion
  74331. * @returns a new quaternion as the inverted current quaternion
  74332. */
  74333. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  74334. /**
  74335. * Inverse a given quaternion
  74336. * @param q defines the source quaternion
  74337. * @param result the quaternion the result will be stored in
  74338. * @returns the result quaternion
  74339. */
  74340. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  74341. /**
  74342. * Creates an identity quaternion
  74343. * @returns the identity quaternion
  74344. */
  74345. static Identity(): Quaternion;
  74346. /**
  74347. * Gets a boolean indicating if the given quaternion is identity
  74348. * @param quaternion defines the quaternion to check
  74349. * @returns true if the quaternion is identity
  74350. */
  74351. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  74352. /**
  74353. * Creates a quaternion from a rotation around an axis
  74354. * @param axis defines the axis to use
  74355. * @param angle defines the angle to use
  74356. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  74357. */
  74358. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  74359. /**
  74360. * Creates a rotation around an axis and stores it into the given quaternion
  74361. * @param axis defines the axis to use
  74362. * @param angle defines the angle to use
  74363. * @param result defines the target quaternion
  74364. * @returns the target quaternion
  74365. */
  74366. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  74367. /**
  74368. * Creates a new quaternion from data stored into an array
  74369. * @param array defines the data source
  74370. * @param offset defines the offset in the source array where the data starts
  74371. * @returns a new quaternion
  74372. */
  74373. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  74374. /**
  74375. * Create a quaternion from Euler rotation angles
  74376. * @param x Pitch
  74377. * @param y Yaw
  74378. * @param z Roll
  74379. * @returns the new Quaternion
  74380. */
  74381. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  74382. /**
  74383. * Updates a quaternion from Euler rotation angles
  74384. * @param x Pitch
  74385. * @param y Yaw
  74386. * @param z Roll
  74387. * @param result the quaternion to store the result
  74388. * @returns the updated quaternion
  74389. */
  74390. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  74391. /**
  74392. * Create a quaternion from Euler rotation vector
  74393. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  74394. * @returns the new Quaternion
  74395. */
  74396. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  74397. /**
  74398. * Updates a quaternion from Euler rotation vector
  74399. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  74400. * @param result the quaternion to store the result
  74401. * @returns the updated quaternion
  74402. */
  74403. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  74404. /**
  74405. * Creates a new quaternion from the given Euler float angles (y, x, z)
  74406. * @param yaw defines the rotation around Y axis
  74407. * @param pitch defines the rotation around X axis
  74408. * @param roll defines the rotation around Z axis
  74409. * @returns the new quaternion
  74410. */
  74411. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  74412. /**
  74413. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  74414. * @param yaw defines the rotation around Y axis
  74415. * @param pitch defines the rotation around X axis
  74416. * @param roll defines the rotation around Z axis
  74417. * @param result defines the target quaternion
  74418. */
  74419. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  74420. /**
  74421. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  74422. * @param alpha defines the rotation around first axis
  74423. * @param beta defines the rotation around second axis
  74424. * @param gamma defines the rotation around third axis
  74425. * @returns the new quaternion
  74426. */
  74427. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  74428. /**
  74429. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  74430. * @param alpha defines the rotation around first axis
  74431. * @param beta defines the rotation around second axis
  74432. * @param gamma defines the rotation around third axis
  74433. * @param result defines the target quaternion
  74434. */
  74435. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  74436. /**
  74437. * 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)
  74438. * @param axis1 defines the first axis
  74439. * @param axis2 defines the second axis
  74440. * @param axis3 defines the third axis
  74441. * @returns the new quaternion
  74442. */
  74443. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  74444. /**
  74445. * 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
  74446. * @param axis1 defines the first axis
  74447. * @param axis2 defines the second axis
  74448. * @param axis3 defines the third axis
  74449. * @param ref defines the target quaternion
  74450. */
  74451. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  74452. /**
  74453. * Interpolates between two quaternions
  74454. * @param left defines first quaternion
  74455. * @param right defines second quaternion
  74456. * @param amount defines the gradient to use
  74457. * @returns the new interpolated quaternion
  74458. */
  74459. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  74460. /**
  74461. * Interpolates between two quaternions and stores it into a target quaternion
  74462. * @param left defines first quaternion
  74463. * @param right defines second quaternion
  74464. * @param amount defines the gradient to use
  74465. * @param result defines the target quaternion
  74466. */
  74467. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  74468. /**
  74469. * Interpolate between two quaternions using Hermite interpolation
  74470. * @param value1 defines first quaternion
  74471. * @param tangent1 defines the incoming tangent
  74472. * @param value2 defines second quaternion
  74473. * @param tangent2 defines the outgoing tangent
  74474. * @param amount defines the target quaternion
  74475. * @returns the new interpolated quaternion
  74476. */
  74477. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  74478. }
  74479. /**
  74480. * Class used to store matrix data (4x4)
  74481. */
  74482. export class Matrix {
  74483. private static _updateFlagSeed;
  74484. private static _identityReadOnly;
  74485. private _isIdentity;
  74486. private _isIdentityDirty;
  74487. private _isIdentity3x2;
  74488. private _isIdentity3x2Dirty;
  74489. /**
  74490. * Gets the update flag of the matrix which is an unique number for the matrix.
  74491. * It will be incremented every time the matrix data change.
  74492. * You can use it to speed the comparison between two versions of the same matrix.
  74493. */
  74494. updateFlag: number;
  74495. private readonly _m;
  74496. /**
  74497. * Gets the internal data of the matrix
  74498. */
  74499. get m(): DeepImmutable<Float32Array>;
  74500. /** @hidden */
  74501. _markAsUpdated(): void;
  74502. /** @hidden */
  74503. private _updateIdentityStatus;
  74504. /**
  74505. * Creates an empty matrix (filled with zeros)
  74506. */
  74507. constructor();
  74508. /**
  74509. * Check if the current matrix is identity
  74510. * @returns true is the matrix is the identity matrix
  74511. */
  74512. isIdentity(): boolean;
  74513. /**
  74514. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  74515. * @returns true is the matrix is the identity matrix
  74516. */
  74517. isIdentityAs3x2(): boolean;
  74518. /**
  74519. * Gets the determinant of the matrix
  74520. * @returns the matrix determinant
  74521. */
  74522. determinant(): number;
  74523. /**
  74524. * Returns the matrix as a Float32Array
  74525. * @returns the matrix underlying array
  74526. */
  74527. toArray(): DeepImmutable<Float32Array>;
  74528. /**
  74529. * Returns the matrix as a Float32Array
  74530. * @returns the matrix underlying array.
  74531. */
  74532. asArray(): DeepImmutable<Float32Array>;
  74533. /**
  74534. * Inverts the current matrix in place
  74535. * @returns the current inverted matrix
  74536. */
  74537. invert(): Matrix;
  74538. /**
  74539. * Sets all the matrix elements to zero
  74540. * @returns the current matrix
  74541. */
  74542. reset(): Matrix;
  74543. /**
  74544. * Adds the current matrix with a second one
  74545. * @param other defines the matrix to add
  74546. * @returns a new matrix as the addition of the current matrix and the given one
  74547. */
  74548. add(other: DeepImmutable<Matrix>): Matrix;
  74549. /**
  74550. * Sets the given matrix "result" to the addition of the current matrix and the given one
  74551. * @param other defines the matrix to add
  74552. * @param result defines the target matrix
  74553. * @returns the current matrix
  74554. */
  74555. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  74556. /**
  74557. * Adds in place the given matrix to the current matrix
  74558. * @param other defines the second operand
  74559. * @returns the current updated matrix
  74560. */
  74561. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  74562. /**
  74563. * Sets the given matrix to the current inverted Matrix
  74564. * @param other defines the target matrix
  74565. * @returns the unmodified current matrix
  74566. */
  74567. invertToRef(other: Matrix): Matrix;
  74568. /**
  74569. * add a value at the specified position in the current Matrix
  74570. * @param index the index of the value within the matrix. between 0 and 15.
  74571. * @param value the value to be added
  74572. * @returns the current updated matrix
  74573. */
  74574. addAtIndex(index: number, value: number): Matrix;
  74575. /**
  74576. * mutiply the specified position in the current Matrix by a value
  74577. * @param index the index of the value within the matrix. between 0 and 15.
  74578. * @param value the value to be added
  74579. * @returns the current updated matrix
  74580. */
  74581. multiplyAtIndex(index: number, value: number): Matrix;
  74582. /**
  74583. * Inserts the translation vector (using 3 floats) in the current matrix
  74584. * @param x defines the 1st component of the translation
  74585. * @param y defines the 2nd component of the translation
  74586. * @param z defines the 3rd component of the translation
  74587. * @returns the current updated matrix
  74588. */
  74589. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  74590. /**
  74591. * Adds the translation vector (using 3 floats) in the current matrix
  74592. * @param x defines the 1st component of the translation
  74593. * @param y defines the 2nd component of the translation
  74594. * @param z defines the 3rd component of the translation
  74595. * @returns the current updated matrix
  74596. */
  74597. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  74598. /**
  74599. * Inserts the translation vector in the current matrix
  74600. * @param vector3 defines the translation to insert
  74601. * @returns the current updated matrix
  74602. */
  74603. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  74604. /**
  74605. * Gets the translation value of the current matrix
  74606. * @returns a new Vector3 as the extracted translation from the matrix
  74607. */
  74608. getTranslation(): Vector3;
  74609. /**
  74610. * Fill a Vector3 with the extracted translation from the matrix
  74611. * @param result defines the Vector3 where to store the translation
  74612. * @returns the current matrix
  74613. */
  74614. getTranslationToRef(result: Vector3): Matrix;
  74615. /**
  74616. * Remove rotation and scaling part from the matrix
  74617. * @returns the updated matrix
  74618. */
  74619. removeRotationAndScaling(): Matrix;
  74620. /**
  74621. * Multiply two matrices
  74622. * @param other defines the second operand
  74623. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  74624. */
  74625. multiply(other: DeepImmutable<Matrix>): Matrix;
  74626. /**
  74627. * Copy the current matrix from the given one
  74628. * @param other defines the source matrix
  74629. * @returns the current updated matrix
  74630. */
  74631. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  74632. /**
  74633. * Populates the given array from the starting index with the current matrix values
  74634. * @param array defines the target array
  74635. * @param offset defines the offset in the target array where to start storing values
  74636. * @returns the current matrix
  74637. */
  74638. copyToArray(array: Float32Array, offset?: number): Matrix;
  74639. /**
  74640. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  74641. * @param other defines the second operand
  74642. * @param result defines the matrix where to store the multiplication
  74643. * @returns the current matrix
  74644. */
  74645. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  74646. /**
  74647. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  74648. * @param other defines the second operand
  74649. * @param result defines the array where to store the multiplication
  74650. * @param offset defines the offset in the target array where to start storing values
  74651. * @returns the current matrix
  74652. */
  74653. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  74654. /**
  74655. * Check equality between this matrix and a second one
  74656. * @param value defines the second matrix to compare
  74657. * @returns true is the current matrix and the given one values are strictly equal
  74658. */
  74659. equals(value: DeepImmutable<Matrix>): boolean;
  74660. /**
  74661. * Clone the current matrix
  74662. * @returns a new matrix from the current matrix
  74663. */
  74664. clone(): Matrix;
  74665. /**
  74666. * Returns the name of the current matrix class
  74667. * @returns the string "Matrix"
  74668. */
  74669. getClassName(): string;
  74670. /**
  74671. * Gets the hash code of the current matrix
  74672. * @returns the hash code
  74673. */
  74674. getHashCode(): number;
  74675. /**
  74676. * Decomposes the current Matrix into a translation, rotation and scaling components
  74677. * @param scale defines the scale vector3 given as a reference to update
  74678. * @param rotation defines the rotation quaternion given as a reference to update
  74679. * @param translation defines the translation vector3 given as a reference to update
  74680. * @returns true if operation was successful
  74681. */
  74682. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  74683. /**
  74684. * Gets specific row of the matrix
  74685. * @param index defines the number of the row to get
  74686. * @returns the index-th row of the current matrix as a new Vector4
  74687. */
  74688. getRow(index: number): Nullable<Vector4>;
  74689. /**
  74690. * Sets the index-th row of the current matrix to the vector4 values
  74691. * @param index defines the number of the row to set
  74692. * @param row defines the target vector4
  74693. * @returns the updated current matrix
  74694. */
  74695. setRow(index: number, row: Vector4): Matrix;
  74696. /**
  74697. * Compute the transpose of the matrix
  74698. * @returns the new transposed matrix
  74699. */
  74700. transpose(): Matrix;
  74701. /**
  74702. * Compute the transpose of the matrix and store it in a given matrix
  74703. * @param result defines the target matrix
  74704. * @returns the current matrix
  74705. */
  74706. transposeToRef(result: Matrix): Matrix;
  74707. /**
  74708. * Sets the index-th row of the current matrix with the given 4 x float values
  74709. * @param index defines the row index
  74710. * @param x defines the x component to set
  74711. * @param y defines the y component to set
  74712. * @param z defines the z component to set
  74713. * @param w defines the w component to set
  74714. * @returns the updated current matrix
  74715. */
  74716. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  74717. /**
  74718. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  74719. * @param scale defines the scale factor
  74720. * @returns a new matrix
  74721. */
  74722. scale(scale: number): Matrix;
  74723. /**
  74724. * Scale the current matrix values by a factor to a given result matrix
  74725. * @param scale defines the scale factor
  74726. * @param result defines the matrix to store the result
  74727. * @returns the current matrix
  74728. */
  74729. scaleToRef(scale: number, result: Matrix): Matrix;
  74730. /**
  74731. * Scale the current matrix values by a factor and add the result to a given matrix
  74732. * @param scale defines the scale factor
  74733. * @param result defines the Matrix to store the result
  74734. * @returns the current matrix
  74735. */
  74736. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  74737. /**
  74738. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  74739. * @param ref matrix to store the result
  74740. */
  74741. toNormalMatrix(ref: Matrix): void;
  74742. /**
  74743. * Gets only rotation part of the current matrix
  74744. * @returns a new matrix sets to the extracted rotation matrix from the current one
  74745. */
  74746. getRotationMatrix(): Matrix;
  74747. /**
  74748. * Extracts the rotation matrix from the current one and sets it as the given "result"
  74749. * @param result defines the target matrix to store data to
  74750. * @returns the current matrix
  74751. */
  74752. getRotationMatrixToRef(result: Matrix): Matrix;
  74753. /**
  74754. * Toggles model matrix from being right handed to left handed in place and vice versa
  74755. */
  74756. toggleModelMatrixHandInPlace(): void;
  74757. /**
  74758. * Toggles projection matrix from being right handed to left handed in place and vice versa
  74759. */
  74760. toggleProjectionMatrixHandInPlace(): void;
  74761. /**
  74762. * Creates a matrix from an array
  74763. * @param array defines the source array
  74764. * @param offset defines an offset in the source array
  74765. * @returns a new Matrix set from the starting index of the given array
  74766. */
  74767. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  74768. /**
  74769. * Copy the content of an array into a given matrix
  74770. * @param array defines the source array
  74771. * @param offset defines an offset in the source array
  74772. * @param result defines the target matrix
  74773. */
  74774. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  74775. /**
  74776. * Stores an array into a matrix after having multiplied each component by a given factor
  74777. * @param array defines the source array
  74778. * @param offset defines the offset in the source array
  74779. * @param scale defines the scaling factor
  74780. * @param result defines the target matrix
  74781. */
  74782. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  74783. /**
  74784. * Gets an identity matrix that must not be updated
  74785. */
  74786. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  74787. /**
  74788. * Stores a list of values (16) inside a given matrix
  74789. * @param initialM11 defines 1st value of 1st row
  74790. * @param initialM12 defines 2nd value of 1st row
  74791. * @param initialM13 defines 3rd value of 1st row
  74792. * @param initialM14 defines 4th value of 1st row
  74793. * @param initialM21 defines 1st value of 2nd row
  74794. * @param initialM22 defines 2nd value of 2nd row
  74795. * @param initialM23 defines 3rd value of 2nd row
  74796. * @param initialM24 defines 4th value of 2nd row
  74797. * @param initialM31 defines 1st value of 3rd row
  74798. * @param initialM32 defines 2nd value of 3rd row
  74799. * @param initialM33 defines 3rd value of 3rd row
  74800. * @param initialM34 defines 4th value of 3rd row
  74801. * @param initialM41 defines 1st value of 4th row
  74802. * @param initialM42 defines 2nd value of 4th row
  74803. * @param initialM43 defines 3rd value of 4th row
  74804. * @param initialM44 defines 4th value of 4th row
  74805. * @param result defines the target matrix
  74806. */
  74807. 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;
  74808. /**
  74809. * Creates new matrix from a list of values (16)
  74810. * @param initialM11 defines 1st value of 1st row
  74811. * @param initialM12 defines 2nd value of 1st row
  74812. * @param initialM13 defines 3rd value of 1st row
  74813. * @param initialM14 defines 4th value of 1st row
  74814. * @param initialM21 defines 1st value of 2nd row
  74815. * @param initialM22 defines 2nd value of 2nd row
  74816. * @param initialM23 defines 3rd value of 2nd row
  74817. * @param initialM24 defines 4th value of 2nd row
  74818. * @param initialM31 defines 1st value of 3rd row
  74819. * @param initialM32 defines 2nd value of 3rd row
  74820. * @param initialM33 defines 3rd value of 3rd row
  74821. * @param initialM34 defines 4th value of 3rd row
  74822. * @param initialM41 defines 1st value of 4th row
  74823. * @param initialM42 defines 2nd value of 4th row
  74824. * @param initialM43 defines 3rd value of 4th row
  74825. * @param initialM44 defines 4th value of 4th row
  74826. * @returns the new matrix
  74827. */
  74828. 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;
  74829. /**
  74830. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  74831. * @param scale defines the scale vector3
  74832. * @param rotation defines the rotation quaternion
  74833. * @param translation defines the translation vector3
  74834. * @returns a new matrix
  74835. */
  74836. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  74837. /**
  74838. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  74839. * @param scale defines the scale vector3
  74840. * @param rotation defines the rotation quaternion
  74841. * @param translation defines the translation vector3
  74842. * @param result defines the target matrix
  74843. */
  74844. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  74845. /**
  74846. * Creates a new identity matrix
  74847. * @returns a new identity matrix
  74848. */
  74849. static Identity(): Matrix;
  74850. /**
  74851. * Creates a new identity matrix and stores the result in a given matrix
  74852. * @param result defines the target matrix
  74853. */
  74854. static IdentityToRef(result: Matrix): void;
  74855. /**
  74856. * Creates a new zero matrix
  74857. * @returns a new zero matrix
  74858. */
  74859. static Zero(): Matrix;
  74860. /**
  74861. * Creates a new rotation matrix for "angle" radians around the X axis
  74862. * @param angle defines the angle (in radians) to use
  74863. * @return the new matrix
  74864. */
  74865. static RotationX(angle: number): Matrix;
  74866. /**
  74867. * Creates a new matrix as the invert of a given matrix
  74868. * @param source defines the source matrix
  74869. * @returns the new matrix
  74870. */
  74871. static Invert(source: DeepImmutable<Matrix>): Matrix;
  74872. /**
  74873. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  74874. * @param angle defines the angle (in radians) to use
  74875. * @param result defines the target matrix
  74876. */
  74877. static RotationXToRef(angle: number, result: Matrix): void;
  74878. /**
  74879. * Creates a new rotation matrix for "angle" radians around the Y axis
  74880. * @param angle defines the angle (in radians) to use
  74881. * @return the new matrix
  74882. */
  74883. static RotationY(angle: number): Matrix;
  74884. /**
  74885. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  74886. * @param angle defines the angle (in radians) to use
  74887. * @param result defines the target matrix
  74888. */
  74889. static RotationYToRef(angle: number, result: Matrix): void;
  74890. /**
  74891. * Creates a new rotation matrix for "angle" radians around the Z axis
  74892. * @param angle defines the angle (in radians) to use
  74893. * @return the new matrix
  74894. */
  74895. static RotationZ(angle: number): Matrix;
  74896. /**
  74897. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  74898. * @param angle defines the angle (in radians) to use
  74899. * @param result defines the target matrix
  74900. */
  74901. static RotationZToRef(angle: number, result: Matrix): void;
  74902. /**
  74903. * Creates a new rotation matrix for "angle" radians around the given axis
  74904. * @param axis defines the axis to use
  74905. * @param angle defines the angle (in radians) to use
  74906. * @return the new matrix
  74907. */
  74908. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  74909. /**
  74910. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  74911. * @param axis defines the axis to use
  74912. * @param angle defines the angle (in radians) to use
  74913. * @param result defines the target matrix
  74914. */
  74915. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  74916. /**
  74917. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  74918. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  74919. * @param from defines the vector to align
  74920. * @param to defines the vector to align to
  74921. * @param result defines the target matrix
  74922. */
  74923. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  74924. /**
  74925. * Creates a rotation matrix
  74926. * @param yaw defines the yaw angle in radians (Y axis)
  74927. * @param pitch defines the pitch angle in radians (X axis)
  74928. * @param roll defines the roll angle in radians (X axis)
  74929. * @returns the new rotation matrix
  74930. */
  74931. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  74932. /**
  74933. * Creates a rotation matrix and stores it in a given matrix
  74934. * @param yaw defines the yaw angle in radians (Y axis)
  74935. * @param pitch defines the pitch angle in radians (X axis)
  74936. * @param roll defines the roll angle in radians (X axis)
  74937. * @param result defines the target matrix
  74938. */
  74939. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  74940. /**
  74941. * Creates a scaling matrix
  74942. * @param x defines the scale factor on X axis
  74943. * @param y defines the scale factor on Y axis
  74944. * @param z defines the scale factor on Z axis
  74945. * @returns the new matrix
  74946. */
  74947. static Scaling(x: number, y: number, z: number): Matrix;
  74948. /**
  74949. * Creates a scaling matrix and stores it in a given matrix
  74950. * @param x defines the scale factor on X axis
  74951. * @param y defines the scale factor on Y axis
  74952. * @param z defines the scale factor on Z axis
  74953. * @param result defines the target matrix
  74954. */
  74955. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  74956. /**
  74957. * Creates a translation matrix
  74958. * @param x defines the translation on X axis
  74959. * @param y defines the translation on Y axis
  74960. * @param z defines the translationon Z axis
  74961. * @returns the new matrix
  74962. */
  74963. static Translation(x: number, y: number, z: number): Matrix;
  74964. /**
  74965. * Creates a translation matrix and stores it in a given matrix
  74966. * @param x defines the translation on X axis
  74967. * @param y defines the translation on Y axis
  74968. * @param z defines the translationon Z axis
  74969. * @param result defines the target matrix
  74970. */
  74971. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  74972. /**
  74973. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  74974. * @param startValue defines the start value
  74975. * @param endValue defines the end value
  74976. * @param gradient defines the gradient factor
  74977. * @returns the new matrix
  74978. */
  74979. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  74980. /**
  74981. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  74982. * @param startValue defines the start value
  74983. * @param endValue defines the end value
  74984. * @param gradient defines the gradient factor
  74985. * @param result defines the Matrix object where to store data
  74986. */
  74987. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  74988. /**
  74989. * Builds a new matrix whose values are computed by:
  74990. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  74991. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  74992. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  74993. * @param startValue defines the first matrix
  74994. * @param endValue defines the second matrix
  74995. * @param gradient defines the gradient between the two matrices
  74996. * @returns the new matrix
  74997. */
  74998. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  74999. /**
  75000. * Update a matrix to values which are computed by:
  75001. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  75002. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  75003. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  75004. * @param startValue defines the first matrix
  75005. * @param endValue defines the second matrix
  75006. * @param gradient defines the gradient between the two matrices
  75007. * @param result defines the target matrix
  75008. */
  75009. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  75010. /**
  75011. * 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"
  75012. * This function works in left handed mode
  75013. * @param eye defines the final position of the entity
  75014. * @param target defines where the entity should look at
  75015. * @param up defines the up vector for the entity
  75016. * @returns the new matrix
  75017. */
  75018. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  75019. /**
  75020. * 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".
  75021. * This function works in left handed mode
  75022. * @param eye defines the final position of the entity
  75023. * @param target defines where the entity should look at
  75024. * @param up defines the up vector for the entity
  75025. * @param result defines the target matrix
  75026. */
  75027. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  75028. /**
  75029. * 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"
  75030. * This function works in right handed mode
  75031. * @param eye defines the final position of the entity
  75032. * @param target defines where the entity should look at
  75033. * @param up defines the up vector for the entity
  75034. * @returns the new matrix
  75035. */
  75036. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  75037. /**
  75038. * 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".
  75039. * This function works in right handed mode
  75040. * @param eye defines the final position of the entity
  75041. * @param target defines where the entity should look at
  75042. * @param up defines the up vector for the entity
  75043. * @param result defines the target matrix
  75044. */
  75045. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  75046. /**
  75047. * Create a left-handed orthographic projection matrix
  75048. * @param width defines the viewport width
  75049. * @param height defines the viewport height
  75050. * @param znear defines the near clip plane
  75051. * @param zfar defines the far clip plane
  75052. * @returns a new matrix as a left-handed orthographic projection matrix
  75053. */
  75054. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  75055. /**
  75056. * Store a left-handed orthographic projection to a given matrix
  75057. * @param width defines the viewport width
  75058. * @param height defines the viewport height
  75059. * @param znear defines the near clip plane
  75060. * @param zfar defines the far clip plane
  75061. * @param result defines the target matrix
  75062. */
  75063. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  75064. /**
  75065. * Create a left-handed orthographic projection matrix
  75066. * @param left defines the viewport left coordinate
  75067. * @param right defines the viewport right coordinate
  75068. * @param bottom defines the viewport bottom coordinate
  75069. * @param top defines the viewport top coordinate
  75070. * @param znear defines the near clip plane
  75071. * @param zfar defines the far clip plane
  75072. * @returns a new matrix as a left-handed orthographic projection matrix
  75073. */
  75074. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  75075. /**
  75076. * Stores a left-handed orthographic projection into a given matrix
  75077. * @param left defines the viewport left coordinate
  75078. * @param right defines the viewport right coordinate
  75079. * @param bottom defines the viewport bottom coordinate
  75080. * @param top defines the viewport top coordinate
  75081. * @param znear defines the near clip plane
  75082. * @param zfar defines the far clip plane
  75083. * @param result defines the target matrix
  75084. */
  75085. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  75086. /**
  75087. * Creates a right-handed orthographic projection matrix
  75088. * @param left defines the viewport left coordinate
  75089. * @param right defines the viewport right coordinate
  75090. * @param bottom defines the viewport bottom coordinate
  75091. * @param top defines the viewport top coordinate
  75092. * @param znear defines the near clip plane
  75093. * @param zfar defines the far clip plane
  75094. * @returns a new matrix as a right-handed orthographic projection matrix
  75095. */
  75096. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  75097. /**
  75098. * Stores a right-handed orthographic projection into a given matrix
  75099. * @param left defines the viewport left coordinate
  75100. * @param right defines the viewport right coordinate
  75101. * @param bottom defines the viewport bottom coordinate
  75102. * @param top defines the viewport top coordinate
  75103. * @param znear defines the near clip plane
  75104. * @param zfar defines the far clip plane
  75105. * @param result defines the target matrix
  75106. */
  75107. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  75108. /**
  75109. * Creates a left-handed perspective projection matrix
  75110. * @param width defines the viewport width
  75111. * @param height defines the viewport height
  75112. * @param znear defines the near clip plane
  75113. * @param zfar defines the far clip plane
  75114. * @returns a new matrix as a left-handed perspective projection matrix
  75115. */
  75116. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  75117. /**
  75118. * Creates a left-handed perspective projection matrix
  75119. * @param fov defines the horizontal field of view
  75120. * @param aspect defines the aspect ratio
  75121. * @param znear defines the near clip plane
  75122. * @param zfar defines the far clip plane
  75123. * @returns a new matrix as a left-handed perspective projection matrix
  75124. */
  75125. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  75126. /**
  75127. * Stores a left-handed perspective projection into a given matrix
  75128. * @param fov defines the horizontal field of view
  75129. * @param aspect defines the aspect ratio
  75130. * @param znear defines the near clip plane
  75131. * @param zfar defines the far clip plane
  75132. * @param result defines the target matrix
  75133. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75134. */
  75135. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75136. /**
  75137. * Stores a left-handed perspective projection into a given matrix with depth reversed
  75138. * @param fov defines the horizontal field of view
  75139. * @param aspect defines the aspect ratio
  75140. * @param znear defines the near clip plane
  75141. * @param zfar not used as infinity is used as far clip
  75142. * @param result defines the target matrix
  75143. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75144. */
  75145. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75146. /**
  75147. * Creates a right-handed perspective projection matrix
  75148. * @param fov defines the horizontal field of view
  75149. * @param aspect defines the aspect ratio
  75150. * @param znear defines the near clip plane
  75151. * @param zfar defines the far clip plane
  75152. * @returns a new matrix as a right-handed perspective projection matrix
  75153. */
  75154. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  75155. /**
  75156. * Stores a right-handed perspective projection into a given matrix
  75157. * @param fov defines the horizontal field of view
  75158. * @param aspect defines the aspect ratio
  75159. * @param znear defines the near clip plane
  75160. * @param zfar defines the far clip plane
  75161. * @param result defines the target matrix
  75162. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75163. */
  75164. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75165. /**
  75166. * Stores a right-handed perspective projection into a given matrix
  75167. * @param fov defines the horizontal field of view
  75168. * @param aspect defines the aspect ratio
  75169. * @param znear defines the near clip plane
  75170. * @param zfar not used as infinity is used as far clip
  75171. * @param result defines the target matrix
  75172. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75173. */
  75174. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75175. /**
  75176. * Stores a perspective projection for WebVR info a given matrix
  75177. * @param fov defines the field of view
  75178. * @param znear defines the near clip plane
  75179. * @param zfar defines the far clip plane
  75180. * @param result defines the target matrix
  75181. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  75182. */
  75183. static PerspectiveFovWebVRToRef(fov: {
  75184. upDegrees: number;
  75185. downDegrees: number;
  75186. leftDegrees: number;
  75187. rightDegrees: number;
  75188. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  75189. /**
  75190. * Computes a complete transformation matrix
  75191. * @param viewport defines the viewport to use
  75192. * @param world defines the world matrix
  75193. * @param view defines the view matrix
  75194. * @param projection defines the projection matrix
  75195. * @param zmin defines the near clip plane
  75196. * @param zmax defines the far clip plane
  75197. * @returns the transformation matrix
  75198. */
  75199. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  75200. /**
  75201. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  75202. * @param matrix defines the matrix to use
  75203. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  75204. */
  75205. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  75206. /**
  75207. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  75208. * @param matrix defines the matrix to use
  75209. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  75210. */
  75211. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  75212. /**
  75213. * Compute the transpose of a given matrix
  75214. * @param matrix defines the matrix to transpose
  75215. * @returns the new matrix
  75216. */
  75217. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  75218. /**
  75219. * Compute the transpose of a matrix and store it in a target matrix
  75220. * @param matrix defines the matrix to transpose
  75221. * @param result defines the target matrix
  75222. */
  75223. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  75224. /**
  75225. * Computes a reflection matrix from a plane
  75226. * @param plane defines the reflection plane
  75227. * @returns a new matrix
  75228. */
  75229. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  75230. /**
  75231. * Computes a reflection matrix from a plane
  75232. * @param plane defines the reflection plane
  75233. * @param result defines the target matrix
  75234. */
  75235. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  75236. /**
  75237. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  75238. * @param xaxis defines the value of the 1st axis
  75239. * @param yaxis defines the value of the 2nd axis
  75240. * @param zaxis defines the value of the 3rd axis
  75241. * @param result defines the target matrix
  75242. */
  75243. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  75244. /**
  75245. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  75246. * @param quat defines the quaternion to use
  75247. * @param result defines the target matrix
  75248. */
  75249. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  75250. }
  75251. /**
  75252. * @hidden
  75253. */
  75254. export class TmpVectors {
  75255. static Vector2: Vector2[];
  75256. static Vector3: Vector3[];
  75257. static Vector4: Vector4[];
  75258. static Quaternion: Quaternion[];
  75259. static Matrix: Matrix[];
  75260. }
  75261. }
  75262. declare module BABYLON {
  75263. /**
  75264. * Defines potential orientation for back face culling
  75265. */
  75266. export enum Orientation {
  75267. /**
  75268. * Clockwise
  75269. */
  75270. CW = 0,
  75271. /** Counter clockwise */
  75272. CCW = 1
  75273. }
  75274. /** Class used to represent a Bezier curve */
  75275. export class BezierCurve {
  75276. /**
  75277. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  75278. * @param t defines the time
  75279. * @param x1 defines the left coordinate on X axis
  75280. * @param y1 defines the left coordinate on Y axis
  75281. * @param x2 defines the right coordinate on X axis
  75282. * @param y2 defines the right coordinate on Y axis
  75283. * @returns the interpolated value
  75284. */
  75285. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  75286. }
  75287. /**
  75288. * Defines angle representation
  75289. */
  75290. export class Angle {
  75291. private _radians;
  75292. /**
  75293. * Creates an Angle object of "radians" radians (float).
  75294. * @param radians the angle in radians
  75295. */
  75296. constructor(radians: number);
  75297. /**
  75298. * Get value in degrees
  75299. * @returns the Angle value in degrees (float)
  75300. */
  75301. degrees(): number;
  75302. /**
  75303. * Get value in radians
  75304. * @returns the Angle value in radians (float)
  75305. */
  75306. radians(): number;
  75307. /**
  75308. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  75309. * @param a defines first vector
  75310. * @param b defines second vector
  75311. * @returns a new Angle
  75312. */
  75313. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  75314. /**
  75315. * Gets a new Angle object from the given float in radians
  75316. * @param radians defines the angle value in radians
  75317. * @returns a new Angle
  75318. */
  75319. static FromRadians(radians: number): Angle;
  75320. /**
  75321. * Gets a new Angle object from the given float in degrees
  75322. * @param degrees defines the angle value in degrees
  75323. * @returns a new Angle
  75324. */
  75325. static FromDegrees(degrees: number): Angle;
  75326. }
  75327. /**
  75328. * This represents an arc in a 2d space.
  75329. */
  75330. export class Arc2 {
  75331. /** Defines the start point of the arc */
  75332. startPoint: Vector2;
  75333. /** Defines the mid point of the arc */
  75334. midPoint: Vector2;
  75335. /** Defines the end point of the arc */
  75336. endPoint: Vector2;
  75337. /**
  75338. * Defines the center point of the arc.
  75339. */
  75340. centerPoint: Vector2;
  75341. /**
  75342. * Defines the radius of the arc.
  75343. */
  75344. radius: number;
  75345. /**
  75346. * Defines the angle of the arc (from mid point to end point).
  75347. */
  75348. angle: Angle;
  75349. /**
  75350. * Defines the start angle of the arc (from start point to middle point).
  75351. */
  75352. startAngle: Angle;
  75353. /**
  75354. * Defines the orientation of the arc (clock wise/counter clock wise).
  75355. */
  75356. orientation: Orientation;
  75357. /**
  75358. * Creates an Arc object from the three given points : start, middle and end.
  75359. * @param startPoint Defines the start point of the arc
  75360. * @param midPoint Defines the midlle point of the arc
  75361. * @param endPoint Defines the end point of the arc
  75362. */
  75363. constructor(
  75364. /** Defines the start point of the arc */
  75365. startPoint: Vector2,
  75366. /** Defines the mid point of the arc */
  75367. midPoint: Vector2,
  75368. /** Defines the end point of the arc */
  75369. endPoint: Vector2);
  75370. }
  75371. /**
  75372. * Represents a 2D path made up of multiple 2D points
  75373. */
  75374. export class Path2 {
  75375. private _points;
  75376. private _length;
  75377. /**
  75378. * If the path start and end point are the same
  75379. */
  75380. closed: boolean;
  75381. /**
  75382. * Creates a Path2 object from the starting 2D coordinates x and y.
  75383. * @param x the starting points x value
  75384. * @param y the starting points y value
  75385. */
  75386. constructor(x: number, y: number);
  75387. /**
  75388. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  75389. * @param x the added points x value
  75390. * @param y the added points y value
  75391. * @returns the updated Path2.
  75392. */
  75393. addLineTo(x: number, y: number): Path2;
  75394. /**
  75395. * 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.
  75396. * @param midX middle point x value
  75397. * @param midY middle point y value
  75398. * @param endX end point x value
  75399. * @param endY end point y value
  75400. * @param numberOfSegments (default: 36)
  75401. * @returns the updated Path2.
  75402. */
  75403. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  75404. /**
  75405. * Closes the Path2.
  75406. * @returns the Path2.
  75407. */
  75408. close(): Path2;
  75409. /**
  75410. * Gets the sum of the distance between each sequential point in the path
  75411. * @returns the Path2 total length (float).
  75412. */
  75413. length(): number;
  75414. /**
  75415. * Gets the points which construct the path
  75416. * @returns the Path2 internal array of points.
  75417. */
  75418. getPoints(): Vector2[];
  75419. /**
  75420. * Retreives the point at the distance aways from the starting point
  75421. * @param normalizedLengthPosition the length along the path to retreive the point from
  75422. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  75423. */
  75424. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  75425. /**
  75426. * Creates a new path starting from an x and y position
  75427. * @param x starting x value
  75428. * @param y starting y value
  75429. * @returns a new Path2 starting at the coordinates (x, y).
  75430. */
  75431. static StartingAt(x: number, y: number): Path2;
  75432. }
  75433. /**
  75434. * Represents a 3D path made up of multiple 3D points
  75435. */
  75436. export class Path3D {
  75437. /**
  75438. * an array of Vector3, the curve axis of the Path3D
  75439. */
  75440. path: Vector3[];
  75441. private _curve;
  75442. private _distances;
  75443. private _tangents;
  75444. private _normals;
  75445. private _binormals;
  75446. private _raw;
  75447. private _alignTangentsWithPath;
  75448. private readonly _pointAtData;
  75449. /**
  75450. * new Path3D(path, normal, raw)
  75451. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  75452. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  75453. * @param path an array of Vector3, the curve axis of the Path3D
  75454. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  75455. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  75456. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  75457. */
  75458. constructor(
  75459. /**
  75460. * an array of Vector3, the curve axis of the Path3D
  75461. */
  75462. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  75463. /**
  75464. * Returns the Path3D array of successive Vector3 designing its curve.
  75465. * @returns the Path3D array of successive Vector3 designing its curve.
  75466. */
  75467. getCurve(): Vector3[];
  75468. /**
  75469. * Returns the Path3D array of successive Vector3 designing its curve.
  75470. * @returns the Path3D array of successive Vector3 designing its curve.
  75471. */
  75472. getPoints(): Vector3[];
  75473. /**
  75474. * @returns the computed length (float) of the path.
  75475. */
  75476. length(): number;
  75477. /**
  75478. * Returns an array populated with tangent vectors on each Path3D curve point.
  75479. * @returns an array populated with tangent vectors on each Path3D curve point.
  75480. */
  75481. getTangents(): Vector3[];
  75482. /**
  75483. * Returns an array populated with normal vectors on each Path3D curve point.
  75484. * @returns an array populated with normal vectors on each Path3D curve point.
  75485. */
  75486. getNormals(): Vector3[];
  75487. /**
  75488. * Returns an array populated with binormal vectors on each Path3D curve point.
  75489. * @returns an array populated with binormal vectors on each Path3D curve point.
  75490. */
  75491. getBinormals(): Vector3[];
  75492. /**
  75493. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  75494. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  75495. */
  75496. getDistances(): number[];
  75497. /**
  75498. * Returns an interpolated point along this path
  75499. * @param position the position of the point along this path, from 0.0 to 1.0
  75500. * @returns a new Vector3 as the point
  75501. */
  75502. getPointAt(position: number): Vector3;
  75503. /**
  75504. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  75505. * @param position the position of the point along this path, from 0.0 to 1.0
  75506. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  75507. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  75508. */
  75509. getTangentAt(position: number, interpolated?: boolean): Vector3;
  75510. /**
  75511. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  75512. * @param position the position of the point along this path, from 0.0 to 1.0
  75513. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  75514. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  75515. */
  75516. getNormalAt(position: number, interpolated?: boolean): Vector3;
  75517. /**
  75518. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  75519. * @param position the position of the point along this path, from 0.0 to 1.0
  75520. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  75521. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  75522. */
  75523. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  75524. /**
  75525. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  75526. * @param position the position of the point along this path, from 0.0 to 1.0
  75527. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  75528. */
  75529. getDistanceAt(position: number): number;
  75530. /**
  75531. * Returns the array index of the previous point of an interpolated point along this path
  75532. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  75533. * @returns the array index
  75534. */
  75535. getPreviousPointIndexAt(position: number): number;
  75536. /**
  75537. * 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)
  75538. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  75539. * @returns the sub position
  75540. */
  75541. getSubPositionAt(position: number): number;
  75542. /**
  75543. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  75544. * @param target the vector of which to get the closest position to
  75545. * @returns the position of the closest virtual point on this path to the target vector
  75546. */
  75547. getClosestPositionTo(target: Vector3): number;
  75548. /**
  75549. * Returns a sub path (slice) of this path
  75550. * @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
  75551. * @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
  75552. * @returns a sub path (slice) of this path
  75553. */
  75554. slice(start?: number, end?: number): Path3D;
  75555. /**
  75556. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  75557. * @param path path which all values are copied into the curves points
  75558. * @param firstNormal which should be projected onto the curve
  75559. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  75560. * @returns the same object updated.
  75561. */
  75562. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  75563. private _compute;
  75564. private _getFirstNonNullVector;
  75565. private _getLastNonNullVector;
  75566. private _normalVector;
  75567. /**
  75568. * Updates the point at data for an interpolated point along this curve
  75569. * @param position the position of the point along this curve, from 0.0 to 1.0
  75570. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  75571. * @returns the (updated) point at data
  75572. */
  75573. private _updatePointAtData;
  75574. /**
  75575. * Updates the point at data from the specified parameters
  75576. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  75577. * @param point the interpolated point
  75578. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  75579. */
  75580. private _setPointAtData;
  75581. /**
  75582. * Updates the point at interpolation matrix for the tangents, normals and binormals
  75583. */
  75584. private _updateInterpolationMatrix;
  75585. }
  75586. /**
  75587. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  75588. * A Curve3 is designed from a series of successive Vector3.
  75589. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  75590. */
  75591. export class Curve3 {
  75592. private _points;
  75593. private _length;
  75594. /**
  75595. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  75596. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  75597. * @param v1 (Vector3) the control point
  75598. * @param v2 (Vector3) the end point of the Quadratic Bezier
  75599. * @param nbPoints (integer) the wanted number of points in the curve
  75600. * @returns the created Curve3
  75601. */
  75602. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  75603. /**
  75604. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  75605. * @param v0 (Vector3) the origin point of the Cubic Bezier
  75606. * @param v1 (Vector3) the first control point
  75607. * @param v2 (Vector3) the second control point
  75608. * @param v3 (Vector3) the end point of the Cubic Bezier
  75609. * @param nbPoints (integer) the wanted number of points in the curve
  75610. * @returns the created Curve3
  75611. */
  75612. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  75613. /**
  75614. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  75615. * @param p1 (Vector3) the origin point of the Hermite Spline
  75616. * @param t1 (Vector3) the tangent vector at the origin point
  75617. * @param p2 (Vector3) the end point of the Hermite Spline
  75618. * @param t2 (Vector3) the tangent vector at the end point
  75619. * @param nbPoints (integer) the wanted number of points in the curve
  75620. * @returns the created Curve3
  75621. */
  75622. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  75623. /**
  75624. * Returns a Curve3 object along a CatmullRom Spline curve :
  75625. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  75626. * @param nbPoints (integer) the wanted number of points between each curve control points
  75627. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  75628. * @returns the created Curve3
  75629. */
  75630. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  75631. /**
  75632. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  75633. * A Curve3 is designed from a series of successive Vector3.
  75634. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  75635. * @param points points which make up the curve
  75636. */
  75637. constructor(points: Vector3[]);
  75638. /**
  75639. * @returns the Curve3 stored array of successive Vector3
  75640. */
  75641. getPoints(): Vector3[];
  75642. /**
  75643. * @returns the computed length (float) of the curve.
  75644. */
  75645. length(): number;
  75646. /**
  75647. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  75648. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  75649. * curveA and curveB keep unchanged.
  75650. * @param curve the curve to continue from this curve
  75651. * @returns the newly constructed curve
  75652. */
  75653. continue(curve: DeepImmutable<Curve3>): Curve3;
  75654. private _computeLength;
  75655. }
  75656. }
  75657. declare module BABYLON {
  75658. /**
  75659. * This represents the main contract an easing function should follow.
  75660. * Easing functions are used throughout the animation system.
  75661. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75662. */
  75663. export interface IEasingFunction {
  75664. /**
  75665. * Given an input gradient between 0 and 1, this returns the corrseponding value
  75666. * of the easing function.
  75667. * The link below provides some of the most common examples of easing functions.
  75668. * @see https://easings.net/
  75669. * @param gradient Defines the value between 0 and 1 we want the easing value for
  75670. * @returns the corresponding value on the curve defined by the easing function
  75671. */
  75672. ease(gradient: number): number;
  75673. }
  75674. /**
  75675. * Base class used for every default easing function.
  75676. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75677. */
  75678. export class EasingFunction implements IEasingFunction {
  75679. /**
  75680. * Interpolation follows the mathematical formula associated with the easing function.
  75681. */
  75682. static readonly EASINGMODE_EASEIN: number;
  75683. /**
  75684. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  75685. */
  75686. static readonly EASINGMODE_EASEOUT: number;
  75687. /**
  75688. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  75689. */
  75690. static readonly EASINGMODE_EASEINOUT: number;
  75691. private _easingMode;
  75692. /**
  75693. * Sets the easing mode of the current function.
  75694. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  75695. */
  75696. setEasingMode(easingMode: number): void;
  75697. /**
  75698. * Gets the current easing mode.
  75699. * @returns the easing mode
  75700. */
  75701. getEasingMode(): number;
  75702. /**
  75703. * @hidden
  75704. */
  75705. easeInCore(gradient: number): number;
  75706. /**
  75707. * Given an input gradient between 0 and 1, this returns the corresponding value
  75708. * of the easing function.
  75709. * @param gradient Defines the value between 0 and 1 we want the easing value for
  75710. * @returns the corresponding value on the curve defined by the easing function
  75711. */
  75712. ease(gradient: number): number;
  75713. }
  75714. /**
  75715. * Easing function with a circle shape (see link below).
  75716. * @see https://easings.net/#easeInCirc
  75717. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75718. */
  75719. export class CircleEase extends EasingFunction implements IEasingFunction {
  75720. /** @hidden */
  75721. easeInCore(gradient: number): number;
  75722. }
  75723. /**
  75724. * Easing function with a ease back shape (see link below).
  75725. * @see https://easings.net/#easeInBack
  75726. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75727. */
  75728. export class BackEase extends EasingFunction implements IEasingFunction {
  75729. /** Defines the amplitude of the function */
  75730. amplitude: number;
  75731. /**
  75732. * Instantiates a back ease easing
  75733. * @see https://easings.net/#easeInBack
  75734. * @param amplitude Defines the amplitude of the function
  75735. */
  75736. constructor(
  75737. /** Defines the amplitude of the function */
  75738. amplitude?: number);
  75739. /** @hidden */
  75740. easeInCore(gradient: number): number;
  75741. }
  75742. /**
  75743. * Easing function with a bouncing shape (see link below).
  75744. * @see https://easings.net/#easeInBounce
  75745. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75746. */
  75747. export class BounceEase extends EasingFunction implements IEasingFunction {
  75748. /** Defines the number of bounces */
  75749. bounces: number;
  75750. /** Defines the amplitude of the bounce */
  75751. bounciness: number;
  75752. /**
  75753. * Instantiates a bounce easing
  75754. * @see https://easings.net/#easeInBounce
  75755. * @param bounces Defines the number of bounces
  75756. * @param bounciness Defines the amplitude of the bounce
  75757. */
  75758. constructor(
  75759. /** Defines the number of bounces */
  75760. bounces?: number,
  75761. /** Defines the amplitude of the bounce */
  75762. bounciness?: number);
  75763. /** @hidden */
  75764. easeInCore(gradient: number): number;
  75765. }
  75766. /**
  75767. * Easing function with a power of 3 shape (see link below).
  75768. * @see https://easings.net/#easeInCubic
  75769. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75770. */
  75771. export class CubicEase extends EasingFunction implements IEasingFunction {
  75772. /** @hidden */
  75773. easeInCore(gradient: number): number;
  75774. }
  75775. /**
  75776. * Easing function with an elastic shape (see link below).
  75777. * @see https://easings.net/#easeInElastic
  75778. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75779. */
  75780. export class ElasticEase extends EasingFunction implements IEasingFunction {
  75781. /** Defines the number of oscillations*/
  75782. oscillations: number;
  75783. /** Defines the amplitude of the oscillations*/
  75784. springiness: number;
  75785. /**
  75786. * Instantiates an elastic easing function
  75787. * @see https://easings.net/#easeInElastic
  75788. * @param oscillations Defines the number of oscillations
  75789. * @param springiness Defines the amplitude of the oscillations
  75790. */
  75791. constructor(
  75792. /** Defines the number of oscillations*/
  75793. oscillations?: number,
  75794. /** Defines the amplitude of the oscillations*/
  75795. springiness?: number);
  75796. /** @hidden */
  75797. easeInCore(gradient: number): number;
  75798. }
  75799. /**
  75800. * Easing function with an exponential shape (see link below).
  75801. * @see https://easings.net/#easeInExpo
  75802. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75803. */
  75804. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  75805. /** Defines the exponent of the function */
  75806. exponent: number;
  75807. /**
  75808. * Instantiates an exponential easing function
  75809. * @see https://easings.net/#easeInExpo
  75810. * @param exponent Defines the exponent of the function
  75811. */
  75812. constructor(
  75813. /** Defines the exponent of the function */
  75814. exponent?: number);
  75815. /** @hidden */
  75816. easeInCore(gradient: number): number;
  75817. }
  75818. /**
  75819. * Easing function with a power shape (see link below).
  75820. * @see https://easings.net/#easeInQuad
  75821. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75822. */
  75823. export class PowerEase extends EasingFunction implements IEasingFunction {
  75824. /** Defines the power of the function */
  75825. power: number;
  75826. /**
  75827. * Instantiates an power base easing function
  75828. * @see https://easings.net/#easeInQuad
  75829. * @param power Defines the power of the function
  75830. */
  75831. constructor(
  75832. /** Defines the power of the function */
  75833. power?: number);
  75834. /** @hidden */
  75835. easeInCore(gradient: number): number;
  75836. }
  75837. /**
  75838. * Easing function with a power of 2 shape (see link below).
  75839. * @see https://easings.net/#easeInQuad
  75840. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75841. */
  75842. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  75843. /** @hidden */
  75844. easeInCore(gradient: number): number;
  75845. }
  75846. /**
  75847. * Easing function with a power of 4 shape (see link below).
  75848. * @see https://easings.net/#easeInQuart
  75849. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75850. */
  75851. export class QuarticEase extends EasingFunction implements IEasingFunction {
  75852. /** @hidden */
  75853. easeInCore(gradient: number): number;
  75854. }
  75855. /**
  75856. * Easing function with a power of 5 shape (see link below).
  75857. * @see https://easings.net/#easeInQuint
  75858. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75859. */
  75860. export class QuinticEase extends EasingFunction implements IEasingFunction {
  75861. /** @hidden */
  75862. easeInCore(gradient: number): number;
  75863. }
  75864. /**
  75865. * Easing function with a sin shape (see link below).
  75866. * @see https://easings.net/#easeInSine
  75867. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75868. */
  75869. export class SineEase extends EasingFunction implements IEasingFunction {
  75870. /** @hidden */
  75871. easeInCore(gradient: number): number;
  75872. }
  75873. /**
  75874. * Easing function with a bezier shape (see link below).
  75875. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  75876. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75877. */
  75878. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  75879. /** Defines the x component of the start tangent in the bezier curve */
  75880. x1: number;
  75881. /** Defines the y component of the start tangent in the bezier curve */
  75882. y1: number;
  75883. /** Defines the x component of the end tangent in the bezier curve */
  75884. x2: number;
  75885. /** Defines the y component of the end tangent in the bezier curve */
  75886. y2: number;
  75887. /**
  75888. * Instantiates a bezier function
  75889. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  75890. * @param x1 Defines the x component of the start tangent in the bezier curve
  75891. * @param y1 Defines the y component of the start tangent in the bezier curve
  75892. * @param x2 Defines the x component of the end tangent in the bezier curve
  75893. * @param y2 Defines the y component of the end tangent in the bezier curve
  75894. */
  75895. constructor(
  75896. /** Defines the x component of the start tangent in the bezier curve */
  75897. x1?: number,
  75898. /** Defines the y component of the start tangent in the bezier curve */
  75899. y1?: number,
  75900. /** Defines the x component of the end tangent in the bezier curve */
  75901. x2?: number,
  75902. /** Defines the y component of the end tangent in the bezier curve */
  75903. y2?: number);
  75904. /** @hidden */
  75905. easeInCore(gradient: number): number;
  75906. }
  75907. }
  75908. declare module BABYLON {
  75909. /**
  75910. * Class used to hold a RBG color
  75911. */
  75912. export class Color3 {
  75913. /**
  75914. * Defines the red component (between 0 and 1, default is 0)
  75915. */
  75916. r: number;
  75917. /**
  75918. * Defines the green component (between 0 and 1, default is 0)
  75919. */
  75920. g: number;
  75921. /**
  75922. * Defines the blue component (between 0 and 1, default is 0)
  75923. */
  75924. b: number;
  75925. /**
  75926. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  75927. * @param r defines the red component (between 0 and 1, default is 0)
  75928. * @param g defines the green component (between 0 and 1, default is 0)
  75929. * @param b defines the blue component (between 0 and 1, default is 0)
  75930. */
  75931. constructor(
  75932. /**
  75933. * Defines the red component (between 0 and 1, default is 0)
  75934. */
  75935. r?: number,
  75936. /**
  75937. * Defines the green component (between 0 and 1, default is 0)
  75938. */
  75939. g?: number,
  75940. /**
  75941. * Defines the blue component (between 0 and 1, default is 0)
  75942. */
  75943. b?: number);
  75944. /**
  75945. * Creates a string with the Color3 current values
  75946. * @returns the string representation of the Color3 object
  75947. */
  75948. toString(): string;
  75949. /**
  75950. * Returns the string "Color3"
  75951. * @returns "Color3"
  75952. */
  75953. getClassName(): string;
  75954. /**
  75955. * Compute the Color3 hash code
  75956. * @returns an unique number that can be used to hash Color3 objects
  75957. */
  75958. getHashCode(): number;
  75959. /**
  75960. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  75961. * @param array defines the array where to store the r,g,b components
  75962. * @param index defines an optional index in the target array to define where to start storing values
  75963. * @returns the current Color3 object
  75964. */
  75965. toArray(array: FloatArray, index?: number): Color3;
  75966. /**
  75967. * Returns a new Color4 object from the current Color3 and the given alpha
  75968. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  75969. * @returns a new Color4 object
  75970. */
  75971. toColor4(alpha?: number): Color4;
  75972. /**
  75973. * Returns a new array populated with 3 numeric elements : red, green and blue values
  75974. * @returns the new array
  75975. */
  75976. asArray(): number[];
  75977. /**
  75978. * Returns the luminance value
  75979. * @returns a float value
  75980. */
  75981. toLuminance(): number;
  75982. /**
  75983. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  75984. * @param otherColor defines the second operand
  75985. * @returns the new Color3 object
  75986. */
  75987. multiply(otherColor: DeepImmutable<Color3>): Color3;
  75988. /**
  75989. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  75990. * @param otherColor defines the second operand
  75991. * @param result defines the Color3 object where to store the result
  75992. * @returns the current Color3
  75993. */
  75994. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  75995. /**
  75996. * Determines equality between Color3 objects
  75997. * @param otherColor defines the second operand
  75998. * @returns true if the rgb values are equal to the given ones
  75999. */
  76000. equals(otherColor: DeepImmutable<Color3>): boolean;
  76001. /**
  76002. * Determines equality between the current Color3 object and a set of r,b,g values
  76003. * @param r defines the red component to check
  76004. * @param g defines the green component to check
  76005. * @param b defines the blue component to check
  76006. * @returns true if the rgb values are equal to the given ones
  76007. */
  76008. equalsFloats(r: number, g: number, b: number): boolean;
  76009. /**
  76010. * Multiplies in place each rgb value by scale
  76011. * @param scale defines the scaling factor
  76012. * @returns the updated Color3
  76013. */
  76014. scale(scale: number): Color3;
  76015. /**
  76016. * Multiplies the rgb values by scale and stores the result into "result"
  76017. * @param scale defines the scaling factor
  76018. * @param result defines the Color3 object where to store the result
  76019. * @returns the unmodified current Color3
  76020. */
  76021. scaleToRef(scale: number, result: Color3): Color3;
  76022. /**
  76023. * Scale the current Color3 values by a factor and add the result to a given Color3
  76024. * @param scale defines the scale factor
  76025. * @param result defines color to store the result into
  76026. * @returns the unmodified current Color3
  76027. */
  76028. scaleAndAddToRef(scale: number, result: Color3): Color3;
  76029. /**
  76030. * Clamps the rgb values by the min and max values and stores the result into "result"
  76031. * @param min defines minimum clamping value (default is 0)
  76032. * @param max defines maximum clamping value (default is 1)
  76033. * @param result defines color to store the result into
  76034. * @returns the original Color3
  76035. */
  76036. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  76037. /**
  76038. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  76039. * @param otherColor defines the second operand
  76040. * @returns the new Color3
  76041. */
  76042. add(otherColor: DeepImmutable<Color3>): Color3;
  76043. /**
  76044. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  76045. * @param otherColor defines the second operand
  76046. * @param result defines Color3 object to store the result into
  76047. * @returns the unmodified current Color3
  76048. */
  76049. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  76050. /**
  76051. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  76052. * @param otherColor defines the second operand
  76053. * @returns the new Color3
  76054. */
  76055. subtract(otherColor: DeepImmutable<Color3>): Color3;
  76056. /**
  76057. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  76058. * @param otherColor defines the second operand
  76059. * @param result defines Color3 object to store the result into
  76060. * @returns the unmodified current Color3
  76061. */
  76062. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  76063. /**
  76064. * Copy the current object
  76065. * @returns a new Color3 copied the current one
  76066. */
  76067. clone(): Color3;
  76068. /**
  76069. * Copies the rgb values from the source in the current Color3
  76070. * @param source defines the source Color3 object
  76071. * @returns the updated Color3 object
  76072. */
  76073. copyFrom(source: DeepImmutable<Color3>): Color3;
  76074. /**
  76075. * Updates the Color3 rgb values from the given floats
  76076. * @param r defines the red component to read from
  76077. * @param g defines the green component to read from
  76078. * @param b defines the blue component to read from
  76079. * @returns the current Color3 object
  76080. */
  76081. copyFromFloats(r: number, g: number, b: number): Color3;
  76082. /**
  76083. * Updates the Color3 rgb values from the given floats
  76084. * @param r defines the red component to read from
  76085. * @param g defines the green component to read from
  76086. * @param b defines the blue component to read from
  76087. * @returns the current Color3 object
  76088. */
  76089. set(r: number, g: number, b: number): Color3;
  76090. /**
  76091. * Compute the Color3 hexadecimal code as a string
  76092. * @returns a string containing the hexadecimal representation of the Color3 object
  76093. */
  76094. toHexString(): string;
  76095. /**
  76096. * Computes a new Color3 converted from the current one to linear space
  76097. * @returns a new Color3 object
  76098. */
  76099. toLinearSpace(): Color3;
  76100. /**
  76101. * Converts current color in rgb space to HSV values
  76102. * @returns a new color3 representing the HSV values
  76103. */
  76104. toHSV(): Color3;
  76105. /**
  76106. * Converts current color in rgb space to HSV values
  76107. * @param result defines the Color3 where to store the HSV values
  76108. */
  76109. toHSVToRef(result: Color3): void;
  76110. /**
  76111. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  76112. * @param convertedColor defines the Color3 object where to store the linear space version
  76113. * @returns the unmodified Color3
  76114. */
  76115. toLinearSpaceToRef(convertedColor: Color3): Color3;
  76116. /**
  76117. * Computes a new Color3 converted from the current one to gamma space
  76118. * @returns a new Color3 object
  76119. */
  76120. toGammaSpace(): Color3;
  76121. /**
  76122. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  76123. * @param convertedColor defines the Color3 object where to store the gamma space version
  76124. * @returns the unmodified Color3
  76125. */
  76126. toGammaSpaceToRef(convertedColor: Color3): Color3;
  76127. private static _BlackReadOnly;
  76128. /**
  76129. * Convert Hue, saturation and value to a Color3 (RGB)
  76130. * @param hue defines the hue
  76131. * @param saturation defines the saturation
  76132. * @param value defines the value
  76133. * @param result defines the Color3 where to store the RGB values
  76134. */
  76135. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  76136. /**
  76137. * Creates a new Color3 from the string containing valid hexadecimal values
  76138. * @param hex defines a string containing valid hexadecimal values
  76139. * @returns a new Color3 object
  76140. */
  76141. static FromHexString(hex: string): Color3;
  76142. /**
  76143. * Creates a new Color3 from the starting index of the given array
  76144. * @param array defines the source array
  76145. * @param offset defines an offset in the source array
  76146. * @returns a new Color3 object
  76147. */
  76148. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  76149. /**
  76150. * Creates a new Color3 from integer values (< 256)
  76151. * @param r defines the red component to read from (value between 0 and 255)
  76152. * @param g defines the green component to read from (value between 0 and 255)
  76153. * @param b defines the blue component to read from (value between 0 and 255)
  76154. * @returns a new Color3 object
  76155. */
  76156. static FromInts(r: number, g: number, b: number): Color3;
  76157. /**
  76158. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  76159. * @param start defines the start Color3 value
  76160. * @param end defines the end Color3 value
  76161. * @param amount defines the gradient value between start and end
  76162. * @returns a new Color3 object
  76163. */
  76164. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  76165. /**
  76166. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  76167. * @param left defines the start value
  76168. * @param right defines the end value
  76169. * @param amount defines the gradient factor
  76170. * @param result defines the Color3 object where to store the result
  76171. */
  76172. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  76173. /**
  76174. * Returns a Color3 value containing a red color
  76175. * @returns a new Color3 object
  76176. */
  76177. static Red(): Color3;
  76178. /**
  76179. * Returns a Color3 value containing a green color
  76180. * @returns a new Color3 object
  76181. */
  76182. static Green(): Color3;
  76183. /**
  76184. * Returns a Color3 value containing a blue color
  76185. * @returns a new Color3 object
  76186. */
  76187. static Blue(): Color3;
  76188. /**
  76189. * Returns a Color3 value containing a black color
  76190. * @returns a new Color3 object
  76191. */
  76192. static Black(): Color3;
  76193. /**
  76194. * Gets a Color3 value containing a black color that must not be updated
  76195. */
  76196. static get BlackReadOnly(): DeepImmutable<Color3>;
  76197. /**
  76198. * Returns a Color3 value containing a white color
  76199. * @returns a new Color3 object
  76200. */
  76201. static White(): Color3;
  76202. /**
  76203. * Returns a Color3 value containing a purple color
  76204. * @returns a new Color3 object
  76205. */
  76206. static Purple(): Color3;
  76207. /**
  76208. * Returns a Color3 value containing a magenta color
  76209. * @returns a new Color3 object
  76210. */
  76211. static Magenta(): Color3;
  76212. /**
  76213. * Returns a Color3 value containing a yellow color
  76214. * @returns a new Color3 object
  76215. */
  76216. static Yellow(): Color3;
  76217. /**
  76218. * Returns a Color3 value containing a gray color
  76219. * @returns a new Color3 object
  76220. */
  76221. static Gray(): Color3;
  76222. /**
  76223. * Returns a Color3 value containing a teal color
  76224. * @returns a new Color3 object
  76225. */
  76226. static Teal(): Color3;
  76227. /**
  76228. * Returns a Color3 value containing a random color
  76229. * @returns a new Color3 object
  76230. */
  76231. static Random(): Color3;
  76232. }
  76233. /**
  76234. * Class used to hold a RBGA color
  76235. */
  76236. export class Color4 {
  76237. /**
  76238. * Defines the red component (between 0 and 1, default is 0)
  76239. */
  76240. r: number;
  76241. /**
  76242. * Defines the green component (between 0 and 1, default is 0)
  76243. */
  76244. g: number;
  76245. /**
  76246. * Defines the blue component (between 0 and 1, default is 0)
  76247. */
  76248. b: number;
  76249. /**
  76250. * Defines the alpha component (between 0 and 1, default is 1)
  76251. */
  76252. a: number;
  76253. /**
  76254. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  76255. * @param r defines the red component (between 0 and 1, default is 0)
  76256. * @param g defines the green component (between 0 and 1, default is 0)
  76257. * @param b defines the blue component (between 0 and 1, default is 0)
  76258. * @param a defines the alpha component (between 0 and 1, default is 1)
  76259. */
  76260. constructor(
  76261. /**
  76262. * Defines the red component (between 0 and 1, default is 0)
  76263. */
  76264. r?: number,
  76265. /**
  76266. * Defines the green component (between 0 and 1, default is 0)
  76267. */
  76268. g?: number,
  76269. /**
  76270. * Defines the blue component (between 0 and 1, default is 0)
  76271. */
  76272. b?: number,
  76273. /**
  76274. * Defines the alpha component (between 0 and 1, default is 1)
  76275. */
  76276. a?: number);
  76277. /**
  76278. * Adds in place the given Color4 values to the current Color4 object
  76279. * @param right defines the second operand
  76280. * @returns the current updated Color4 object
  76281. */
  76282. addInPlace(right: DeepImmutable<Color4>): Color4;
  76283. /**
  76284. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  76285. * @returns the new array
  76286. */
  76287. asArray(): number[];
  76288. /**
  76289. * Stores from the starting index in the given array the Color4 successive values
  76290. * @param array defines the array where to store the r,g,b components
  76291. * @param index defines an optional index in the target array to define where to start storing values
  76292. * @returns the current Color4 object
  76293. */
  76294. toArray(array: number[], index?: number): Color4;
  76295. /**
  76296. * Determines equality between Color4 objects
  76297. * @param otherColor defines the second operand
  76298. * @returns true if the rgba values are equal to the given ones
  76299. */
  76300. equals(otherColor: DeepImmutable<Color4>): boolean;
  76301. /**
  76302. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  76303. * @param right defines the second operand
  76304. * @returns a new Color4 object
  76305. */
  76306. add(right: DeepImmutable<Color4>): Color4;
  76307. /**
  76308. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  76309. * @param right defines the second operand
  76310. * @returns a new Color4 object
  76311. */
  76312. subtract(right: DeepImmutable<Color4>): Color4;
  76313. /**
  76314. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  76315. * @param right defines the second operand
  76316. * @param result defines the Color4 object where to store the result
  76317. * @returns the current Color4 object
  76318. */
  76319. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  76320. /**
  76321. * Creates a new Color4 with the current Color4 values multiplied by scale
  76322. * @param scale defines the scaling factor to apply
  76323. * @returns a new Color4 object
  76324. */
  76325. scale(scale: number): Color4;
  76326. /**
  76327. * Multiplies the current Color4 values by scale and stores the result in "result"
  76328. * @param scale defines the scaling factor to apply
  76329. * @param result defines the Color4 object where to store the result
  76330. * @returns the current unmodified Color4
  76331. */
  76332. scaleToRef(scale: number, result: Color4): Color4;
  76333. /**
  76334. * Scale the current Color4 values by a factor and add the result to a given Color4
  76335. * @param scale defines the scale factor
  76336. * @param result defines the Color4 object where to store the result
  76337. * @returns the unmodified current Color4
  76338. */
  76339. scaleAndAddToRef(scale: number, result: Color4): Color4;
  76340. /**
  76341. * Clamps the rgb values by the min and max values and stores the result into "result"
  76342. * @param min defines minimum clamping value (default is 0)
  76343. * @param max defines maximum clamping value (default is 1)
  76344. * @param result defines color to store the result into.
  76345. * @returns the cuurent Color4
  76346. */
  76347. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  76348. /**
  76349. * Multipy an Color4 value by another and return a new Color4 object
  76350. * @param color defines the Color4 value to multiply by
  76351. * @returns a new Color4 object
  76352. */
  76353. multiply(color: Color4): Color4;
  76354. /**
  76355. * Multipy a Color4 value by another and push the result in a reference value
  76356. * @param color defines the Color4 value to multiply by
  76357. * @param result defines the Color4 to fill the result in
  76358. * @returns the result Color4
  76359. */
  76360. multiplyToRef(color: Color4, result: Color4): Color4;
  76361. /**
  76362. * Creates a string with the Color4 current values
  76363. * @returns the string representation of the Color4 object
  76364. */
  76365. toString(): string;
  76366. /**
  76367. * Returns the string "Color4"
  76368. * @returns "Color4"
  76369. */
  76370. getClassName(): string;
  76371. /**
  76372. * Compute the Color4 hash code
  76373. * @returns an unique number that can be used to hash Color4 objects
  76374. */
  76375. getHashCode(): number;
  76376. /**
  76377. * Creates a new Color4 copied from the current one
  76378. * @returns a new Color4 object
  76379. */
  76380. clone(): Color4;
  76381. /**
  76382. * Copies the given Color4 values into the current one
  76383. * @param source defines the source Color4 object
  76384. * @returns the current updated Color4 object
  76385. */
  76386. copyFrom(source: Color4): Color4;
  76387. /**
  76388. * Copies the given float values into the current one
  76389. * @param r defines the red component to read from
  76390. * @param g defines the green component to read from
  76391. * @param b defines the blue component to read from
  76392. * @param a defines the alpha component to read from
  76393. * @returns the current updated Color4 object
  76394. */
  76395. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  76396. /**
  76397. * Copies the given float values into the current one
  76398. * @param r defines the red component to read from
  76399. * @param g defines the green component to read from
  76400. * @param b defines the blue component to read from
  76401. * @param a defines the alpha component to read from
  76402. * @returns the current updated Color4 object
  76403. */
  76404. set(r: number, g: number, b: number, a: number): Color4;
  76405. /**
  76406. * Compute the Color4 hexadecimal code as a string
  76407. * @returns a string containing the hexadecimal representation of the Color4 object
  76408. */
  76409. toHexString(): string;
  76410. /**
  76411. * Computes a new Color4 converted from the current one to linear space
  76412. * @returns a new Color4 object
  76413. */
  76414. toLinearSpace(): Color4;
  76415. /**
  76416. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  76417. * @param convertedColor defines the Color4 object where to store the linear space version
  76418. * @returns the unmodified Color4
  76419. */
  76420. toLinearSpaceToRef(convertedColor: Color4): Color4;
  76421. /**
  76422. * Computes a new Color4 converted from the current one to gamma space
  76423. * @returns a new Color4 object
  76424. */
  76425. toGammaSpace(): Color4;
  76426. /**
  76427. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  76428. * @param convertedColor defines the Color4 object where to store the gamma space version
  76429. * @returns the unmodified Color4
  76430. */
  76431. toGammaSpaceToRef(convertedColor: Color4): Color4;
  76432. /**
  76433. * Creates a new Color4 from the string containing valid hexadecimal values
  76434. * @param hex defines a string containing valid hexadecimal values
  76435. * @returns a new Color4 object
  76436. */
  76437. static FromHexString(hex: string): Color4;
  76438. /**
  76439. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  76440. * @param left defines the start value
  76441. * @param right defines the end value
  76442. * @param amount defines the gradient factor
  76443. * @returns a new Color4 object
  76444. */
  76445. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  76446. /**
  76447. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  76448. * @param left defines the start value
  76449. * @param right defines the end value
  76450. * @param amount defines the gradient factor
  76451. * @param result defines the Color4 object where to store data
  76452. */
  76453. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  76454. /**
  76455. * Creates a new Color4 from a Color3 and an alpha value
  76456. * @param color3 defines the source Color3 to read from
  76457. * @param alpha defines the alpha component (1.0 by default)
  76458. * @returns a new Color4 object
  76459. */
  76460. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  76461. /**
  76462. * Creates a new Color4 from the starting index element of the given array
  76463. * @param array defines the source array to read from
  76464. * @param offset defines the offset in the source array
  76465. * @returns a new Color4 object
  76466. */
  76467. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  76468. /**
  76469. * Creates a new Color3 from integer values (< 256)
  76470. * @param r defines the red component to read from (value between 0 and 255)
  76471. * @param g defines the green component to read from (value between 0 and 255)
  76472. * @param b defines the blue component to read from (value between 0 and 255)
  76473. * @param a defines the alpha component to read from (value between 0 and 255)
  76474. * @returns a new Color3 object
  76475. */
  76476. static FromInts(r: number, g: number, b: number, a: number): Color4;
  76477. /**
  76478. * Check the content of a given array and convert it to an array containing RGBA data
  76479. * If the original array was already containing count * 4 values then it is returned directly
  76480. * @param colors defines the array to check
  76481. * @param count defines the number of RGBA data to expect
  76482. * @returns an array containing count * 4 values (RGBA)
  76483. */
  76484. static CheckColors4(colors: number[], count: number): number[];
  76485. }
  76486. /**
  76487. * @hidden
  76488. */
  76489. export class TmpColors {
  76490. static Color3: Color3[];
  76491. static Color4: Color4[];
  76492. }
  76493. }
  76494. declare module BABYLON {
  76495. /**
  76496. * Defines an interface which represents an animation key frame
  76497. */
  76498. export interface IAnimationKey {
  76499. /**
  76500. * Frame of the key frame
  76501. */
  76502. frame: number;
  76503. /**
  76504. * Value at the specifies key frame
  76505. */
  76506. value: any;
  76507. /**
  76508. * The input tangent for the cubic hermite spline
  76509. */
  76510. inTangent?: any;
  76511. /**
  76512. * The output tangent for the cubic hermite spline
  76513. */
  76514. outTangent?: any;
  76515. /**
  76516. * The animation interpolation type
  76517. */
  76518. interpolation?: AnimationKeyInterpolation;
  76519. }
  76520. /**
  76521. * Enum for the animation key frame interpolation type
  76522. */
  76523. export enum AnimationKeyInterpolation {
  76524. /**
  76525. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  76526. */
  76527. STEP = 1
  76528. }
  76529. }
  76530. declare module BABYLON {
  76531. /**
  76532. * Represents the range of an animation
  76533. */
  76534. export class AnimationRange {
  76535. /**The name of the animation range**/
  76536. name: string;
  76537. /**The starting frame of the animation */
  76538. from: number;
  76539. /**The ending frame of the animation*/
  76540. to: number;
  76541. /**
  76542. * Initializes the range of an animation
  76543. * @param name The name of the animation range
  76544. * @param from The starting frame of the animation
  76545. * @param to The ending frame of the animation
  76546. */
  76547. constructor(
  76548. /**The name of the animation range**/
  76549. name: string,
  76550. /**The starting frame of the animation */
  76551. from: number,
  76552. /**The ending frame of the animation*/
  76553. to: number);
  76554. /**
  76555. * Makes a copy of the animation range
  76556. * @returns A copy of the animation range
  76557. */
  76558. clone(): AnimationRange;
  76559. }
  76560. }
  76561. declare module BABYLON {
  76562. /**
  76563. * Composed of a frame, and an action function
  76564. */
  76565. export class AnimationEvent {
  76566. /** The frame for which the event is triggered **/
  76567. frame: number;
  76568. /** The event to perform when triggered **/
  76569. action: (currentFrame: number) => void;
  76570. /** Specifies if the event should be triggered only once**/
  76571. onlyOnce?: boolean | undefined;
  76572. /**
  76573. * Specifies if the animation event is done
  76574. */
  76575. isDone: boolean;
  76576. /**
  76577. * Initializes the animation event
  76578. * @param frame The frame for which the event is triggered
  76579. * @param action The event to perform when triggered
  76580. * @param onlyOnce Specifies if the event should be triggered only once
  76581. */
  76582. constructor(
  76583. /** The frame for which the event is triggered **/
  76584. frame: number,
  76585. /** The event to perform when triggered **/
  76586. action: (currentFrame: number) => void,
  76587. /** Specifies if the event should be triggered only once**/
  76588. onlyOnce?: boolean | undefined);
  76589. /** @hidden */
  76590. _clone(): AnimationEvent;
  76591. }
  76592. }
  76593. declare module BABYLON {
  76594. /**
  76595. * Interface used to define a behavior
  76596. */
  76597. export interface Behavior<T> {
  76598. /** gets or sets behavior's name */
  76599. name: string;
  76600. /**
  76601. * Function called when the behavior needs to be initialized (after attaching it to a target)
  76602. */
  76603. init(): void;
  76604. /**
  76605. * Called when the behavior is attached to a target
  76606. * @param target defines the target where the behavior is attached to
  76607. */
  76608. attach(target: T): void;
  76609. /**
  76610. * Called when the behavior is detached from its target
  76611. */
  76612. detach(): void;
  76613. }
  76614. /**
  76615. * Interface implemented by classes supporting behaviors
  76616. */
  76617. export interface IBehaviorAware<T> {
  76618. /**
  76619. * Attach a behavior
  76620. * @param behavior defines the behavior to attach
  76621. * @returns the current host
  76622. */
  76623. addBehavior(behavior: Behavior<T>): T;
  76624. /**
  76625. * Remove a behavior from the current object
  76626. * @param behavior defines the behavior to detach
  76627. * @returns the current host
  76628. */
  76629. removeBehavior(behavior: Behavior<T>): T;
  76630. /**
  76631. * Gets a behavior using its name to search
  76632. * @param name defines the name to search
  76633. * @returns the behavior or null if not found
  76634. */
  76635. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  76636. }
  76637. }
  76638. declare module BABYLON {
  76639. /**
  76640. * Defines an array and its length.
  76641. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  76642. */
  76643. export interface ISmartArrayLike<T> {
  76644. /**
  76645. * The data of the array.
  76646. */
  76647. data: Array<T>;
  76648. /**
  76649. * The active length of the array.
  76650. */
  76651. length: number;
  76652. }
  76653. /**
  76654. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  76655. */
  76656. export class SmartArray<T> implements ISmartArrayLike<T> {
  76657. /**
  76658. * The full set of data from the array.
  76659. */
  76660. data: Array<T>;
  76661. /**
  76662. * The active length of the array.
  76663. */
  76664. length: number;
  76665. protected _id: number;
  76666. /**
  76667. * Instantiates a Smart Array.
  76668. * @param capacity defines the default capacity of the array.
  76669. */
  76670. constructor(capacity: number);
  76671. /**
  76672. * Pushes a value at the end of the active data.
  76673. * @param value defines the object to push in the array.
  76674. */
  76675. push(value: T): void;
  76676. /**
  76677. * Iterates over the active data and apply the lambda to them.
  76678. * @param func defines the action to apply on each value.
  76679. */
  76680. forEach(func: (content: T) => void): void;
  76681. /**
  76682. * Sorts the full sets of data.
  76683. * @param compareFn defines the comparison function to apply.
  76684. */
  76685. sort(compareFn: (a: T, b: T) => number): void;
  76686. /**
  76687. * Resets the active data to an empty array.
  76688. */
  76689. reset(): void;
  76690. /**
  76691. * Releases all the data from the array as well as the array.
  76692. */
  76693. dispose(): void;
  76694. /**
  76695. * Concats the active data with a given array.
  76696. * @param array defines the data to concatenate with.
  76697. */
  76698. concat(array: any): void;
  76699. /**
  76700. * Returns the position of a value in the active data.
  76701. * @param value defines the value to find the index for
  76702. * @returns the index if found in the active data otherwise -1
  76703. */
  76704. indexOf(value: T): number;
  76705. /**
  76706. * Returns whether an element is part of the active data.
  76707. * @param value defines the value to look for
  76708. * @returns true if found in the active data otherwise false
  76709. */
  76710. contains(value: T): boolean;
  76711. private static _GlobalId;
  76712. }
  76713. /**
  76714. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  76715. * The data in this array can only be present once
  76716. */
  76717. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  76718. private _duplicateId;
  76719. /**
  76720. * Pushes a value at the end of the active data.
  76721. * THIS DOES NOT PREVENT DUPPLICATE DATA
  76722. * @param value defines the object to push in the array.
  76723. */
  76724. push(value: T): void;
  76725. /**
  76726. * Pushes a value at the end of the active data.
  76727. * If the data is already present, it won t be added again
  76728. * @param value defines the object to push in the array.
  76729. * @returns true if added false if it was already present
  76730. */
  76731. pushNoDuplicate(value: T): boolean;
  76732. /**
  76733. * Resets the active data to an empty array.
  76734. */
  76735. reset(): void;
  76736. /**
  76737. * Concats the active data with a given array.
  76738. * This ensures no dupplicate will be present in the result.
  76739. * @param array defines the data to concatenate with.
  76740. */
  76741. concatWithNoDuplicate(array: any): void;
  76742. }
  76743. }
  76744. declare module BABYLON {
  76745. /**
  76746. * @ignore
  76747. * This is a list of all the different input types that are available in the application.
  76748. * Fo instance: ArcRotateCameraGamepadInput...
  76749. */
  76750. export var CameraInputTypes: {};
  76751. /**
  76752. * This is the contract to implement in order to create a new input class.
  76753. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  76754. */
  76755. export interface ICameraInput<TCamera extends Camera> {
  76756. /**
  76757. * Defines the camera the input is attached to.
  76758. */
  76759. camera: Nullable<TCamera>;
  76760. /**
  76761. * Gets the class name of the current intput.
  76762. * @returns the class name
  76763. */
  76764. getClassName(): string;
  76765. /**
  76766. * Get the friendly name associated with the input class.
  76767. * @returns the input friendly name
  76768. */
  76769. getSimpleName(): string;
  76770. /**
  76771. * Attach the input controls to a specific dom element to get the input from.
  76772. * @param element Defines the element the controls should be listened from
  76773. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76774. */
  76775. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76776. /**
  76777. * Detach the current controls from the specified dom element.
  76778. * @param element Defines the element to stop listening the inputs from
  76779. */
  76780. detachControl(element: Nullable<HTMLElement>): void;
  76781. /**
  76782. * Update the current camera state depending on the inputs that have been used this frame.
  76783. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76784. */
  76785. checkInputs?: () => void;
  76786. }
  76787. /**
  76788. * Represents a map of input types to input instance or input index to input instance.
  76789. */
  76790. export interface CameraInputsMap<TCamera extends Camera> {
  76791. /**
  76792. * Accessor to the input by input type.
  76793. */
  76794. [name: string]: ICameraInput<TCamera>;
  76795. /**
  76796. * Accessor to the input by input index.
  76797. */
  76798. [idx: number]: ICameraInput<TCamera>;
  76799. }
  76800. /**
  76801. * This represents the input manager used within a camera.
  76802. * It helps dealing with all the different kind of input attached to a camera.
  76803. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76804. */
  76805. export class CameraInputsManager<TCamera extends Camera> {
  76806. /**
  76807. * Defines the list of inputs attahed to the camera.
  76808. */
  76809. attached: CameraInputsMap<TCamera>;
  76810. /**
  76811. * Defines the dom element the camera is collecting inputs from.
  76812. * This is null if the controls have not been attached.
  76813. */
  76814. attachedElement: Nullable<HTMLElement>;
  76815. /**
  76816. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76817. */
  76818. noPreventDefault: boolean;
  76819. /**
  76820. * Defined the camera the input manager belongs to.
  76821. */
  76822. camera: TCamera;
  76823. /**
  76824. * Update the current camera state depending on the inputs that have been used this frame.
  76825. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76826. */
  76827. checkInputs: () => void;
  76828. /**
  76829. * Instantiate a new Camera Input Manager.
  76830. * @param camera Defines the camera the input manager blongs to
  76831. */
  76832. constructor(camera: TCamera);
  76833. /**
  76834. * Add an input method to a camera
  76835. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76836. * @param input camera input method
  76837. */
  76838. add(input: ICameraInput<TCamera>): void;
  76839. /**
  76840. * Remove a specific input method from a camera
  76841. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  76842. * @param inputToRemove camera input method
  76843. */
  76844. remove(inputToRemove: ICameraInput<TCamera>): void;
  76845. /**
  76846. * Remove a specific input type from a camera
  76847. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  76848. * @param inputType the type of the input to remove
  76849. */
  76850. removeByType(inputType: string): void;
  76851. private _addCheckInputs;
  76852. /**
  76853. * Attach the input controls to the currently attached dom element to listen the events from.
  76854. * @param input Defines the input to attach
  76855. */
  76856. attachInput(input: ICameraInput<TCamera>): void;
  76857. /**
  76858. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  76859. * @param element Defines the dom element to collect the events from
  76860. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76861. */
  76862. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  76863. /**
  76864. * Detach the current manager inputs controls from a specific dom element.
  76865. * @param element Defines the dom element to collect the events from
  76866. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  76867. */
  76868. detachElement(element: HTMLElement, disconnect?: boolean): void;
  76869. /**
  76870. * Rebuild the dynamic inputCheck function from the current list of
  76871. * defined inputs in the manager.
  76872. */
  76873. rebuildInputCheck(): void;
  76874. /**
  76875. * Remove all attached input methods from a camera
  76876. */
  76877. clear(): void;
  76878. /**
  76879. * Serialize the current input manager attached to a camera.
  76880. * This ensures than once parsed,
  76881. * the input associated to the camera will be identical to the current ones
  76882. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  76883. */
  76884. serialize(serializedCamera: any): void;
  76885. /**
  76886. * Parses an input manager serialized JSON to restore the previous list of inputs
  76887. * and states associated to a camera.
  76888. * @param parsedCamera Defines the JSON to parse
  76889. */
  76890. parse(parsedCamera: any): void;
  76891. }
  76892. }
  76893. declare module BABYLON {
  76894. /**
  76895. * Class used to store data that will be store in GPU memory
  76896. */
  76897. export class Buffer {
  76898. private _engine;
  76899. private _buffer;
  76900. /** @hidden */
  76901. _data: Nullable<DataArray>;
  76902. private _updatable;
  76903. private _instanced;
  76904. private _divisor;
  76905. /**
  76906. * Gets the byte stride.
  76907. */
  76908. readonly byteStride: number;
  76909. /**
  76910. * Constructor
  76911. * @param engine the engine
  76912. * @param data the data to use for this buffer
  76913. * @param updatable whether the data is updatable
  76914. * @param stride the stride (optional)
  76915. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  76916. * @param instanced whether the buffer is instanced (optional)
  76917. * @param useBytes set to true if the stride in in bytes (optional)
  76918. * @param divisor sets an optional divisor for instances (1 by default)
  76919. */
  76920. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  76921. /**
  76922. * Create a new VertexBuffer based on the current buffer
  76923. * @param kind defines the vertex buffer kind (position, normal, etc.)
  76924. * @param offset defines offset in the buffer (0 by default)
  76925. * @param size defines the size in floats of attributes (position is 3 for instance)
  76926. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  76927. * @param instanced defines if the vertex buffer contains indexed data
  76928. * @param useBytes defines if the offset and stride are in bytes *
  76929. * @param divisor sets an optional divisor for instances (1 by default)
  76930. * @returns the new vertex buffer
  76931. */
  76932. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  76933. /**
  76934. * Gets a boolean indicating if the Buffer is updatable?
  76935. * @returns true if the buffer is updatable
  76936. */
  76937. isUpdatable(): boolean;
  76938. /**
  76939. * Gets current buffer's data
  76940. * @returns a DataArray or null
  76941. */
  76942. getData(): Nullable<DataArray>;
  76943. /**
  76944. * Gets underlying native buffer
  76945. * @returns underlying native buffer
  76946. */
  76947. getBuffer(): Nullable<DataBuffer>;
  76948. /**
  76949. * Gets the stride in float32 units (i.e. byte stride / 4).
  76950. * May not be an integer if the byte stride is not divisible by 4.
  76951. * @returns the stride in float32 units
  76952. * @deprecated Please use byteStride instead.
  76953. */
  76954. getStrideSize(): number;
  76955. /**
  76956. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  76957. * @param data defines the data to store
  76958. */
  76959. create(data?: Nullable<DataArray>): void;
  76960. /** @hidden */
  76961. _rebuild(): void;
  76962. /**
  76963. * Update current buffer data
  76964. * @param data defines the data to store
  76965. */
  76966. update(data: DataArray): void;
  76967. /**
  76968. * Updates the data directly.
  76969. * @param data the new data
  76970. * @param offset the new offset
  76971. * @param vertexCount the vertex count (optional)
  76972. * @param useBytes set to true if the offset is in bytes
  76973. */
  76974. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  76975. /**
  76976. * Release all resources
  76977. */
  76978. dispose(): void;
  76979. }
  76980. /**
  76981. * Specialized buffer used to store vertex data
  76982. */
  76983. export class VertexBuffer {
  76984. /** @hidden */
  76985. _buffer: Buffer;
  76986. private _kind;
  76987. private _size;
  76988. private _ownsBuffer;
  76989. private _instanced;
  76990. private _instanceDivisor;
  76991. /**
  76992. * The byte type.
  76993. */
  76994. static readonly BYTE: number;
  76995. /**
  76996. * The unsigned byte type.
  76997. */
  76998. static readonly UNSIGNED_BYTE: number;
  76999. /**
  77000. * The short type.
  77001. */
  77002. static readonly SHORT: number;
  77003. /**
  77004. * The unsigned short type.
  77005. */
  77006. static readonly UNSIGNED_SHORT: number;
  77007. /**
  77008. * The integer type.
  77009. */
  77010. static readonly INT: number;
  77011. /**
  77012. * The unsigned integer type.
  77013. */
  77014. static readonly UNSIGNED_INT: number;
  77015. /**
  77016. * The float type.
  77017. */
  77018. static readonly FLOAT: number;
  77019. /**
  77020. * Gets or sets the instance divisor when in instanced mode
  77021. */
  77022. get instanceDivisor(): number;
  77023. set instanceDivisor(value: number);
  77024. /**
  77025. * Gets the byte stride.
  77026. */
  77027. readonly byteStride: number;
  77028. /**
  77029. * Gets the byte offset.
  77030. */
  77031. readonly byteOffset: number;
  77032. /**
  77033. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  77034. */
  77035. readonly normalized: boolean;
  77036. /**
  77037. * Gets the data type of each component in the array.
  77038. */
  77039. readonly type: number;
  77040. /**
  77041. * Constructor
  77042. * @param engine the engine
  77043. * @param data the data to use for this vertex buffer
  77044. * @param kind the vertex buffer kind
  77045. * @param updatable whether the data is updatable
  77046. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  77047. * @param stride the stride (optional)
  77048. * @param instanced whether the buffer is instanced (optional)
  77049. * @param offset the offset of the data (optional)
  77050. * @param size the number of components (optional)
  77051. * @param type the type of the component (optional)
  77052. * @param normalized whether the data contains normalized data (optional)
  77053. * @param useBytes set to true if stride and offset are in bytes (optional)
  77054. * @param divisor defines the instance divisor to use (1 by default)
  77055. */
  77056. 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);
  77057. /** @hidden */
  77058. _rebuild(): void;
  77059. /**
  77060. * Returns the kind of the VertexBuffer (string)
  77061. * @returns a string
  77062. */
  77063. getKind(): string;
  77064. /**
  77065. * Gets a boolean indicating if the VertexBuffer is updatable?
  77066. * @returns true if the buffer is updatable
  77067. */
  77068. isUpdatable(): boolean;
  77069. /**
  77070. * Gets current buffer's data
  77071. * @returns a DataArray or null
  77072. */
  77073. getData(): Nullable<DataArray>;
  77074. /**
  77075. * Gets underlying native buffer
  77076. * @returns underlying native buffer
  77077. */
  77078. getBuffer(): Nullable<DataBuffer>;
  77079. /**
  77080. * Gets the stride in float32 units (i.e. byte stride / 4).
  77081. * May not be an integer if the byte stride is not divisible by 4.
  77082. * @returns the stride in float32 units
  77083. * @deprecated Please use byteStride instead.
  77084. */
  77085. getStrideSize(): number;
  77086. /**
  77087. * Returns the offset as a multiple of the type byte length.
  77088. * @returns the offset in bytes
  77089. * @deprecated Please use byteOffset instead.
  77090. */
  77091. getOffset(): number;
  77092. /**
  77093. * Returns the number of components per vertex attribute (integer)
  77094. * @returns the size in float
  77095. */
  77096. getSize(): number;
  77097. /**
  77098. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  77099. * @returns true if this buffer is instanced
  77100. */
  77101. getIsInstanced(): boolean;
  77102. /**
  77103. * Returns the instancing divisor, zero for non-instanced (integer).
  77104. * @returns a number
  77105. */
  77106. getInstanceDivisor(): number;
  77107. /**
  77108. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  77109. * @param data defines the data to store
  77110. */
  77111. create(data?: DataArray): void;
  77112. /**
  77113. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  77114. * This function will create a new buffer if the current one is not updatable
  77115. * @param data defines the data to store
  77116. */
  77117. update(data: DataArray): void;
  77118. /**
  77119. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  77120. * Returns the directly updated WebGLBuffer.
  77121. * @param data the new data
  77122. * @param offset the new offset
  77123. * @param useBytes set to true if the offset is in bytes
  77124. */
  77125. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  77126. /**
  77127. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  77128. */
  77129. dispose(): void;
  77130. /**
  77131. * Enumerates each value of this vertex buffer as numbers.
  77132. * @param count the number of values to enumerate
  77133. * @param callback the callback function called for each value
  77134. */
  77135. forEach(count: number, callback: (value: number, index: number) => void): void;
  77136. /**
  77137. * Positions
  77138. */
  77139. static readonly PositionKind: string;
  77140. /**
  77141. * Normals
  77142. */
  77143. static readonly NormalKind: string;
  77144. /**
  77145. * Tangents
  77146. */
  77147. static readonly TangentKind: string;
  77148. /**
  77149. * Texture coordinates
  77150. */
  77151. static readonly UVKind: string;
  77152. /**
  77153. * Texture coordinates 2
  77154. */
  77155. static readonly UV2Kind: string;
  77156. /**
  77157. * Texture coordinates 3
  77158. */
  77159. static readonly UV3Kind: string;
  77160. /**
  77161. * Texture coordinates 4
  77162. */
  77163. static readonly UV4Kind: string;
  77164. /**
  77165. * Texture coordinates 5
  77166. */
  77167. static readonly UV5Kind: string;
  77168. /**
  77169. * Texture coordinates 6
  77170. */
  77171. static readonly UV6Kind: string;
  77172. /**
  77173. * Colors
  77174. */
  77175. static readonly ColorKind: string;
  77176. /**
  77177. * Matrix indices (for bones)
  77178. */
  77179. static readonly MatricesIndicesKind: string;
  77180. /**
  77181. * Matrix weights (for bones)
  77182. */
  77183. static readonly MatricesWeightsKind: string;
  77184. /**
  77185. * Additional matrix indices (for bones)
  77186. */
  77187. static readonly MatricesIndicesExtraKind: string;
  77188. /**
  77189. * Additional matrix weights (for bones)
  77190. */
  77191. static readonly MatricesWeightsExtraKind: string;
  77192. /**
  77193. * Deduces the stride given a kind.
  77194. * @param kind The kind string to deduce
  77195. * @returns The deduced stride
  77196. */
  77197. static DeduceStride(kind: string): number;
  77198. /**
  77199. * Gets the byte length of the given type.
  77200. * @param type the type
  77201. * @returns the number of bytes
  77202. */
  77203. static GetTypeByteLength(type: number): number;
  77204. /**
  77205. * Enumerates each value of the given parameters as numbers.
  77206. * @param data the data to enumerate
  77207. * @param byteOffset the byte offset of the data
  77208. * @param byteStride the byte stride of the data
  77209. * @param componentCount the number of components per element
  77210. * @param componentType the type of the component
  77211. * @param count the number of values to enumerate
  77212. * @param normalized whether the data is normalized
  77213. * @param callback the callback function called for each value
  77214. */
  77215. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  77216. private static _GetFloatValue;
  77217. }
  77218. }
  77219. declare module BABYLON {
  77220. /**
  77221. * @hidden
  77222. */
  77223. export class IntersectionInfo {
  77224. bu: Nullable<number>;
  77225. bv: Nullable<number>;
  77226. distance: number;
  77227. faceId: number;
  77228. subMeshId: number;
  77229. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  77230. }
  77231. }
  77232. declare module BABYLON {
  77233. /**
  77234. * Represens a plane by the equation ax + by + cz + d = 0
  77235. */
  77236. export class Plane {
  77237. private static _TmpMatrix;
  77238. /**
  77239. * Normal of the plane (a,b,c)
  77240. */
  77241. normal: Vector3;
  77242. /**
  77243. * d component of the plane
  77244. */
  77245. d: number;
  77246. /**
  77247. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  77248. * @param a a component of the plane
  77249. * @param b b component of the plane
  77250. * @param c c component of the plane
  77251. * @param d d component of the plane
  77252. */
  77253. constructor(a: number, b: number, c: number, d: number);
  77254. /**
  77255. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  77256. */
  77257. asArray(): number[];
  77258. /**
  77259. * @returns a new plane copied from the current Plane.
  77260. */
  77261. clone(): Plane;
  77262. /**
  77263. * @returns the string "Plane".
  77264. */
  77265. getClassName(): string;
  77266. /**
  77267. * @returns the Plane hash code.
  77268. */
  77269. getHashCode(): number;
  77270. /**
  77271. * Normalize the current Plane in place.
  77272. * @returns the updated Plane.
  77273. */
  77274. normalize(): Plane;
  77275. /**
  77276. * Applies a transformation the plane and returns the result
  77277. * @param transformation the transformation matrix to be applied to the plane
  77278. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  77279. */
  77280. transform(transformation: DeepImmutable<Matrix>): Plane;
  77281. /**
  77282. * Calcualtte the dot product between the point and the plane normal
  77283. * @param point point to calculate the dot product with
  77284. * @returns the dot product (float) of the point coordinates and the plane normal.
  77285. */
  77286. dotCoordinate(point: DeepImmutable<Vector3>): number;
  77287. /**
  77288. * Updates the current Plane from the plane defined by the three given points.
  77289. * @param point1 one of the points used to contruct the plane
  77290. * @param point2 one of the points used to contruct the plane
  77291. * @param point3 one of the points used to contruct the plane
  77292. * @returns the updated Plane.
  77293. */
  77294. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  77295. /**
  77296. * Checks if the plane is facing a given direction
  77297. * @param direction the direction to check if the plane is facing
  77298. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  77299. * @returns True is the vector "direction" is the same side than the plane normal.
  77300. */
  77301. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  77302. /**
  77303. * Calculates the distance to a point
  77304. * @param point point to calculate distance to
  77305. * @returns the signed distance (float) from the given point to the Plane.
  77306. */
  77307. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  77308. /**
  77309. * Creates a plane from an array
  77310. * @param array the array to create a plane from
  77311. * @returns a new Plane from the given array.
  77312. */
  77313. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  77314. /**
  77315. * Creates a plane from three points
  77316. * @param point1 point used to create the plane
  77317. * @param point2 point used to create the plane
  77318. * @param point3 point used to create the plane
  77319. * @returns a new Plane defined by the three given points.
  77320. */
  77321. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  77322. /**
  77323. * Creates a plane from an origin point and a normal
  77324. * @param origin origin of the plane to be constructed
  77325. * @param normal normal of the plane to be constructed
  77326. * @returns a new Plane the normal vector to this plane at the given origin point.
  77327. * Note : the vector "normal" is updated because normalized.
  77328. */
  77329. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  77330. /**
  77331. * Calculates the distance from a plane and a point
  77332. * @param origin origin of the plane to be constructed
  77333. * @param normal normal of the plane to be constructed
  77334. * @param point point to calculate distance to
  77335. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  77336. */
  77337. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  77338. }
  77339. }
  77340. declare module BABYLON {
  77341. /**
  77342. * Class used to store bounding sphere information
  77343. */
  77344. export class BoundingSphere {
  77345. /**
  77346. * Gets the center of the bounding sphere in local space
  77347. */
  77348. readonly center: Vector3;
  77349. /**
  77350. * Radius of the bounding sphere in local space
  77351. */
  77352. radius: number;
  77353. /**
  77354. * Gets the center of the bounding sphere in world space
  77355. */
  77356. readonly centerWorld: Vector3;
  77357. /**
  77358. * Radius of the bounding sphere in world space
  77359. */
  77360. radiusWorld: number;
  77361. /**
  77362. * Gets the minimum vector in local space
  77363. */
  77364. readonly minimum: Vector3;
  77365. /**
  77366. * Gets the maximum vector in local space
  77367. */
  77368. readonly maximum: Vector3;
  77369. private _worldMatrix;
  77370. private static readonly TmpVector3;
  77371. /**
  77372. * Creates a new bounding sphere
  77373. * @param min defines the minimum vector (in local space)
  77374. * @param max defines the maximum vector (in local space)
  77375. * @param worldMatrix defines the new world matrix
  77376. */
  77377. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  77378. /**
  77379. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  77380. * @param min defines the new minimum vector (in local space)
  77381. * @param max defines the new maximum vector (in local space)
  77382. * @param worldMatrix defines the new world matrix
  77383. */
  77384. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  77385. /**
  77386. * Scale the current bounding sphere by applying a scale factor
  77387. * @param factor defines the scale factor to apply
  77388. * @returns the current bounding box
  77389. */
  77390. scale(factor: number): BoundingSphere;
  77391. /**
  77392. * Gets the world matrix of the bounding box
  77393. * @returns a matrix
  77394. */
  77395. getWorldMatrix(): DeepImmutable<Matrix>;
  77396. /** @hidden */
  77397. _update(worldMatrix: DeepImmutable<Matrix>): void;
  77398. /**
  77399. * Tests if the bounding sphere is intersecting the frustum planes
  77400. * @param frustumPlanes defines the frustum planes to test
  77401. * @returns true if there is an intersection
  77402. */
  77403. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77404. /**
  77405. * Tests if the bounding sphere center is in between the frustum planes.
  77406. * Used for optimistic fast inclusion.
  77407. * @param frustumPlanes defines the frustum planes to test
  77408. * @returns true if the sphere center is in between the frustum planes
  77409. */
  77410. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77411. /**
  77412. * Tests if a point is inside the bounding sphere
  77413. * @param point defines the point to test
  77414. * @returns true if the point is inside the bounding sphere
  77415. */
  77416. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  77417. /**
  77418. * Checks if two sphere intersct
  77419. * @param sphere0 sphere 0
  77420. * @param sphere1 sphere 1
  77421. * @returns true if the speres intersect
  77422. */
  77423. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  77424. }
  77425. }
  77426. declare module BABYLON {
  77427. /**
  77428. * Class used to store bounding box information
  77429. */
  77430. export class BoundingBox implements ICullable {
  77431. /**
  77432. * Gets the 8 vectors representing the bounding box in local space
  77433. */
  77434. readonly vectors: Vector3[];
  77435. /**
  77436. * Gets the center of the bounding box in local space
  77437. */
  77438. readonly center: Vector3;
  77439. /**
  77440. * Gets the center of the bounding box in world space
  77441. */
  77442. readonly centerWorld: Vector3;
  77443. /**
  77444. * Gets the extend size in local space
  77445. */
  77446. readonly extendSize: Vector3;
  77447. /**
  77448. * Gets the extend size in world space
  77449. */
  77450. readonly extendSizeWorld: Vector3;
  77451. /**
  77452. * Gets the OBB (object bounding box) directions
  77453. */
  77454. readonly directions: Vector3[];
  77455. /**
  77456. * Gets the 8 vectors representing the bounding box in world space
  77457. */
  77458. readonly vectorsWorld: Vector3[];
  77459. /**
  77460. * Gets the minimum vector in world space
  77461. */
  77462. readonly minimumWorld: Vector3;
  77463. /**
  77464. * Gets the maximum vector in world space
  77465. */
  77466. readonly maximumWorld: Vector3;
  77467. /**
  77468. * Gets the minimum vector in local space
  77469. */
  77470. readonly minimum: Vector3;
  77471. /**
  77472. * Gets the maximum vector in local space
  77473. */
  77474. readonly maximum: Vector3;
  77475. private _worldMatrix;
  77476. private static readonly TmpVector3;
  77477. /**
  77478. * @hidden
  77479. */
  77480. _tag: number;
  77481. /**
  77482. * Creates a new bounding box
  77483. * @param min defines the minimum vector (in local space)
  77484. * @param max defines the maximum vector (in local space)
  77485. * @param worldMatrix defines the new world matrix
  77486. */
  77487. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  77488. /**
  77489. * Recreates the entire bounding box from scratch as if we call the constructor in place
  77490. * @param min defines the new minimum vector (in local space)
  77491. * @param max defines the new maximum vector (in local space)
  77492. * @param worldMatrix defines the new world matrix
  77493. */
  77494. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  77495. /**
  77496. * Scale the current bounding box by applying a scale factor
  77497. * @param factor defines the scale factor to apply
  77498. * @returns the current bounding box
  77499. */
  77500. scale(factor: number): BoundingBox;
  77501. /**
  77502. * Gets the world matrix of the bounding box
  77503. * @returns a matrix
  77504. */
  77505. getWorldMatrix(): DeepImmutable<Matrix>;
  77506. /** @hidden */
  77507. _update(world: DeepImmutable<Matrix>): void;
  77508. /**
  77509. * Tests if the bounding box is intersecting the frustum planes
  77510. * @param frustumPlanes defines the frustum planes to test
  77511. * @returns true if there is an intersection
  77512. */
  77513. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77514. /**
  77515. * Tests if the bounding box is entirely inside the frustum planes
  77516. * @param frustumPlanes defines the frustum planes to test
  77517. * @returns true if there is an inclusion
  77518. */
  77519. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77520. /**
  77521. * Tests if a point is inside the bounding box
  77522. * @param point defines the point to test
  77523. * @returns true if the point is inside the bounding box
  77524. */
  77525. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  77526. /**
  77527. * Tests if the bounding box intersects with a bounding sphere
  77528. * @param sphere defines the sphere to test
  77529. * @returns true if there is an intersection
  77530. */
  77531. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  77532. /**
  77533. * Tests if the bounding box intersects with a box defined by a min and max vectors
  77534. * @param min defines the min vector to use
  77535. * @param max defines the max vector to use
  77536. * @returns true if there is an intersection
  77537. */
  77538. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  77539. /**
  77540. * Tests if two bounding boxes are intersections
  77541. * @param box0 defines the first box to test
  77542. * @param box1 defines the second box to test
  77543. * @returns true if there is an intersection
  77544. */
  77545. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  77546. /**
  77547. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  77548. * @param minPoint defines the minimum vector of the bounding box
  77549. * @param maxPoint defines the maximum vector of the bounding box
  77550. * @param sphereCenter defines the sphere center
  77551. * @param sphereRadius defines the sphere radius
  77552. * @returns true if there is an intersection
  77553. */
  77554. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  77555. /**
  77556. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  77557. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  77558. * @param frustumPlanes defines the frustum planes to test
  77559. * @return true if there is an inclusion
  77560. */
  77561. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77562. /**
  77563. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  77564. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  77565. * @param frustumPlanes defines the frustum planes to test
  77566. * @return true if there is an intersection
  77567. */
  77568. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77569. }
  77570. }
  77571. declare module BABYLON {
  77572. /** @hidden */
  77573. export class Collider {
  77574. /** Define if a collision was found */
  77575. collisionFound: boolean;
  77576. /**
  77577. * Define last intersection point in local space
  77578. */
  77579. intersectionPoint: Vector3;
  77580. /**
  77581. * Define last collided mesh
  77582. */
  77583. collidedMesh: Nullable<AbstractMesh>;
  77584. private _collisionPoint;
  77585. private _planeIntersectionPoint;
  77586. private _tempVector;
  77587. private _tempVector2;
  77588. private _tempVector3;
  77589. private _tempVector4;
  77590. private _edge;
  77591. private _baseToVertex;
  77592. private _destinationPoint;
  77593. private _slidePlaneNormal;
  77594. private _displacementVector;
  77595. /** @hidden */
  77596. _radius: Vector3;
  77597. /** @hidden */
  77598. _retry: number;
  77599. private _velocity;
  77600. private _basePoint;
  77601. private _epsilon;
  77602. /** @hidden */
  77603. _velocityWorldLength: number;
  77604. /** @hidden */
  77605. _basePointWorld: Vector3;
  77606. private _velocityWorld;
  77607. private _normalizedVelocity;
  77608. /** @hidden */
  77609. _initialVelocity: Vector3;
  77610. /** @hidden */
  77611. _initialPosition: Vector3;
  77612. private _nearestDistance;
  77613. private _collisionMask;
  77614. get collisionMask(): number;
  77615. set collisionMask(mask: number);
  77616. /**
  77617. * Gets the plane normal used to compute the sliding response (in local space)
  77618. */
  77619. get slidePlaneNormal(): Vector3;
  77620. /** @hidden */
  77621. _initialize(source: Vector3, dir: Vector3, e: number): void;
  77622. /** @hidden */
  77623. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  77624. /** @hidden */
  77625. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  77626. /** @hidden */
  77627. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  77628. /** @hidden */
  77629. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  77630. /** @hidden */
  77631. _getResponse(pos: Vector3, vel: Vector3): void;
  77632. }
  77633. }
  77634. declare module BABYLON {
  77635. /**
  77636. * Interface for cullable objects
  77637. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  77638. */
  77639. export interface ICullable {
  77640. /**
  77641. * Checks if the object or part of the object is in the frustum
  77642. * @param frustumPlanes Camera near/planes
  77643. * @returns true if the object is in frustum otherwise false
  77644. */
  77645. isInFrustum(frustumPlanes: Plane[]): boolean;
  77646. /**
  77647. * Checks if a cullable object (mesh...) is in the camera frustum
  77648. * Unlike isInFrustum this cheks the full bounding box
  77649. * @param frustumPlanes Camera near/planes
  77650. * @returns true if the object is in frustum otherwise false
  77651. */
  77652. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  77653. }
  77654. /**
  77655. * Info for a bounding data of a mesh
  77656. */
  77657. export class BoundingInfo implements ICullable {
  77658. /**
  77659. * Bounding box for the mesh
  77660. */
  77661. readonly boundingBox: BoundingBox;
  77662. /**
  77663. * Bounding sphere for the mesh
  77664. */
  77665. readonly boundingSphere: BoundingSphere;
  77666. private _isLocked;
  77667. private static readonly TmpVector3;
  77668. /**
  77669. * Constructs bounding info
  77670. * @param minimum min vector of the bounding box/sphere
  77671. * @param maximum max vector of the bounding box/sphere
  77672. * @param worldMatrix defines the new world matrix
  77673. */
  77674. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  77675. /**
  77676. * Recreates the entire bounding info from scratch as if we call the constructor in place
  77677. * @param min defines the new minimum vector (in local space)
  77678. * @param max defines the new maximum vector (in local space)
  77679. * @param worldMatrix defines the new world matrix
  77680. */
  77681. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  77682. /**
  77683. * min vector of the bounding box/sphere
  77684. */
  77685. get minimum(): Vector3;
  77686. /**
  77687. * max vector of the bounding box/sphere
  77688. */
  77689. get maximum(): Vector3;
  77690. /**
  77691. * If the info is locked and won't be updated to avoid perf overhead
  77692. */
  77693. get isLocked(): boolean;
  77694. set isLocked(value: boolean);
  77695. /**
  77696. * Updates the bounding sphere and box
  77697. * @param world world matrix to be used to update
  77698. */
  77699. update(world: DeepImmutable<Matrix>): void;
  77700. /**
  77701. * Recreate the bounding info to be centered around a specific point given a specific extend.
  77702. * @param center New center of the bounding info
  77703. * @param extend New extend of the bounding info
  77704. * @returns the current bounding info
  77705. */
  77706. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  77707. /**
  77708. * Scale the current bounding info by applying a scale factor
  77709. * @param factor defines the scale factor to apply
  77710. * @returns the current bounding info
  77711. */
  77712. scale(factor: number): BoundingInfo;
  77713. /**
  77714. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  77715. * @param frustumPlanes defines the frustum to test
  77716. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  77717. * @returns true if the bounding info is in the frustum planes
  77718. */
  77719. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  77720. /**
  77721. * Gets the world distance between the min and max points of the bounding box
  77722. */
  77723. get diagonalLength(): number;
  77724. /**
  77725. * Checks if a cullable object (mesh...) is in the camera frustum
  77726. * Unlike isInFrustum this cheks the full bounding box
  77727. * @param frustumPlanes Camera near/planes
  77728. * @returns true if the object is in frustum otherwise false
  77729. */
  77730. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77731. /** @hidden */
  77732. _checkCollision(collider: Collider): boolean;
  77733. /**
  77734. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  77735. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  77736. * @param point the point to check intersection with
  77737. * @returns if the point intersects
  77738. */
  77739. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  77740. /**
  77741. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  77742. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  77743. * @param boundingInfo the bounding info to check intersection with
  77744. * @param precise if the intersection should be done using OBB
  77745. * @returns if the bounding info intersects
  77746. */
  77747. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  77748. }
  77749. }
  77750. declare module BABYLON {
  77751. /**
  77752. * Extracts minimum and maximum values from a list of indexed positions
  77753. * @param positions defines the positions to use
  77754. * @param indices defines the indices to the positions
  77755. * @param indexStart defines the start index
  77756. * @param indexCount defines the end index
  77757. * @param bias defines bias value to add to the result
  77758. * @return minimum and maximum values
  77759. */
  77760. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  77761. minimum: Vector3;
  77762. maximum: Vector3;
  77763. };
  77764. /**
  77765. * Extracts minimum and maximum values from a list of positions
  77766. * @param positions defines the positions to use
  77767. * @param start defines the start index in the positions array
  77768. * @param count defines the number of positions to handle
  77769. * @param bias defines bias value to add to the result
  77770. * @param stride defines the stride size to use (distance between two positions in the positions array)
  77771. * @return minimum and maximum values
  77772. */
  77773. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  77774. minimum: Vector3;
  77775. maximum: Vector3;
  77776. };
  77777. }
  77778. declare module BABYLON {
  77779. /** @hidden */
  77780. export class WebGLDataBuffer extends DataBuffer {
  77781. private _buffer;
  77782. constructor(resource: WebGLBuffer);
  77783. get underlyingResource(): any;
  77784. }
  77785. }
  77786. declare module BABYLON {
  77787. /** @hidden */
  77788. export class WebGLPipelineContext implements IPipelineContext {
  77789. engine: ThinEngine;
  77790. program: Nullable<WebGLProgram>;
  77791. context?: WebGLRenderingContext;
  77792. vertexShader?: WebGLShader;
  77793. fragmentShader?: WebGLShader;
  77794. isParallelCompiled: boolean;
  77795. onCompiled?: () => void;
  77796. transformFeedback?: WebGLTransformFeedback | null;
  77797. vertexCompilationError: Nullable<string>;
  77798. fragmentCompilationError: Nullable<string>;
  77799. programLinkError: Nullable<string>;
  77800. programValidationError: Nullable<string>;
  77801. get isAsync(): boolean;
  77802. get isReady(): boolean;
  77803. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  77804. }
  77805. }
  77806. declare module BABYLON {
  77807. interface ThinEngine {
  77808. /**
  77809. * Create an uniform buffer
  77810. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  77811. * @param elements defines the content of the uniform buffer
  77812. * @returns the webGL uniform buffer
  77813. */
  77814. createUniformBuffer(elements: FloatArray): DataBuffer;
  77815. /**
  77816. * Create a dynamic uniform buffer
  77817. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  77818. * @param elements defines the content of the uniform buffer
  77819. * @returns the webGL uniform buffer
  77820. */
  77821. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  77822. /**
  77823. * Update an existing uniform buffer
  77824. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  77825. * @param uniformBuffer defines the target uniform buffer
  77826. * @param elements defines the content to update
  77827. * @param offset defines the offset in the uniform buffer where update should start
  77828. * @param count defines the size of the data to update
  77829. */
  77830. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  77831. /**
  77832. * Bind an uniform buffer to the current webGL context
  77833. * @param buffer defines the buffer to bind
  77834. */
  77835. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  77836. /**
  77837. * Bind a buffer to the current webGL context at a given location
  77838. * @param buffer defines the buffer to bind
  77839. * @param location defines the index where to bind the buffer
  77840. */
  77841. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  77842. /**
  77843. * Bind a specific block at a given index in a specific shader program
  77844. * @param pipelineContext defines the pipeline context to use
  77845. * @param blockName defines the block name
  77846. * @param index defines the index where to bind the block
  77847. */
  77848. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  77849. }
  77850. }
  77851. declare module BABYLON {
  77852. /**
  77853. * Uniform buffer objects.
  77854. *
  77855. * Handles blocks of uniform on the GPU.
  77856. *
  77857. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  77858. *
  77859. * For more information, please refer to :
  77860. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  77861. */
  77862. export class UniformBuffer {
  77863. private _engine;
  77864. private _buffer;
  77865. private _data;
  77866. private _bufferData;
  77867. private _dynamic?;
  77868. private _uniformLocations;
  77869. private _uniformSizes;
  77870. private _uniformLocationPointer;
  77871. private _needSync;
  77872. private _noUBO;
  77873. private _currentEffect;
  77874. /** @hidden */
  77875. _alreadyBound: boolean;
  77876. private static _MAX_UNIFORM_SIZE;
  77877. private static _tempBuffer;
  77878. /**
  77879. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  77880. * This is dynamic to allow compat with webgl 1 and 2.
  77881. * You will need to pass the name of the uniform as well as the value.
  77882. */
  77883. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  77884. /**
  77885. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  77886. * This is dynamic to allow compat with webgl 1 and 2.
  77887. * You will need to pass the name of the uniform as well as the value.
  77888. */
  77889. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  77890. /**
  77891. * Lambda to Update a single float in a uniform buffer.
  77892. * This is dynamic to allow compat with webgl 1 and 2.
  77893. * You will need to pass the name of the uniform as well as the value.
  77894. */
  77895. updateFloat: (name: string, x: number) => void;
  77896. /**
  77897. * Lambda to Update a vec2 of float in a uniform buffer.
  77898. * This is dynamic to allow compat with webgl 1 and 2.
  77899. * You will need to pass the name of the uniform as well as the value.
  77900. */
  77901. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  77902. /**
  77903. * Lambda to Update a vec3 of float in a uniform buffer.
  77904. * This is dynamic to allow compat with webgl 1 and 2.
  77905. * You will need to pass the name of the uniform as well as the value.
  77906. */
  77907. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  77908. /**
  77909. * Lambda to Update a vec4 of float in a uniform buffer.
  77910. * This is dynamic to allow compat with webgl 1 and 2.
  77911. * You will need to pass the name of the uniform as well as the value.
  77912. */
  77913. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  77914. /**
  77915. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  77916. * This is dynamic to allow compat with webgl 1 and 2.
  77917. * You will need to pass the name of the uniform as well as the value.
  77918. */
  77919. updateMatrix: (name: string, mat: Matrix) => void;
  77920. /**
  77921. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  77922. * This is dynamic to allow compat with webgl 1 and 2.
  77923. * You will need to pass the name of the uniform as well as the value.
  77924. */
  77925. updateVector3: (name: string, vector: Vector3) => void;
  77926. /**
  77927. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  77928. * This is dynamic to allow compat with webgl 1 and 2.
  77929. * You will need to pass the name of the uniform as well as the value.
  77930. */
  77931. updateVector4: (name: string, vector: Vector4) => void;
  77932. /**
  77933. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  77934. * This is dynamic to allow compat with webgl 1 and 2.
  77935. * You will need to pass the name of the uniform as well as the value.
  77936. */
  77937. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  77938. /**
  77939. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  77940. * This is dynamic to allow compat with webgl 1 and 2.
  77941. * You will need to pass the name of the uniform as well as the value.
  77942. */
  77943. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  77944. /**
  77945. * Instantiates a new Uniform buffer objects.
  77946. *
  77947. * Handles blocks of uniform on the GPU.
  77948. *
  77949. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  77950. *
  77951. * For more information, please refer to :
  77952. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  77953. * @param engine Define the engine the buffer is associated with
  77954. * @param data Define the data contained in the buffer
  77955. * @param dynamic Define if the buffer is updatable
  77956. */
  77957. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  77958. /**
  77959. * Indicates if the buffer is using the WebGL2 UBO implementation,
  77960. * or just falling back on setUniformXXX calls.
  77961. */
  77962. get useUbo(): boolean;
  77963. /**
  77964. * Indicates if the WebGL underlying uniform buffer is in sync
  77965. * with the javascript cache data.
  77966. */
  77967. get isSync(): boolean;
  77968. /**
  77969. * Indicates if the WebGL underlying uniform buffer is dynamic.
  77970. * Also, a dynamic UniformBuffer will disable cache verification and always
  77971. * update the underlying WebGL uniform buffer to the GPU.
  77972. * @returns if Dynamic, otherwise false
  77973. */
  77974. isDynamic(): boolean;
  77975. /**
  77976. * The data cache on JS side.
  77977. * @returns the underlying data as a float array
  77978. */
  77979. getData(): Float32Array;
  77980. /**
  77981. * The underlying WebGL Uniform buffer.
  77982. * @returns the webgl buffer
  77983. */
  77984. getBuffer(): Nullable<DataBuffer>;
  77985. /**
  77986. * std140 layout specifies how to align data within an UBO structure.
  77987. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  77988. * for specs.
  77989. */
  77990. private _fillAlignment;
  77991. /**
  77992. * Adds an uniform in the buffer.
  77993. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  77994. * for the layout to be correct !
  77995. * @param name Name of the uniform, as used in the uniform block in the shader.
  77996. * @param size Data size, or data directly.
  77997. */
  77998. addUniform(name: string, size: number | number[]): void;
  77999. /**
  78000. * Adds a Matrix 4x4 to the uniform buffer.
  78001. * @param name Name of the uniform, as used in the uniform block in the shader.
  78002. * @param mat A 4x4 matrix.
  78003. */
  78004. addMatrix(name: string, mat: Matrix): void;
  78005. /**
  78006. * Adds a vec2 to the uniform buffer.
  78007. * @param name Name of the uniform, as used in the uniform block in the shader.
  78008. * @param x Define the x component value of the vec2
  78009. * @param y Define the y component value of the vec2
  78010. */
  78011. addFloat2(name: string, x: number, y: number): void;
  78012. /**
  78013. * Adds a vec3 to the uniform buffer.
  78014. * @param name Name of the uniform, as used in the uniform block in the shader.
  78015. * @param x Define the x component value of the vec3
  78016. * @param y Define the y component value of the vec3
  78017. * @param z Define the z component value of the vec3
  78018. */
  78019. addFloat3(name: string, x: number, y: number, z: number): void;
  78020. /**
  78021. * Adds a vec3 to the uniform buffer.
  78022. * @param name Name of the uniform, as used in the uniform block in the shader.
  78023. * @param color Define the vec3 from a Color
  78024. */
  78025. addColor3(name: string, color: Color3): void;
  78026. /**
  78027. * Adds a vec4 to the uniform buffer.
  78028. * @param name Name of the uniform, as used in the uniform block in the shader.
  78029. * @param color Define the rgb components from a Color
  78030. * @param alpha Define the a component of the vec4
  78031. */
  78032. addColor4(name: string, color: Color3, alpha: number): void;
  78033. /**
  78034. * Adds a vec3 to the uniform buffer.
  78035. * @param name Name of the uniform, as used in the uniform block in the shader.
  78036. * @param vector Define the vec3 components from a Vector
  78037. */
  78038. addVector3(name: string, vector: Vector3): void;
  78039. /**
  78040. * Adds a Matrix 3x3 to the uniform buffer.
  78041. * @param name Name of the uniform, as used in the uniform block in the shader.
  78042. */
  78043. addMatrix3x3(name: string): void;
  78044. /**
  78045. * Adds a Matrix 2x2 to the uniform buffer.
  78046. * @param name Name of the uniform, as used in the uniform block in the shader.
  78047. */
  78048. addMatrix2x2(name: string): void;
  78049. /**
  78050. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  78051. */
  78052. create(): void;
  78053. /** @hidden */
  78054. _rebuild(): void;
  78055. /**
  78056. * Updates the WebGL Uniform Buffer on the GPU.
  78057. * If the `dynamic` flag is set to true, no cache comparison is done.
  78058. * Otherwise, the buffer will be updated only if the cache differs.
  78059. */
  78060. update(): void;
  78061. /**
  78062. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  78063. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  78064. * @param data Define the flattened data
  78065. * @param size Define the size of the data.
  78066. */
  78067. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  78068. private _valueCache;
  78069. private _cacheMatrix;
  78070. private _updateMatrix3x3ForUniform;
  78071. private _updateMatrix3x3ForEffect;
  78072. private _updateMatrix2x2ForEffect;
  78073. private _updateMatrix2x2ForUniform;
  78074. private _updateFloatForEffect;
  78075. private _updateFloatForUniform;
  78076. private _updateFloat2ForEffect;
  78077. private _updateFloat2ForUniform;
  78078. private _updateFloat3ForEffect;
  78079. private _updateFloat3ForUniform;
  78080. private _updateFloat4ForEffect;
  78081. private _updateFloat4ForUniform;
  78082. private _updateMatrixForEffect;
  78083. private _updateMatrixForUniform;
  78084. private _updateVector3ForEffect;
  78085. private _updateVector3ForUniform;
  78086. private _updateVector4ForEffect;
  78087. private _updateVector4ForUniform;
  78088. private _updateColor3ForEffect;
  78089. private _updateColor3ForUniform;
  78090. private _updateColor4ForEffect;
  78091. private _updateColor4ForUniform;
  78092. /**
  78093. * Sets a sampler uniform on the effect.
  78094. * @param name Define the name of the sampler.
  78095. * @param texture Define the texture to set in the sampler
  78096. */
  78097. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  78098. /**
  78099. * Directly updates the value of the uniform in the cache AND on the GPU.
  78100. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  78101. * @param data Define the flattened data
  78102. */
  78103. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  78104. /**
  78105. * Binds this uniform buffer to an effect.
  78106. * @param effect Define the effect to bind the buffer to
  78107. * @param name Name of the uniform block in the shader.
  78108. */
  78109. bindToEffect(effect: Effect, name: string): void;
  78110. /**
  78111. * Disposes the uniform buffer.
  78112. */
  78113. dispose(): void;
  78114. }
  78115. }
  78116. declare module BABYLON {
  78117. /**
  78118. * Enum that determines the text-wrapping mode to use.
  78119. */
  78120. export enum InspectableType {
  78121. /**
  78122. * Checkbox for booleans
  78123. */
  78124. Checkbox = 0,
  78125. /**
  78126. * Sliders for numbers
  78127. */
  78128. Slider = 1,
  78129. /**
  78130. * Vector3
  78131. */
  78132. Vector3 = 2,
  78133. /**
  78134. * Quaternions
  78135. */
  78136. Quaternion = 3,
  78137. /**
  78138. * Color3
  78139. */
  78140. Color3 = 4,
  78141. /**
  78142. * String
  78143. */
  78144. String = 5
  78145. }
  78146. /**
  78147. * Interface used to define custom inspectable properties.
  78148. * This interface is used by the inspector to display custom property grids
  78149. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78150. */
  78151. export interface IInspectable {
  78152. /**
  78153. * Gets the label to display
  78154. */
  78155. label: string;
  78156. /**
  78157. * Gets the name of the property to edit
  78158. */
  78159. propertyName: string;
  78160. /**
  78161. * Gets the type of the editor to use
  78162. */
  78163. type: InspectableType;
  78164. /**
  78165. * Gets the minimum value of the property when using in "slider" mode
  78166. */
  78167. min?: number;
  78168. /**
  78169. * Gets the maximum value of the property when using in "slider" mode
  78170. */
  78171. max?: number;
  78172. /**
  78173. * Gets the setp to use when using in "slider" mode
  78174. */
  78175. step?: number;
  78176. }
  78177. }
  78178. declare module BABYLON {
  78179. /**
  78180. * Class used to provide helper for timing
  78181. */
  78182. export class TimingTools {
  78183. /**
  78184. * Polyfill for setImmediate
  78185. * @param action defines the action to execute after the current execution block
  78186. */
  78187. static SetImmediate(action: () => void): void;
  78188. }
  78189. }
  78190. declare module BABYLON {
  78191. /**
  78192. * Class used to enable instatition of objects by class name
  78193. */
  78194. export class InstantiationTools {
  78195. /**
  78196. * Use this object to register external classes like custom textures or material
  78197. * to allow the laoders to instantiate them
  78198. */
  78199. static RegisteredExternalClasses: {
  78200. [key: string]: Object;
  78201. };
  78202. /**
  78203. * Tries to instantiate a new object from a given class name
  78204. * @param className defines the class name to instantiate
  78205. * @returns the new object or null if the system was not able to do the instantiation
  78206. */
  78207. static Instantiate(className: string): any;
  78208. }
  78209. }
  78210. declare module BABYLON {
  78211. /**
  78212. * Define options used to create a depth texture
  78213. */
  78214. export class DepthTextureCreationOptions {
  78215. /** Specifies whether or not a stencil should be allocated in the texture */
  78216. generateStencil?: boolean;
  78217. /** Specifies whether or not bilinear filtering is enable on the texture */
  78218. bilinearFiltering?: boolean;
  78219. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  78220. comparisonFunction?: number;
  78221. /** Specifies if the created texture is a cube texture */
  78222. isCube?: boolean;
  78223. }
  78224. }
  78225. declare module BABYLON {
  78226. interface ThinEngine {
  78227. /**
  78228. * Creates a depth stencil cube texture.
  78229. * This is only available in WebGL 2.
  78230. * @param size The size of face edge in the cube texture.
  78231. * @param options The options defining the cube texture.
  78232. * @returns The cube texture
  78233. */
  78234. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  78235. /**
  78236. * Creates a cube texture
  78237. * @param rootUrl defines the url where the files to load is located
  78238. * @param scene defines the current scene
  78239. * @param files defines the list of files to load (1 per face)
  78240. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  78241. * @param onLoad defines an optional callback raised when the texture is loaded
  78242. * @param onError defines an optional callback raised if there is an issue to load the texture
  78243. * @param format defines the format of the data
  78244. * @param forcedExtension defines the extension to use to pick the right loader
  78245. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  78246. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  78247. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  78248. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  78249. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  78250. * @returns the cube texture as an InternalTexture
  78251. */
  78252. 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;
  78253. /**
  78254. * Creates a cube texture
  78255. * @param rootUrl defines the url where the files to load is located
  78256. * @param scene defines the current scene
  78257. * @param files defines the list of files to load (1 per face)
  78258. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  78259. * @param onLoad defines an optional callback raised when the texture is loaded
  78260. * @param onError defines an optional callback raised if there is an issue to load the texture
  78261. * @param format defines the format of the data
  78262. * @param forcedExtension defines the extension to use to pick the right loader
  78263. * @returns the cube texture as an InternalTexture
  78264. */
  78265. 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;
  78266. /**
  78267. * Creates a cube texture
  78268. * @param rootUrl defines the url where the files to load is located
  78269. * @param scene defines the current scene
  78270. * @param files defines the list of files to load (1 per face)
  78271. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  78272. * @param onLoad defines an optional callback raised when the texture is loaded
  78273. * @param onError defines an optional callback raised if there is an issue to load the texture
  78274. * @param format defines the format of the data
  78275. * @param forcedExtension defines the extension to use to pick the right loader
  78276. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  78277. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  78278. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  78279. * @returns the cube texture as an InternalTexture
  78280. */
  78281. 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;
  78282. /** @hidden */
  78283. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  78284. /** @hidden */
  78285. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  78286. /** @hidden */
  78287. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  78288. /** @hidden */
  78289. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  78290. /**
  78291. * @hidden
  78292. */
  78293. _setCubeMapTextureParams(loadMipmap: boolean): void;
  78294. }
  78295. }
  78296. declare module BABYLON {
  78297. /**
  78298. * Class for creating a cube texture
  78299. */
  78300. export class CubeTexture extends BaseTexture {
  78301. private _delayedOnLoad;
  78302. /**
  78303. * The url of the texture
  78304. */
  78305. url: string;
  78306. /**
  78307. * Gets or sets the center of the bounding box associated with the cube texture.
  78308. * It must define where the camera used to render the texture was set
  78309. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  78310. */
  78311. boundingBoxPosition: Vector3;
  78312. private _boundingBoxSize;
  78313. /**
  78314. * Gets or sets the size of the bounding box associated with the cube texture
  78315. * When defined, the cubemap will switch to local mode
  78316. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  78317. * @example https://www.babylonjs-playground.com/#RNASML
  78318. */
  78319. set boundingBoxSize(value: Vector3);
  78320. /**
  78321. * Returns the bounding box size
  78322. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  78323. */
  78324. get boundingBoxSize(): Vector3;
  78325. protected _rotationY: number;
  78326. /**
  78327. * Sets texture matrix rotation angle around Y axis in radians.
  78328. */
  78329. set rotationY(value: number);
  78330. /**
  78331. * Gets texture matrix rotation angle around Y axis radians.
  78332. */
  78333. get rotationY(): number;
  78334. /**
  78335. * Are mip maps generated for this texture or not.
  78336. */
  78337. get noMipmap(): boolean;
  78338. private _noMipmap;
  78339. private _files;
  78340. protected _forcedExtension: Nullable<string>;
  78341. private _extensions;
  78342. private _textureMatrix;
  78343. private _format;
  78344. private _createPolynomials;
  78345. /** @hidden */
  78346. _prefiltered: boolean;
  78347. /**
  78348. * Creates a cube texture from an array of image urls
  78349. * @param files defines an array of image urls
  78350. * @param scene defines the hosting scene
  78351. * @param noMipmap specifies if mip maps are not used
  78352. * @returns a cube texture
  78353. */
  78354. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  78355. /**
  78356. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  78357. * @param url defines the url of the prefiltered texture
  78358. * @param scene defines the scene the texture is attached to
  78359. * @param forcedExtension defines the extension of the file if different from the url
  78360. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  78361. * @return the prefiltered texture
  78362. */
  78363. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  78364. /**
  78365. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  78366. * as prefiltered data.
  78367. * @param rootUrl defines the url of the texture or the root name of the six images
  78368. * @param scene defines the scene the texture is attached to
  78369. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  78370. * @param noMipmap defines if mipmaps should be created or not
  78371. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  78372. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  78373. * @param onError defines a callback triggered in case of error during load
  78374. * @param format defines the internal format to use for the texture once loaded
  78375. * @param prefiltered defines whether or not the texture is created from prefiltered data
  78376. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  78377. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  78378. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  78379. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  78380. * @return the cube texture
  78381. */
  78382. 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);
  78383. /**
  78384. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  78385. */
  78386. get isPrefiltered(): boolean;
  78387. /**
  78388. * Get the current class name of the texture useful for serialization or dynamic coding.
  78389. * @returns "CubeTexture"
  78390. */
  78391. getClassName(): string;
  78392. /**
  78393. * Update the url (and optional buffer) of this texture if url was null during construction.
  78394. * @param url the url of the texture
  78395. * @param forcedExtension defines the extension to use
  78396. * @param onLoad callback called when the texture is loaded (defaults to null)
  78397. */
  78398. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  78399. /**
  78400. * Delays loading of the cube texture
  78401. * @param forcedExtension defines the extension to use
  78402. */
  78403. delayLoad(forcedExtension?: string): void;
  78404. /**
  78405. * Returns the reflection texture matrix
  78406. * @returns the reflection texture matrix
  78407. */
  78408. getReflectionTextureMatrix(): Matrix;
  78409. /**
  78410. * Sets the reflection texture matrix
  78411. * @param value Reflection texture matrix
  78412. */
  78413. setReflectionTextureMatrix(value: Matrix): void;
  78414. /**
  78415. * Parses text to create a cube texture
  78416. * @param parsedTexture define the serialized text to read from
  78417. * @param scene defines the hosting scene
  78418. * @param rootUrl defines the root url of the cube texture
  78419. * @returns a cube texture
  78420. */
  78421. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  78422. /**
  78423. * Makes a clone, or deep copy, of the cube texture
  78424. * @returns a new cube texture
  78425. */
  78426. clone(): CubeTexture;
  78427. }
  78428. }
  78429. declare module BABYLON {
  78430. /**
  78431. * Manages the defines for the Material
  78432. */
  78433. export class MaterialDefines {
  78434. /** @hidden */
  78435. protected _keys: string[];
  78436. private _isDirty;
  78437. /** @hidden */
  78438. _renderId: number;
  78439. /** @hidden */
  78440. _areLightsDirty: boolean;
  78441. /** @hidden */
  78442. _areLightsDisposed: boolean;
  78443. /** @hidden */
  78444. _areAttributesDirty: boolean;
  78445. /** @hidden */
  78446. _areTexturesDirty: boolean;
  78447. /** @hidden */
  78448. _areFresnelDirty: boolean;
  78449. /** @hidden */
  78450. _areMiscDirty: boolean;
  78451. /** @hidden */
  78452. _areImageProcessingDirty: boolean;
  78453. /** @hidden */
  78454. _normals: boolean;
  78455. /** @hidden */
  78456. _uvs: boolean;
  78457. /** @hidden */
  78458. _needNormals: boolean;
  78459. /** @hidden */
  78460. _needUVs: boolean;
  78461. [id: string]: any;
  78462. /**
  78463. * Specifies if the material needs to be re-calculated
  78464. */
  78465. get isDirty(): boolean;
  78466. /**
  78467. * Marks the material to indicate that it has been re-calculated
  78468. */
  78469. markAsProcessed(): void;
  78470. /**
  78471. * Marks the material to indicate that it needs to be re-calculated
  78472. */
  78473. markAsUnprocessed(): void;
  78474. /**
  78475. * Marks the material to indicate all of its defines need to be re-calculated
  78476. */
  78477. markAllAsDirty(): void;
  78478. /**
  78479. * Marks the material to indicate that image processing needs to be re-calculated
  78480. */
  78481. markAsImageProcessingDirty(): void;
  78482. /**
  78483. * Marks the material to indicate the lights need to be re-calculated
  78484. * @param disposed Defines whether the light is dirty due to dispose or not
  78485. */
  78486. markAsLightDirty(disposed?: boolean): void;
  78487. /**
  78488. * Marks the attribute state as changed
  78489. */
  78490. markAsAttributesDirty(): void;
  78491. /**
  78492. * Marks the texture state as changed
  78493. */
  78494. markAsTexturesDirty(): void;
  78495. /**
  78496. * Marks the fresnel state as changed
  78497. */
  78498. markAsFresnelDirty(): void;
  78499. /**
  78500. * Marks the misc state as changed
  78501. */
  78502. markAsMiscDirty(): void;
  78503. /**
  78504. * Rebuilds the material defines
  78505. */
  78506. rebuild(): void;
  78507. /**
  78508. * Specifies if two material defines are equal
  78509. * @param other - A material define instance to compare to
  78510. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  78511. */
  78512. isEqual(other: MaterialDefines): boolean;
  78513. /**
  78514. * Clones this instance's defines to another instance
  78515. * @param other - material defines to clone values to
  78516. */
  78517. cloneTo(other: MaterialDefines): void;
  78518. /**
  78519. * Resets the material define values
  78520. */
  78521. reset(): void;
  78522. /**
  78523. * Converts the material define values to a string
  78524. * @returns - String of material define information
  78525. */
  78526. toString(): string;
  78527. }
  78528. }
  78529. declare module BABYLON {
  78530. /**
  78531. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  78532. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  78533. * 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;
  78534. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  78535. */
  78536. export class ColorCurves {
  78537. private _dirty;
  78538. private _tempColor;
  78539. private _globalCurve;
  78540. private _highlightsCurve;
  78541. private _midtonesCurve;
  78542. private _shadowsCurve;
  78543. private _positiveCurve;
  78544. private _negativeCurve;
  78545. private _globalHue;
  78546. private _globalDensity;
  78547. private _globalSaturation;
  78548. private _globalExposure;
  78549. /**
  78550. * Gets the global Hue value.
  78551. * 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).
  78552. */
  78553. get globalHue(): number;
  78554. /**
  78555. * Sets the global Hue value.
  78556. * 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).
  78557. */
  78558. set globalHue(value: number);
  78559. /**
  78560. * Gets the global Density value.
  78561. * 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.
  78562. * Values less than zero provide a filter of opposite hue.
  78563. */
  78564. get globalDensity(): number;
  78565. /**
  78566. * Sets the global Density value.
  78567. * 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.
  78568. * Values less than zero provide a filter of opposite hue.
  78569. */
  78570. set globalDensity(value: number);
  78571. /**
  78572. * Gets the global Saturation value.
  78573. * 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.
  78574. */
  78575. get globalSaturation(): number;
  78576. /**
  78577. * Sets the global Saturation value.
  78578. * 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.
  78579. */
  78580. set globalSaturation(value: number);
  78581. /**
  78582. * Gets the global Exposure value.
  78583. * 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.
  78584. */
  78585. get globalExposure(): number;
  78586. /**
  78587. * Sets the global Exposure value.
  78588. * 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.
  78589. */
  78590. set globalExposure(value: number);
  78591. private _highlightsHue;
  78592. private _highlightsDensity;
  78593. private _highlightsSaturation;
  78594. private _highlightsExposure;
  78595. /**
  78596. * Gets the highlights Hue value.
  78597. * 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).
  78598. */
  78599. get highlightsHue(): number;
  78600. /**
  78601. * Sets the highlights Hue value.
  78602. * 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).
  78603. */
  78604. set highlightsHue(value: number);
  78605. /**
  78606. * Gets the highlights Density value.
  78607. * 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.
  78608. * Values less than zero provide a filter of opposite hue.
  78609. */
  78610. get highlightsDensity(): number;
  78611. /**
  78612. * Sets the highlights Density value.
  78613. * 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.
  78614. * Values less than zero provide a filter of opposite hue.
  78615. */
  78616. set highlightsDensity(value: number);
  78617. /**
  78618. * Gets the highlights Saturation value.
  78619. * 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.
  78620. */
  78621. get highlightsSaturation(): number;
  78622. /**
  78623. * Sets the highlights Saturation value.
  78624. * 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.
  78625. */
  78626. set highlightsSaturation(value: number);
  78627. /**
  78628. * Gets the highlights Exposure value.
  78629. * 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.
  78630. */
  78631. get highlightsExposure(): number;
  78632. /**
  78633. * Sets the highlights Exposure value.
  78634. * 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.
  78635. */
  78636. set highlightsExposure(value: number);
  78637. private _midtonesHue;
  78638. private _midtonesDensity;
  78639. private _midtonesSaturation;
  78640. private _midtonesExposure;
  78641. /**
  78642. * Gets the midtones Hue value.
  78643. * 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).
  78644. */
  78645. get midtonesHue(): number;
  78646. /**
  78647. * Sets the midtones Hue value.
  78648. * 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).
  78649. */
  78650. set midtonesHue(value: number);
  78651. /**
  78652. * Gets the midtones Density value.
  78653. * 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.
  78654. * Values less than zero provide a filter of opposite hue.
  78655. */
  78656. get midtonesDensity(): number;
  78657. /**
  78658. * Sets the midtones Density value.
  78659. * 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.
  78660. * Values less than zero provide a filter of opposite hue.
  78661. */
  78662. set midtonesDensity(value: number);
  78663. /**
  78664. * Gets the midtones Saturation value.
  78665. * 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.
  78666. */
  78667. get midtonesSaturation(): number;
  78668. /**
  78669. * Sets the midtones Saturation value.
  78670. * 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.
  78671. */
  78672. set midtonesSaturation(value: number);
  78673. /**
  78674. * Gets the midtones Exposure value.
  78675. * 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.
  78676. */
  78677. get midtonesExposure(): number;
  78678. /**
  78679. * Sets the midtones Exposure value.
  78680. * 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.
  78681. */
  78682. set midtonesExposure(value: number);
  78683. private _shadowsHue;
  78684. private _shadowsDensity;
  78685. private _shadowsSaturation;
  78686. private _shadowsExposure;
  78687. /**
  78688. * Gets the shadows Hue value.
  78689. * 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).
  78690. */
  78691. get shadowsHue(): number;
  78692. /**
  78693. * Sets the shadows Hue value.
  78694. * 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).
  78695. */
  78696. set shadowsHue(value: number);
  78697. /**
  78698. * Gets the shadows Density value.
  78699. * 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.
  78700. * Values less than zero provide a filter of opposite hue.
  78701. */
  78702. get shadowsDensity(): number;
  78703. /**
  78704. * Sets the shadows Density value.
  78705. * 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.
  78706. * Values less than zero provide a filter of opposite hue.
  78707. */
  78708. set shadowsDensity(value: number);
  78709. /**
  78710. * Gets the shadows Saturation value.
  78711. * 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.
  78712. */
  78713. get shadowsSaturation(): number;
  78714. /**
  78715. * Sets the shadows Saturation value.
  78716. * 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.
  78717. */
  78718. set shadowsSaturation(value: number);
  78719. /**
  78720. * Gets the shadows Exposure value.
  78721. * 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.
  78722. */
  78723. get shadowsExposure(): number;
  78724. /**
  78725. * Sets the shadows Exposure value.
  78726. * 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.
  78727. */
  78728. set shadowsExposure(value: number);
  78729. /**
  78730. * Returns the class name
  78731. * @returns The class name
  78732. */
  78733. getClassName(): string;
  78734. /**
  78735. * Binds the color curves to the shader.
  78736. * @param colorCurves The color curve to bind
  78737. * @param effect The effect to bind to
  78738. * @param positiveUniform The positive uniform shader parameter
  78739. * @param neutralUniform The neutral uniform shader parameter
  78740. * @param negativeUniform The negative uniform shader parameter
  78741. */
  78742. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  78743. /**
  78744. * Prepare the list of uniforms associated with the ColorCurves effects.
  78745. * @param uniformsList The list of uniforms used in the effect
  78746. */
  78747. static PrepareUniforms(uniformsList: string[]): void;
  78748. /**
  78749. * Returns color grading data based on a hue, density, saturation and exposure value.
  78750. * @param filterHue The hue of the color filter.
  78751. * @param filterDensity The density of the color filter.
  78752. * @param saturation The saturation.
  78753. * @param exposure The exposure.
  78754. * @param result The result data container.
  78755. */
  78756. private getColorGradingDataToRef;
  78757. /**
  78758. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  78759. * @param value The input slider value in range [-100,100].
  78760. * @returns Adjusted value.
  78761. */
  78762. private static applyColorGradingSliderNonlinear;
  78763. /**
  78764. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  78765. * @param hue The hue (H) input.
  78766. * @param saturation The saturation (S) input.
  78767. * @param brightness The brightness (B) input.
  78768. * @result An RGBA color represented as Vector4.
  78769. */
  78770. private static fromHSBToRef;
  78771. /**
  78772. * Returns a value clamped between min and max
  78773. * @param value The value to clamp
  78774. * @param min The minimum of value
  78775. * @param max The maximum of value
  78776. * @returns The clamped value.
  78777. */
  78778. private static clamp;
  78779. /**
  78780. * Clones the current color curve instance.
  78781. * @return The cloned curves
  78782. */
  78783. clone(): ColorCurves;
  78784. /**
  78785. * Serializes the current color curve instance to a json representation.
  78786. * @return a JSON representation
  78787. */
  78788. serialize(): any;
  78789. /**
  78790. * Parses the color curve from a json representation.
  78791. * @param source the JSON source to parse
  78792. * @return The parsed curves
  78793. */
  78794. static Parse(source: any): ColorCurves;
  78795. }
  78796. }
  78797. declare module BABYLON {
  78798. /**
  78799. * Interface to follow in your material defines to integrate easily the
  78800. * Image proccessing functions.
  78801. * @hidden
  78802. */
  78803. export interface IImageProcessingConfigurationDefines {
  78804. IMAGEPROCESSING: boolean;
  78805. VIGNETTE: boolean;
  78806. VIGNETTEBLENDMODEMULTIPLY: boolean;
  78807. VIGNETTEBLENDMODEOPAQUE: boolean;
  78808. TONEMAPPING: boolean;
  78809. TONEMAPPING_ACES: boolean;
  78810. CONTRAST: boolean;
  78811. EXPOSURE: boolean;
  78812. COLORCURVES: boolean;
  78813. COLORGRADING: boolean;
  78814. COLORGRADING3D: boolean;
  78815. SAMPLER3DGREENDEPTH: boolean;
  78816. SAMPLER3DBGRMAP: boolean;
  78817. IMAGEPROCESSINGPOSTPROCESS: boolean;
  78818. }
  78819. /**
  78820. * @hidden
  78821. */
  78822. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  78823. IMAGEPROCESSING: boolean;
  78824. VIGNETTE: boolean;
  78825. VIGNETTEBLENDMODEMULTIPLY: boolean;
  78826. VIGNETTEBLENDMODEOPAQUE: boolean;
  78827. TONEMAPPING: boolean;
  78828. TONEMAPPING_ACES: boolean;
  78829. CONTRAST: boolean;
  78830. COLORCURVES: boolean;
  78831. COLORGRADING: boolean;
  78832. COLORGRADING3D: boolean;
  78833. SAMPLER3DGREENDEPTH: boolean;
  78834. SAMPLER3DBGRMAP: boolean;
  78835. IMAGEPROCESSINGPOSTPROCESS: boolean;
  78836. EXPOSURE: boolean;
  78837. constructor();
  78838. }
  78839. /**
  78840. * This groups together the common properties used for image processing either in direct forward pass
  78841. * or through post processing effect depending on the use of the image processing pipeline in your scene
  78842. * or not.
  78843. */
  78844. export class ImageProcessingConfiguration {
  78845. /**
  78846. * Default tone mapping applied in BabylonJS.
  78847. */
  78848. static readonly TONEMAPPING_STANDARD: number;
  78849. /**
  78850. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  78851. * to other engines rendering to increase portability.
  78852. */
  78853. static readonly TONEMAPPING_ACES: number;
  78854. /**
  78855. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  78856. */
  78857. colorCurves: Nullable<ColorCurves>;
  78858. private _colorCurvesEnabled;
  78859. /**
  78860. * Gets wether the color curves effect is enabled.
  78861. */
  78862. get colorCurvesEnabled(): boolean;
  78863. /**
  78864. * Sets wether the color curves effect is enabled.
  78865. */
  78866. set colorCurvesEnabled(value: boolean);
  78867. private _colorGradingTexture;
  78868. /**
  78869. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  78870. */
  78871. get colorGradingTexture(): Nullable<BaseTexture>;
  78872. /**
  78873. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  78874. */
  78875. set colorGradingTexture(value: Nullable<BaseTexture>);
  78876. private _colorGradingEnabled;
  78877. /**
  78878. * Gets wether the color grading effect is enabled.
  78879. */
  78880. get colorGradingEnabled(): boolean;
  78881. /**
  78882. * Sets wether the color grading effect is enabled.
  78883. */
  78884. set colorGradingEnabled(value: boolean);
  78885. private _colorGradingWithGreenDepth;
  78886. /**
  78887. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  78888. */
  78889. get colorGradingWithGreenDepth(): boolean;
  78890. /**
  78891. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  78892. */
  78893. set colorGradingWithGreenDepth(value: boolean);
  78894. private _colorGradingBGR;
  78895. /**
  78896. * Gets wether the color grading texture contains BGR values.
  78897. */
  78898. get colorGradingBGR(): boolean;
  78899. /**
  78900. * Sets wether the color grading texture contains BGR values.
  78901. */
  78902. set colorGradingBGR(value: boolean);
  78903. /** @hidden */
  78904. _exposure: number;
  78905. /**
  78906. * Gets the Exposure used in the effect.
  78907. */
  78908. get exposure(): number;
  78909. /**
  78910. * Sets the Exposure used in the effect.
  78911. */
  78912. set exposure(value: number);
  78913. private _toneMappingEnabled;
  78914. /**
  78915. * Gets wether the tone mapping effect is enabled.
  78916. */
  78917. get toneMappingEnabled(): boolean;
  78918. /**
  78919. * Sets wether the tone mapping effect is enabled.
  78920. */
  78921. set toneMappingEnabled(value: boolean);
  78922. private _toneMappingType;
  78923. /**
  78924. * Gets the type of tone mapping effect.
  78925. */
  78926. get toneMappingType(): number;
  78927. /**
  78928. * Sets the type of tone mapping effect used in BabylonJS.
  78929. */
  78930. set toneMappingType(value: number);
  78931. protected _contrast: number;
  78932. /**
  78933. * Gets the contrast used in the effect.
  78934. */
  78935. get contrast(): number;
  78936. /**
  78937. * Sets the contrast used in the effect.
  78938. */
  78939. set contrast(value: number);
  78940. /**
  78941. * Vignette stretch size.
  78942. */
  78943. vignetteStretch: number;
  78944. /**
  78945. * Vignette centre X Offset.
  78946. */
  78947. vignetteCentreX: number;
  78948. /**
  78949. * Vignette centre Y Offset.
  78950. */
  78951. vignetteCentreY: number;
  78952. /**
  78953. * Vignette weight or intensity of the vignette effect.
  78954. */
  78955. vignetteWeight: number;
  78956. /**
  78957. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  78958. * if vignetteEnabled is set to true.
  78959. */
  78960. vignetteColor: Color4;
  78961. /**
  78962. * Camera field of view used by the Vignette effect.
  78963. */
  78964. vignetteCameraFov: number;
  78965. private _vignetteBlendMode;
  78966. /**
  78967. * Gets the vignette blend mode allowing different kind of effect.
  78968. */
  78969. get vignetteBlendMode(): number;
  78970. /**
  78971. * Sets the vignette blend mode allowing different kind of effect.
  78972. */
  78973. set vignetteBlendMode(value: number);
  78974. private _vignetteEnabled;
  78975. /**
  78976. * Gets wether the vignette effect is enabled.
  78977. */
  78978. get vignetteEnabled(): boolean;
  78979. /**
  78980. * Sets wether the vignette effect is enabled.
  78981. */
  78982. set vignetteEnabled(value: boolean);
  78983. private _applyByPostProcess;
  78984. /**
  78985. * Gets wether the image processing is applied through a post process or not.
  78986. */
  78987. get applyByPostProcess(): boolean;
  78988. /**
  78989. * Sets wether the image processing is applied through a post process or not.
  78990. */
  78991. set applyByPostProcess(value: boolean);
  78992. private _isEnabled;
  78993. /**
  78994. * Gets wether the image processing is enabled or not.
  78995. */
  78996. get isEnabled(): boolean;
  78997. /**
  78998. * Sets wether the image processing is enabled or not.
  78999. */
  79000. set isEnabled(value: boolean);
  79001. /**
  79002. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  79003. */
  79004. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  79005. /**
  79006. * Method called each time the image processing information changes requires to recompile the effect.
  79007. */
  79008. protected _updateParameters(): void;
  79009. /**
  79010. * Gets the current class name.
  79011. * @return "ImageProcessingConfiguration"
  79012. */
  79013. getClassName(): string;
  79014. /**
  79015. * Prepare the list of uniforms associated with the Image Processing effects.
  79016. * @param uniforms The list of uniforms used in the effect
  79017. * @param defines the list of defines currently in use
  79018. */
  79019. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  79020. /**
  79021. * Prepare the list of samplers associated with the Image Processing effects.
  79022. * @param samplersList The list of uniforms used in the effect
  79023. * @param defines the list of defines currently in use
  79024. */
  79025. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  79026. /**
  79027. * Prepare the list of defines associated to the shader.
  79028. * @param defines the list of defines to complete
  79029. * @param forPostProcess Define if we are currently in post process mode or not
  79030. */
  79031. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  79032. /**
  79033. * Returns true if all the image processing information are ready.
  79034. * @returns True if ready, otherwise, false
  79035. */
  79036. isReady(): boolean;
  79037. /**
  79038. * Binds the image processing to the shader.
  79039. * @param effect The effect to bind to
  79040. * @param overrideAspectRatio Override the aspect ratio of the effect
  79041. */
  79042. bind(effect: Effect, overrideAspectRatio?: number): void;
  79043. /**
  79044. * Clones the current image processing instance.
  79045. * @return The cloned image processing
  79046. */
  79047. clone(): ImageProcessingConfiguration;
  79048. /**
  79049. * Serializes the current image processing instance to a json representation.
  79050. * @return a JSON representation
  79051. */
  79052. serialize(): any;
  79053. /**
  79054. * Parses the image processing from a json representation.
  79055. * @param source the JSON source to parse
  79056. * @return The parsed image processing
  79057. */
  79058. static Parse(source: any): ImageProcessingConfiguration;
  79059. private static _VIGNETTEMODE_MULTIPLY;
  79060. private static _VIGNETTEMODE_OPAQUE;
  79061. /**
  79062. * Used to apply the vignette as a mix with the pixel color.
  79063. */
  79064. static get VIGNETTEMODE_MULTIPLY(): number;
  79065. /**
  79066. * Used to apply the vignette as a replacement of the pixel color.
  79067. */
  79068. static get VIGNETTEMODE_OPAQUE(): number;
  79069. }
  79070. }
  79071. declare module BABYLON {
  79072. /** @hidden */
  79073. export var postprocessVertexShader: {
  79074. name: string;
  79075. shader: string;
  79076. };
  79077. }
  79078. declare module BABYLON {
  79079. interface ThinEngine {
  79080. /**
  79081. * Creates a new render target texture
  79082. * @param size defines the size of the texture
  79083. * @param options defines the options used to create the texture
  79084. * @returns a new render target texture stored in an InternalTexture
  79085. */
  79086. createRenderTargetTexture(size: number | {
  79087. width: number;
  79088. height: number;
  79089. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  79090. /**
  79091. * Creates a depth stencil texture.
  79092. * This is only available in WebGL 2 or with the depth texture extension available.
  79093. * @param size The size of face edge in the texture.
  79094. * @param options The options defining the texture.
  79095. * @returns The texture
  79096. */
  79097. createDepthStencilTexture(size: number | {
  79098. width: number;
  79099. height: number;
  79100. }, options: DepthTextureCreationOptions): InternalTexture;
  79101. /** @hidden */
  79102. _createDepthStencilTexture(size: number | {
  79103. width: number;
  79104. height: number;
  79105. }, options: DepthTextureCreationOptions): InternalTexture;
  79106. }
  79107. }
  79108. declare module BABYLON {
  79109. /** Defines supported spaces */
  79110. export enum Space {
  79111. /** Local (object) space */
  79112. LOCAL = 0,
  79113. /** World space */
  79114. WORLD = 1,
  79115. /** Bone space */
  79116. BONE = 2
  79117. }
  79118. /** Defines the 3 main axes */
  79119. export class Axis {
  79120. /** X axis */
  79121. static X: Vector3;
  79122. /** Y axis */
  79123. static Y: Vector3;
  79124. /** Z axis */
  79125. static Z: Vector3;
  79126. }
  79127. }
  79128. declare module BABYLON {
  79129. /**
  79130. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  79131. * This is the base of the follow, arc rotate cameras and Free camera
  79132. * @see http://doc.babylonjs.com/features/cameras
  79133. */
  79134. export class TargetCamera extends Camera {
  79135. private static _RigCamTransformMatrix;
  79136. private static _TargetTransformMatrix;
  79137. private static _TargetFocalPoint;
  79138. /**
  79139. * Define the current direction the camera is moving to
  79140. */
  79141. cameraDirection: Vector3;
  79142. /**
  79143. * Define the current rotation the camera is rotating to
  79144. */
  79145. cameraRotation: Vector2;
  79146. /**
  79147. * When set, the up vector of the camera will be updated by the rotation of the camera
  79148. */
  79149. updateUpVectorFromRotation: boolean;
  79150. private _tmpQuaternion;
  79151. /**
  79152. * Define the current rotation of the camera
  79153. */
  79154. rotation: Vector3;
  79155. /**
  79156. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  79157. */
  79158. rotationQuaternion: Quaternion;
  79159. /**
  79160. * Define the current speed of the camera
  79161. */
  79162. speed: number;
  79163. /**
  79164. * Add constraint to the camera to prevent it to move freely in all directions and
  79165. * around all axis.
  79166. */
  79167. noRotationConstraint: boolean;
  79168. /**
  79169. * Define the current target of the camera as an object or a position.
  79170. */
  79171. lockedTarget: any;
  79172. /** @hidden */
  79173. _currentTarget: Vector3;
  79174. /** @hidden */
  79175. _initialFocalDistance: number;
  79176. /** @hidden */
  79177. _viewMatrix: Matrix;
  79178. /** @hidden */
  79179. _camMatrix: Matrix;
  79180. /** @hidden */
  79181. _cameraTransformMatrix: Matrix;
  79182. /** @hidden */
  79183. _cameraRotationMatrix: Matrix;
  79184. /** @hidden */
  79185. _referencePoint: Vector3;
  79186. /** @hidden */
  79187. _transformedReferencePoint: Vector3;
  79188. protected _globalCurrentTarget: Vector3;
  79189. protected _globalCurrentUpVector: Vector3;
  79190. /** @hidden */
  79191. _reset: () => void;
  79192. private _defaultUp;
  79193. /**
  79194. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  79195. * This is the base of the follow, arc rotate cameras and Free camera
  79196. * @see http://doc.babylonjs.com/features/cameras
  79197. * @param name Defines the name of the camera in the scene
  79198. * @param position Defines the start position of the camera in the scene
  79199. * @param scene Defines the scene the camera belongs to
  79200. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79201. */
  79202. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79203. /**
  79204. * Gets the position in front of the camera at a given distance.
  79205. * @param distance The distance from the camera we want the position to be
  79206. * @returns the position
  79207. */
  79208. getFrontPosition(distance: number): Vector3;
  79209. /** @hidden */
  79210. _getLockedTargetPosition(): Nullable<Vector3>;
  79211. private _storedPosition;
  79212. private _storedRotation;
  79213. private _storedRotationQuaternion;
  79214. /**
  79215. * Store current camera state of the camera (fov, position, rotation, etc..)
  79216. * @returns the camera
  79217. */
  79218. storeState(): Camera;
  79219. /**
  79220. * Restored camera state. You must call storeState() first
  79221. * @returns whether it was successful or not
  79222. * @hidden
  79223. */
  79224. _restoreStateValues(): boolean;
  79225. /** @hidden */
  79226. _initCache(): void;
  79227. /** @hidden */
  79228. _updateCache(ignoreParentClass?: boolean): void;
  79229. /** @hidden */
  79230. _isSynchronizedViewMatrix(): boolean;
  79231. /** @hidden */
  79232. _computeLocalCameraSpeed(): number;
  79233. /**
  79234. * Defines the target the camera should look at.
  79235. * @param target Defines the new target as a Vector or a mesh
  79236. */
  79237. setTarget(target: Vector3): void;
  79238. /**
  79239. * Return the current target position of the camera. This value is expressed in local space.
  79240. * @returns the target position
  79241. */
  79242. getTarget(): Vector3;
  79243. /** @hidden */
  79244. _decideIfNeedsToMove(): boolean;
  79245. /** @hidden */
  79246. _updatePosition(): void;
  79247. /** @hidden */
  79248. _checkInputs(): void;
  79249. protected _updateCameraRotationMatrix(): void;
  79250. /**
  79251. * 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)
  79252. * @returns the current camera
  79253. */
  79254. private _rotateUpVectorWithCameraRotationMatrix;
  79255. private _cachedRotationZ;
  79256. private _cachedQuaternionRotationZ;
  79257. /** @hidden */
  79258. _getViewMatrix(): Matrix;
  79259. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  79260. /**
  79261. * @hidden
  79262. */
  79263. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  79264. /**
  79265. * @hidden
  79266. */
  79267. _updateRigCameras(): void;
  79268. private _getRigCamPositionAndTarget;
  79269. /**
  79270. * Gets the current object class name.
  79271. * @return the class name
  79272. */
  79273. getClassName(): string;
  79274. }
  79275. }
  79276. declare module BABYLON {
  79277. /**
  79278. * Gather the list of keyboard event types as constants.
  79279. */
  79280. export class KeyboardEventTypes {
  79281. /**
  79282. * The keydown event is fired when a key becomes active (pressed).
  79283. */
  79284. static readonly KEYDOWN: number;
  79285. /**
  79286. * The keyup event is fired when a key has been released.
  79287. */
  79288. static readonly KEYUP: number;
  79289. }
  79290. /**
  79291. * This class is used to store keyboard related info for the onKeyboardObservable event.
  79292. */
  79293. export class KeyboardInfo {
  79294. /**
  79295. * Defines the type of event (KeyboardEventTypes)
  79296. */
  79297. type: number;
  79298. /**
  79299. * Defines the related dom event
  79300. */
  79301. event: KeyboardEvent;
  79302. /**
  79303. * Instantiates a new keyboard info.
  79304. * This class is used to store keyboard related info for the onKeyboardObservable event.
  79305. * @param type Defines the type of event (KeyboardEventTypes)
  79306. * @param event Defines the related dom event
  79307. */
  79308. constructor(
  79309. /**
  79310. * Defines the type of event (KeyboardEventTypes)
  79311. */
  79312. type: number,
  79313. /**
  79314. * Defines the related dom event
  79315. */
  79316. event: KeyboardEvent);
  79317. }
  79318. /**
  79319. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  79320. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  79321. */
  79322. export class KeyboardInfoPre extends KeyboardInfo {
  79323. /**
  79324. * Defines the type of event (KeyboardEventTypes)
  79325. */
  79326. type: number;
  79327. /**
  79328. * Defines the related dom event
  79329. */
  79330. event: KeyboardEvent;
  79331. /**
  79332. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  79333. */
  79334. skipOnPointerObservable: boolean;
  79335. /**
  79336. * Instantiates a new keyboard pre info.
  79337. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  79338. * @param type Defines the type of event (KeyboardEventTypes)
  79339. * @param event Defines the related dom event
  79340. */
  79341. constructor(
  79342. /**
  79343. * Defines the type of event (KeyboardEventTypes)
  79344. */
  79345. type: number,
  79346. /**
  79347. * Defines the related dom event
  79348. */
  79349. event: KeyboardEvent);
  79350. }
  79351. }
  79352. declare module BABYLON {
  79353. /**
  79354. * Manage the keyboard inputs to control the movement of a free camera.
  79355. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79356. */
  79357. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  79358. /**
  79359. * Defines the camera the input is attached to.
  79360. */
  79361. camera: FreeCamera;
  79362. /**
  79363. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  79364. */
  79365. keysUp: number[];
  79366. /**
  79367. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  79368. */
  79369. keysDown: number[];
  79370. /**
  79371. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  79372. */
  79373. keysLeft: number[];
  79374. /**
  79375. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  79376. */
  79377. keysRight: number[];
  79378. private _keys;
  79379. private _onCanvasBlurObserver;
  79380. private _onKeyboardObserver;
  79381. private _engine;
  79382. private _scene;
  79383. /**
  79384. * Attach the input controls to a specific dom element to get the input from.
  79385. * @param element Defines the element the controls should be listened from
  79386. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79387. */
  79388. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79389. /**
  79390. * Detach the current controls from the specified dom element.
  79391. * @param element Defines the element to stop listening the inputs from
  79392. */
  79393. detachControl(element: Nullable<HTMLElement>): void;
  79394. /**
  79395. * Update the current camera state depending on the inputs that have been used this frame.
  79396. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79397. */
  79398. checkInputs(): void;
  79399. /**
  79400. * Gets the class name of the current intput.
  79401. * @returns the class name
  79402. */
  79403. getClassName(): string;
  79404. /** @hidden */
  79405. _onLostFocus(): void;
  79406. /**
  79407. * Get the friendly name associated with the input class.
  79408. * @returns the input friendly name
  79409. */
  79410. getSimpleName(): string;
  79411. }
  79412. }
  79413. declare module BABYLON {
  79414. /**
  79415. * Interface describing all the common properties and methods a shadow light needs to implement.
  79416. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  79417. * as well as binding the different shadow properties to the effects.
  79418. */
  79419. export interface IShadowLight extends Light {
  79420. /**
  79421. * The light id in the scene (used in scene.findLighById for instance)
  79422. */
  79423. id: string;
  79424. /**
  79425. * The position the shdow will be casted from.
  79426. */
  79427. position: Vector3;
  79428. /**
  79429. * In 2d mode (needCube being false), the direction used to cast the shadow.
  79430. */
  79431. direction: Vector3;
  79432. /**
  79433. * The transformed position. Position of the light in world space taking parenting in account.
  79434. */
  79435. transformedPosition: Vector3;
  79436. /**
  79437. * The transformed direction. Direction of the light in world space taking parenting in account.
  79438. */
  79439. transformedDirection: Vector3;
  79440. /**
  79441. * The friendly name of the light in the scene.
  79442. */
  79443. name: string;
  79444. /**
  79445. * Defines the shadow projection clipping minimum z value.
  79446. */
  79447. shadowMinZ: number;
  79448. /**
  79449. * Defines the shadow projection clipping maximum z value.
  79450. */
  79451. shadowMaxZ: number;
  79452. /**
  79453. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  79454. * @returns true if the information has been computed, false if it does not need to (no parenting)
  79455. */
  79456. computeTransformedInformation(): boolean;
  79457. /**
  79458. * Gets the scene the light belongs to.
  79459. * @returns The scene
  79460. */
  79461. getScene(): Scene;
  79462. /**
  79463. * Callback defining a custom Projection Matrix Builder.
  79464. * This can be used to override the default projection matrix computation.
  79465. */
  79466. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  79467. /**
  79468. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  79469. * @param matrix The materix to updated with the projection information
  79470. * @param viewMatrix The transform matrix of the light
  79471. * @param renderList The list of mesh to render in the map
  79472. * @returns The current light
  79473. */
  79474. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  79475. /**
  79476. * Gets the current depth scale used in ESM.
  79477. * @returns The scale
  79478. */
  79479. getDepthScale(): number;
  79480. /**
  79481. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  79482. * @returns true if a cube texture needs to be use
  79483. */
  79484. needCube(): boolean;
  79485. /**
  79486. * Detects if the projection matrix requires to be recomputed this frame.
  79487. * @returns true if it requires to be recomputed otherwise, false.
  79488. */
  79489. needProjectionMatrixCompute(): boolean;
  79490. /**
  79491. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  79492. */
  79493. forceProjectionMatrixCompute(): void;
  79494. /**
  79495. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  79496. * @param faceIndex The index of the face we are computed the direction to generate shadow
  79497. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  79498. */
  79499. getShadowDirection(faceIndex?: number): Vector3;
  79500. /**
  79501. * Gets the minZ used for shadow according to both the scene and the light.
  79502. * @param activeCamera The camera we are returning the min for
  79503. * @returns the depth min z
  79504. */
  79505. getDepthMinZ(activeCamera: Camera): number;
  79506. /**
  79507. * Gets the maxZ used for shadow according to both the scene and the light.
  79508. * @param activeCamera The camera we are returning the max for
  79509. * @returns the depth max z
  79510. */
  79511. getDepthMaxZ(activeCamera: Camera): number;
  79512. }
  79513. /**
  79514. * Base implementation IShadowLight
  79515. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  79516. */
  79517. export abstract class ShadowLight extends Light implements IShadowLight {
  79518. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  79519. protected _position: Vector3;
  79520. protected _setPosition(value: Vector3): void;
  79521. /**
  79522. * Sets the position the shadow will be casted from. Also use as the light position for both
  79523. * point and spot lights.
  79524. */
  79525. get position(): Vector3;
  79526. /**
  79527. * Sets the position the shadow will be casted from. Also use as the light position for both
  79528. * point and spot lights.
  79529. */
  79530. set position(value: Vector3);
  79531. protected _direction: Vector3;
  79532. protected _setDirection(value: Vector3): void;
  79533. /**
  79534. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  79535. * Also use as the light direction on spot and directional lights.
  79536. */
  79537. get direction(): Vector3;
  79538. /**
  79539. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  79540. * Also use as the light direction on spot and directional lights.
  79541. */
  79542. set direction(value: Vector3);
  79543. private _shadowMinZ;
  79544. /**
  79545. * Gets the shadow projection clipping minimum z value.
  79546. */
  79547. get shadowMinZ(): number;
  79548. /**
  79549. * Sets the shadow projection clipping minimum z value.
  79550. */
  79551. set shadowMinZ(value: number);
  79552. private _shadowMaxZ;
  79553. /**
  79554. * Sets the shadow projection clipping maximum z value.
  79555. */
  79556. get shadowMaxZ(): number;
  79557. /**
  79558. * Gets the shadow projection clipping maximum z value.
  79559. */
  79560. set shadowMaxZ(value: number);
  79561. /**
  79562. * Callback defining a custom Projection Matrix Builder.
  79563. * This can be used to override the default projection matrix computation.
  79564. */
  79565. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  79566. /**
  79567. * The transformed position. Position of the light in world space taking parenting in account.
  79568. */
  79569. transformedPosition: Vector3;
  79570. /**
  79571. * The transformed direction. Direction of the light in world space taking parenting in account.
  79572. */
  79573. transformedDirection: Vector3;
  79574. private _needProjectionMatrixCompute;
  79575. /**
  79576. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  79577. * @returns true if the information has been computed, false if it does not need to (no parenting)
  79578. */
  79579. computeTransformedInformation(): boolean;
  79580. /**
  79581. * Return the depth scale used for the shadow map.
  79582. * @returns the depth scale.
  79583. */
  79584. getDepthScale(): number;
  79585. /**
  79586. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  79587. * @param faceIndex The index of the face we are computed the direction to generate shadow
  79588. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  79589. */
  79590. getShadowDirection(faceIndex?: number): Vector3;
  79591. /**
  79592. * Returns the ShadowLight absolute position in the World.
  79593. * @returns the position vector in world space
  79594. */
  79595. getAbsolutePosition(): Vector3;
  79596. /**
  79597. * Sets the ShadowLight direction toward the passed target.
  79598. * @param target The point to target in local space
  79599. * @returns the updated ShadowLight direction
  79600. */
  79601. setDirectionToTarget(target: Vector3): Vector3;
  79602. /**
  79603. * Returns the light rotation in euler definition.
  79604. * @returns the x y z rotation in local space.
  79605. */
  79606. getRotation(): Vector3;
  79607. /**
  79608. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  79609. * @returns true if a cube texture needs to be use
  79610. */
  79611. needCube(): boolean;
  79612. /**
  79613. * Detects if the projection matrix requires to be recomputed this frame.
  79614. * @returns true if it requires to be recomputed otherwise, false.
  79615. */
  79616. needProjectionMatrixCompute(): boolean;
  79617. /**
  79618. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  79619. */
  79620. forceProjectionMatrixCompute(): void;
  79621. /** @hidden */
  79622. _initCache(): void;
  79623. /** @hidden */
  79624. _isSynchronized(): boolean;
  79625. /**
  79626. * Computes the world matrix of the node
  79627. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  79628. * @returns the world matrix
  79629. */
  79630. computeWorldMatrix(force?: boolean): Matrix;
  79631. /**
  79632. * Gets the minZ used for shadow according to both the scene and the light.
  79633. * @param activeCamera The camera we are returning the min for
  79634. * @returns the depth min z
  79635. */
  79636. getDepthMinZ(activeCamera: Camera): number;
  79637. /**
  79638. * Gets the maxZ used for shadow according to both the scene and the light.
  79639. * @param activeCamera The camera we are returning the max for
  79640. * @returns the depth max z
  79641. */
  79642. getDepthMaxZ(activeCamera: Camera): number;
  79643. /**
  79644. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  79645. * @param matrix The materix to updated with the projection information
  79646. * @param viewMatrix The transform matrix of the light
  79647. * @param renderList The list of mesh to render in the map
  79648. * @returns The current light
  79649. */
  79650. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  79651. }
  79652. }
  79653. declare module BABYLON {
  79654. /**
  79655. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  79656. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  79657. */
  79658. export class EffectFallbacks implements IEffectFallbacks {
  79659. private _defines;
  79660. private _currentRank;
  79661. private _maxRank;
  79662. private _mesh;
  79663. /**
  79664. * Removes the fallback from the bound mesh.
  79665. */
  79666. unBindMesh(): void;
  79667. /**
  79668. * Adds a fallback on the specified property.
  79669. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  79670. * @param define The name of the define in the shader
  79671. */
  79672. addFallback(rank: number, define: string): void;
  79673. /**
  79674. * Sets the mesh to use CPU skinning when needing to fallback.
  79675. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  79676. * @param mesh The mesh to use the fallbacks.
  79677. */
  79678. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  79679. /**
  79680. * Checks to see if more fallbacks are still availible.
  79681. */
  79682. get hasMoreFallbacks(): boolean;
  79683. /**
  79684. * Removes the defines that should be removed when falling back.
  79685. * @param currentDefines defines the current define statements for the shader.
  79686. * @param effect defines the current effect we try to compile
  79687. * @returns The resulting defines with defines of the current rank removed.
  79688. */
  79689. reduce(currentDefines: string, effect: Effect): string;
  79690. }
  79691. }
  79692. declare module BABYLON {
  79693. /**
  79694. * "Static Class" containing the most commonly used helper while dealing with material for
  79695. * rendering purpose.
  79696. *
  79697. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  79698. *
  79699. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  79700. */
  79701. export class MaterialHelper {
  79702. /**
  79703. * Bind the current view position to an effect.
  79704. * @param effect The effect to be bound
  79705. * @param scene The scene the eyes position is used from
  79706. */
  79707. static BindEyePosition(effect: Effect, scene: Scene): void;
  79708. /**
  79709. * Helps preparing the defines values about the UVs in used in the effect.
  79710. * UVs are shared as much as we can accross channels in the shaders.
  79711. * @param texture The texture we are preparing the UVs for
  79712. * @param defines The defines to update
  79713. * @param key The channel key "diffuse", "specular"... used in the shader
  79714. */
  79715. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  79716. /**
  79717. * Binds a texture matrix value to its corrsponding uniform
  79718. * @param texture The texture to bind the matrix for
  79719. * @param uniformBuffer The uniform buffer receivin the data
  79720. * @param key The channel key "diffuse", "specular"... used in the shader
  79721. */
  79722. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  79723. /**
  79724. * Gets the current status of the fog (should it be enabled?)
  79725. * @param mesh defines the mesh to evaluate for fog support
  79726. * @param scene defines the hosting scene
  79727. * @returns true if fog must be enabled
  79728. */
  79729. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  79730. /**
  79731. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  79732. * @param mesh defines the current mesh
  79733. * @param scene defines the current scene
  79734. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  79735. * @param pointsCloud defines if point cloud rendering has to be turned on
  79736. * @param fogEnabled defines if fog has to be turned on
  79737. * @param alphaTest defines if alpha testing has to be turned on
  79738. * @param defines defines the current list of defines
  79739. */
  79740. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  79741. /**
  79742. * Helper used to prepare the list of defines associated with frame values for shader compilation
  79743. * @param scene defines the current scene
  79744. * @param engine defines the current engine
  79745. * @param defines specifies the list of active defines
  79746. * @param useInstances defines if instances have to be turned on
  79747. * @param useClipPlane defines if clip plane have to be turned on
  79748. */
  79749. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  79750. /**
  79751. * Prepares the defines for bones
  79752. * @param mesh The mesh containing the geometry data we will draw
  79753. * @param defines The defines to update
  79754. */
  79755. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  79756. /**
  79757. * Prepares the defines for morph targets
  79758. * @param mesh The mesh containing the geometry data we will draw
  79759. * @param defines The defines to update
  79760. */
  79761. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  79762. /**
  79763. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  79764. * @param mesh The mesh containing the geometry data we will draw
  79765. * @param defines The defines to update
  79766. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  79767. * @param useBones Precise whether bones should be used or not (override mesh info)
  79768. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  79769. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  79770. * @returns false if defines are considered not dirty and have not been checked
  79771. */
  79772. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  79773. /**
  79774. * Prepares the defines related to multiview
  79775. * @param scene The scene we are intending to draw
  79776. * @param defines The defines to update
  79777. */
  79778. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  79779. /**
  79780. * Prepares the defines related to the light information passed in parameter
  79781. * @param scene The scene we are intending to draw
  79782. * @param mesh The mesh the effect is compiling for
  79783. * @param light The light the effect is compiling for
  79784. * @param lightIndex The index of the light
  79785. * @param defines The defines to update
  79786. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  79787. * @param state Defines the current state regarding what is needed (normals, etc...)
  79788. */
  79789. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  79790. needNormals: boolean;
  79791. needRebuild: boolean;
  79792. shadowEnabled: boolean;
  79793. specularEnabled: boolean;
  79794. lightmapMode: boolean;
  79795. }): void;
  79796. /**
  79797. * Prepares the defines related to the light information passed in parameter
  79798. * @param scene The scene we are intending to draw
  79799. * @param mesh The mesh the effect is compiling for
  79800. * @param defines The defines to update
  79801. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  79802. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  79803. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  79804. * @returns true if normals will be required for the rest of the effect
  79805. */
  79806. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  79807. /**
  79808. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  79809. * @param lightIndex defines the light index
  79810. * @param uniformsList The uniform list
  79811. * @param samplersList The sampler list
  79812. * @param projectedLightTexture defines if projected texture must be used
  79813. * @param uniformBuffersList defines an optional list of uniform buffers
  79814. */
  79815. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  79816. /**
  79817. * Prepares the uniforms and samplers list to be used in the effect
  79818. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  79819. * @param samplersList The sampler list
  79820. * @param defines The defines helping in the list generation
  79821. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  79822. */
  79823. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  79824. /**
  79825. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  79826. * @param defines The defines to update while falling back
  79827. * @param fallbacks The authorized effect fallbacks
  79828. * @param maxSimultaneousLights The maximum number of lights allowed
  79829. * @param rank the current rank of the Effect
  79830. * @returns The newly affected rank
  79831. */
  79832. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  79833. private static _TmpMorphInfluencers;
  79834. /**
  79835. * Prepares the list of attributes required for morph targets according to the effect defines.
  79836. * @param attribs The current list of supported attribs
  79837. * @param mesh The mesh to prepare the morph targets attributes for
  79838. * @param influencers The number of influencers
  79839. */
  79840. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  79841. /**
  79842. * Prepares the list of attributes required for morph targets according to the effect defines.
  79843. * @param attribs The current list of supported attribs
  79844. * @param mesh The mesh to prepare the morph targets attributes for
  79845. * @param defines The current Defines of the effect
  79846. */
  79847. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  79848. /**
  79849. * Prepares the list of attributes required for bones according to the effect defines.
  79850. * @param attribs The current list of supported attribs
  79851. * @param mesh The mesh to prepare the bones attributes for
  79852. * @param defines The current Defines of the effect
  79853. * @param fallbacks The current efffect fallback strategy
  79854. */
  79855. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  79856. /**
  79857. * Check and prepare the list of attributes required for instances according to the effect defines.
  79858. * @param attribs The current list of supported attribs
  79859. * @param defines The current MaterialDefines of the effect
  79860. */
  79861. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  79862. /**
  79863. * Add the list of attributes required for instances to the attribs array.
  79864. * @param attribs The current list of supported attribs
  79865. */
  79866. static PushAttributesForInstances(attribs: string[]): void;
  79867. /**
  79868. * Binds the light information to the effect.
  79869. * @param light The light containing the generator
  79870. * @param effect The effect we are binding the data to
  79871. * @param lightIndex The light index in the effect used to render
  79872. */
  79873. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  79874. /**
  79875. * Binds the lights information from the scene to the effect for the given mesh.
  79876. * @param light Light to bind
  79877. * @param lightIndex Light index
  79878. * @param scene The scene where the light belongs to
  79879. * @param effect The effect we are binding the data to
  79880. * @param useSpecular Defines if specular is supported
  79881. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  79882. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  79883. */
  79884. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  79885. /**
  79886. * Binds the lights information from the scene to the effect for the given mesh.
  79887. * @param scene The scene the lights belongs to
  79888. * @param mesh The mesh we are binding the information to render
  79889. * @param effect The effect we are binding the data to
  79890. * @param defines The generated defines for the effect
  79891. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  79892. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  79893. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  79894. */
  79895. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  79896. private static _tempFogColor;
  79897. /**
  79898. * Binds the fog information from the scene to the effect for the given mesh.
  79899. * @param scene The scene the lights belongs to
  79900. * @param mesh The mesh we are binding the information to render
  79901. * @param effect The effect we are binding the data to
  79902. * @param linearSpace Defines if the fog effect is applied in linear space
  79903. */
  79904. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  79905. /**
  79906. * Binds the bones information from the mesh to the effect.
  79907. * @param mesh The mesh we are binding the information to render
  79908. * @param effect The effect we are binding the data to
  79909. */
  79910. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  79911. /**
  79912. * Binds the morph targets information from the mesh to the effect.
  79913. * @param abstractMesh The mesh we are binding the information to render
  79914. * @param effect The effect we are binding the data to
  79915. */
  79916. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  79917. /**
  79918. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  79919. * @param defines The generated defines used in the effect
  79920. * @param effect The effect we are binding the data to
  79921. * @param scene The scene we are willing to render with logarithmic scale for
  79922. */
  79923. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  79924. /**
  79925. * Binds the clip plane information from the scene to the effect.
  79926. * @param scene The scene the clip plane information are extracted from
  79927. * @param effect The effect we are binding the data to
  79928. */
  79929. static BindClipPlane(effect: Effect, scene: Scene): void;
  79930. }
  79931. }
  79932. declare module BABYLON {
  79933. /** @hidden */
  79934. export var packingFunctions: {
  79935. name: string;
  79936. shader: string;
  79937. };
  79938. }
  79939. declare module BABYLON {
  79940. /** @hidden */
  79941. export var shadowMapPixelShader: {
  79942. name: string;
  79943. shader: string;
  79944. };
  79945. }
  79946. declare module BABYLON {
  79947. /** @hidden */
  79948. export var bonesDeclaration: {
  79949. name: string;
  79950. shader: string;
  79951. };
  79952. }
  79953. declare module BABYLON {
  79954. /** @hidden */
  79955. export var morphTargetsVertexGlobalDeclaration: {
  79956. name: string;
  79957. shader: string;
  79958. };
  79959. }
  79960. declare module BABYLON {
  79961. /** @hidden */
  79962. export var morphTargetsVertexDeclaration: {
  79963. name: string;
  79964. shader: string;
  79965. };
  79966. }
  79967. declare module BABYLON {
  79968. /** @hidden */
  79969. export var instancesDeclaration: {
  79970. name: string;
  79971. shader: string;
  79972. };
  79973. }
  79974. declare module BABYLON {
  79975. /** @hidden */
  79976. export var helperFunctions: {
  79977. name: string;
  79978. shader: string;
  79979. };
  79980. }
  79981. declare module BABYLON {
  79982. /** @hidden */
  79983. export var morphTargetsVertex: {
  79984. name: string;
  79985. shader: string;
  79986. };
  79987. }
  79988. declare module BABYLON {
  79989. /** @hidden */
  79990. export var instancesVertex: {
  79991. name: string;
  79992. shader: string;
  79993. };
  79994. }
  79995. declare module BABYLON {
  79996. /** @hidden */
  79997. export var bonesVertex: {
  79998. name: string;
  79999. shader: string;
  80000. };
  80001. }
  80002. declare module BABYLON {
  80003. /** @hidden */
  80004. export var shadowMapVertexShader: {
  80005. name: string;
  80006. shader: string;
  80007. };
  80008. }
  80009. declare module BABYLON {
  80010. /** @hidden */
  80011. export var depthBoxBlurPixelShader: {
  80012. name: string;
  80013. shader: string;
  80014. };
  80015. }
  80016. declare module BABYLON {
  80017. /**
  80018. * Defines the options associated with the creation of a custom shader for a shadow generator.
  80019. */
  80020. export interface ICustomShaderOptions {
  80021. /**
  80022. * Gets or sets the custom shader name to use
  80023. */
  80024. shaderName: string;
  80025. /**
  80026. * The list of attribute names used in the shader
  80027. */
  80028. attributes?: string[];
  80029. /**
  80030. * The list of unifrom names used in the shader
  80031. */
  80032. uniforms?: string[];
  80033. /**
  80034. * The list of sampler names used in the shader
  80035. */
  80036. samplers?: string[];
  80037. /**
  80038. * The list of defines used in the shader
  80039. */
  80040. defines?: string[];
  80041. }
  80042. /**
  80043. * Interface to implement to create a shadow generator compatible with BJS.
  80044. */
  80045. export interface IShadowGenerator {
  80046. /**
  80047. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  80048. * @returns The render target texture if present otherwise, null
  80049. */
  80050. getShadowMap(): Nullable<RenderTargetTexture>;
  80051. /**
  80052. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  80053. * @returns The render target texture if the shadow map is present otherwise, null
  80054. */
  80055. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  80056. /**
  80057. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  80058. * @param subMesh The submesh we want to render in the shadow map
  80059. * @param useInstances Defines wether will draw in the map using instances
  80060. * @returns true if ready otherwise, false
  80061. */
  80062. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  80063. /**
  80064. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  80065. * @param defines Defines of the material we want to update
  80066. * @param lightIndex Index of the light in the enabled light list of the material
  80067. */
  80068. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  80069. /**
  80070. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  80071. * defined in the generator but impacting the effect).
  80072. * It implies the unifroms available on the materials are the standard BJS ones.
  80073. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  80074. * @param effect The effect we are binfing the information for
  80075. */
  80076. bindShadowLight(lightIndex: string, effect: Effect): void;
  80077. /**
  80078. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  80079. * (eq to shadow prjection matrix * light transform matrix)
  80080. * @returns The transform matrix used to create the shadow map
  80081. */
  80082. getTransformMatrix(): Matrix;
  80083. /**
  80084. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  80085. * Cube and 2D textures for instance.
  80086. */
  80087. recreateShadowMap(): void;
  80088. /**
  80089. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80090. * @param onCompiled Callback triggered at the and of the effects compilation
  80091. * @param options Sets of optional options forcing the compilation with different modes
  80092. */
  80093. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  80094. useInstances: boolean;
  80095. }>): void;
  80096. /**
  80097. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80098. * @param options Sets of optional options forcing the compilation with different modes
  80099. * @returns A promise that resolves when the compilation completes
  80100. */
  80101. forceCompilationAsync(options?: Partial<{
  80102. useInstances: boolean;
  80103. }>): Promise<void>;
  80104. /**
  80105. * Serializes the shadow generator setup to a json object.
  80106. * @returns The serialized JSON object
  80107. */
  80108. serialize(): any;
  80109. /**
  80110. * Disposes the Shadow map and related Textures and effects.
  80111. */
  80112. dispose(): void;
  80113. }
  80114. /**
  80115. * Default implementation IShadowGenerator.
  80116. * This is the main object responsible of generating shadows in the framework.
  80117. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  80118. */
  80119. export class ShadowGenerator implements IShadowGenerator {
  80120. /**
  80121. * Shadow generator mode None: no filtering applied.
  80122. */
  80123. static readonly FILTER_NONE: number;
  80124. /**
  80125. * Shadow generator mode ESM: Exponential Shadow Mapping.
  80126. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80127. */
  80128. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  80129. /**
  80130. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  80131. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  80132. */
  80133. static readonly FILTER_POISSONSAMPLING: number;
  80134. /**
  80135. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  80136. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80137. */
  80138. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  80139. /**
  80140. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  80141. * edge artifacts on steep falloff.
  80142. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80143. */
  80144. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  80145. /**
  80146. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  80147. * edge artifacts on steep falloff.
  80148. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80149. */
  80150. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  80151. /**
  80152. * Shadow generator mode PCF: Percentage Closer Filtering
  80153. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  80154. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  80155. */
  80156. static readonly FILTER_PCF: number;
  80157. /**
  80158. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  80159. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  80160. * Contact Hardening
  80161. */
  80162. static readonly FILTER_PCSS: number;
  80163. /**
  80164. * Reserved for PCF and PCSS
  80165. * Highest Quality.
  80166. *
  80167. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  80168. *
  80169. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  80170. */
  80171. static readonly QUALITY_HIGH: number;
  80172. /**
  80173. * Reserved for PCF and PCSS
  80174. * Good tradeoff for quality/perf cross devices
  80175. *
  80176. * Execute PCF on a 3*3 kernel.
  80177. *
  80178. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  80179. */
  80180. static readonly QUALITY_MEDIUM: number;
  80181. /**
  80182. * Reserved for PCF and PCSS
  80183. * The lowest quality but the fastest.
  80184. *
  80185. * Execute PCF on a 1*1 kernel.
  80186. *
  80187. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  80188. */
  80189. static readonly QUALITY_LOW: number;
  80190. /** Gets or sets the custom shader name to use */
  80191. customShaderOptions: ICustomShaderOptions;
  80192. /**
  80193. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  80194. */
  80195. onBeforeShadowMapRenderObservable: Observable<Effect>;
  80196. /**
  80197. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  80198. */
  80199. onAfterShadowMapRenderObservable: Observable<Effect>;
  80200. /**
  80201. * Observable triggered before a mesh is rendered in the shadow map.
  80202. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  80203. */
  80204. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  80205. /**
  80206. * Observable triggered after a mesh is rendered in the shadow map.
  80207. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  80208. */
  80209. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  80210. private _bias;
  80211. /**
  80212. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  80213. */
  80214. get bias(): number;
  80215. /**
  80216. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  80217. */
  80218. set bias(bias: number);
  80219. private _normalBias;
  80220. /**
  80221. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  80222. */
  80223. get normalBias(): number;
  80224. /**
  80225. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  80226. */
  80227. set normalBias(normalBias: number);
  80228. private _blurBoxOffset;
  80229. /**
  80230. * Gets the blur box offset: offset applied during the blur pass.
  80231. * Only useful if useKernelBlur = false
  80232. */
  80233. get blurBoxOffset(): number;
  80234. /**
  80235. * Sets the blur box offset: offset applied during the blur pass.
  80236. * Only useful if useKernelBlur = false
  80237. */
  80238. set blurBoxOffset(value: number);
  80239. private _blurScale;
  80240. /**
  80241. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  80242. * 2 means half of the size.
  80243. */
  80244. get blurScale(): number;
  80245. /**
  80246. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  80247. * 2 means half of the size.
  80248. */
  80249. set blurScale(value: number);
  80250. private _blurKernel;
  80251. /**
  80252. * Gets the blur kernel: kernel size of the blur pass.
  80253. * Only useful if useKernelBlur = true
  80254. */
  80255. get blurKernel(): number;
  80256. /**
  80257. * Sets the blur kernel: kernel size of the blur pass.
  80258. * Only useful if useKernelBlur = true
  80259. */
  80260. set blurKernel(value: number);
  80261. private _useKernelBlur;
  80262. /**
  80263. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  80264. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  80265. */
  80266. get useKernelBlur(): boolean;
  80267. /**
  80268. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  80269. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  80270. */
  80271. set useKernelBlur(value: boolean);
  80272. private _depthScale;
  80273. /**
  80274. * Gets the depth scale used in ESM mode.
  80275. */
  80276. get depthScale(): number;
  80277. /**
  80278. * Sets the depth scale used in ESM mode.
  80279. * This can override the scale stored on the light.
  80280. */
  80281. set depthScale(value: number);
  80282. private _filter;
  80283. /**
  80284. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  80285. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  80286. */
  80287. get filter(): number;
  80288. /**
  80289. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  80290. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  80291. */
  80292. set filter(value: number);
  80293. /**
  80294. * Gets if the current filter is set to Poisson Sampling.
  80295. */
  80296. get usePoissonSampling(): boolean;
  80297. /**
  80298. * Sets the current filter to Poisson Sampling.
  80299. */
  80300. set usePoissonSampling(value: boolean);
  80301. /**
  80302. * Gets if the current filter is set to ESM.
  80303. */
  80304. get useExponentialShadowMap(): boolean;
  80305. /**
  80306. * Sets the current filter is to ESM.
  80307. */
  80308. set useExponentialShadowMap(value: boolean);
  80309. /**
  80310. * Gets if the current filter is set to filtered ESM.
  80311. */
  80312. get useBlurExponentialShadowMap(): boolean;
  80313. /**
  80314. * Gets if the current filter is set to filtered ESM.
  80315. */
  80316. set useBlurExponentialShadowMap(value: boolean);
  80317. /**
  80318. * Gets if the current filter is set to "close ESM" (using the inverse of the
  80319. * exponential to prevent steep falloff artifacts).
  80320. */
  80321. get useCloseExponentialShadowMap(): boolean;
  80322. /**
  80323. * Sets the current filter to "close ESM" (using the inverse of the
  80324. * exponential to prevent steep falloff artifacts).
  80325. */
  80326. set useCloseExponentialShadowMap(value: boolean);
  80327. /**
  80328. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  80329. * exponential to prevent steep falloff artifacts).
  80330. */
  80331. get useBlurCloseExponentialShadowMap(): boolean;
  80332. /**
  80333. * Sets the current filter to filtered "close ESM" (using the inverse of the
  80334. * exponential to prevent steep falloff artifacts).
  80335. */
  80336. set useBlurCloseExponentialShadowMap(value: boolean);
  80337. /**
  80338. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  80339. */
  80340. get usePercentageCloserFiltering(): boolean;
  80341. /**
  80342. * Sets the current filter to "PCF" (percentage closer filtering).
  80343. */
  80344. set usePercentageCloserFiltering(value: boolean);
  80345. private _filteringQuality;
  80346. /**
  80347. * Gets the PCF or PCSS Quality.
  80348. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  80349. */
  80350. get filteringQuality(): number;
  80351. /**
  80352. * Sets the PCF or PCSS Quality.
  80353. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  80354. */
  80355. set filteringQuality(filteringQuality: number);
  80356. /**
  80357. * Gets if the current filter is set to "PCSS" (contact hardening).
  80358. */
  80359. get useContactHardeningShadow(): boolean;
  80360. /**
  80361. * Sets the current filter to "PCSS" (contact hardening).
  80362. */
  80363. set useContactHardeningShadow(value: boolean);
  80364. private _contactHardeningLightSizeUVRatio;
  80365. /**
  80366. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  80367. * Using a ratio helps keeping shape stability independently of the map size.
  80368. *
  80369. * It does not account for the light projection as it was having too much
  80370. * instability during the light setup or during light position changes.
  80371. *
  80372. * Only valid if useContactHardeningShadow is true.
  80373. */
  80374. get contactHardeningLightSizeUVRatio(): number;
  80375. /**
  80376. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  80377. * Using a ratio helps keeping shape stability independently of the map size.
  80378. *
  80379. * It does not account for the light projection as it was having too much
  80380. * instability during the light setup or during light position changes.
  80381. *
  80382. * Only valid if useContactHardeningShadow is true.
  80383. */
  80384. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  80385. private _darkness;
  80386. /** Gets or sets the actual darkness of a shadow */
  80387. get darkness(): number;
  80388. set darkness(value: number);
  80389. /**
  80390. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  80391. * 0 means strongest and 1 would means no shadow.
  80392. * @returns the darkness.
  80393. */
  80394. getDarkness(): number;
  80395. /**
  80396. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  80397. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  80398. * @returns the shadow generator allowing fluent coding.
  80399. */
  80400. setDarkness(darkness: number): ShadowGenerator;
  80401. private _transparencyShadow;
  80402. /** Gets or sets the ability to have transparent shadow */
  80403. get transparencyShadow(): boolean;
  80404. set transparencyShadow(value: boolean);
  80405. /**
  80406. * Sets the ability to have transparent shadow (boolean).
  80407. * @param transparent True if transparent else False
  80408. * @returns the shadow generator allowing fluent coding
  80409. */
  80410. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  80411. private _shadowMap;
  80412. private _shadowMap2;
  80413. /**
  80414. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  80415. * @returns The render target texture if present otherwise, null
  80416. */
  80417. getShadowMap(): Nullable<RenderTargetTexture>;
  80418. /**
  80419. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  80420. * @returns The render target texture if the shadow map is present otherwise, null
  80421. */
  80422. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  80423. /**
  80424. * Gets the class name of that object
  80425. * @returns "ShadowGenerator"
  80426. */
  80427. getClassName(): string;
  80428. /**
  80429. * Helper function to add a mesh and its descendants to the list of shadow casters.
  80430. * @param mesh Mesh to add
  80431. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  80432. * @returns the Shadow Generator itself
  80433. */
  80434. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  80435. /**
  80436. * Helper function to remove a mesh and its descendants from the list of shadow casters
  80437. * @param mesh Mesh to remove
  80438. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  80439. * @returns the Shadow Generator itself
  80440. */
  80441. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  80442. /**
  80443. * Controls the extent to which the shadows fade out at the edge of the frustum
  80444. * Used only by directionals and spots
  80445. */
  80446. frustumEdgeFalloff: number;
  80447. private _light;
  80448. /**
  80449. * Returns the associated light object.
  80450. * @returns the light generating the shadow
  80451. */
  80452. getLight(): IShadowLight;
  80453. /**
  80454. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  80455. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  80456. * It might on the other hand introduce peter panning.
  80457. */
  80458. forceBackFacesOnly: boolean;
  80459. private _scene;
  80460. private _lightDirection;
  80461. private _effect;
  80462. private _viewMatrix;
  80463. private _projectionMatrix;
  80464. private _transformMatrix;
  80465. private _cachedPosition;
  80466. private _cachedDirection;
  80467. private _cachedDefines;
  80468. private _currentRenderID;
  80469. private _boxBlurPostprocess;
  80470. private _kernelBlurXPostprocess;
  80471. private _kernelBlurYPostprocess;
  80472. private _blurPostProcesses;
  80473. private _mapSize;
  80474. private _currentFaceIndex;
  80475. private _currentFaceIndexCache;
  80476. private _textureType;
  80477. private _defaultTextureMatrix;
  80478. private _storedUniqueId;
  80479. /** @hidden */
  80480. static _SceneComponentInitialization: (scene: Scene) => void;
  80481. /**
  80482. * Creates a ShadowGenerator object.
  80483. * A ShadowGenerator is the required tool to use the shadows.
  80484. * Each light casting shadows needs to use its own ShadowGenerator.
  80485. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  80486. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  80487. * @param light The light object generating the shadows.
  80488. * @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.
  80489. */
  80490. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  80491. private _initializeGenerator;
  80492. private _initializeShadowMap;
  80493. private _initializeBlurRTTAndPostProcesses;
  80494. private _renderForShadowMap;
  80495. private _renderSubMeshForShadowMap;
  80496. private _applyFilterValues;
  80497. /**
  80498. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80499. * @param onCompiled Callback triggered at the and of the effects compilation
  80500. * @param options Sets of optional options forcing the compilation with different modes
  80501. */
  80502. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  80503. useInstances: boolean;
  80504. }>): void;
  80505. /**
  80506. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80507. * @param options Sets of optional options forcing the compilation with different modes
  80508. * @returns A promise that resolves when the compilation completes
  80509. */
  80510. forceCompilationAsync(options?: Partial<{
  80511. useInstances: boolean;
  80512. }>): Promise<void>;
  80513. /**
  80514. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  80515. * @param subMesh The submesh we want to render in the shadow map
  80516. * @param useInstances Defines wether will draw in the map using instances
  80517. * @returns true if ready otherwise, false
  80518. */
  80519. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  80520. /**
  80521. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  80522. * @param defines Defines of the material we want to update
  80523. * @param lightIndex Index of the light in the enabled light list of the material
  80524. */
  80525. prepareDefines(defines: any, lightIndex: number): void;
  80526. /**
  80527. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  80528. * defined in the generator but impacting the effect).
  80529. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  80530. * @param effect The effect we are binfing the information for
  80531. */
  80532. bindShadowLight(lightIndex: string, effect: Effect): void;
  80533. /**
  80534. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  80535. * (eq to shadow prjection matrix * light transform matrix)
  80536. * @returns The transform matrix used to create the shadow map
  80537. */
  80538. getTransformMatrix(): Matrix;
  80539. /**
  80540. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  80541. * Cube and 2D textures for instance.
  80542. */
  80543. recreateShadowMap(): void;
  80544. private _disposeBlurPostProcesses;
  80545. private _disposeRTTandPostProcesses;
  80546. /**
  80547. * Disposes the ShadowGenerator.
  80548. * Returns nothing.
  80549. */
  80550. dispose(): void;
  80551. /**
  80552. * Serializes the shadow generator setup to a json object.
  80553. * @returns The serialized JSON object
  80554. */
  80555. serialize(): any;
  80556. /**
  80557. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  80558. * @param parsedShadowGenerator The JSON object to parse
  80559. * @param scene The scene to create the shadow map for
  80560. * @returns The parsed shadow generator
  80561. */
  80562. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  80563. }
  80564. }
  80565. declare module BABYLON {
  80566. /**
  80567. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  80568. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  80569. * 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.
  80570. */
  80571. export abstract class Light extends Node {
  80572. /**
  80573. * Falloff Default: light is falling off following the material specification:
  80574. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  80575. */
  80576. static readonly FALLOFF_DEFAULT: number;
  80577. /**
  80578. * Falloff Physical: light is falling off following the inverse squared distance law.
  80579. */
  80580. static readonly FALLOFF_PHYSICAL: number;
  80581. /**
  80582. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  80583. * to enhance interoperability with other engines.
  80584. */
  80585. static readonly FALLOFF_GLTF: number;
  80586. /**
  80587. * Falloff Standard: light is falling off like in the standard material
  80588. * to enhance interoperability with other materials.
  80589. */
  80590. static readonly FALLOFF_STANDARD: number;
  80591. /**
  80592. * If every light affecting the material is in this lightmapMode,
  80593. * material.lightmapTexture adds or multiplies
  80594. * (depends on material.useLightmapAsShadowmap)
  80595. * after every other light calculations.
  80596. */
  80597. static readonly LIGHTMAP_DEFAULT: number;
  80598. /**
  80599. * material.lightmapTexture as only diffuse lighting from this light
  80600. * adds only specular lighting from this light
  80601. * adds dynamic shadows
  80602. */
  80603. static readonly LIGHTMAP_SPECULAR: number;
  80604. /**
  80605. * material.lightmapTexture as only lighting
  80606. * no light calculation from this light
  80607. * only adds dynamic shadows from this light
  80608. */
  80609. static readonly LIGHTMAP_SHADOWSONLY: number;
  80610. /**
  80611. * Each light type uses the default quantity according to its type:
  80612. * point/spot lights use luminous intensity
  80613. * directional lights use illuminance
  80614. */
  80615. static readonly INTENSITYMODE_AUTOMATIC: number;
  80616. /**
  80617. * lumen (lm)
  80618. */
  80619. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  80620. /**
  80621. * candela (lm/sr)
  80622. */
  80623. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  80624. /**
  80625. * lux (lm/m^2)
  80626. */
  80627. static readonly INTENSITYMODE_ILLUMINANCE: number;
  80628. /**
  80629. * nit (cd/m^2)
  80630. */
  80631. static readonly INTENSITYMODE_LUMINANCE: number;
  80632. /**
  80633. * Light type const id of the point light.
  80634. */
  80635. static readonly LIGHTTYPEID_POINTLIGHT: number;
  80636. /**
  80637. * Light type const id of the directional light.
  80638. */
  80639. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  80640. /**
  80641. * Light type const id of the spot light.
  80642. */
  80643. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  80644. /**
  80645. * Light type const id of the hemispheric light.
  80646. */
  80647. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  80648. /**
  80649. * Diffuse gives the basic color to an object.
  80650. */
  80651. diffuse: Color3;
  80652. /**
  80653. * Specular produces a highlight color on an object.
  80654. * Note: This is note affecting PBR materials.
  80655. */
  80656. specular: Color3;
  80657. /**
  80658. * Defines the falloff type for this light. This lets overrriding how punctual light are
  80659. * falling off base on range or angle.
  80660. * This can be set to any values in Light.FALLOFF_x.
  80661. *
  80662. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  80663. * other types of materials.
  80664. */
  80665. falloffType: number;
  80666. /**
  80667. * Strength of the light.
  80668. * Note: By default it is define in the framework own unit.
  80669. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  80670. */
  80671. intensity: number;
  80672. private _range;
  80673. protected _inverseSquaredRange: number;
  80674. /**
  80675. * Defines how far from the source the light is impacting in scene units.
  80676. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  80677. */
  80678. get range(): number;
  80679. /**
  80680. * Defines how far from the source the light is impacting in scene units.
  80681. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  80682. */
  80683. set range(value: number);
  80684. /**
  80685. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  80686. * of light.
  80687. */
  80688. private _photometricScale;
  80689. private _intensityMode;
  80690. /**
  80691. * Gets the photometric scale used to interpret the intensity.
  80692. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  80693. */
  80694. get intensityMode(): number;
  80695. /**
  80696. * Sets the photometric scale used to interpret the intensity.
  80697. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  80698. */
  80699. set intensityMode(value: number);
  80700. private _radius;
  80701. /**
  80702. * Gets the light radius used by PBR Materials to simulate soft area lights.
  80703. */
  80704. get radius(): number;
  80705. /**
  80706. * sets the light radius used by PBR Materials to simulate soft area lights.
  80707. */
  80708. set radius(value: number);
  80709. private _renderPriority;
  80710. /**
  80711. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  80712. * exceeding the number allowed of the materials.
  80713. */
  80714. renderPriority: number;
  80715. private _shadowEnabled;
  80716. /**
  80717. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  80718. * the current shadow generator.
  80719. */
  80720. get shadowEnabled(): boolean;
  80721. /**
  80722. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  80723. * the current shadow generator.
  80724. */
  80725. set shadowEnabled(value: boolean);
  80726. private _includedOnlyMeshes;
  80727. /**
  80728. * Gets the only meshes impacted by this light.
  80729. */
  80730. get includedOnlyMeshes(): AbstractMesh[];
  80731. /**
  80732. * Sets the only meshes impacted by this light.
  80733. */
  80734. set includedOnlyMeshes(value: AbstractMesh[]);
  80735. private _excludedMeshes;
  80736. /**
  80737. * Gets the meshes not impacted by this light.
  80738. */
  80739. get excludedMeshes(): AbstractMesh[];
  80740. /**
  80741. * Sets the meshes not impacted by this light.
  80742. */
  80743. set excludedMeshes(value: AbstractMesh[]);
  80744. private _excludeWithLayerMask;
  80745. /**
  80746. * Gets the layer id use to find what meshes are not impacted by the light.
  80747. * Inactive if 0
  80748. */
  80749. get excludeWithLayerMask(): number;
  80750. /**
  80751. * Sets the layer id use to find what meshes are not impacted by the light.
  80752. * Inactive if 0
  80753. */
  80754. set excludeWithLayerMask(value: number);
  80755. private _includeOnlyWithLayerMask;
  80756. /**
  80757. * Gets the layer id use to find what meshes are impacted by the light.
  80758. * Inactive if 0
  80759. */
  80760. get includeOnlyWithLayerMask(): number;
  80761. /**
  80762. * Sets the layer id use to find what meshes are impacted by the light.
  80763. * Inactive if 0
  80764. */
  80765. set includeOnlyWithLayerMask(value: number);
  80766. private _lightmapMode;
  80767. /**
  80768. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  80769. */
  80770. get lightmapMode(): number;
  80771. /**
  80772. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  80773. */
  80774. set lightmapMode(value: number);
  80775. /**
  80776. * Shadow generator associted to the light.
  80777. * @hidden Internal use only.
  80778. */
  80779. _shadowGenerator: Nullable<IShadowGenerator>;
  80780. /**
  80781. * @hidden Internal use only.
  80782. */
  80783. _excludedMeshesIds: string[];
  80784. /**
  80785. * @hidden Internal use only.
  80786. */
  80787. _includedOnlyMeshesIds: string[];
  80788. /**
  80789. * The current light unifom buffer.
  80790. * @hidden Internal use only.
  80791. */
  80792. _uniformBuffer: UniformBuffer;
  80793. /** @hidden */
  80794. _renderId: number;
  80795. /**
  80796. * Creates a Light object in the scene.
  80797. * Documentation : https://doc.babylonjs.com/babylon101/lights
  80798. * @param name The firendly name of the light
  80799. * @param scene The scene the light belongs too
  80800. */
  80801. constructor(name: string, scene: Scene);
  80802. protected abstract _buildUniformLayout(): void;
  80803. /**
  80804. * Sets the passed Effect "effect" with the Light information.
  80805. * @param effect The effect to update
  80806. * @param lightIndex The index of the light in the effect to update
  80807. * @returns The light
  80808. */
  80809. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  80810. /**
  80811. * Sets the passed Effect "effect" with the Light textures.
  80812. * @param effect The effect to update
  80813. * @param lightIndex The index of the light in the effect to update
  80814. * @returns The light
  80815. */
  80816. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  80817. /**
  80818. * Binds the lights information from the scene to the effect for the given mesh.
  80819. * @param lightIndex Light index
  80820. * @param scene The scene where the light belongs to
  80821. * @param effect The effect we are binding the data to
  80822. * @param useSpecular Defines if specular is supported
  80823. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  80824. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  80825. */
  80826. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  80827. /**
  80828. * Sets the passed Effect "effect" with the Light information.
  80829. * @param effect The effect to update
  80830. * @param lightDataUniformName The uniform used to store light data (position or direction)
  80831. * @returns The light
  80832. */
  80833. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  80834. /**
  80835. * Returns the string "Light".
  80836. * @returns the class name
  80837. */
  80838. getClassName(): string;
  80839. /** @hidden */
  80840. readonly _isLight: boolean;
  80841. /**
  80842. * Converts the light information to a readable string for debug purpose.
  80843. * @param fullDetails Supports for multiple levels of logging within scene loading
  80844. * @returns the human readable light info
  80845. */
  80846. toString(fullDetails?: boolean): string;
  80847. /** @hidden */
  80848. protected _syncParentEnabledState(): void;
  80849. /**
  80850. * Set the enabled state of this node.
  80851. * @param value - the new enabled state
  80852. */
  80853. setEnabled(value: boolean): void;
  80854. /**
  80855. * Returns the Light associated shadow generator if any.
  80856. * @return the associated shadow generator.
  80857. */
  80858. getShadowGenerator(): Nullable<IShadowGenerator>;
  80859. /**
  80860. * Returns a Vector3, the absolute light position in the World.
  80861. * @returns the world space position of the light
  80862. */
  80863. getAbsolutePosition(): Vector3;
  80864. /**
  80865. * Specifies if the light will affect the passed mesh.
  80866. * @param mesh The mesh to test against the light
  80867. * @return true the mesh is affected otherwise, false.
  80868. */
  80869. canAffectMesh(mesh: AbstractMesh): boolean;
  80870. /**
  80871. * Sort function to order lights for rendering.
  80872. * @param a First Light object to compare to second.
  80873. * @param b Second Light object to compare first.
  80874. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  80875. */
  80876. static CompareLightsPriority(a: Light, b: Light): number;
  80877. /**
  80878. * Releases resources associated with this node.
  80879. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80880. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80881. */
  80882. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80883. /**
  80884. * Returns the light type ID (integer).
  80885. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  80886. */
  80887. getTypeID(): number;
  80888. /**
  80889. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  80890. * @returns the scaled intensity in intensity mode unit
  80891. */
  80892. getScaledIntensity(): number;
  80893. /**
  80894. * Returns a new Light object, named "name", from the current one.
  80895. * @param name The name of the cloned light
  80896. * @returns the new created light
  80897. */
  80898. clone(name: string): Nullable<Light>;
  80899. /**
  80900. * Serializes the current light into a Serialization object.
  80901. * @returns the serialized object.
  80902. */
  80903. serialize(): any;
  80904. /**
  80905. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  80906. * This new light is named "name" and added to the passed scene.
  80907. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  80908. * @param name The friendly name of the light
  80909. * @param scene The scene the new light will belong to
  80910. * @returns the constructor function
  80911. */
  80912. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  80913. /**
  80914. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  80915. * @param parsedLight The JSON representation of the light
  80916. * @param scene The scene to create the parsed light in
  80917. * @returns the created light after parsing
  80918. */
  80919. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  80920. private _hookArrayForExcluded;
  80921. private _hookArrayForIncludedOnly;
  80922. private _resyncMeshes;
  80923. /**
  80924. * Forces the meshes to update their light related information in their rendering used effects
  80925. * @hidden Internal Use Only
  80926. */
  80927. _markMeshesAsLightDirty(): void;
  80928. /**
  80929. * Recomputes the cached photometric scale if needed.
  80930. */
  80931. private _computePhotometricScale;
  80932. /**
  80933. * Returns the Photometric Scale according to the light type and intensity mode.
  80934. */
  80935. private _getPhotometricScale;
  80936. /**
  80937. * Reorder the light in the scene according to their defined priority.
  80938. * @hidden Internal Use Only
  80939. */
  80940. _reorderLightsInScene(): void;
  80941. /**
  80942. * Prepares the list of defines specific to the light type.
  80943. * @param defines the list of defines
  80944. * @param lightIndex defines the index of the light for the effect
  80945. */
  80946. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  80947. }
  80948. }
  80949. declare module BABYLON {
  80950. /**
  80951. * Interface used to define Action
  80952. */
  80953. export interface IAction {
  80954. /**
  80955. * Trigger for the action
  80956. */
  80957. trigger: number;
  80958. /** Options of the trigger */
  80959. triggerOptions: any;
  80960. /**
  80961. * Gets the trigger parameters
  80962. * @returns the trigger parameters
  80963. */
  80964. getTriggerParameter(): any;
  80965. /**
  80966. * Internal only - executes current action event
  80967. * @hidden
  80968. */
  80969. _executeCurrent(evt?: ActionEvent): void;
  80970. /**
  80971. * Serialize placeholder for child classes
  80972. * @param parent of child
  80973. * @returns the serialized object
  80974. */
  80975. serialize(parent: any): any;
  80976. /**
  80977. * Internal only
  80978. * @hidden
  80979. */
  80980. _prepare(): void;
  80981. /**
  80982. * Internal only - manager for action
  80983. * @hidden
  80984. */
  80985. _actionManager: AbstractActionManager;
  80986. /**
  80987. * Adds action to chain of actions, may be a DoNothingAction
  80988. * @param action defines the next action to execute
  80989. * @returns The action passed in
  80990. * @see https://www.babylonjs-playground.com/#1T30HR#0
  80991. */
  80992. then(action: IAction): IAction;
  80993. }
  80994. /**
  80995. * The action to be carried out following a trigger
  80996. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  80997. */
  80998. export class Action implements IAction {
  80999. /** the trigger, with or without parameters, for the action */
  81000. triggerOptions: any;
  81001. /**
  81002. * Trigger for the action
  81003. */
  81004. trigger: number;
  81005. /**
  81006. * Internal only - manager for action
  81007. * @hidden
  81008. */
  81009. _actionManager: ActionManager;
  81010. private _nextActiveAction;
  81011. private _child;
  81012. private _condition?;
  81013. private _triggerParameter;
  81014. /**
  81015. * An event triggered prior to action being executed.
  81016. */
  81017. onBeforeExecuteObservable: Observable<Action>;
  81018. /**
  81019. * Creates a new Action
  81020. * @param triggerOptions the trigger, with or without parameters, for the action
  81021. * @param condition an optional determinant of action
  81022. */
  81023. constructor(
  81024. /** the trigger, with or without parameters, for the action */
  81025. triggerOptions: any, condition?: Condition);
  81026. /**
  81027. * Internal only
  81028. * @hidden
  81029. */
  81030. _prepare(): void;
  81031. /**
  81032. * Gets the trigger parameters
  81033. * @returns the trigger parameters
  81034. */
  81035. getTriggerParameter(): any;
  81036. /**
  81037. * Internal only - executes current action event
  81038. * @hidden
  81039. */
  81040. _executeCurrent(evt?: ActionEvent): void;
  81041. /**
  81042. * Execute placeholder for child classes
  81043. * @param evt optional action event
  81044. */
  81045. execute(evt?: ActionEvent): void;
  81046. /**
  81047. * Skips to next active action
  81048. */
  81049. skipToNextActiveAction(): void;
  81050. /**
  81051. * Adds action to chain of actions, may be a DoNothingAction
  81052. * @param action defines the next action to execute
  81053. * @returns The action passed in
  81054. * @see https://www.babylonjs-playground.com/#1T30HR#0
  81055. */
  81056. then(action: Action): Action;
  81057. /**
  81058. * Internal only
  81059. * @hidden
  81060. */
  81061. _getProperty(propertyPath: string): string;
  81062. /**
  81063. * Internal only
  81064. * @hidden
  81065. */
  81066. _getEffectiveTarget(target: any, propertyPath: string): any;
  81067. /**
  81068. * Serialize placeholder for child classes
  81069. * @param parent of child
  81070. * @returns the serialized object
  81071. */
  81072. serialize(parent: any): any;
  81073. /**
  81074. * Internal only called by serialize
  81075. * @hidden
  81076. */
  81077. protected _serialize(serializedAction: any, parent?: any): any;
  81078. /**
  81079. * Internal only
  81080. * @hidden
  81081. */
  81082. static _SerializeValueAsString: (value: any) => string;
  81083. /**
  81084. * Internal only
  81085. * @hidden
  81086. */
  81087. static _GetTargetProperty: (target: Node | Scene) => {
  81088. name: string;
  81089. targetType: string;
  81090. value: string;
  81091. };
  81092. }
  81093. }
  81094. declare module BABYLON {
  81095. /**
  81096. * A Condition applied to an Action
  81097. */
  81098. export class Condition {
  81099. /**
  81100. * Internal only - manager for action
  81101. * @hidden
  81102. */
  81103. _actionManager: ActionManager;
  81104. /**
  81105. * Internal only
  81106. * @hidden
  81107. */
  81108. _evaluationId: number;
  81109. /**
  81110. * Internal only
  81111. * @hidden
  81112. */
  81113. _currentResult: boolean;
  81114. /**
  81115. * Creates a new Condition
  81116. * @param actionManager the manager of the action the condition is applied to
  81117. */
  81118. constructor(actionManager: ActionManager);
  81119. /**
  81120. * Check if the current condition is valid
  81121. * @returns a boolean
  81122. */
  81123. isValid(): boolean;
  81124. /**
  81125. * Internal only
  81126. * @hidden
  81127. */
  81128. _getProperty(propertyPath: string): string;
  81129. /**
  81130. * Internal only
  81131. * @hidden
  81132. */
  81133. _getEffectiveTarget(target: any, propertyPath: string): any;
  81134. /**
  81135. * Serialize placeholder for child classes
  81136. * @returns the serialized object
  81137. */
  81138. serialize(): any;
  81139. /**
  81140. * Internal only
  81141. * @hidden
  81142. */
  81143. protected _serialize(serializedCondition: any): any;
  81144. }
  81145. /**
  81146. * Defines specific conditional operators as extensions of Condition
  81147. */
  81148. export class ValueCondition extends Condition {
  81149. /** path to specify the property of the target the conditional operator uses */
  81150. propertyPath: string;
  81151. /** the value compared by the conditional operator against the current value of the property */
  81152. value: any;
  81153. /** the conditional operator, default ValueCondition.IsEqual */
  81154. operator: number;
  81155. /**
  81156. * Internal only
  81157. * @hidden
  81158. */
  81159. private static _IsEqual;
  81160. /**
  81161. * Internal only
  81162. * @hidden
  81163. */
  81164. private static _IsDifferent;
  81165. /**
  81166. * Internal only
  81167. * @hidden
  81168. */
  81169. private static _IsGreater;
  81170. /**
  81171. * Internal only
  81172. * @hidden
  81173. */
  81174. private static _IsLesser;
  81175. /**
  81176. * returns the number for IsEqual
  81177. */
  81178. static get IsEqual(): number;
  81179. /**
  81180. * Returns the number for IsDifferent
  81181. */
  81182. static get IsDifferent(): number;
  81183. /**
  81184. * Returns the number for IsGreater
  81185. */
  81186. static get IsGreater(): number;
  81187. /**
  81188. * Returns the number for IsLesser
  81189. */
  81190. static get IsLesser(): number;
  81191. /**
  81192. * Internal only The action manager for the condition
  81193. * @hidden
  81194. */
  81195. _actionManager: ActionManager;
  81196. /**
  81197. * Internal only
  81198. * @hidden
  81199. */
  81200. private _target;
  81201. /**
  81202. * Internal only
  81203. * @hidden
  81204. */
  81205. private _effectiveTarget;
  81206. /**
  81207. * Internal only
  81208. * @hidden
  81209. */
  81210. private _property;
  81211. /**
  81212. * Creates a new ValueCondition
  81213. * @param actionManager manager for the action the condition applies to
  81214. * @param target for the action
  81215. * @param propertyPath path to specify the property of the target the conditional operator uses
  81216. * @param value the value compared by the conditional operator against the current value of the property
  81217. * @param operator the conditional operator, default ValueCondition.IsEqual
  81218. */
  81219. constructor(actionManager: ActionManager, target: any,
  81220. /** path to specify the property of the target the conditional operator uses */
  81221. propertyPath: string,
  81222. /** the value compared by the conditional operator against the current value of the property */
  81223. value: any,
  81224. /** the conditional operator, default ValueCondition.IsEqual */
  81225. operator?: number);
  81226. /**
  81227. * Compares the given value with the property value for the specified conditional operator
  81228. * @returns the result of the comparison
  81229. */
  81230. isValid(): boolean;
  81231. /**
  81232. * Serialize the ValueCondition into a JSON compatible object
  81233. * @returns serialization object
  81234. */
  81235. serialize(): any;
  81236. /**
  81237. * Gets the name of the conditional operator for the ValueCondition
  81238. * @param operator the conditional operator
  81239. * @returns the name
  81240. */
  81241. static GetOperatorName(operator: number): string;
  81242. }
  81243. /**
  81244. * Defines a predicate condition as an extension of Condition
  81245. */
  81246. export class PredicateCondition extends Condition {
  81247. /** defines the predicate function used to validate the condition */
  81248. predicate: () => boolean;
  81249. /**
  81250. * Internal only - manager for action
  81251. * @hidden
  81252. */
  81253. _actionManager: ActionManager;
  81254. /**
  81255. * Creates a new PredicateCondition
  81256. * @param actionManager manager for the action the condition applies to
  81257. * @param predicate defines the predicate function used to validate the condition
  81258. */
  81259. constructor(actionManager: ActionManager,
  81260. /** defines the predicate function used to validate the condition */
  81261. predicate: () => boolean);
  81262. /**
  81263. * @returns the validity of the predicate condition
  81264. */
  81265. isValid(): boolean;
  81266. }
  81267. /**
  81268. * Defines a state condition as an extension of Condition
  81269. */
  81270. export class StateCondition extends Condition {
  81271. /** Value to compare with target state */
  81272. value: string;
  81273. /**
  81274. * Internal only - manager for action
  81275. * @hidden
  81276. */
  81277. _actionManager: ActionManager;
  81278. /**
  81279. * Internal only
  81280. * @hidden
  81281. */
  81282. private _target;
  81283. /**
  81284. * Creates a new StateCondition
  81285. * @param actionManager manager for the action the condition applies to
  81286. * @param target of the condition
  81287. * @param value to compare with target state
  81288. */
  81289. constructor(actionManager: ActionManager, target: any,
  81290. /** Value to compare with target state */
  81291. value: string);
  81292. /**
  81293. * Gets a boolean indicating if the current condition is met
  81294. * @returns the validity of the state
  81295. */
  81296. isValid(): boolean;
  81297. /**
  81298. * Serialize the StateCondition into a JSON compatible object
  81299. * @returns serialization object
  81300. */
  81301. serialize(): any;
  81302. }
  81303. }
  81304. declare module BABYLON {
  81305. /**
  81306. * This defines an action responsible to toggle a boolean once triggered.
  81307. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81308. */
  81309. export class SwitchBooleanAction extends Action {
  81310. /**
  81311. * The path to the boolean property in the target object
  81312. */
  81313. propertyPath: string;
  81314. private _target;
  81315. private _effectiveTarget;
  81316. private _property;
  81317. /**
  81318. * Instantiate the action
  81319. * @param triggerOptions defines the trigger options
  81320. * @param target defines the object containing the boolean
  81321. * @param propertyPath defines the path to the boolean property in the target object
  81322. * @param condition defines the trigger related conditions
  81323. */
  81324. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  81325. /** @hidden */
  81326. _prepare(): void;
  81327. /**
  81328. * Execute the action toggle the boolean value.
  81329. */
  81330. execute(): void;
  81331. /**
  81332. * Serializes the actions and its related information.
  81333. * @param parent defines the object to serialize in
  81334. * @returns the serialized object
  81335. */
  81336. serialize(parent: any): any;
  81337. }
  81338. /**
  81339. * This defines an action responsible to set a the state field of the target
  81340. * to a desired value once triggered.
  81341. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81342. */
  81343. export class SetStateAction extends Action {
  81344. /**
  81345. * The value to store in the state field.
  81346. */
  81347. value: string;
  81348. private _target;
  81349. /**
  81350. * Instantiate the action
  81351. * @param triggerOptions defines the trigger options
  81352. * @param target defines the object containing the state property
  81353. * @param value defines the value to store in the state field
  81354. * @param condition defines the trigger related conditions
  81355. */
  81356. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  81357. /**
  81358. * Execute the action and store the value on the target state property.
  81359. */
  81360. execute(): void;
  81361. /**
  81362. * Serializes the actions and its related information.
  81363. * @param parent defines the object to serialize in
  81364. * @returns the serialized object
  81365. */
  81366. serialize(parent: any): any;
  81367. }
  81368. /**
  81369. * This defines an action responsible to set a property of the target
  81370. * to a desired value once triggered.
  81371. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81372. */
  81373. export class SetValueAction extends Action {
  81374. /**
  81375. * The path of the property to set in the target.
  81376. */
  81377. propertyPath: string;
  81378. /**
  81379. * The value to set in the property
  81380. */
  81381. value: any;
  81382. private _target;
  81383. private _effectiveTarget;
  81384. private _property;
  81385. /**
  81386. * Instantiate the action
  81387. * @param triggerOptions defines the trigger options
  81388. * @param target defines the object containing the property
  81389. * @param propertyPath defines the path of the property to set in the target
  81390. * @param value defines the value to set in the property
  81391. * @param condition defines the trigger related conditions
  81392. */
  81393. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  81394. /** @hidden */
  81395. _prepare(): void;
  81396. /**
  81397. * Execute the action and set the targetted property to the desired value.
  81398. */
  81399. execute(): void;
  81400. /**
  81401. * Serializes the actions and its related information.
  81402. * @param parent defines the object to serialize in
  81403. * @returns the serialized object
  81404. */
  81405. serialize(parent: any): any;
  81406. }
  81407. /**
  81408. * This defines an action responsible to increment the target value
  81409. * to a desired value once triggered.
  81410. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81411. */
  81412. export class IncrementValueAction extends Action {
  81413. /**
  81414. * The path of the property to increment in the target.
  81415. */
  81416. propertyPath: string;
  81417. /**
  81418. * The value we should increment the property by.
  81419. */
  81420. value: any;
  81421. private _target;
  81422. private _effectiveTarget;
  81423. private _property;
  81424. /**
  81425. * Instantiate the action
  81426. * @param triggerOptions defines the trigger options
  81427. * @param target defines the object containing the property
  81428. * @param propertyPath defines the path of the property to increment in the target
  81429. * @param value defines the value value we should increment the property by
  81430. * @param condition defines the trigger related conditions
  81431. */
  81432. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  81433. /** @hidden */
  81434. _prepare(): void;
  81435. /**
  81436. * Execute the action and increment the target of the value amount.
  81437. */
  81438. execute(): void;
  81439. /**
  81440. * Serializes the actions and its related information.
  81441. * @param parent defines the object to serialize in
  81442. * @returns the serialized object
  81443. */
  81444. serialize(parent: any): any;
  81445. }
  81446. /**
  81447. * This defines an action responsible to start an animation once triggered.
  81448. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81449. */
  81450. export class PlayAnimationAction extends Action {
  81451. /**
  81452. * Where the animation should start (animation frame)
  81453. */
  81454. from: number;
  81455. /**
  81456. * Where the animation should stop (animation frame)
  81457. */
  81458. to: number;
  81459. /**
  81460. * Define if the animation should loop or stop after the first play.
  81461. */
  81462. loop?: boolean;
  81463. private _target;
  81464. /**
  81465. * Instantiate the action
  81466. * @param triggerOptions defines the trigger options
  81467. * @param target defines the target animation or animation name
  81468. * @param from defines from where the animation should start (animation frame)
  81469. * @param end defines where the animation should stop (animation frame)
  81470. * @param loop defines if the animation should loop or stop after the first play
  81471. * @param condition defines the trigger related conditions
  81472. */
  81473. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  81474. /** @hidden */
  81475. _prepare(): void;
  81476. /**
  81477. * Execute the action and play the animation.
  81478. */
  81479. execute(): void;
  81480. /**
  81481. * Serializes the actions and its related information.
  81482. * @param parent defines the object to serialize in
  81483. * @returns the serialized object
  81484. */
  81485. serialize(parent: any): any;
  81486. }
  81487. /**
  81488. * This defines an action responsible to stop an animation once triggered.
  81489. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81490. */
  81491. export class StopAnimationAction extends Action {
  81492. private _target;
  81493. /**
  81494. * Instantiate the action
  81495. * @param triggerOptions defines the trigger options
  81496. * @param target defines the target animation or animation name
  81497. * @param condition defines the trigger related conditions
  81498. */
  81499. constructor(triggerOptions: any, target: any, condition?: Condition);
  81500. /** @hidden */
  81501. _prepare(): void;
  81502. /**
  81503. * Execute the action and stop the animation.
  81504. */
  81505. execute(): void;
  81506. /**
  81507. * Serializes the actions and its related information.
  81508. * @param parent defines the object to serialize in
  81509. * @returns the serialized object
  81510. */
  81511. serialize(parent: any): any;
  81512. }
  81513. /**
  81514. * This defines an action responsible that does nothing once triggered.
  81515. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81516. */
  81517. export class DoNothingAction extends Action {
  81518. /**
  81519. * Instantiate the action
  81520. * @param triggerOptions defines the trigger options
  81521. * @param condition defines the trigger related conditions
  81522. */
  81523. constructor(triggerOptions?: any, condition?: Condition);
  81524. /**
  81525. * Execute the action and do nothing.
  81526. */
  81527. execute(): void;
  81528. /**
  81529. * Serializes the actions and its related information.
  81530. * @param parent defines the object to serialize in
  81531. * @returns the serialized object
  81532. */
  81533. serialize(parent: any): any;
  81534. }
  81535. /**
  81536. * This defines an action responsible to trigger several actions once triggered.
  81537. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81538. */
  81539. export class CombineAction extends Action {
  81540. /**
  81541. * The list of aggregated animations to run.
  81542. */
  81543. children: Action[];
  81544. /**
  81545. * Instantiate the action
  81546. * @param triggerOptions defines the trigger options
  81547. * @param children defines the list of aggregated animations to run
  81548. * @param condition defines the trigger related conditions
  81549. */
  81550. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  81551. /** @hidden */
  81552. _prepare(): void;
  81553. /**
  81554. * Execute the action and executes all the aggregated actions.
  81555. */
  81556. execute(evt: ActionEvent): void;
  81557. /**
  81558. * Serializes the actions and its related information.
  81559. * @param parent defines the object to serialize in
  81560. * @returns the serialized object
  81561. */
  81562. serialize(parent: any): any;
  81563. }
  81564. /**
  81565. * This defines an action responsible to run code (external event) once triggered.
  81566. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81567. */
  81568. export class ExecuteCodeAction extends Action {
  81569. /**
  81570. * The callback function to run.
  81571. */
  81572. func: (evt: ActionEvent) => void;
  81573. /**
  81574. * Instantiate the action
  81575. * @param triggerOptions defines the trigger options
  81576. * @param func defines the callback function to run
  81577. * @param condition defines the trigger related conditions
  81578. */
  81579. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  81580. /**
  81581. * Execute the action and run the attached code.
  81582. */
  81583. execute(evt: ActionEvent): void;
  81584. }
  81585. /**
  81586. * This defines an action responsible to set the parent property of the target once triggered.
  81587. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81588. */
  81589. export class SetParentAction extends Action {
  81590. private _parent;
  81591. private _target;
  81592. /**
  81593. * Instantiate the action
  81594. * @param triggerOptions defines the trigger options
  81595. * @param target defines the target containing the parent property
  81596. * @param parent defines from where the animation should start (animation frame)
  81597. * @param condition defines the trigger related conditions
  81598. */
  81599. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  81600. /** @hidden */
  81601. _prepare(): void;
  81602. /**
  81603. * Execute the action and set the parent property.
  81604. */
  81605. execute(): void;
  81606. /**
  81607. * Serializes the actions and its related information.
  81608. * @param parent defines the object to serialize in
  81609. * @returns the serialized object
  81610. */
  81611. serialize(parent: any): any;
  81612. }
  81613. }
  81614. declare module BABYLON {
  81615. /**
  81616. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  81617. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  81618. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81619. */
  81620. export class ActionManager extends AbstractActionManager {
  81621. /**
  81622. * Nothing
  81623. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81624. */
  81625. static readonly NothingTrigger: number;
  81626. /**
  81627. * On pick
  81628. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81629. */
  81630. static readonly OnPickTrigger: number;
  81631. /**
  81632. * On left pick
  81633. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81634. */
  81635. static readonly OnLeftPickTrigger: number;
  81636. /**
  81637. * On right pick
  81638. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81639. */
  81640. static readonly OnRightPickTrigger: number;
  81641. /**
  81642. * On center pick
  81643. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81644. */
  81645. static readonly OnCenterPickTrigger: number;
  81646. /**
  81647. * On pick down
  81648. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81649. */
  81650. static readonly OnPickDownTrigger: number;
  81651. /**
  81652. * On double pick
  81653. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81654. */
  81655. static readonly OnDoublePickTrigger: number;
  81656. /**
  81657. * On pick up
  81658. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81659. */
  81660. static readonly OnPickUpTrigger: number;
  81661. /**
  81662. * On pick out.
  81663. * This trigger will only be raised if you also declared a OnPickDown
  81664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81665. */
  81666. static readonly OnPickOutTrigger: number;
  81667. /**
  81668. * On long press
  81669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81670. */
  81671. static readonly OnLongPressTrigger: number;
  81672. /**
  81673. * On pointer over
  81674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81675. */
  81676. static readonly OnPointerOverTrigger: number;
  81677. /**
  81678. * On pointer out
  81679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81680. */
  81681. static readonly OnPointerOutTrigger: number;
  81682. /**
  81683. * On every frame
  81684. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81685. */
  81686. static readonly OnEveryFrameTrigger: number;
  81687. /**
  81688. * On intersection enter
  81689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81690. */
  81691. static readonly OnIntersectionEnterTrigger: number;
  81692. /**
  81693. * On intersection exit
  81694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81695. */
  81696. static readonly OnIntersectionExitTrigger: number;
  81697. /**
  81698. * On key down
  81699. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81700. */
  81701. static readonly OnKeyDownTrigger: number;
  81702. /**
  81703. * On key up
  81704. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81705. */
  81706. static readonly OnKeyUpTrigger: number;
  81707. private _scene;
  81708. /**
  81709. * Creates a new action manager
  81710. * @param scene defines the hosting scene
  81711. */
  81712. constructor(scene: Scene);
  81713. /**
  81714. * Releases all associated resources
  81715. */
  81716. dispose(): void;
  81717. /**
  81718. * Gets hosting scene
  81719. * @returns the hosting scene
  81720. */
  81721. getScene(): Scene;
  81722. /**
  81723. * Does this action manager handles actions of any of the given triggers
  81724. * @param triggers defines the triggers to be tested
  81725. * @return a boolean indicating whether one (or more) of the triggers is handled
  81726. */
  81727. hasSpecificTriggers(triggers: number[]): boolean;
  81728. /**
  81729. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  81730. * speed.
  81731. * @param triggerA defines the trigger to be tested
  81732. * @param triggerB defines the trigger to be tested
  81733. * @return a boolean indicating whether one (or more) of the triggers is handled
  81734. */
  81735. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  81736. /**
  81737. * Does this action manager handles actions of a given trigger
  81738. * @param trigger defines the trigger to be tested
  81739. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  81740. * @return whether the trigger is handled
  81741. */
  81742. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  81743. /**
  81744. * Does this action manager has pointer triggers
  81745. */
  81746. get hasPointerTriggers(): boolean;
  81747. /**
  81748. * Does this action manager has pick triggers
  81749. */
  81750. get hasPickTriggers(): boolean;
  81751. /**
  81752. * Registers an action to this action manager
  81753. * @param action defines the action to be registered
  81754. * @return the action amended (prepared) after registration
  81755. */
  81756. registerAction(action: IAction): Nullable<IAction>;
  81757. /**
  81758. * Unregisters an action to this action manager
  81759. * @param action defines the action to be unregistered
  81760. * @return a boolean indicating whether the action has been unregistered
  81761. */
  81762. unregisterAction(action: IAction): Boolean;
  81763. /**
  81764. * Process a specific trigger
  81765. * @param trigger defines the trigger to process
  81766. * @param evt defines the event details to be processed
  81767. */
  81768. processTrigger(trigger: number, evt?: IActionEvent): void;
  81769. /** @hidden */
  81770. _getEffectiveTarget(target: any, propertyPath: string): any;
  81771. /** @hidden */
  81772. _getProperty(propertyPath: string): string;
  81773. /**
  81774. * Serialize this manager to a JSON object
  81775. * @param name defines the property name to store this manager
  81776. * @returns a JSON representation of this manager
  81777. */
  81778. serialize(name: string): any;
  81779. /**
  81780. * Creates a new ActionManager from a JSON data
  81781. * @param parsedActions defines the JSON data to read from
  81782. * @param object defines the hosting mesh
  81783. * @param scene defines the hosting scene
  81784. */
  81785. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  81786. /**
  81787. * Get a trigger name by index
  81788. * @param trigger defines the trigger index
  81789. * @returns a trigger name
  81790. */
  81791. static GetTriggerName(trigger: number): string;
  81792. }
  81793. }
  81794. declare module BABYLON {
  81795. /**
  81796. * Class representing a ray with position and direction
  81797. */
  81798. export class Ray {
  81799. /** origin point */
  81800. origin: Vector3;
  81801. /** direction */
  81802. direction: Vector3;
  81803. /** length of the ray */
  81804. length: number;
  81805. private static readonly TmpVector3;
  81806. private _tmpRay;
  81807. /**
  81808. * Creates a new ray
  81809. * @param origin origin point
  81810. * @param direction direction
  81811. * @param length length of the ray
  81812. */
  81813. constructor(
  81814. /** origin point */
  81815. origin: Vector3,
  81816. /** direction */
  81817. direction: Vector3,
  81818. /** length of the ray */
  81819. length?: number);
  81820. /**
  81821. * Checks if the ray intersects a box
  81822. * @param minimum bound of the box
  81823. * @param maximum bound of the box
  81824. * @param intersectionTreshold extra extend to be added to the box in all direction
  81825. * @returns if the box was hit
  81826. */
  81827. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  81828. /**
  81829. * Checks if the ray intersects a box
  81830. * @param box the bounding box to check
  81831. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  81832. * @returns if the box was hit
  81833. */
  81834. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  81835. /**
  81836. * If the ray hits a sphere
  81837. * @param sphere the bounding sphere to check
  81838. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  81839. * @returns true if it hits the sphere
  81840. */
  81841. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  81842. /**
  81843. * If the ray hits a triange
  81844. * @param vertex0 triangle vertex
  81845. * @param vertex1 triangle vertex
  81846. * @param vertex2 triangle vertex
  81847. * @returns intersection information if hit
  81848. */
  81849. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  81850. /**
  81851. * Checks if ray intersects a plane
  81852. * @param plane the plane to check
  81853. * @returns the distance away it was hit
  81854. */
  81855. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  81856. /**
  81857. * Calculate the intercept of a ray on a given axis
  81858. * @param axis to check 'x' | 'y' | 'z'
  81859. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  81860. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  81861. */
  81862. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  81863. /**
  81864. * Checks if ray intersects a mesh
  81865. * @param mesh the mesh to check
  81866. * @param fastCheck if only the bounding box should checked
  81867. * @returns picking info of the intersecton
  81868. */
  81869. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  81870. /**
  81871. * Checks if ray intersects a mesh
  81872. * @param meshes the meshes to check
  81873. * @param fastCheck if only the bounding box should checked
  81874. * @param results array to store result in
  81875. * @returns Array of picking infos
  81876. */
  81877. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  81878. private _comparePickingInfo;
  81879. private static smallnum;
  81880. private static rayl;
  81881. /**
  81882. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  81883. * @param sega the first point of the segment to test the intersection against
  81884. * @param segb the second point of the segment to test the intersection against
  81885. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  81886. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  81887. */
  81888. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  81889. /**
  81890. * Update the ray from viewport position
  81891. * @param x position
  81892. * @param y y position
  81893. * @param viewportWidth viewport width
  81894. * @param viewportHeight viewport height
  81895. * @param world world matrix
  81896. * @param view view matrix
  81897. * @param projection projection matrix
  81898. * @returns this ray updated
  81899. */
  81900. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  81901. /**
  81902. * Creates a ray with origin and direction of 0,0,0
  81903. * @returns the new ray
  81904. */
  81905. static Zero(): Ray;
  81906. /**
  81907. * Creates a new ray from screen space and viewport
  81908. * @param x position
  81909. * @param y y position
  81910. * @param viewportWidth viewport width
  81911. * @param viewportHeight viewport height
  81912. * @param world world matrix
  81913. * @param view view matrix
  81914. * @param projection projection matrix
  81915. * @returns new ray
  81916. */
  81917. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  81918. /**
  81919. * 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
  81920. * transformed to the given world matrix.
  81921. * @param origin The origin point
  81922. * @param end The end point
  81923. * @param world a matrix to transform the ray to. Default is the identity matrix.
  81924. * @returns the new ray
  81925. */
  81926. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  81927. /**
  81928. * Transforms a ray by a matrix
  81929. * @param ray ray to transform
  81930. * @param matrix matrix to apply
  81931. * @returns the resulting new ray
  81932. */
  81933. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  81934. /**
  81935. * Transforms a ray by a matrix
  81936. * @param ray ray to transform
  81937. * @param matrix matrix to apply
  81938. * @param result ray to store result in
  81939. */
  81940. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  81941. /**
  81942. * Unproject a ray from screen space to object space
  81943. * @param sourceX defines the screen space x coordinate to use
  81944. * @param sourceY defines the screen space y coordinate to use
  81945. * @param viewportWidth defines the current width of the viewport
  81946. * @param viewportHeight defines the current height of the viewport
  81947. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81948. * @param view defines the view matrix to use
  81949. * @param projection defines the projection matrix to use
  81950. */
  81951. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  81952. }
  81953. /**
  81954. * Type used to define predicate used to select faces when a mesh intersection is detected
  81955. */
  81956. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  81957. interface Scene {
  81958. /** @hidden */
  81959. _tempPickingRay: Nullable<Ray>;
  81960. /** @hidden */
  81961. _cachedRayForTransform: Ray;
  81962. /** @hidden */
  81963. _pickWithRayInverseMatrix: Matrix;
  81964. /** @hidden */
  81965. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  81966. /** @hidden */
  81967. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  81968. }
  81969. }
  81970. declare module BABYLON {
  81971. /**
  81972. * Groups all the scene component constants in one place to ease maintenance.
  81973. * @hidden
  81974. */
  81975. export class SceneComponentConstants {
  81976. static readonly NAME_EFFECTLAYER: string;
  81977. static readonly NAME_LAYER: string;
  81978. static readonly NAME_LENSFLARESYSTEM: string;
  81979. static readonly NAME_BOUNDINGBOXRENDERER: string;
  81980. static readonly NAME_PARTICLESYSTEM: string;
  81981. static readonly NAME_GAMEPAD: string;
  81982. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  81983. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  81984. static readonly NAME_DEPTHRENDERER: string;
  81985. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  81986. static readonly NAME_SPRITE: string;
  81987. static readonly NAME_OUTLINERENDERER: string;
  81988. static readonly NAME_PROCEDURALTEXTURE: string;
  81989. static readonly NAME_SHADOWGENERATOR: string;
  81990. static readonly NAME_OCTREE: string;
  81991. static readonly NAME_PHYSICSENGINE: string;
  81992. static readonly NAME_AUDIO: string;
  81993. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  81994. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  81995. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  81996. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  81997. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  81998. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  81999. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  82000. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  82001. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  82002. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  82003. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  82004. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  82005. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  82006. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  82007. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  82008. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  82009. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  82010. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  82011. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  82012. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  82013. static readonly STEP_AFTERRENDER_AUDIO: number;
  82014. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  82015. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  82016. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  82017. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  82018. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  82019. static readonly STEP_POINTERMOVE_SPRITE: number;
  82020. static readonly STEP_POINTERDOWN_SPRITE: number;
  82021. static readonly STEP_POINTERUP_SPRITE: number;
  82022. }
  82023. /**
  82024. * This represents a scene component.
  82025. *
  82026. * This is used to decouple the dependency the scene is having on the different workloads like
  82027. * layers, post processes...
  82028. */
  82029. export interface ISceneComponent {
  82030. /**
  82031. * The name of the component. Each component must have a unique name.
  82032. */
  82033. name: string;
  82034. /**
  82035. * The scene the component belongs to.
  82036. */
  82037. scene: Scene;
  82038. /**
  82039. * Register the component to one instance of a scene.
  82040. */
  82041. register(): void;
  82042. /**
  82043. * Rebuilds the elements related to this component in case of
  82044. * context lost for instance.
  82045. */
  82046. rebuild(): void;
  82047. /**
  82048. * Disposes the component and the associated ressources.
  82049. */
  82050. dispose(): void;
  82051. }
  82052. /**
  82053. * This represents a SERIALIZABLE scene component.
  82054. *
  82055. * This extends Scene Component to add Serialization methods on top.
  82056. */
  82057. export interface ISceneSerializableComponent extends ISceneComponent {
  82058. /**
  82059. * Adds all the elements from the container to the scene
  82060. * @param container the container holding the elements
  82061. */
  82062. addFromContainer(container: AbstractScene): void;
  82063. /**
  82064. * Removes all the elements in the container from the scene
  82065. * @param container contains the elements to remove
  82066. * @param dispose if the removed element should be disposed (default: false)
  82067. */
  82068. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  82069. /**
  82070. * Serializes the component data to the specified json object
  82071. * @param serializationObject The object to serialize to
  82072. */
  82073. serialize(serializationObject: any): void;
  82074. }
  82075. /**
  82076. * Strong typing of a Mesh related stage step action
  82077. */
  82078. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  82079. /**
  82080. * Strong typing of a Evaluate Sub Mesh related stage step action
  82081. */
  82082. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  82083. /**
  82084. * Strong typing of a Active Mesh related stage step action
  82085. */
  82086. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  82087. /**
  82088. * Strong typing of a Camera related stage step action
  82089. */
  82090. export type CameraStageAction = (camera: Camera) => void;
  82091. /**
  82092. * Strong typing of a Camera Frame buffer related stage step action
  82093. */
  82094. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  82095. /**
  82096. * Strong typing of a Render Target related stage step action
  82097. */
  82098. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  82099. /**
  82100. * Strong typing of a RenderingGroup related stage step action
  82101. */
  82102. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  82103. /**
  82104. * Strong typing of a Mesh Render related stage step action
  82105. */
  82106. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  82107. /**
  82108. * Strong typing of a simple stage step action
  82109. */
  82110. export type SimpleStageAction = () => void;
  82111. /**
  82112. * Strong typing of a render target action.
  82113. */
  82114. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  82115. /**
  82116. * Strong typing of a pointer move action.
  82117. */
  82118. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  82119. /**
  82120. * Strong typing of a pointer up/down action.
  82121. */
  82122. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  82123. /**
  82124. * Representation of a stage in the scene (Basically a list of ordered steps)
  82125. * @hidden
  82126. */
  82127. export class Stage<T extends Function> extends Array<{
  82128. index: number;
  82129. component: ISceneComponent;
  82130. action: T;
  82131. }> {
  82132. /**
  82133. * Hide ctor from the rest of the world.
  82134. * @param items The items to add.
  82135. */
  82136. private constructor();
  82137. /**
  82138. * Creates a new Stage.
  82139. * @returns A new instance of a Stage
  82140. */
  82141. static Create<T extends Function>(): Stage<T>;
  82142. /**
  82143. * Registers a step in an ordered way in the targeted stage.
  82144. * @param index Defines the position to register the step in
  82145. * @param component Defines the component attached to the step
  82146. * @param action Defines the action to launch during the step
  82147. */
  82148. registerStep(index: number, component: ISceneComponent, action: T): void;
  82149. /**
  82150. * Clears all the steps from the stage.
  82151. */
  82152. clear(): void;
  82153. }
  82154. }
  82155. declare module BABYLON {
  82156. interface Scene {
  82157. /** @hidden */
  82158. _pointerOverSprite: Nullable<Sprite>;
  82159. /** @hidden */
  82160. _pickedDownSprite: Nullable<Sprite>;
  82161. /** @hidden */
  82162. _tempSpritePickingRay: Nullable<Ray>;
  82163. /**
  82164. * All of the sprite managers added to this scene
  82165. * @see http://doc.babylonjs.com/babylon101/sprites
  82166. */
  82167. spriteManagers: Array<ISpriteManager>;
  82168. /**
  82169. * An event triggered when sprites rendering is about to start
  82170. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  82171. */
  82172. onBeforeSpritesRenderingObservable: Observable<Scene>;
  82173. /**
  82174. * An event triggered when sprites rendering is done
  82175. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  82176. */
  82177. onAfterSpritesRenderingObservable: Observable<Scene>;
  82178. /** @hidden */
  82179. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  82180. /** Launch a ray to try to pick a sprite in the scene
  82181. * @param x position on screen
  82182. * @param y position on screen
  82183. * @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
  82184. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  82185. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  82186. * @returns a PickingInfo
  82187. */
  82188. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  82189. /** Use the given ray to pick a sprite in the scene
  82190. * @param ray The ray (in world space) to use to pick meshes
  82191. * @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
  82192. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  82193. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  82194. * @returns a PickingInfo
  82195. */
  82196. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  82197. /** @hidden */
  82198. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  82199. /** Launch a ray to try to pick sprites in the scene
  82200. * @param x position on screen
  82201. * @param y position on screen
  82202. * @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
  82203. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  82204. * @returns a PickingInfo array
  82205. */
  82206. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  82207. /** Use the given ray to pick sprites in the scene
  82208. * @param ray The ray (in world space) to use to pick meshes
  82209. * @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
  82210. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  82211. * @returns a PickingInfo array
  82212. */
  82213. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  82214. /**
  82215. * Force the sprite under the pointer
  82216. * @param sprite defines the sprite to use
  82217. */
  82218. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  82219. /**
  82220. * Gets the sprite under the pointer
  82221. * @returns a Sprite or null if no sprite is under the pointer
  82222. */
  82223. getPointerOverSprite(): Nullable<Sprite>;
  82224. }
  82225. /**
  82226. * Defines the sprite scene component responsible to manage sprites
  82227. * in a given scene.
  82228. */
  82229. export class SpriteSceneComponent implements ISceneComponent {
  82230. /**
  82231. * The component name helpfull to identify the component in the list of scene components.
  82232. */
  82233. readonly name: string;
  82234. /**
  82235. * The scene the component belongs to.
  82236. */
  82237. scene: Scene;
  82238. /** @hidden */
  82239. private _spritePredicate;
  82240. /**
  82241. * Creates a new instance of the component for the given scene
  82242. * @param scene Defines the scene to register the component in
  82243. */
  82244. constructor(scene: Scene);
  82245. /**
  82246. * Registers the component in a given scene
  82247. */
  82248. register(): void;
  82249. /**
  82250. * Rebuilds the elements related to this component in case of
  82251. * context lost for instance.
  82252. */
  82253. rebuild(): void;
  82254. /**
  82255. * Disposes the component and the associated ressources.
  82256. */
  82257. dispose(): void;
  82258. private _pickSpriteButKeepRay;
  82259. private _pointerMove;
  82260. private _pointerDown;
  82261. private _pointerUp;
  82262. }
  82263. }
  82264. declare module BABYLON {
  82265. /** @hidden */
  82266. export var fogFragmentDeclaration: {
  82267. name: string;
  82268. shader: string;
  82269. };
  82270. }
  82271. declare module BABYLON {
  82272. /** @hidden */
  82273. export var fogFragment: {
  82274. name: string;
  82275. shader: string;
  82276. };
  82277. }
  82278. declare module BABYLON {
  82279. /** @hidden */
  82280. export var spritesPixelShader: {
  82281. name: string;
  82282. shader: string;
  82283. };
  82284. }
  82285. declare module BABYLON {
  82286. /** @hidden */
  82287. export var fogVertexDeclaration: {
  82288. name: string;
  82289. shader: string;
  82290. };
  82291. }
  82292. declare module BABYLON {
  82293. /** @hidden */
  82294. export var spritesVertexShader: {
  82295. name: string;
  82296. shader: string;
  82297. };
  82298. }
  82299. declare module BABYLON {
  82300. /**
  82301. * Defines the minimum interface to fullfil in order to be a sprite manager.
  82302. */
  82303. export interface ISpriteManager extends IDisposable {
  82304. /**
  82305. * Restricts the camera to viewing objects with the same layerMask.
  82306. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  82307. */
  82308. layerMask: number;
  82309. /**
  82310. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  82311. */
  82312. isPickable: boolean;
  82313. /**
  82314. * Specifies the rendering group id for this mesh (0 by default)
  82315. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  82316. */
  82317. renderingGroupId: number;
  82318. /**
  82319. * Defines the list of sprites managed by the manager.
  82320. */
  82321. sprites: Array<Sprite>;
  82322. /**
  82323. * Tests the intersection of a sprite with a specific ray.
  82324. * @param ray The ray we are sending to test the collision
  82325. * @param camera The camera space we are sending rays in
  82326. * @param predicate A predicate allowing excluding sprites from the list of object to test
  82327. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  82328. * @returns picking info or null.
  82329. */
  82330. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  82331. /**
  82332. * Intersects the sprites with a ray
  82333. * @param ray defines the ray to intersect with
  82334. * @param camera defines the current active camera
  82335. * @param predicate defines a predicate used to select candidate sprites
  82336. * @returns null if no hit or a PickingInfo array
  82337. */
  82338. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  82339. /**
  82340. * Renders the list of sprites on screen.
  82341. */
  82342. render(): void;
  82343. }
  82344. /**
  82345. * Class used to manage multiple sprites on the same spritesheet
  82346. * @see http://doc.babylonjs.com/babylon101/sprites
  82347. */
  82348. export class SpriteManager implements ISpriteManager {
  82349. /** defines the manager's name */
  82350. name: string;
  82351. /** Gets the list of sprites */
  82352. sprites: Sprite[];
  82353. /** Gets or sets the rendering group id (0 by default) */
  82354. renderingGroupId: number;
  82355. /** Gets or sets camera layer mask */
  82356. layerMask: number;
  82357. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  82358. fogEnabled: boolean;
  82359. /** Gets or sets a boolean indicating if the sprites are pickable */
  82360. isPickable: boolean;
  82361. /** Defines the default width of a cell in the spritesheet */
  82362. cellWidth: number;
  82363. /** Defines the default height of a cell in the spritesheet */
  82364. cellHeight: number;
  82365. /** Associative array from JSON sprite data file */
  82366. private _cellData;
  82367. /** Array of sprite names from JSON sprite data file */
  82368. private _spriteMap;
  82369. /** True when packed cell data from JSON file is ready*/
  82370. private _packedAndReady;
  82371. /**
  82372. * An event triggered when the manager is disposed.
  82373. */
  82374. onDisposeObservable: Observable<SpriteManager>;
  82375. private _onDisposeObserver;
  82376. /**
  82377. * Callback called when the manager is disposed
  82378. */
  82379. set onDispose(callback: () => void);
  82380. private _capacity;
  82381. private _fromPacked;
  82382. private _spriteTexture;
  82383. private _epsilon;
  82384. private _scene;
  82385. private _vertexData;
  82386. private _buffer;
  82387. private _vertexBuffers;
  82388. private _indexBuffer;
  82389. private _effectBase;
  82390. private _effectFog;
  82391. /**
  82392. * Gets or sets the spritesheet texture
  82393. */
  82394. get texture(): Texture;
  82395. set texture(value: Texture);
  82396. /**
  82397. * Creates a new sprite manager
  82398. * @param name defines the manager's name
  82399. * @param imgUrl defines the sprite sheet url
  82400. * @param capacity defines the maximum allowed number of sprites
  82401. * @param cellSize defines the size of a sprite cell
  82402. * @param scene defines the hosting scene
  82403. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  82404. * @param samplingMode defines the smapling mode to use with spritesheet
  82405. * @param fromPacked set to false; do not alter
  82406. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  82407. */
  82408. constructor(
  82409. /** defines the manager's name */
  82410. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  82411. private _makePacked;
  82412. private _appendSpriteVertex;
  82413. /**
  82414. * Intersects the sprites with a ray
  82415. * @param ray defines the ray to intersect with
  82416. * @param camera defines the current active camera
  82417. * @param predicate defines a predicate used to select candidate sprites
  82418. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  82419. * @returns null if no hit or a PickingInfo
  82420. */
  82421. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  82422. /**
  82423. * Intersects the sprites with a ray
  82424. * @param ray defines the ray to intersect with
  82425. * @param camera defines the current active camera
  82426. * @param predicate defines a predicate used to select candidate sprites
  82427. * @returns null if no hit or a PickingInfo array
  82428. */
  82429. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  82430. /**
  82431. * Render all child sprites
  82432. */
  82433. render(): void;
  82434. /**
  82435. * Release associated resources
  82436. */
  82437. dispose(): void;
  82438. }
  82439. }
  82440. declare module BABYLON {
  82441. /**
  82442. * Class used to represent a sprite
  82443. * @see http://doc.babylonjs.com/babylon101/sprites
  82444. */
  82445. export class Sprite {
  82446. /** defines the name */
  82447. name: string;
  82448. /** Gets or sets the current world position */
  82449. position: Vector3;
  82450. /** Gets or sets the main color */
  82451. color: Color4;
  82452. /** Gets or sets the width */
  82453. width: number;
  82454. /** Gets or sets the height */
  82455. height: number;
  82456. /** Gets or sets rotation angle */
  82457. angle: number;
  82458. /** Gets or sets the cell index in the sprite sheet */
  82459. cellIndex: number;
  82460. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  82461. cellRef: string;
  82462. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  82463. invertU: number;
  82464. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  82465. invertV: number;
  82466. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  82467. disposeWhenFinishedAnimating: boolean;
  82468. /** Gets the list of attached animations */
  82469. animations: Animation[];
  82470. /** Gets or sets a boolean indicating if the sprite can be picked */
  82471. isPickable: boolean;
  82472. /**
  82473. * Gets or sets the associated action manager
  82474. */
  82475. actionManager: Nullable<ActionManager>;
  82476. private _animationStarted;
  82477. private _loopAnimation;
  82478. private _fromIndex;
  82479. private _toIndex;
  82480. private _delay;
  82481. private _direction;
  82482. private _manager;
  82483. private _time;
  82484. private _onAnimationEnd;
  82485. /**
  82486. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  82487. */
  82488. isVisible: boolean;
  82489. /**
  82490. * Gets or sets the sprite size
  82491. */
  82492. get size(): number;
  82493. set size(value: number);
  82494. /**
  82495. * Creates a new Sprite
  82496. * @param name defines the name
  82497. * @param manager defines the manager
  82498. */
  82499. constructor(
  82500. /** defines the name */
  82501. name: string, manager: ISpriteManager);
  82502. /**
  82503. * Starts an animation
  82504. * @param from defines the initial key
  82505. * @param to defines the end key
  82506. * @param loop defines if the animation must loop
  82507. * @param delay defines the start delay (in ms)
  82508. * @param onAnimationEnd defines a callback to call when animation ends
  82509. */
  82510. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  82511. /** Stops current animation (if any) */
  82512. stopAnimation(): void;
  82513. /** @hidden */
  82514. _animate(deltaTime: number): void;
  82515. /** Release associated resources */
  82516. dispose(): void;
  82517. }
  82518. }
  82519. declare module BABYLON {
  82520. /**
  82521. * Information about the result of picking within a scene
  82522. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  82523. */
  82524. export class PickingInfo {
  82525. /** @hidden */
  82526. _pickingUnavailable: boolean;
  82527. /**
  82528. * If the pick collided with an object
  82529. */
  82530. hit: boolean;
  82531. /**
  82532. * Distance away where the pick collided
  82533. */
  82534. distance: number;
  82535. /**
  82536. * The location of pick collision
  82537. */
  82538. pickedPoint: Nullable<Vector3>;
  82539. /**
  82540. * The mesh corresponding the the pick collision
  82541. */
  82542. pickedMesh: Nullable<AbstractMesh>;
  82543. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  82544. bu: number;
  82545. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  82546. bv: number;
  82547. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  82548. faceId: number;
  82549. /** Id of the the submesh that was picked */
  82550. subMeshId: number;
  82551. /** If a sprite was picked, this will be the sprite the pick collided with */
  82552. pickedSprite: Nullable<Sprite>;
  82553. /**
  82554. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  82555. */
  82556. originMesh: Nullable<AbstractMesh>;
  82557. /**
  82558. * The ray that was used to perform the picking.
  82559. */
  82560. ray: Nullable<Ray>;
  82561. /**
  82562. * Gets the normal correspodning to the face the pick collided with
  82563. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  82564. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  82565. * @returns The normal correspodning to the face the pick collided with
  82566. */
  82567. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  82568. /**
  82569. * Gets the texture coordinates of where the pick occured
  82570. * @returns the vector containing the coordnates of the texture
  82571. */
  82572. getTextureCoordinates(): Nullable<Vector2>;
  82573. }
  82574. }
  82575. declare module BABYLON {
  82576. /**
  82577. * Gather the list of pointer event types as constants.
  82578. */
  82579. export class PointerEventTypes {
  82580. /**
  82581. * 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.
  82582. */
  82583. static readonly POINTERDOWN: number;
  82584. /**
  82585. * The pointerup event is fired when a pointer is no longer active.
  82586. */
  82587. static readonly POINTERUP: number;
  82588. /**
  82589. * The pointermove event is fired when a pointer changes coordinates.
  82590. */
  82591. static readonly POINTERMOVE: number;
  82592. /**
  82593. * The pointerwheel event is fired when a mouse wheel has been rotated.
  82594. */
  82595. static readonly POINTERWHEEL: number;
  82596. /**
  82597. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  82598. */
  82599. static readonly POINTERPICK: number;
  82600. /**
  82601. * The pointertap event is fired when a the object has been touched and released without drag.
  82602. */
  82603. static readonly POINTERTAP: number;
  82604. /**
  82605. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  82606. */
  82607. static readonly POINTERDOUBLETAP: number;
  82608. }
  82609. /**
  82610. * Base class of pointer info types.
  82611. */
  82612. export class PointerInfoBase {
  82613. /**
  82614. * Defines the type of event (PointerEventTypes)
  82615. */
  82616. type: number;
  82617. /**
  82618. * Defines the related dom event
  82619. */
  82620. event: PointerEvent | MouseWheelEvent;
  82621. /**
  82622. * Instantiates the base class of pointers info.
  82623. * @param type Defines the type of event (PointerEventTypes)
  82624. * @param event Defines the related dom event
  82625. */
  82626. constructor(
  82627. /**
  82628. * Defines the type of event (PointerEventTypes)
  82629. */
  82630. type: number,
  82631. /**
  82632. * Defines the related dom event
  82633. */
  82634. event: PointerEvent | MouseWheelEvent);
  82635. }
  82636. /**
  82637. * This class is used to store pointer related info for the onPrePointerObservable event.
  82638. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  82639. */
  82640. export class PointerInfoPre extends PointerInfoBase {
  82641. /**
  82642. * Ray from a pointer if availible (eg. 6dof controller)
  82643. */
  82644. ray: Nullable<Ray>;
  82645. /**
  82646. * Defines the local position of the pointer on the canvas.
  82647. */
  82648. localPosition: Vector2;
  82649. /**
  82650. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  82651. */
  82652. skipOnPointerObservable: boolean;
  82653. /**
  82654. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  82655. * @param type Defines the type of event (PointerEventTypes)
  82656. * @param event Defines the related dom event
  82657. * @param localX Defines the local x coordinates of the pointer when the event occured
  82658. * @param localY Defines the local y coordinates of the pointer when the event occured
  82659. */
  82660. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  82661. }
  82662. /**
  82663. * This type contains all the data related to a pointer event in Babylon.js.
  82664. * 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.
  82665. */
  82666. export class PointerInfo extends PointerInfoBase {
  82667. /**
  82668. * Defines the picking info associated to the info (if any)\
  82669. */
  82670. pickInfo: Nullable<PickingInfo>;
  82671. /**
  82672. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  82673. * @param type Defines the type of event (PointerEventTypes)
  82674. * @param event Defines the related dom event
  82675. * @param pickInfo Defines the picking info associated to the info (if any)\
  82676. */
  82677. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  82678. /**
  82679. * Defines the picking info associated to the info (if any)\
  82680. */
  82681. pickInfo: Nullable<PickingInfo>);
  82682. }
  82683. /**
  82684. * Data relating to a touch event on the screen.
  82685. */
  82686. export interface PointerTouch {
  82687. /**
  82688. * X coordinate of touch.
  82689. */
  82690. x: number;
  82691. /**
  82692. * Y coordinate of touch.
  82693. */
  82694. y: number;
  82695. /**
  82696. * Id of touch. Unique for each finger.
  82697. */
  82698. pointerId: number;
  82699. /**
  82700. * Event type passed from DOM.
  82701. */
  82702. type: any;
  82703. }
  82704. }
  82705. declare module BABYLON {
  82706. /**
  82707. * Manage the mouse inputs to control the movement of a free camera.
  82708. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82709. */
  82710. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  82711. /**
  82712. * Define if touch is enabled in the mouse input
  82713. */
  82714. touchEnabled: boolean;
  82715. /**
  82716. * Defines the camera the input is attached to.
  82717. */
  82718. camera: FreeCamera;
  82719. /**
  82720. * Defines the buttons associated with the input to handle camera move.
  82721. */
  82722. buttons: number[];
  82723. /**
  82724. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  82725. */
  82726. angularSensibility: number;
  82727. private _pointerInput;
  82728. private _onMouseMove;
  82729. private _observer;
  82730. private previousPosition;
  82731. /**
  82732. * Observable for when a pointer move event occurs containing the move offset
  82733. */
  82734. onPointerMovedObservable: Observable<{
  82735. offsetX: number;
  82736. offsetY: number;
  82737. }>;
  82738. /**
  82739. * @hidden
  82740. * If the camera should be rotated automatically based on pointer movement
  82741. */
  82742. _allowCameraRotation: boolean;
  82743. /**
  82744. * Manage the mouse inputs to control the movement of a free camera.
  82745. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82746. * @param touchEnabled Defines if touch is enabled or not
  82747. */
  82748. constructor(
  82749. /**
  82750. * Define if touch is enabled in the mouse input
  82751. */
  82752. touchEnabled?: boolean);
  82753. /**
  82754. * Attach the input controls to a specific dom element to get the input from.
  82755. * @param element Defines the element the controls should be listened from
  82756. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82757. */
  82758. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82759. /**
  82760. * Called on JS contextmenu event.
  82761. * Override this method to provide functionality.
  82762. */
  82763. protected onContextMenu(evt: PointerEvent): void;
  82764. /**
  82765. * Detach the current controls from the specified dom element.
  82766. * @param element Defines the element to stop listening the inputs from
  82767. */
  82768. detachControl(element: Nullable<HTMLElement>): void;
  82769. /**
  82770. * Gets the class name of the current intput.
  82771. * @returns the class name
  82772. */
  82773. getClassName(): string;
  82774. /**
  82775. * Get the friendly name associated with the input class.
  82776. * @returns the input friendly name
  82777. */
  82778. getSimpleName(): string;
  82779. }
  82780. }
  82781. declare module BABYLON {
  82782. /**
  82783. * Manage the touch inputs to control the movement of a free camera.
  82784. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82785. */
  82786. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  82787. /**
  82788. * Defines the camera the input is attached to.
  82789. */
  82790. camera: FreeCamera;
  82791. /**
  82792. * Defines the touch sensibility for rotation.
  82793. * The higher the faster.
  82794. */
  82795. touchAngularSensibility: number;
  82796. /**
  82797. * Defines the touch sensibility for move.
  82798. * The higher the faster.
  82799. */
  82800. touchMoveSensibility: number;
  82801. private _offsetX;
  82802. private _offsetY;
  82803. private _pointerPressed;
  82804. private _pointerInput;
  82805. private _observer;
  82806. private _onLostFocus;
  82807. /**
  82808. * Attach the input controls to a specific dom element to get the input from.
  82809. * @param element Defines the element the controls should be listened from
  82810. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82811. */
  82812. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82813. /**
  82814. * Detach the current controls from the specified dom element.
  82815. * @param element Defines the element to stop listening the inputs from
  82816. */
  82817. detachControl(element: Nullable<HTMLElement>): void;
  82818. /**
  82819. * Update the current camera state depending on the inputs that have been used this frame.
  82820. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82821. */
  82822. checkInputs(): void;
  82823. /**
  82824. * Gets the class name of the current intput.
  82825. * @returns the class name
  82826. */
  82827. getClassName(): string;
  82828. /**
  82829. * Get the friendly name associated with the input class.
  82830. * @returns the input friendly name
  82831. */
  82832. getSimpleName(): string;
  82833. }
  82834. }
  82835. declare module BABYLON {
  82836. /**
  82837. * Default Inputs manager for the FreeCamera.
  82838. * It groups all the default supported inputs for ease of use.
  82839. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82840. */
  82841. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  82842. /**
  82843. * @hidden
  82844. */
  82845. _mouseInput: Nullable<FreeCameraMouseInput>;
  82846. /**
  82847. * Instantiates a new FreeCameraInputsManager.
  82848. * @param camera Defines the camera the inputs belong to
  82849. */
  82850. constructor(camera: FreeCamera);
  82851. /**
  82852. * Add keyboard input support to the input manager.
  82853. * @returns the current input manager
  82854. */
  82855. addKeyboard(): FreeCameraInputsManager;
  82856. /**
  82857. * Add mouse input support to the input manager.
  82858. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  82859. * @returns the current input manager
  82860. */
  82861. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  82862. /**
  82863. * Removes the mouse input support from the manager
  82864. * @returns the current input manager
  82865. */
  82866. removeMouse(): FreeCameraInputsManager;
  82867. /**
  82868. * Add touch input support to the input manager.
  82869. * @returns the current input manager
  82870. */
  82871. addTouch(): FreeCameraInputsManager;
  82872. /**
  82873. * Remove all attached input methods from a camera
  82874. */
  82875. clear(): void;
  82876. }
  82877. }
  82878. declare module BABYLON {
  82879. /**
  82880. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  82881. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  82882. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  82883. */
  82884. export class FreeCamera extends TargetCamera {
  82885. /**
  82886. * Define the collision ellipsoid of the camera.
  82887. * This is helpful to simulate a camera body like the player body around the camera
  82888. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  82889. */
  82890. ellipsoid: Vector3;
  82891. /**
  82892. * Define an offset for the position of the ellipsoid around the camera.
  82893. * This can be helpful to determine the center of the body near the gravity center of the body
  82894. * instead of its head.
  82895. */
  82896. ellipsoidOffset: Vector3;
  82897. /**
  82898. * Enable or disable collisions of the camera with the rest of the scene objects.
  82899. */
  82900. checkCollisions: boolean;
  82901. /**
  82902. * Enable or disable gravity on the camera.
  82903. */
  82904. applyGravity: boolean;
  82905. /**
  82906. * Define the input manager associated to the camera.
  82907. */
  82908. inputs: FreeCameraInputsManager;
  82909. /**
  82910. * Gets the input sensibility for a mouse input. (default is 2000.0)
  82911. * Higher values reduce sensitivity.
  82912. */
  82913. get angularSensibility(): number;
  82914. /**
  82915. * Sets the input sensibility for a mouse input. (default is 2000.0)
  82916. * Higher values reduce sensitivity.
  82917. */
  82918. set angularSensibility(value: number);
  82919. /**
  82920. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  82921. */
  82922. get keysUp(): number[];
  82923. set keysUp(value: number[]);
  82924. /**
  82925. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  82926. */
  82927. get keysDown(): number[];
  82928. set keysDown(value: number[]);
  82929. /**
  82930. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  82931. */
  82932. get keysLeft(): number[];
  82933. set keysLeft(value: number[]);
  82934. /**
  82935. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  82936. */
  82937. get keysRight(): number[];
  82938. set keysRight(value: number[]);
  82939. /**
  82940. * Event raised when the camera collide with a mesh in the scene.
  82941. */
  82942. onCollide: (collidedMesh: AbstractMesh) => void;
  82943. private _collider;
  82944. private _needMoveForGravity;
  82945. private _oldPosition;
  82946. private _diffPosition;
  82947. private _newPosition;
  82948. /** @hidden */
  82949. _localDirection: Vector3;
  82950. /** @hidden */
  82951. _transformedDirection: Vector3;
  82952. /**
  82953. * Instantiates a Free Camera.
  82954. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  82955. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  82956. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  82957. * @param name Define the name of the camera in the scene
  82958. * @param position Define the start position of the camera in the scene
  82959. * @param scene Define the scene the camera belongs to
  82960. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  82961. */
  82962. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  82963. /**
  82964. * Attached controls to the current camera.
  82965. * @param element Defines the element the controls should be listened from
  82966. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82967. */
  82968. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82969. /**
  82970. * Detach the current controls from the camera.
  82971. * The camera will stop reacting to inputs.
  82972. * @param element Defines the element to stop listening the inputs from
  82973. */
  82974. detachControl(element: HTMLElement): void;
  82975. private _collisionMask;
  82976. /**
  82977. * Define a collision mask to limit the list of object the camera can collide with
  82978. */
  82979. get collisionMask(): number;
  82980. set collisionMask(mask: number);
  82981. /** @hidden */
  82982. _collideWithWorld(displacement: Vector3): void;
  82983. private _onCollisionPositionChange;
  82984. /** @hidden */
  82985. _checkInputs(): void;
  82986. /** @hidden */
  82987. _decideIfNeedsToMove(): boolean;
  82988. /** @hidden */
  82989. _updatePosition(): void;
  82990. /**
  82991. * Destroy the camera and release the current resources hold by it.
  82992. */
  82993. dispose(): void;
  82994. /**
  82995. * Gets the current object class name.
  82996. * @return the class name
  82997. */
  82998. getClassName(): string;
  82999. }
  83000. }
  83001. declare module BABYLON {
  83002. /**
  83003. * Represents a gamepad control stick position
  83004. */
  83005. export class StickValues {
  83006. /**
  83007. * The x component of the control stick
  83008. */
  83009. x: number;
  83010. /**
  83011. * The y component of the control stick
  83012. */
  83013. y: number;
  83014. /**
  83015. * Initializes the gamepad x and y control stick values
  83016. * @param x The x component of the gamepad control stick value
  83017. * @param y The y component of the gamepad control stick value
  83018. */
  83019. constructor(
  83020. /**
  83021. * The x component of the control stick
  83022. */
  83023. x: number,
  83024. /**
  83025. * The y component of the control stick
  83026. */
  83027. y: number);
  83028. }
  83029. /**
  83030. * An interface which manages callbacks for gamepad button changes
  83031. */
  83032. export interface GamepadButtonChanges {
  83033. /**
  83034. * Called when a gamepad has been changed
  83035. */
  83036. changed: boolean;
  83037. /**
  83038. * Called when a gamepad press event has been triggered
  83039. */
  83040. pressChanged: boolean;
  83041. /**
  83042. * Called when a touch event has been triggered
  83043. */
  83044. touchChanged: boolean;
  83045. /**
  83046. * Called when a value has changed
  83047. */
  83048. valueChanged: boolean;
  83049. }
  83050. /**
  83051. * Represents a gamepad
  83052. */
  83053. export class Gamepad {
  83054. /**
  83055. * The id of the gamepad
  83056. */
  83057. id: string;
  83058. /**
  83059. * The index of the gamepad
  83060. */
  83061. index: number;
  83062. /**
  83063. * The browser gamepad
  83064. */
  83065. browserGamepad: any;
  83066. /**
  83067. * Specifies what type of gamepad this represents
  83068. */
  83069. type: number;
  83070. private _leftStick;
  83071. private _rightStick;
  83072. /** @hidden */
  83073. _isConnected: boolean;
  83074. private _leftStickAxisX;
  83075. private _leftStickAxisY;
  83076. private _rightStickAxisX;
  83077. private _rightStickAxisY;
  83078. /**
  83079. * Triggered when the left control stick has been changed
  83080. */
  83081. private _onleftstickchanged;
  83082. /**
  83083. * Triggered when the right control stick has been changed
  83084. */
  83085. private _onrightstickchanged;
  83086. /**
  83087. * Represents a gamepad controller
  83088. */
  83089. static GAMEPAD: number;
  83090. /**
  83091. * Represents a generic controller
  83092. */
  83093. static GENERIC: number;
  83094. /**
  83095. * Represents an XBox controller
  83096. */
  83097. static XBOX: number;
  83098. /**
  83099. * Represents a pose-enabled controller
  83100. */
  83101. static POSE_ENABLED: number;
  83102. /**
  83103. * Represents an Dual Shock controller
  83104. */
  83105. static DUALSHOCK: number;
  83106. /**
  83107. * Specifies whether the left control stick should be Y-inverted
  83108. */
  83109. protected _invertLeftStickY: boolean;
  83110. /**
  83111. * Specifies if the gamepad has been connected
  83112. */
  83113. get isConnected(): boolean;
  83114. /**
  83115. * Initializes the gamepad
  83116. * @param id The id of the gamepad
  83117. * @param index The index of the gamepad
  83118. * @param browserGamepad The browser gamepad
  83119. * @param leftStickX The x component of the left joystick
  83120. * @param leftStickY The y component of the left joystick
  83121. * @param rightStickX The x component of the right joystick
  83122. * @param rightStickY The y component of the right joystick
  83123. */
  83124. constructor(
  83125. /**
  83126. * The id of the gamepad
  83127. */
  83128. id: string,
  83129. /**
  83130. * The index of the gamepad
  83131. */
  83132. index: number,
  83133. /**
  83134. * The browser gamepad
  83135. */
  83136. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  83137. /**
  83138. * Callback triggered when the left joystick has changed
  83139. * @param callback
  83140. */
  83141. onleftstickchanged(callback: (values: StickValues) => void): void;
  83142. /**
  83143. * Callback triggered when the right joystick has changed
  83144. * @param callback
  83145. */
  83146. onrightstickchanged(callback: (values: StickValues) => void): void;
  83147. /**
  83148. * Gets the left joystick
  83149. */
  83150. get leftStick(): StickValues;
  83151. /**
  83152. * Sets the left joystick values
  83153. */
  83154. set leftStick(newValues: StickValues);
  83155. /**
  83156. * Gets the right joystick
  83157. */
  83158. get rightStick(): StickValues;
  83159. /**
  83160. * Sets the right joystick value
  83161. */
  83162. set rightStick(newValues: StickValues);
  83163. /**
  83164. * Updates the gamepad joystick positions
  83165. */
  83166. update(): void;
  83167. /**
  83168. * Disposes the gamepad
  83169. */
  83170. dispose(): void;
  83171. }
  83172. /**
  83173. * Represents a generic gamepad
  83174. */
  83175. export class GenericPad extends Gamepad {
  83176. private _buttons;
  83177. private _onbuttondown;
  83178. private _onbuttonup;
  83179. /**
  83180. * Observable triggered when a button has been pressed
  83181. */
  83182. onButtonDownObservable: Observable<number>;
  83183. /**
  83184. * Observable triggered when a button has been released
  83185. */
  83186. onButtonUpObservable: Observable<number>;
  83187. /**
  83188. * Callback triggered when a button has been pressed
  83189. * @param callback Called when a button has been pressed
  83190. */
  83191. onbuttondown(callback: (buttonPressed: number) => void): void;
  83192. /**
  83193. * Callback triggered when a button has been released
  83194. * @param callback Called when a button has been released
  83195. */
  83196. onbuttonup(callback: (buttonReleased: number) => void): void;
  83197. /**
  83198. * Initializes the generic gamepad
  83199. * @param id The id of the generic gamepad
  83200. * @param index The index of the generic gamepad
  83201. * @param browserGamepad The browser gamepad
  83202. */
  83203. constructor(id: string, index: number, browserGamepad: any);
  83204. private _setButtonValue;
  83205. /**
  83206. * Updates the generic gamepad
  83207. */
  83208. update(): void;
  83209. /**
  83210. * Disposes the generic gamepad
  83211. */
  83212. dispose(): void;
  83213. }
  83214. }
  83215. declare module BABYLON {
  83216. interface Engine {
  83217. /**
  83218. * Creates a raw texture
  83219. * @param data defines the data to store in the texture
  83220. * @param width defines the width of the texture
  83221. * @param height defines the height of the texture
  83222. * @param format defines the format of the data
  83223. * @param generateMipMaps defines if the engine should generate the mip levels
  83224. * @param invertY defines if data must be stored with Y axis inverted
  83225. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83226. * @param compression defines the compression used (null by default)
  83227. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83228. * @returns the raw texture inside an InternalTexture
  83229. */
  83230. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  83231. /**
  83232. * Update a raw texture
  83233. * @param texture defines the texture to update
  83234. * @param data defines the data to store in the texture
  83235. * @param format defines the format of the data
  83236. * @param invertY defines if data must be stored with Y axis inverted
  83237. */
  83238. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83239. /**
  83240. * Update a raw texture
  83241. * @param texture defines the texture to update
  83242. * @param data defines the data to store in the texture
  83243. * @param format defines the format of the data
  83244. * @param invertY defines if data must be stored with Y axis inverted
  83245. * @param compression defines the compression used (null by default)
  83246. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83247. */
  83248. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  83249. /**
  83250. * Creates a new raw cube texture
  83251. * @param data defines the array of data to use to create each face
  83252. * @param size defines the size of the textures
  83253. * @param format defines the format of the data
  83254. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83255. * @param generateMipMaps defines if the engine should generate the mip levels
  83256. * @param invertY defines if data must be stored with Y axis inverted
  83257. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83258. * @param compression defines the compression used (null by default)
  83259. * @returns the cube texture as an InternalTexture
  83260. */
  83261. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  83262. /**
  83263. * Update a raw cube texture
  83264. * @param texture defines the texture to udpdate
  83265. * @param data defines the data to store
  83266. * @param format defines the data format
  83267. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83268. * @param invertY defines if data must be stored with Y axis inverted
  83269. */
  83270. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  83271. /**
  83272. * Update a raw cube texture
  83273. * @param texture defines the texture to udpdate
  83274. * @param data defines the data to store
  83275. * @param format defines the data format
  83276. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83277. * @param invertY defines if data must be stored with Y axis inverted
  83278. * @param compression defines the compression used (null by default)
  83279. */
  83280. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  83281. /**
  83282. * Update a raw cube texture
  83283. * @param texture defines the texture to udpdate
  83284. * @param data defines the data to store
  83285. * @param format defines the data format
  83286. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83287. * @param invertY defines if data must be stored with Y axis inverted
  83288. * @param compression defines the compression used (null by default)
  83289. * @param level defines which level of the texture to update
  83290. */
  83291. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  83292. /**
  83293. * Creates a new raw cube texture from a specified url
  83294. * @param url defines the url where the data is located
  83295. * @param scene defines the current scene
  83296. * @param size defines the size of the textures
  83297. * @param format defines the format of the data
  83298. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83299. * @param noMipmap defines if the engine should avoid generating the mip levels
  83300. * @param callback defines a callback used to extract texture data from loaded data
  83301. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83302. * @param onLoad defines a callback called when texture is loaded
  83303. * @param onError defines a callback called if there is an error
  83304. * @returns the cube texture as an InternalTexture
  83305. */
  83306. 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;
  83307. /**
  83308. * Creates a new raw cube texture from a specified url
  83309. * @param url defines the url where the data is located
  83310. * @param scene defines the current scene
  83311. * @param size defines the size of the textures
  83312. * @param format defines the format of the data
  83313. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83314. * @param noMipmap defines if the engine should avoid generating the mip levels
  83315. * @param callback defines a callback used to extract texture data from loaded data
  83316. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83317. * @param onLoad defines a callback called when texture is loaded
  83318. * @param onError defines a callback called if there is an error
  83319. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83320. * @param invertY defines if data must be stored with Y axis inverted
  83321. * @returns the cube texture as an InternalTexture
  83322. */
  83323. 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;
  83324. /**
  83325. * Creates a new raw 3D texture
  83326. * @param data defines the data used to create the texture
  83327. * @param width defines the width of the texture
  83328. * @param height defines the height of the texture
  83329. * @param depth defines the depth of the texture
  83330. * @param format defines the format of the texture
  83331. * @param generateMipMaps defines if the engine must generate mip levels
  83332. * @param invertY defines if data must be stored with Y axis inverted
  83333. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83334. * @param compression defines the compressed used (can be null)
  83335. * @param textureType defines the compressed used (can be null)
  83336. * @returns a new raw 3D texture (stored in an InternalTexture)
  83337. */
  83338. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83339. /**
  83340. * Update a raw 3D texture
  83341. * @param texture defines the texture to update
  83342. * @param data defines the data to store
  83343. * @param format defines the data format
  83344. * @param invertY defines if data must be stored with Y axis inverted
  83345. */
  83346. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83347. /**
  83348. * Update a raw 3D texture
  83349. * @param texture defines the texture to update
  83350. * @param data defines the data to store
  83351. * @param format defines the data format
  83352. * @param invertY defines if data must be stored with Y axis inverted
  83353. * @param compression defines the used compression (can be null)
  83354. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83355. */
  83356. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83357. /**
  83358. * Creates a new raw 2D array texture
  83359. * @param data defines the data used to create the texture
  83360. * @param width defines the width of the texture
  83361. * @param height defines the height of the texture
  83362. * @param depth defines the number of layers of the texture
  83363. * @param format defines the format of the texture
  83364. * @param generateMipMaps defines if the engine must generate mip levels
  83365. * @param invertY defines if data must be stored with Y axis inverted
  83366. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83367. * @param compression defines the compressed used (can be null)
  83368. * @param textureType defines the compressed used (can be null)
  83369. * @returns a new raw 2D array texture (stored in an InternalTexture)
  83370. */
  83371. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83372. /**
  83373. * Update a raw 2D array texture
  83374. * @param texture defines the texture to update
  83375. * @param data defines the data to store
  83376. * @param format defines the data format
  83377. * @param invertY defines if data must be stored with Y axis inverted
  83378. */
  83379. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83380. /**
  83381. * Update a raw 2D array texture
  83382. * @param texture defines the texture to update
  83383. * @param data defines the data to store
  83384. * @param format defines the data format
  83385. * @param invertY defines if data must be stored with Y axis inverted
  83386. * @param compression defines the used compression (can be null)
  83387. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83388. */
  83389. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83390. }
  83391. }
  83392. declare module BABYLON {
  83393. /**
  83394. * Raw texture can help creating a texture directly from an array of data.
  83395. * This can be super useful if you either get the data from an uncompressed source or
  83396. * if you wish to create your texture pixel by pixel.
  83397. */
  83398. export class RawTexture extends Texture {
  83399. /**
  83400. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83401. */
  83402. format: number;
  83403. private _engine;
  83404. /**
  83405. * Instantiates a new RawTexture.
  83406. * Raw texture can help creating a texture directly from an array of data.
  83407. * This can be super useful if you either get the data from an uncompressed source or
  83408. * if you wish to create your texture pixel by pixel.
  83409. * @param data define the array of data to use to create the texture
  83410. * @param width define the width of the texture
  83411. * @param height define the height of the texture
  83412. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83413. * @param scene define the scene the texture belongs to
  83414. * @param generateMipMaps define whether mip maps should be generated or not
  83415. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83416. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83417. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83418. */
  83419. constructor(data: ArrayBufferView, width: number, height: number,
  83420. /**
  83421. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83422. */
  83423. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  83424. /**
  83425. * Updates the texture underlying data.
  83426. * @param data Define the new data of the texture
  83427. */
  83428. update(data: ArrayBufferView): void;
  83429. /**
  83430. * Creates a luminance texture from some data.
  83431. * @param data Define the texture data
  83432. * @param width Define the width of the texture
  83433. * @param height Define the height of the texture
  83434. * @param scene Define the scene the texture belongs to
  83435. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83436. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83437. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83438. * @returns the luminance texture
  83439. */
  83440. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83441. /**
  83442. * Creates a luminance alpha texture from some data.
  83443. * @param data Define the texture data
  83444. * @param width Define the width of the texture
  83445. * @param height Define the height of the texture
  83446. * @param scene Define the scene the texture belongs to
  83447. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83448. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83449. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83450. * @returns the luminance alpha texture
  83451. */
  83452. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83453. /**
  83454. * Creates an alpha texture from some data.
  83455. * @param data Define the texture data
  83456. * @param width Define the width of the texture
  83457. * @param height Define the height of the texture
  83458. * @param scene Define the scene the texture belongs to
  83459. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83460. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83461. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83462. * @returns the alpha texture
  83463. */
  83464. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83465. /**
  83466. * Creates a RGB texture from some data.
  83467. * @param data Define the texture data
  83468. * @param width Define the width of the texture
  83469. * @param height Define the height of the texture
  83470. * @param scene Define the scene the texture belongs to
  83471. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83472. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83473. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83474. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83475. * @returns the RGB alpha texture
  83476. */
  83477. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83478. /**
  83479. * Creates a RGBA texture from some data.
  83480. * @param data Define the texture data
  83481. * @param width Define the width of the texture
  83482. * @param height Define the height of the texture
  83483. * @param scene Define the scene the texture belongs to
  83484. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83485. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83486. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83487. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83488. * @returns the RGBA texture
  83489. */
  83490. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83491. /**
  83492. * Creates a R texture from some data.
  83493. * @param data Define the texture data
  83494. * @param width Define the width of the texture
  83495. * @param height Define the height of the texture
  83496. * @param scene Define the scene the texture belongs to
  83497. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83498. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83499. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83500. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83501. * @returns the R texture
  83502. */
  83503. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83504. }
  83505. }
  83506. declare module BABYLON {
  83507. /**
  83508. * Interface for the size containing width and height
  83509. */
  83510. export interface ISize {
  83511. /**
  83512. * Width
  83513. */
  83514. width: number;
  83515. /**
  83516. * Heighht
  83517. */
  83518. height: number;
  83519. }
  83520. /**
  83521. * Size containing widht and height
  83522. */
  83523. export class Size implements ISize {
  83524. /**
  83525. * Width
  83526. */
  83527. width: number;
  83528. /**
  83529. * Height
  83530. */
  83531. height: number;
  83532. /**
  83533. * Creates a Size object from the given width and height (floats).
  83534. * @param width width of the new size
  83535. * @param height height of the new size
  83536. */
  83537. constructor(width: number, height: number);
  83538. /**
  83539. * Returns a string with the Size width and height
  83540. * @returns a string with the Size width and height
  83541. */
  83542. toString(): string;
  83543. /**
  83544. * "Size"
  83545. * @returns the string "Size"
  83546. */
  83547. getClassName(): string;
  83548. /**
  83549. * Returns the Size hash code.
  83550. * @returns a hash code for a unique width and height
  83551. */
  83552. getHashCode(): number;
  83553. /**
  83554. * Updates the current size from the given one.
  83555. * @param src the given size
  83556. */
  83557. copyFrom(src: Size): void;
  83558. /**
  83559. * Updates in place the current Size from the given floats.
  83560. * @param width width of the new size
  83561. * @param height height of the new size
  83562. * @returns the updated Size.
  83563. */
  83564. copyFromFloats(width: number, height: number): Size;
  83565. /**
  83566. * Updates in place the current Size from the given floats.
  83567. * @param width width to set
  83568. * @param height height to set
  83569. * @returns the updated Size.
  83570. */
  83571. set(width: number, height: number): Size;
  83572. /**
  83573. * Multiplies the width and height by numbers
  83574. * @param w factor to multiple the width by
  83575. * @param h factor to multiple the height by
  83576. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83577. */
  83578. multiplyByFloats(w: number, h: number): Size;
  83579. /**
  83580. * Clones the size
  83581. * @returns a new Size copied from the given one.
  83582. */
  83583. clone(): Size;
  83584. /**
  83585. * True if the current Size and the given one width and height are strictly equal.
  83586. * @param other the other size to compare against
  83587. * @returns True if the current Size and the given one width and height are strictly equal.
  83588. */
  83589. equals(other: Size): boolean;
  83590. /**
  83591. * The surface of the Size : width * height (float).
  83592. */
  83593. get surface(): number;
  83594. /**
  83595. * Create a new size of zero
  83596. * @returns a new Size set to (0.0, 0.0)
  83597. */
  83598. static Zero(): Size;
  83599. /**
  83600. * Sums the width and height of two sizes
  83601. * @param otherSize size to add to this size
  83602. * @returns a new Size set as the addition result of the current Size and the given one.
  83603. */
  83604. add(otherSize: Size): Size;
  83605. /**
  83606. * Subtracts the width and height of two
  83607. * @param otherSize size to subtract to this size
  83608. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83609. */
  83610. subtract(otherSize: Size): Size;
  83611. /**
  83612. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83613. * @param start starting size to lerp between
  83614. * @param end end size to lerp between
  83615. * @param amount amount to lerp between the start and end values
  83616. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83617. */
  83618. static Lerp(start: Size, end: Size, amount: number): Size;
  83619. }
  83620. }
  83621. declare module BABYLON {
  83622. /**
  83623. * Defines a runtime animation
  83624. */
  83625. export class RuntimeAnimation {
  83626. private _events;
  83627. /**
  83628. * The current frame of the runtime animation
  83629. */
  83630. private _currentFrame;
  83631. /**
  83632. * The animation used by the runtime animation
  83633. */
  83634. private _animation;
  83635. /**
  83636. * The target of the runtime animation
  83637. */
  83638. private _target;
  83639. /**
  83640. * The initiating animatable
  83641. */
  83642. private _host;
  83643. /**
  83644. * The original value of the runtime animation
  83645. */
  83646. private _originalValue;
  83647. /**
  83648. * The original blend value of the runtime animation
  83649. */
  83650. private _originalBlendValue;
  83651. /**
  83652. * The offsets cache of the runtime animation
  83653. */
  83654. private _offsetsCache;
  83655. /**
  83656. * The high limits cache of the runtime animation
  83657. */
  83658. private _highLimitsCache;
  83659. /**
  83660. * Specifies if the runtime animation has been stopped
  83661. */
  83662. private _stopped;
  83663. /**
  83664. * The blending factor of the runtime animation
  83665. */
  83666. private _blendingFactor;
  83667. /**
  83668. * The BabylonJS scene
  83669. */
  83670. private _scene;
  83671. /**
  83672. * The current value of the runtime animation
  83673. */
  83674. private _currentValue;
  83675. /** @hidden */
  83676. _animationState: _IAnimationState;
  83677. /**
  83678. * The active target of the runtime animation
  83679. */
  83680. private _activeTargets;
  83681. private _currentActiveTarget;
  83682. private _directTarget;
  83683. /**
  83684. * The target path of the runtime animation
  83685. */
  83686. private _targetPath;
  83687. /**
  83688. * The weight of the runtime animation
  83689. */
  83690. private _weight;
  83691. /**
  83692. * The ratio offset of the runtime animation
  83693. */
  83694. private _ratioOffset;
  83695. /**
  83696. * The previous delay of the runtime animation
  83697. */
  83698. private _previousDelay;
  83699. /**
  83700. * The previous ratio of the runtime animation
  83701. */
  83702. private _previousRatio;
  83703. private _enableBlending;
  83704. private _keys;
  83705. private _minFrame;
  83706. private _maxFrame;
  83707. private _minValue;
  83708. private _maxValue;
  83709. private _targetIsArray;
  83710. /**
  83711. * Gets the current frame of the runtime animation
  83712. */
  83713. get currentFrame(): number;
  83714. /**
  83715. * Gets the weight of the runtime animation
  83716. */
  83717. get weight(): number;
  83718. /**
  83719. * Gets the current value of the runtime animation
  83720. */
  83721. get currentValue(): any;
  83722. /**
  83723. * Gets the target path of the runtime animation
  83724. */
  83725. get targetPath(): string;
  83726. /**
  83727. * Gets the actual target of the runtime animation
  83728. */
  83729. get target(): any;
  83730. /** @hidden */
  83731. _onLoop: () => void;
  83732. /**
  83733. * Create a new RuntimeAnimation object
  83734. * @param target defines the target of the animation
  83735. * @param animation defines the source animation object
  83736. * @param scene defines the hosting scene
  83737. * @param host defines the initiating Animatable
  83738. */
  83739. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  83740. private _preparePath;
  83741. /**
  83742. * Gets the animation from the runtime animation
  83743. */
  83744. get animation(): Animation;
  83745. /**
  83746. * Resets the runtime animation to the beginning
  83747. * @param restoreOriginal defines whether to restore the target property to the original value
  83748. */
  83749. reset(restoreOriginal?: boolean): void;
  83750. /**
  83751. * Specifies if the runtime animation is stopped
  83752. * @returns Boolean specifying if the runtime animation is stopped
  83753. */
  83754. isStopped(): boolean;
  83755. /**
  83756. * Disposes of the runtime animation
  83757. */
  83758. dispose(): void;
  83759. /**
  83760. * Apply the interpolated value to the target
  83761. * @param currentValue defines the value computed by the animation
  83762. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  83763. */
  83764. setValue(currentValue: any, weight: number): void;
  83765. private _getOriginalValues;
  83766. private _setValue;
  83767. /**
  83768. * Gets the loop pmode of the runtime animation
  83769. * @returns Loop Mode
  83770. */
  83771. private _getCorrectLoopMode;
  83772. /**
  83773. * Move the current animation to a given frame
  83774. * @param frame defines the frame to move to
  83775. */
  83776. goToFrame(frame: number): void;
  83777. /**
  83778. * @hidden Internal use only
  83779. */
  83780. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  83781. /**
  83782. * Execute the current animation
  83783. * @param delay defines the delay to add to the current frame
  83784. * @param from defines the lower bound of the animation range
  83785. * @param to defines the upper bound of the animation range
  83786. * @param loop defines if the current animation must loop
  83787. * @param speedRatio defines the current speed ratio
  83788. * @param weight defines the weight of the animation (default is -1 so no weight)
  83789. * @param onLoop optional callback called when animation loops
  83790. * @returns a boolean indicating if the animation is running
  83791. */
  83792. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  83793. }
  83794. }
  83795. declare module BABYLON {
  83796. /**
  83797. * Class used to store an actual running animation
  83798. */
  83799. export class Animatable {
  83800. /** defines the target object */
  83801. target: any;
  83802. /** defines the starting frame number (default is 0) */
  83803. fromFrame: number;
  83804. /** defines the ending frame number (default is 100) */
  83805. toFrame: number;
  83806. /** defines if the animation must loop (default is false) */
  83807. loopAnimation: boolean;
  83808. /** defines a callback to call when animation ends if it is not looping */
  83809. onAnimationEnd?: (() => void) | null | undefined;
  83810. /** defines a callback to call when animation loops */
  83811. onAnimationLoop?: (() => void) | null | undefined;
  83812. private _localDelayOffset;
  83813. private _pausedDelay;
  83814. private _runtimeAnimations;
  83815. private _paused;
  83816. private _scene;
  83817. private _speedRatio;
  83818. private _weight;
  83819. private _syncRoot;
  83820. /**
  83821. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  83822. * This will only apply for non looping animation (default is true)
  83823. */
  83824. disposeOnEnd: boolean;
  83825. /**
  83826. * Gets a boolean indicating if the animation has started
  83827. */
  83828. animationStarted: boolean;
  83829. /**
  83830. * Observer raised when the animation ends
  83831. */
  83832. onAnimationEndObservable: Observable<Animatable>;
  83833. /**
  83834. * Observer raised when the animation loops
  83835. */
  83836. onAnimationLoopObservable: Observable<Animatable>;
  83837. /**
  83838. * Gets the root Animatable used to synchronize and normalize animations
  83839. */
  83840. get syncRoot(): Nullable<Animatable>;
  83841. /**
  83842. * Gets the current frame of the first RuntimeAnimation
  83843. * Used to synchronize Animatables
  83844. */
  83845. get masterFrame(): number;
  83846. /**
  83847. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  83848. */
  83849. get weight(): number;
  83850. set weight(value: number);
  83851. /**
  83852. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  83853. */
  83854. get speedRatio(): number;
  83855. set speedRatio(value: number);
  83856. /**
  83857. * Creates a new Animatable
  83858. * @param scene defines the hosting scene
  83859. * @param target defines the target object
  83860. * @param fromFrame defines the starting frame number (default is 0)
  83861. * @param toFrame defines the ending frame number (default is 100)
  83862. * @param loopAnimation defines if the animation must loop (default is false)
  83863. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  83864. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  83865. * @param animations defines a group of animation to add to the new Animatable
  83866. * @param onAnimationLoop defines a callback to call when animation loops
  83867. */
  83868. constructor(scene: Scene,
  83869. /** defines the target object */
  83870. target: any,
  83871. /** defines the starting frame number (default is 0) */
  83872. fromFrame?: number,
  83873. /** defines the ending frame number (default is 100) */
  83874. toFrame?: number,
  83875. /** defines if the animation must loop (default is false) */
  83876. loopAnimation?: boolean, speedRatio?: number,
  83877. /** defines a callback to call when animation ends if it is not looping */
  83878. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  83879. /** defines a callback to call when animation loops */
  83880. onAnimationLoop?: (() => void) | null | undefined);
  83881. /**
  83882. * Synchronize and normalize current Animatable with a source Animatable
  83883. * This is useful when using animation weights and when animations are not of the same length
  83884. * @param root defines the root Animatable to synchronize with
  83885. * @returns the current Animatable
  83886. */
  83887. syncWith(root: Animatable): Animatable;
  83888. /**
  83889. * Gets the list of runtime animations
  83890. * @returns an array of RuntimeAnimation
  83891. */
  83892. getAnimations(): RuntimeAnimation[];
  83893. /**
  83894. * Adds more animations to the current animatable
  83895. * @param target defines the target of the animations
  83896. * @param animations defines the new animations to add
  83897. */
  83898. appendAnimations(target: any, animations: Animation[]): void;
  83899. /**
  83900. * Gets the source animation for a specific property
  83901. * @param property defines the propertyu to look for
  83902. * @returns null or the source animation for the given property
  83903. */
  83904. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  83905. /**
  83906. * Gets the runtime animation for a specific property
  83907. * @param property defines the propertyu to look for
  83908. * @returns null or the runtime animation for the given property
  83909. */
  83910. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  83911. /**
  83912. * Resets the animatable to its original state
  83913. */
  83914. reset(): void;
  83915. /**
  83916. * Allows the animatable to blend with current running animations
  83917. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  83918. * @param blendingSpeed defines the blending speed to use
  83919. */
  83920. enableBlending(blendingSpeed: number): void;
  83921. /**
  83922. * Disable animation blending
  83923. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  83924. */
  83925. disableBlending(): void;
  83926. /**
  83927. * Jump directly to a given frame
  83928. * @param frame defines the frame to jump to
  83929. */
  83930. goToFrame(frame: number): void;
  83931. /**
  83932. * Pause the animation
  83933. */
  83934. pause(): void;
  83935. /**
  83936. * Restart the animation
  83937. */
  83938. restart(): void;
  83939. private _raiseOnAnimationEnd;
  83940. /**
  83941. * Stop and delete the current animation
  83942. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  83943. * @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)
  83944. */
  83945. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  83946. /**
  83947. * Wait asynchronously for the animation to end
  83948. * @returns a promise which will be fullfilled when the animation ends
  83949. */
  83950. waitAsync(): Promise<Animatable>;
  83951. /** @hidden */
  83952. _animate(delay: number): boolean;
  83953. }
  83954. interface Scene {
  83955. /** @hidden */
  83956. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  83957. /** @hidden */
  83958. _processLateAnimationBindingsForMatrices(holder: {
  83959. totalWeight: number;
  83960. animations: RuntimeAnimation[];
  83961. originalValue: Matrix;
  83962. }): any;
  83963. /** @hidden */
  83964. _processLateAnimationBindingsForQuaternions(holder: {
  83965. totalWeight: number;
  83966. animations: RuntimeAnimation[];
  83967. originalValue: Quaternion;
  83968. }, refQuaternion: Quaternion): Quaternion;
  83969. /** @hidden */
  83970. _processLateAnimationBindings(): void;
  83971. /**
  83972. * Will start the animation sequence of a given target
  83973. * @param target defines the target
  83974. * @param from defines from which frame should animation start
  83975. * @param to defines until which frame should animation run.
  83976. * @param weight defines the weight to apply to the animation (1.0 by default)
  83977. * @param loop defines if the animation loops
  83978. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  83979. * @param onAnimationEnd defines the function to be executed when the animation ends
  83980. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  83981. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  83982. * @param onAnimationLoop defines the callback to call when an animation loops
  83983. * @returns the animatable object created for this animation
  83984. */
  83985. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  83986. /**
  83987. * Will start the animation sequence of a given target
  83988. * @param target defines the target
  83989. * @param from defines from which frame should animation start
  83990. * @param to defines until which frame should animation run.
  83991. * @param loop defines if the animation loops
  83992. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  83993. * @param onAnimationEnd defines the function to be executed when the animation ends
  83994. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  83995. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  83996. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  83997. * @param onAnimationLoop defines the callback to call when an animation loops
  83998. * @returns the animatable object created for this animation
  83999. */
  84000. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  84001. /**
  84002. * Will start the animation sequence of a given target and its hierarchy
  84003. * @param target defines the target
  84004. * @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.
  84005. * @param from defines from which frame should animation start
  84006. * @param to defines until which frame should animation run.
  84007. * @param loop defines if the animation loops
  84008. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  84009. * @param onAnimationEnd defines the function to be executed when the animation ends
  84010. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  84011. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  84012. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  84013. * @param onAnimationLoop defines the callback to call when an animation loops
  84014. * @returns the list of created animatables
  84015. */
  84016. 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[];
  84017. /**
  84018. * Begin a new animation on a given node
  84019. * @param target defines the target where the animation will take place
  84020. * @param animations defines the list of animations to start
  84021. * @param from defines the initial value
  84022. * @param to defines the final value
  84023. * @param loop defines if you want animation to loop (off by default)
  84024. * @param speedRatio defines the speed ratio to apply to all animations
  84025. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  84026. * @param onAnimationLoop defines the callback to call when an animation loops
  84027. * @returns the list of created animatables
  84028. */
  84029. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  84030. /**
  84031. * Begin a new animation on a given node and its hierarchy
  84032. * @param target defines the root node where the animation will take place
  84033. * @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.
  84034. * @param animations defines the list of animations to start
  84035. * @param from defines the initial value
  84036. * @param to defines the final value
  84037. * @param loop defines if you want animation to loop (off by default)
  84038. * @param speedRatio defines the speed ratio to apply to all animations
  84039. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  84040. * @param onAnimationLoop defines the callback to call when an animation loops
  84041. * @returns the list of animatables created for all nodes
  84042. */
  84043. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  84044. /**
  84045. * Gets the animatable associated with a specific target
  84046. * @param target defines the target of the animatable
  84047. * @returns the required animatable if found
  84048. */
  84049. getAnimatableByTarget(target: any): Nullable<Animatable>;
  84050. /**
  84051. * Gets all animatables associated with a given target
  84052. * @param target defines the target to look animatables for
  84053. * @returns an array of Animatables
  84054. */
  84055. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  84056. /**
  84057. * Stops and removes all animations that have been applied to the scene
  84058. */
  84059. stopAllAnimations(): void;
  84060. /**
  84061. * Gets the current delta time used by animation engine
  84062. */
  84063. deltaTime: number;
  84064. }
  84065. interface Bone {
  84066. /**
  84067. * Copy an animation range from another bone
  84068. * @param source defines the source bone
  84069. * @param rangeName defines the range name to copy
  84070. * @param frameOffset defines the frame offset
  84071. * @param rescaleAsRequired defines if rescaling must be applied if required
  84072. * @param skelDimensionsRatio defines the scaling ratio
  84073. * @returns true if operation was successful
  84074. */
  84075. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  84076. }
  84077. }
  84078. declare module BABYLON {
  84079. /**
  84080. * Class used to override all child animations of a given target
  84081. */
  84082. export class AnimationPropertiesOverride {
  84083. /**
  84084. * Gets or sets a value indicating if animation blending must be used
  84085. */
  84086. enableBlending: boolean;
  84087. /**
  84088. * Gets or sets the blending speed to use when enableBlending is true
  84089. */
  84090. blendingSpeed: number;
  84091. /**
  84092. * Gets or sets the default loop mode to use
  84093. */
  84094. loopMode: number;
  84095. }
  84096. }
  84097. declare module BABYLON {
  84098. /**
  84099. * Class used to handle skinning animations
  84100. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84101. */
  84102. export class Skeleton implements IAnimatable {
  84103. /** defines the skeleton name */
  84104. name: string;
  84105. /** defines the skeleton Id */
  84106. id: string;
  84107. /**
  84108. * Defines the list of child bones
  84109. */
  84110. bones: Bone[];
  84111. /**
  84112. * Defines an estimate of the dimension of the skeleton at rest
  84113. */
  84114. dimensionsAtRest: Vector3;
  84115. /**
  84116. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  84117. */
  84118. needInitialSkinMatrix: boolean;
  84119. /**
  84120. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  84121. */
  84122. overrideMesh: Nullable<AbstractMesh>;
  84123. /**
  84124. * Gets the list of animations attached to this skeleton
  84125. */
  84126. animations: Array<Animation>;
  84127. private _scene;
  84128. private _isDirty;
  84129. private _transformMatrices;
  84130. private _transformMatrixTexture;
  84131. private _meshesWithPoseMatrix;
  84132. private _animatables;
  84133. private _identity;
  84134. private _synchronizedWithMesh;
  84135. private _ranges;
  84136. private _lastAbsoluteTransformsUpdateId;
  84137. private _canUseTextureForBones;
  84138. private _uniqueId;
  84139. /** @hidden */
  84140. _numBonesWithLinkedTransformNode: number;
  84141. /** @hidden */
  84142. _hasWaitingData: Nullable<boolean>;
  84143. /**
  84144. * Specifies if the skeleton should be serialized
  84145. */
  84146. doNotSerialize: boolean;
  84147. private _useTextureToStoreBoneMatrices;
  84148. /**
  84149. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  84150. * Please note that this option is not available if the hardware does not support it
  84151. */
  84152. get useTextureToStoreBoneMatrices(): boolean;
  84153. set useTextureToStoreBoneMatrices(value: boolean);
  84154. private _animationPropertiesOverride;
  84155. /**
  84156. * Gets or sets the animation properties override
  84157. */
  84158. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  84159. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  84160. /**
  84161. * List of inspectable custom properties (used by the Inspector)
  84162. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84163. */
  84164. inspectableCustomProperties: IInspectable[];
  84165. /**
  84166. * An observable triggered before computing the skeleton's matrices
  84167. */
  84168. onBeforeComputeObservable: Observable<Skeleton>;
  84169. /**
  84170. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  84171. */
  84172. get isUsingTextureForMatrices(): boolean;
  84173. /**
  84174. * Gets the unique ID of this skeleton
  84175. */
  84176. get uniqueId(): number;
  84177. /**
  84178. * Creates a new skeleton
  84179. * @param name defines the skeleton name
  84180. * @param id defines the skeleton Id
  84181. * @param scene defines the hosting scene
  84182. */
  84183. constructor(
  84184. /** defines the skeleton name */
  84185. name: string,
  84186. /** defines the skeleton Id */
  84187. id: string, scene: Scene);
  84188. /**
  84189. * Gets the current object class name.
  84190. * @return the class name
  84191. */
  84192. getClassName(): string;
  84193. /**
  84194. * Returns an array containing the root bones
  84195. * @returns an array containing the root bones
  84196. */
  84197. getChildren(): Array<Bone>;
  84198. /**
  84199. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  84200. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  84201. * @returns a Float32Array containing matrices data
  84202. */
  84203. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  84204. /**
  84205. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  84206. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  84207. * @returns a raw texture containing the data
  84208. */
  84209. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  84210. /**
  84211. * Gets the current hosting scene
  84212. * @returns a scene object
  84213. */
  84214. getScene(): Scene;
  84215. /**
  84216. * Gets a string representing the current skeleton data
  84217. * @param fullDetails defines a boolean indicating if we want a verbose version
  84218. * @returns a string representing the current skeleton data
  84219. */
  84220. toString(fullDetails?: boolean): string;
  84221. /**
  84222. * Get bone's index searching by name
  84223. * @param name defines bone's name to search for
  84224. * @return the indice of the bone. Returns -1 if not found
  84225. */
  84226. getBoneIndexByName(name: string): number;
  84227. /**
  84228. * Creater a new animation range
  84229. * @param name defines the name of the range
  84230. * @param from defines the start key
  84231. * @param to defines the end key
  84232. */
  84233. createAnimationRange(name: string, from: number, to: number): void;
  84234. /**
  84235. * Delete a specific animation range
  84236. * @param name defines the name of the range
  84237. * @param deleteFrames defines if frames must be removed as well
  84238. */
  84239. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  84240. /**
  84241. * Gets a specific animation range
  84242. * @param name defines the name of the range to look for
  84243. * @returns the requested animation range or null if not found
  84244. */
  84245. getAnimationRange(name: string): Nullable<AnimationRange>;
  84246. /**
  84247. * Gets the list of all animation ranges defined on this skeleton
  84248. * @returns an array
  84249. */
  84250. getAnimationRanges(): Nullable<AnimationRange>[];
  84251. /**
  84252. * Copy animation range from a source skeleton.
  84253. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  84254. * @param source defines the source skeleton
  84255. * @param name defines the name of the range to copy
  84256. * @param rescaleAsRequired defines if rescaling must be applied if required
  84257. * @returns true if operation was successful
  84258. */
  84259. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  84260. /**
  84261. * Forces the skeleton to go to rest pose
  84262. */
  84263. returnToRest(): void;
  84264. private _getHighestAnimationFrame;
  84265. /**
  84266. * Begin a specific animation range
  84267. * @param name defines the name of the range to start
  84268. * @param loop defines if looping must be turned on (false by default)
  84269. * @param speedRatio defines the speed ratio to apply (1 by default)
  84270. * @param onAnimationEnd defines a callback which will be called when animation will end
  84271. * @returns a new animatable
  84272. */
  84273. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  84274. /** @hidden */
  84275. _markAsDirty(): void;
  84276. /** @hidden */
  84277. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  84278. /** @hidden */
  84279. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  84280. private _computeTransformMatrices;
  84281. /**
  84282. * Build all resources required to render a skeleton
  84283. */
  84284. prepare(): void;
  84285. /**
  84286. * Gets the list of animatables currently running for this skeleton
  84287. * @returns an array of animatables
  84288. */
  84289. getAnimatables(): IAnimatable[];
  84290. /**
  84291. * Clone the current skeleton
  84292. * @param name defines the name of the new skeleton
  84293. * @param id defines the id of the new skeleton
  84294. * @returns the new skeleton
  84295. */
  84296. clone(name: string, id?: string): Skeleton;
  84297. /**
  84298. * Enable animation blending for this skeleton
  84299. * @param blendingSpeed defines the blending speed to apply
  84300. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  84301. */
  84302. enableBlending(blendingSpeed?: number): void;
  84303. /**
  84304. * Releases all resources associated with the current skeleton
  84305. */
  84306. dispose(): void;
  84307. /**
  84308. * Serialize the skeleton in a JSON object
  84309. * @returns a JSON object
  84310. */
  84311. serialize(): any;
  84312. /**
  84313. * Creates a new skeleton from serialized data
  84314. * @param parsedSkeleton defines the serialized data
  84315. * @param scene defines the hosting scene
  84316. * @returns a new skeleton
  84317. */
  84318. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  84319. /**
  84320. * Compute all node absolute transforms
  84321. * @param forceUpdate defines if computation must be done even if cache is up to date
  84322. */
  84323. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  84324. /**
  84325. * Gets the root pose matrix
  84326. * @returns a matrix
  84327. */
  84328. getPoseMatrix(): Nullable<Matrix>;
  84329. /**
  84330. * Sorts bones per internal index
  84331. */
  84332. sortBones(): void;
  84333. private _sortBones;
  84334. }
  84335. }
  84336. declare module BABYLON {
  84337. /**
  84338. * Class used to store bone information
  84339. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84340. */
  84341. export class Bone extends Node {
  84342. /**
  84343. * defines the bone name
  84344. */
  84345. name: string;
  84346. private static _tmpVecs;
  84347. private static _tmpQuat;
  84348. private static _tmpMats;
  84349. /**
  84350. * Gets the list of child bones
  84351. */
  84352. children: Bone[];
  84353. /** Gets the animations associated with this bone */
  84354. animations: Animation[];
  84355. /**
  84356. * Gets or sets bone length
  84357. */
  84358. length: number;
  84359. /**
  84360. * @hidden Internal only
  84361. * Set this value to map this bone to a different index in the transform matrices
  84362. * Set this value to -1 to exclude the bone from the transform matrices
  84363. */
  84364. _index: Nullable<number>;
  84365. private _skeleton;
  84366. private _localMatrix;
  84367. private _restPose;
  84368. private _baseMatrix;
  84369. private _absoluteTransform;
  84370. private _invertedAbsoluteTransform;
  84371. private _parent;
  84372. private _scalingDeterminant;
  84373. private _worldTransform;
  84374. private _localScaling;
  84375. private _localRotation;
  84376. private _localPosition;
  84377. private _needToDecompose;
  84378. private _needToCompose;
  84379. /** @hidden */
  84380. _linkedTransformNode: Nullable<TransformNode>;
  84381. /** @hidden */
  84382. _waitingTransformNodeId: Nullable<string>;
  84383. /** @hidden */
  84384. get _matrix(): Matrix;
  84385. /** @hidden */
  84386. set _matrix(value: Matrix);
  84387. /**
  84388. * Create a new bone
  84389. * @param name defines the bone name
  84390. * @param skeleton defines the parent skeleton
  84391. * @param parentBone defines the parent (can be null if the bone is the root)
  84392. * @param localMatrix defines the local matrix
  84393. * @param restPose defines the rest pose matrix
  84394. * @param baseMatrix defines the base matrix
  84395. * @param index defines index of the bone in the hiearchy
  84396. */
  84397. constructor(
  84398. /**
  84399. * defines the bone name
  84400. */
  84401. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  84402. /**
  84403. * Gets the current object class name.
  84404. * @return the class name
  84405. */
  84406. getClassName(): string;
  84407. /**
  84408. * Gets the parent skeleton
  84409. * @returns a skeleton
  84410. */
  84411. getSkeleton(): Skeleton;
  84412. /**
  84413. * Gets parent bone
  84414. * @returns a bone or null if the bone is the root of the bone hierarchy
  84415. */
  84416. getParent(): Nullable<Bone>;
  84417. /**
  84418. * Returns an array containing the root bones
  84419. * @returns an array containing the root bones
  84420. */
  84421. getChildren(): Array<Bone>;
  84422. /**
  84423. * Gets the node index in matrix array generated for rendering
  84424. * @returns the node index
  84425. */
  84426. getIndex(): number;
  84427. /**
  84428. * Sets the parent bone
  84429. * @param parent defines the parent (can be null if the bone is the root)
  84430. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  84431. */
  84432. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  84433. /**
  84434. * Gets the local matrix
  84435. * @returns a matrix
  84436. */
  84437. getLocalMatrix(): Matrix;
  84438. /**
  84439. * Gets the base matrix (initial matrix which remains unchanged)
  84440. * @returns a matrix
  84441. */
  84442. getBaseMatrix(): Matrix;
  84443. /**
  84444. * Gets the rest pose matrix
  84445. * @returns a matrix
  84446. */
  84447. getRestPose(): Matrix;
  84448. /**
  84449. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  84450. */
  84451. getWorldMatrix(): Matrix;
  84452. /**
  84453. * Sets the local matrix to rest pose matrix
  84454. */
  84455. returnToRest(): void;
  84456. /**
  84457. * Gets the inverse of the absolute transform matrix.
  84458. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  84459. * @returns a matrix
  84460. */
  84461. getInvertedAbsoluteTransform(): Matrix;
  84462. /**
  84463. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  84464. * @returns a matrix
  84465. */
  84466. getAbsoluteTransform(): Matrix;
  84467. /**
  84468. * Links with the given transform node.
  84469. * The local matrix of this bone is copied from the transform node every frame.
  84470. * @param transformNode defines the transform node to link to
  84471. */
  84472. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  84473. /**
  84474. * Gets the node used to drive the bone's transformation
  84475. * @returns a transform node or null
  84476. */
  84477. getTransformNode(): Nullable<TransformNode>;
  84478. /** Gets or sets current position (in local space) */
  84479. get position(): Vector3;
  84480. set position(newPosition: Vector3);
  84481. /** Gets or sets current rotation (in local space) */
  84482. get rotation(): Vector3;
  84483. set rotation(newRotation: Vector3);
  84484. /** Gets or sets current rotation quaternion (in local space) */
  84485. get rotationQuaternion(): Quaternion;
  84486. set rotationQuaternion(newRotation: Quaternion);
  84487. /** Gets or sets current scaling (in local space) */
  84488. get scaling(): Vector3;
  84489. set scaling(newScaling: Vector3);
  84490. /**
  84491. * Gets the animation properties override
  84492. */
  84493. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  84494. private _decompose;
  84495. private _compose;
  84496. /**
  84497. * Update the base and local matrices
  84498. * @param matrix defines the new base or local matrix
  84499. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  84500. * @param updateLocalMatrix defines if the local matrix should be updated
  84501. */
  84502. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  84503. /** @hidden */
  84504. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  84505. /**
  84506. * Flag the bone as dirty (Forcing it to update everything)
  84507. */
  84508. markAsDirty(): void;
  84509. /** @hidden */
  84510. _markAsDirtyAndCompose(): void;
  84511. private _markAsDirtyAndDecompose;
  84512. /**
  84513. * Translate the bone in local or world space
  84514. * @param vec The amount to translate the bone
  84515. * @param space The space that the translation is in
  84516. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84517. */
  84518. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  84519. /**
  84520. * Set the postion of the bone in local or world space
  84521. * @param position The position to set the bone
  84522. * @param space The space that the position is in
  84523. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84524. */
  84525. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  84526. /**
  84527. * Set the absolute position of the bone (world space)
  84528. * @param position The position to set the bone
  84529. * @param mesh The mesh that this bone is attached to
  84530. */
  84531. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  84532. /**
  84533. * Scale the bone on the x, y and z axes (in local space)
  84534. * @param x The amount to scale the bone on the x axis
  84535. * @param y The amount to scale the bone on the y axis
  84536. * @param z The amount to scale the bone on the z axis
  84537. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  84538. */
  84539. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  84540. /**
  84541. * Set the bone scaling in local space
  84542. * @param scale defines the scaling vector
  84543. */
  84544. setScale(scale: Vector3): void;
  84545. /**
  84546. * Gets the current scaling in local space
  84547. * @returns the current scaling vector
  84548. */
  84549. getScale(): Vector3;
  84550. /**
  84551. * Gets the current scaling in local space and stores it in a target vector
  84552. * @param result defines the target vector
  84553. */
  84554. getScaleToRef(result: Vector3): void;
  84555. /**
  84556. * Set the yaw, pitch, and roll of the bone in local or world space
  84557. * @param yaw The rotation of the bone on the y axis
  84558. * @param pitch The rotation of the bone on the x axis
  84559. * @param roll The rotation of the bone on the z axis
  84560. * @param space The space that the axes of rotation are in
  84561. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84562. */
  84563. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  84564. /**
  84565. * Add a rotation to the bone on an axis in local or world space
  84566. * @param axis The axis to rotate the bone on
  84567. * @param amount The amount to rotate the bone
  84568. * @param space The space that the axis is in
  84569. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84570. */
  84571. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  84572. /**
  84573. * Set the rotation of the bone to a particular axis angle in local or world space
  84574. * @param axis The axis to rotate the bone on
  84575. * @param angle The angle that the bone should be rotated to
  84576. * @param space The space that the axis is in
  84577. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84578. */
  84579. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  84580. /**
  84581. * Set the euler rotation of the bone in local of world space
  84582. * @param rotation The euler rotation that the bone should be set to
  84583. * @param space The space that the rotation is in
  84584. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84585. */
  84586. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  84587. /**
  84588. * Set the quaternion rotation of the bone in local of world space
  84589. * @param quat The quaternion rotation that the bone should be set to
  84590. * @param space The space that the rotation is in
  84591. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84592. */
  84593. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  84594. /**
  84595. * Set the rotation matrix of the bone in local of world space
  84596. * @param rotMat The rotation matrix that the bone should be set to
  84597. * @param space The space that the rotation is in
  84598. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84599. */
  84600. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  84601. private _rotateWithMatrix;
  84602. private _getNegativeRotationToRef;
  84603. /**
  84604. * Get the position of the bone in local or world space
  84605. * @param space The space that the returned position is in
  84606. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84607. * @returns The position of the bone
  84608. */
  84609. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  84610. /**
  84611. * Copy the position of the bone to a vector3 in local or world space
  84612. * @param space The space that the returned position is in
  84613. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84614. * @param result The vector3 to copy the position to
  84615. */
  84616. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  84617. /**
  84618. * Get the absolute position of the bone (world space)
  84619. * @param mesh The mesh that this bone is attached to
  84620. * @returns The absolute position of the bone
  84621. */
  84622. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  84623. /**
  84624. * Copy the absolute position of the bone (world space) to the result param
  84625. * @param mesh The mesh that this bone is attached to
  84626. * @param result The vector3 to copy the absolute position to
  84627. */
  84628. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  84629. /**
  84630. * Compute the absolute transforms of this bone and its children
  84631. */
  84632. computeAbsoluteTransforms(): void;
  84633. /**
  84634. * Get the world direction from an axis that is in the local space of the bone
  84635. * @param localAxis The local direction that is used to compute the world direction
  84636. * @param mesh The mesh that this bone is attached to
  84637. * @returns The world direction
  84638. */
  84639. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  84640. /**
  84641. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  84642. * @param localAxis The local direction that is used to compute the world direction
  84643. * @param mesh The mesh that this bone is attached to
  84644. * @param result The vector3 that the world direction will be copied to
  84645. */
  84646. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  84647. /**
  84648. * Get the euler rotation of the bone in local or world space
  84649. * @param space The space that the rotation should be in
  84650. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84651. * @returns The euler rotation
  84652. */
  84653. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  84654. /**
  84655. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  84656. * @param space The space that the rotation should be in
  84657. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84658. * @param result The vector3 that the rotation should be copied to
  84659. */
  84660. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  84661. /**
  84662. * Get the quaternion rotation of the bone in either local or world space
  84663. * @param space The space that the rotation should be in
  84664. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84665. * @returns The quaternion rotation
  84666. */
  84667. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  84668. /**
  84669. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  84670. * @param space The space that the rotation should be in
  84671. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84672. * @param result The quaternion that the rotation should be copied to
  84673. */
  84674. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  84675. /**
  84676. * Get the rotation matrix of the bone in local or world space
  84677. * @param space The space that the rotation should be in
  84678. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84679. * @returns The rotation matrix
  84680. */
  84681. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  84682. /**
  84683. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  84684. * @param space The space that the rotation should be in
  84685. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84686. * @param result The quaternion that the rotation should be copied to
  84687. */
  84688. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  84689. /**
  84690. * Get the world position of a point that is in the local space of the bone
  84691. * @param position The local position
  84692. * @param mesh The mesh that this bone is attached to
  84693. * @returns The world position
  84694. */
  84695. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  84696. /**
  84697. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  84698. * @param position The local position
  84699. * @param mesh The mesh that this bone is attached to
  84700. * @param result The vector3 that the world position should be copied to
  84701. */
  84702. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  84703. /**
  84704. * Get the local position of a point that is in world space
  84705. * @param position The world position
  84706. * @param mesh The mesh that this bone is attached to
  84707. * @returns The local position
  84708. */
  84709. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  84710. /**
  84711. * Get the local position of a point that is in world space and copy it to the result param
  84712. * @param position The world position
  84713. * @param mesh The mesh that this bone is attached to
  84714. * @param result The vector3 that the local position should be copied to
  84715. */
  84716. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  84717. }
  84718. }
  84719. declare module BABYLON {
  84720. /**
  84721. * 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.
  84722. * @see https://doc.babylonjs.com/how_to/transformnode
  84723. */
  84724. export class TransformNode extends Node {
  84725. /**
  84726. * Object will not rotate to face the camera
  84727. */
  84728. static BILLBOARDMODE_NONE: number;
  84729. /**
  84730. * Object will rotate to face the camera but only on the x axis
  84731. */
  84732. static BILLBOARDMODE_X: number;
  84733. /**
  84734. * Object will rotate to face the camera but only on the y axis
  84735. */
  84736. static BILLBOARDMODE_Y: number;
  84737. /**
  84738. * Object will rotate to face the camera but only on the z axis
  84739. */
  84740. static BILLBOARDMODE_Z: number;
  84741. /**
  84742. * Object will rotate to face the camera
  84743. */
  84744. static BILLBOARDMODE_ALL: number;
  84745. /**
  84746. * Object will rotate to face the camera's position instead of orientation
  84747. */
  84748. static BILLBOARDMODE_USE_POSITION: number;
  84749. private _forward;
  84750. private _forwardInverted;
  84751. private _up;
  84752. private _right;
  84753. private _rightInverted;
  84754. private _position;
  84755. private _rotation;
  84756. private _rotationQuaternion;
  84757. protected _scaling: Vector3;
  84758. protected _isDirty: boolean;
  84759. private _transformToBoneReferal;
  84760. private _isAbsoluteSynced;
  84761. private _billboardMode;
  84762. /**
  84763. * Gets or sets the billboard mode. Default is 0.
  84764. *
  84765. * | Value | Type | Description |
  84766. * | --- | --- | --- |
  84767. * | 0 | BILLBOARDMODE_NONE | |
  84768. * | 1 | BILLBOARDMODE_X | |
  84769. * | 2 | BILLBOARDMODE_Y | |
  84770. * | 4 | BILLBOARDMODE_Z | |
  84771. * | 7 | BILLBOARDMODE_ALL | |
  84772. *
  84773. */
  84774. get billboardMode(): number;
  84775. set billboardMode(value: number);
  84776. private _preserveParentRotationForBillboard;
  84777. /**
  84778. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  84779. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  84780. */
  84781. get preserveParentRotationForBillboard(): boolean;
  84782. set preserveParentRotationForBillboard(value: boolean);
  84783. /**
  84784. * 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
  84785. */
  84786. scalingDeterminant: number;
  84787. private _infiniteDistance;
  84788. /**
  84789. * Gets or sets the distance of the object to max, often used by skybox
  84790. */
  84791. get infiniteDistance(): boolean;
  84792. set infiniteDistance(value: boolean);
  84793. /**
  84794. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  84795. * By default the system will update normals to compensate
  84796. */
  84797. ignoreNonUniformScaling: boolean;
  84798. /**
  84799. * 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
  84800. */
  84801. reIntegrateRotationIntoRotationQuaternion: boolean;
  84802. /** @hidden */
  84803. _poseMatrix: Nullable<Matrix>;
  84804. /** @hidden */
  84805. _localMatrix: Matrix;
  84806. private _usePivotMatrix;
  84807. private _absolutePosition;
  84808. private _absoluteScaling;
  84809. private _absoluteRotationQuaternion;
  84810. private _pivotMatrix;
  84811. private _pivotMatrixInverse;
  84812. protected _postMultiplyPivotMatrix: boolean;
  84813. protected _isWorldMatrixFrozen: boolean;
  84814. /** @hidden */
  84815. _indexInSceneTransformNodesArray: number;
  84816. /**
  84817. * An event triggered after the world matrix is updated
  84818. */
  84819. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  84820. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  84821. /**
  84822. * Gets a string identifying the name of the class
  84823. * @returns "TransformNode" string
  84824. */
  84825. getClassName(): string;
  84826. /**
  84827. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  84828. */
  84829. get position(): Vector3;
  84830. set position(newPosition: Vector3);
  84831. /**
  84832. * 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)).
  84833. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  84834. */
  84835. get rotation(): Vector3;
  84836. set rotation(newRotation: Vector3);
  84837. /**
  84838. * 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)).
  84839. */
  84840. get scaling(): Vector3;
  84841. set scaling(newScaling: Vector3);
  84842. /**
  84843. * 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).
  84844. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  84845. */
  84846. get rotationQuaternion(): Nullable<Quaternion>;
  84847. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  84848. /**
  84849. * The forward direction of that transform in world space.
  84850. */
  84851. get forward(): Vector3;
  84852. /**
  84853. * The up direction of that transform in world space.
  84854. */
  84855. get up(): Vector3;
  84856. /**
  84857. * The right direction of that transform in world space.
  84858. */
  84859. get right(): Vector3;
  84860. /**
  84861. * Copies the parameter passed Matrix into the mesh Pose matrix.
  84862. * @param matrix the matrix to copy the pose from
  84863. * @returns this TransformNode.
  84864. */
  84865. updatePoseMatrix(matrix: Matrix): TransformNode;
  84866. /**
  84867. * Returns the mesh Pose matrix.
  84868. * @returns the pose matrix
  84869. */
  84870. getPoseMatrix(): Matrix;
  84871. /** @hidden */
  84872. _isSynchronized(): boolean;
  84873. /** @hidden */
  84874. _initCache(): void;
  84875. /**
  84876. * Flag the transform node as dirty (Forcing it to update everything)
  84877. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  84878. * @returns this transform node
  84879. */
  84880. markAsDirty(property: string): TransformNode;
  84881. /**
  84882. * Returns the current mesh absolute position.
  84883. * Returns a Vector3.
  84884. */
  84885. get absolutePosition(): Vector3;
  84886. /**
  84887. * Returns the current mesh absolute scaling.
  84888. * Returns a Vector3.
  84889. */
  84890. get absoluteScaling(): Vector3;
  84891. /**
  84892. * Returns the current mesh absolute rotation.
  84893. * Returns a Quaternion.
  84894. */
  84895. get absoluteRotationQuaternion(): Quaternion;
  84896. /**
  84897. * Sets a new matrix to apply before all other transformation
  84898. * @param matrix defines the transform matrix
  84899. * @returns the current TransformNode
  84900. */
  84901. setPreTransformMatrix(matrix: Matrix): TransformNode;
  84902. /**
  84903. * Sets a new pivot matrix to the current node
  84904. * @param matrix defines the new pivot matrix to use
  84905. * @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
  84906. * @returns the current TransformNode
  84907. */
  84908. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  84909. /**
  84910. * Returns the mesh pivot matrix.
  84911. * Default : Identity.
  84912. * @returns the matrix
  84913. */
  84914. getPivotMatrix(): Matrix;
  84915. /**
  84916. * Instantiate (when possible) or clone that node with its hierarchy
  84917. * @param newParent defines the new parent to use for the instance (or clone)
  84918. * @param options defines options to configure how copy is done
  84919. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  84920. * @returns an instance (or a clone) of the current node with its hiearchy
  84921. */
  84922. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  84923. doNotInstantiate: boolean;
  84924. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  84925. /**
  84926. * Prevents the World matrix to be computed any longer
  84927. * @param newWorldMatrix defines an optional matrix to use as world matrix
  84928. * @returns the TransformNode.
  84929. */
  84930. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  84931. /**
  84932. * Allows back the World matrix computation.
  84933. * @returns the TransformNode.
  84934. */
  84935. unfreezeWorldMatrix(): this;
  84936. /**
  84937. * True if the World matrix has been frozen.
  84938. */
  84939. get isWorldMatrixFrozen(): boolean;
  84940. /**
  84941. * Retuns the mesh absolute position in the World.
  84942. * @returns a Vector3.
  84943. */
  84944. getAbsolutePosition(): Vector3;
  84945. /**
  84946. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  84947. * @param absolutePosition the absolute position to set
  84948. * @returns the TransformNode.
  84949. */
  84950. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  84951. /**
  84952. * Sets the mesh position in its local space.
  84953. * @param vector3 the position to set in localspace
  84954. * @returns the TransformNode.
  84955. */
  84956. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  84957. /**
  84958. * Returns the mesh position in the local space from the current World matrix values.
  84959. * @returns a new Vector3.
  84960. */
  84961. getPositionExpressedInLocalSpace(): Vector3;
  84962. /**
  84963. * Translates the mesh along the passed Vector3 in its local space.
  84964. * @param vector3 the distance to translate in localspace
  84965. * @returns the TransformNode.
  84966. */
  84967. locallyTranslate(vector3: Vector3): TransformNode;
  84968. private static _lookAtVectorCache;
  84969. /**
  84970. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  84971. * @param targetPoint the position (must be in same space as current mesh) to look at
  84972. * @param yawCor optional yaw (y-axis) correction in radians
  84973. * @param pitchCor optional pitch (x-axis) correction in radians
  84974. * @param rollCor optional roll (z-axis) correction in radians
  84975. * @param space the choosen space of the target
  84976. * @returns the TransformNode.
  84977. */
  84978. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  84979. /**
  84980. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  84981. * This Vector3 is expressed in the World space.
  84982. * @param localAxis axis to rotate
  84983. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  84984. */
  84985. getDirection(localAxis: Vector3): Vector3;
  84986. /**
  84987. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  84988. * localAxis is expressed in the mesh local space.
  84989. * result is computed in the Wordl space from the mesh World matrix.
  84990. * @param localAxis axis to rotate
  84991. * @param result the resulting transformnode
  84992. * @returns this TransformNode.
  84993. */
  84994. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  84995. /**
  84996. * Sets this transform node rotation to the given local axis.
  84997. * @param localAxis the axis in local space
  84998. * @param yawCor optional yaw (y-axis) correction in radians
  84999. * @param pitchCor optional pitch (x-axis) correction in radians
  85000. * @param rollCor optional roll (z-axis) correction in radians
  85001. * @returns this TransformNode
  85002. */
  85003. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  85004. /**
  85005. * Sets a new pivot point to the current node
  85006. * @param point defines the new pivot point to use
  85007. * @param space defines if the point is in world or local space (local by default)
  85008. * @returns the current TransformNode
  85009. */
  85010. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  85011. /**
  85012. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  85013. * @returns the pivot point
  85014. */
  85015. getPivotPoint(): Vector3;
  85016. /**
  85017. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  85018. * @param result the vector3 to store the result
  85019. * @returns this TransformNode.
  85020. */
  85021. getPivotPointToRef(result: Vector3): TransformNode;
  85022. /**
  85023. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  85024. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  85025. */
  85026. getAbsolutePivotPoint(): Vector3;
  85027. /**
  85028. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  85029. * @param result vector3 to store the result
  85030. * @returns this TransformNode.
  85031. */
  85032. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  85033. /**
  85034. * Defines the passed node as the parent of the current node.
  85035. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  85036. * @see https://doc.babylonjs.com/how_to/parenting
  85037. * @param node the node ot set as the parent
  85038. * @returns this TransformNode.
  85039. */
  85040. setParent(node: Nullable<Node>): TransformNode;
  85041. private _nonUniformScaling;
  85042. /**
  85043. * True if the scaling property of this object is non uniform eg. (1,2,1)
  85044. */
  85045. get nonUniformScaling(): boolean;
  85046. /** @hidden */
  85047. _updateNonUniformScalingState(value: boolean): boolean;
  85048. /**
  85049. * Attach the current TransformNode to another TransformNode associated with a bone
  85050. * @param bone Bone affecting the TransformNode
  85051. * @param affectedTransformNode TransformNode associated with the bone
  85052. * @returns this object
  85053. */
  85054. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  85055. /**
  85056. * Detach the transform node if its associated with a bone
  85057. * @returns this object
  85058. */
  85059. detachFromBone(): TransformNode;
  85060. private static _rotationAxisCache;
  85061. /**
  85062. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  85063. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  85064. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  85065. * The passed axis is also normalized.
  85066. * @param axis the axis to rotate around
  85067. * @param amount the amount to rotate in radians
  85068. * @param space Space to rotate in (Default: local)
  85069. * @returns the TransformNode.
  85070. */
  85071. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  85072. /**
  85073. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  85074. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  85075. * The passed axis is also normalized. .
  85076. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  85077. * @param point the point to rotate around
  85078. * @param axis the axis to rotate around
  85079. * @param amount the amount to rotate in radians
  85080. * @returns the TransformNode
  85081. */
  85082. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  85083. /**
  85084. * Translates the mesh along the axis vector for the passed distance in the given space.
  85085. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  85086. * @param axis the axis to translate in
  85087. * @param distance the distance to translate
  85088. * @param space Space to rotate in (Default: local)
  85089. * @returns the TransformNode.
  85090. */
  85091. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  85092. /**
  85093. * Adds a rotation step to the mesh current rotation.
  85094. * x, y, z are Euler angles expressed in radians.
  85095. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  85096. * This means this rotation is made in the mesh local space only.
  85097. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  85098. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  85099. * ```javascript
  85100. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  85101. * ```
  85102. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  85103. * 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.
  85104. * @param x Rotation to add
  85105. * @param y Rotation to add
  85106. * @param z Rotation to add
  85107. * @returns the TransformNode.
  85108. */
  85109. addRotation(x: number, y: number, z: number): TransformNode;
  85110. /**
  85111. * @hidden
  85112. */
  85113. protected _getEffectiveParent(): Nullable<Node>;
  85114. /**
  85115. * Computes the world matrix of the node
  85116. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85117. * @returns the world matrix
  85118. */
  85119. computeWorldMatrix(force?: boolean): Matrix;
  85120. protected _afterComputeWorldMatrix(): void;
  85121. /**
  85122. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  85123. * @param func callback function to add
  85124. *
  85125. * @returns the TransformNode.
  85126. */
  85127. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  85128. /**
  85129. * Removes a registered callback function.
  85130. * @param func callback function to remove
  85131. * @returns the TransformNode.
  85132. */
  85133. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  85134. /**
  85135. * Gets the position of the current mesh in camera space
  85136. * @param camera defines the camera to use
  85137. * @returns a position
  85138. */
  85139. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  85140. /**
  85141. * Returns the distance from the mesh to the active camera
  85142. * @param camera defines the camera to use
  85143. * @returns the distance
  85144. */
  85145. getDistanceToCamera(camera?: Nullable<Camera>): number;
  85146. /**
  85147. * Clone the current transform node
  85148. * @param name Name of the new clone
  85149. * @param newParent New parent for the clone
  85150. * @param doNotCloneChildren Do not clone children hierarchy
  85151. * @returns the new transform node
  85152. */
  85153. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  85154. /**
  85155. * Serializes the objects information.
  85156. * @param currentSerializationObject defines the object to serialize in
  85157. * @returns the serialized object
  85158. */
  85159. serialize(currentSerializationObject?: any): any;
  85160. /**
  85161. * Returns a new TransformNode object parsed from the source provided.
  85162. * @param parsedTransformNode is the source.
  85163. * @param scene the scne the object belongs to
  85164. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  85165. * @returns a new TransformNode object parsed from the source provided.
  85166. */
  85167. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  85168. /**
  85169. * Get all child-transformNodes of this node
  85170. * @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
  85171. * @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
  85172. * @returns an array of TransformNode
  85173. */
  85174. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  85175. /**
  85176. * Releases resources associated with this transform node.
  85177. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  85178. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  85179. */
  85180. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85181. /**
  85182. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  85183. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  85184. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  85185. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  85186. * @returns the current mesh
  85187. */
  85188. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  85189. private _syncAbsoluteScalingAndRotation;
  85190. }
  85191. }
  85192. declare module BABYLON {
  85193. /**
  85194. * Defines the types of pose enabled controllers that are supported
  85195. */
  85196. export enum PoseEnabledControllerType {
  85197. /**
  85198. * HTC Vive
  85199. */
  85200. VIVE = 0,
  85201. /**
  85202. * Oculus Rift
  85203. */
  85204. OCULUS = 1,
  85205. /**
  85206. * Windows mixed reality
  85207. */
  85208. WINDOWS = 2,
  85209. /**
  85210. * Samsung gear VR
  85211. */
  85212. GEAR_VR = 3,
  85213. /**
  85214. * Google Daydream
  85215. */
  85216. DAYDREAM = 4,
  85217. /**
  85218. * Generic
  85219. */
  85220. GENERIC = 5
  85221. }
  85222. /**
  85223. * Defines the MutableGamepadButton interface for the state of a gamepad button
  85224. */
  85225. export interface MutableGamepadButton {
  85226. /**
  85227. * Value of the button/trigger
  85228. */
  85229. value: number;
  85230. /**
  85231. * If the button/trigger is currently touched
  85232. */
  85233. touched: boolean;
  85234. /**
  85235. * If the button/trigger is currently pressed
  85236. */
  85237. pressed: boolean;
  85238. }
  85239. /**
  85240. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  85241. * @hidden
  85242. */
  85243. export interface ExtendedGamepadButton extends GamepadButton {
  85244. /**
  85245. * If the button/trigger is currently pressed
  85246. */
  85247. readonly pressed: boolean;
  85248. /**
  85249. * If the button/trigger is currently touched
  85250. */
  85251. readonly touched: boolean;
  85252. /**
  85253. * Value of the button/trigger
  85254. */
  85255. readonly value: number;
  85256. }
  85257. /** @hidden */
  85258. export interface _GamePadFactory {
  85259. /**
  85260. * Returns wether or not the current gamepad can be created for this type of controller.
  85261. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  85262. * @returns true if it can be created, otherwise false
  85263. */
  85264. canCreate(gamepadInfo: any): boolean;
  85265. /**
  85266. * Creates a new instance of the Gamepad.
  85267. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  85268. * @returns the new gamepad instance
  85269. */
  85270. create(gamepadInfo: any): Gamepad;
  85271. }
  85272. /**
  85273. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  85274. */
  85275. export class PoseEnabledControllerHelper {
  85276. /** @hidden */
  85277. static _ControllerFactories: _GamePadFactory[];
  85278. /** @hidden */
  85279. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  85280. /**
  85281. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  85282. * @param vrGamepad the gamepad to initialized
  85283. * @returns a vr controller of the type the gamepad identified as
  85284. */
  85285. static InitiateController(vrGamepad: any): Gamepad;
  85286. }
  85287. /**
  85288. * Defines the PoseEnabledController object that contains state of a vr capable controller
  85289. */
  85290. export class PoseEnabledController extends Gamepad implements PoseControlled {
  85291. /**
  85292. * If the controller is used in a webXR session
  85293. */
  85294. isXR: boolean;
  85295. private _deviceRoomPosition;
  85296. private _deviceRoomRotationQuaternion;
  85297. /**
  85298. * The device position in babylon space
  85299. */
  85300. devicePosition: Vector3;
  85301. /**
  85302. * The device rotation in babylon space
  85303. */
  85304. deviceRotationQuaternion: Quaternion;
  85305. /**
  85306. * The scale factor of the device in babylon space
  85307. */
  85308. deviceScaleFactor: number;
  85309. /**
  85310. * (Likely devicePosition should be used instead) The device position in its room space
  85311. */
  85312. position: Vector3;
  85313. /**
  85314. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  85315. */
  85316. rotationQuaternion: Quaternion;
  85317. /**
  85318. * The type of controller (Eg. Windows mixed reality)
  85319. */
  85320. controllerType: PoseEnabledControllerType;
  85321. protected _calculatedPosition: Vector3;
  85322. private _calculatedRotation;
  85323. /**
  85324. * The raw pose from the device
  85325. */
  85326. rawPose: DevicePose;
  85327. private _trackPosition;
  85328. private _maxRotationDistFromHeadset;
  85329. private _draggedRoomRotation;
  85330. /**
  85331. * @hidden
  85332. */
  85333. _disableTrackPosition(fixedPosition: Vector3): void;
  85334. /**
  85335. * Internal, the mesh attached to the controller
  85336. * @hidden
  85337. */
  85338. _mesh: Nullable<AbstractMesh>;
  85339. private _poseControlledCamera;
  85340. private _leftHandSystemQuaternion;
  85341. /**
  85342. * Internal, matrix used to convert room space to babylon space
  85343. * @hidden
  85344. */
  85345. _deviceToWorld: Matrix;
  85346. /**
  85347. * Node to be used when casting a ray from the controller
  85348. * @hidden
  85349. */
  85350. _pointingPoseNode: Nullable<TransformNode>;
  85351. /**
  85352. * Name of the child mesh that can be used to cast a ray from the controller
  85353. */
  85354. static readonly POINTING_POSE: string;
  85355. /**
  85356. * Creates a new PoseEnabledController from a gamepad
  85357. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  85358. */
  85359. constructor(browserGamepad: any);
  85360. private _workingMatrix;
  85361. /**
  85362. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  85363. */
  85364. update(): void;
  85365. /**
  85366. * Updates only the pose device and mesh without doing any button event checking
  85367. */
  85368. protected _updatePoseAndMesh(): void;
  85369. /**
  85370. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  85371. * @param poseData raw pose fromthe device
  85372. */
  85373. updateFromDevice(poseData: DevicePose): void;
  85374. /**
  85375. * @hidden
  85376. */
  85377. _meshAttachedObservable: Observable<AbstractMesh>;
  85378. /**
  85379. * Attaches a mesh to the controller
  85380. * @param mesh the mesh to be attached
  85381. */
  85382. attachToMesh(mesh: AbstractMesh): void;
  85383. /**
  85384. * Attaches the controllers mesh to a camera
  85385. * @param camera the camera the mesh should be attached to
  85386. */
  85387. attachToPoseControlledCamera(camera: TargetCamera): void;
  85388. /**
  85389. * Disposes of the controller
  85390. */
  85391. dispose(): void;
  85392. /**
  85393. * The mesh that is attached to the controller
  85394. */
  85395. get mesh(): Nullable<AbstractMesh>;
  85396. /**
  85397. * Gets the ray of the controller in the direction the controller is pointing
  85398. * @param length the length the resulting ray should be
  85399. * @returns a ray in the direction the controller is pointing
  85400. */
  85401. getForwardRay(length?: number): Ray;
  85402. }
  85403. }
  85404. declare module BABYLON {
  85405. /**
  85406. * Defines the WebVRController object that represents controllers tracked in 3D space
  85407. */
  85408. export abstract class WebVRController extends PoseEnabledController {
  85409. /**
  85410. * Internal, the default controller model for the controller
  85411. */
  85412. protected _defaultModel: Nullable<AbstractMesh>;
  85413. /**
  85414. * Fired when the trigger state has changed
  85415. */
  85416. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  85417. /**
  85418. * Fired when the main button state has changed
  85419. */
  85420. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  85421. /**
  85422. * Fired when the secondary button state has changed
  85423. */
  85424. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  85425. /**
  85426. * Fired when the pad state has changed
  85427. */
  85428. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  85429. /**
  85430. * Fired when controllers stick values have changed
  85431. */
  85432. onPadValuesChangedObservable: Observable<StickValues>;
  85433. /**
  85434. * Array of button availible on the controller
  85435. */
  85436. protected _buttons: Array<MutableGamepadButton>;
  85437. private _onButtonStateChange;
  85438. /**
  85439. * Fired when a controller button's state has changed
  85440. * @param callback the callback containing the button that was modified
  85441. */
  85442. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  85443. /**
  85444. * X and Y axis corresponding to the controllers joystick
  85445. */
  85446. pad: StickValues;
  85447. /**
  85448. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  85449. */
  85450. hand: string;
  85451. /**
  85452. * The default controller model for the controller
  85453. */
  85454. get defaultModel(): Nullable<AbstractMesh>;
  85455. /**
  85456. * Creates a new WebVRController from a gamepad
  85457. * @param vrGamepad the gamepad that the WebVRController should be created from
  85458. */
  85459. constructor(vrGamepad: any);
  85460. /**
  85461. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  85462. */
  85463. update(): void;
  85464. /**
  85465. * Function to be called when a button is modified
  85466. */
  85467. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  85468. /**
  85469. * Loads a mesh and attaches it to the controller
  85470. * @param scene the scene the mesh should be added to
  85471. * @param meshLoaded callback for when the mesh has been loaded
  85472. */
  85473. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  85474. private _setButtonValue;
  85475. private _changes;
  85476. private _checkChanges;
  85477. /**
  85478. * Disposes of th webVRCOntroller
  85479. */
  85480. dispose(): void;
  85481. }
  85482. }
  85483. declare module BABYLON {
  85484. /**
  85485. * The HemisphericLight simulates the ambient environment light,
  85486. * so the passed direction is the light reflection direction, not the incoming direction.
  85487. */
  85488. export class HemisphericLight extends Light {
  85489. /**
  85490. * The groundColor is the light in the opposite direction to the one specified during creation.
  85491. * 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.
  85492. */
  85493. groundColor: Color3;
  85494. /**
  85495. * The light reflection direction, not the incoming direction.
  85496. */
  85497. direction: Vector3;
  85498. /**
  85499. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  85500. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  85501. * The HemisphericLight can't cast shadows.
  85502. * Documentation : https://doc.babylonjs.com/babylon101/lights
  85503. * @param name The friendly name of the light
  85504. * @param direction The direction of the light reflection
  85505. * @param scene The scene the light belongs to
  85506. */
  85507. constructor(name: string, direction: Vector3, scene: Scene);
  85508. protected _buildUniformLayout(): void;
  85509. /**
  85510. * Returns the string "HemisphericLight".
  85511. * @return The class name
  85512. */
  85513. getClassName(): string;
  85514. /**
  85515. * Sets the HemisphericLight direction towards the passed target (Vector3).
  85516. * Returns the updated direction.
  85517. * @param target The target the direction should point to
  85518. * @return The computed direction
  85519. */
  85520. setDirectionToTarget(target: Vector3): Vector3;
  85521. /**
  85522. * Returns the shadow generator associated to the light.
  85523. * @returns Always null for hemispheric lights because it does not support shadows.
  85524. */
  85525. getShadowGenerator(): Nullable<IShadowGenerator>;
  85526. /**
  85527. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  85528. * @param effect The effect to update
  85529. * @param lightIndex The index of the light in the effect to update
  85530. * @returns The hemispheric light
  85531. */
  85532. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  85533. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  85534. /**
  85535. * Computes the world matrix of the node
  85536. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85537. * @param useWasUpdatedFlag defines a reserved property
  85538. * @returns the world matrix
  85539. */
  85540. computeWorldMatrix(): Matrix;
  85541. /**
  85542. * Returns the integer 3.
  85543. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  85544. */
  85545. getTypeID(): number;
  85546. /**
  85547. * Prepares the list of defines specific to the light type.
  85548. * @param defines the list of defines
  85549. * @param lightIndex defines the index of the light for the effect
  85550. */
  85551. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  85552. }
  85553. }
  85554. declare module BABYLON {
  85555. /** @hidden */
  85556. export var vrMultiviewToSingleviewPixelShader: {
  85557. name: string;
  85558. shader: string;
  85559. };
  85560. }
  85561. declare module BABYLON {
  85562. /**
  85563. * Renders to multiple views with a single draw call
  85564. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  85565. */
  85566. export class MultiviewRenderTarget extends RenderTargetTexture {
  85567. /**
  85568. * Creates a multiview render target
  85569. * @param scene scene used with the render target
  85570. * @param size the size of the render target (used for each view)
  85571. */
  85572. constructor(scene: Scene, size?: number | {
  85573. width: number;
  85574. height: number;
  85575. } | {
  85576. ratio: number;
  85577. });
  85578. /**
  85579. * @hidden
  85580. * @param faceIndex the face index, if its a cube texture
  85581. */
  85582. _bindFrameBuffer(faceIndex?: number): void;
  85583. /**
  85584. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  85585. * @returns the view count
  85586. */
  85587. getViewCount(): number;
  85588. }
  85589. }
  85590. declare module BABYLON {
  85591. /**
  85592. * Represents a camera frustum
  85593. */
  85594. export class Frustum {
  85595. /**
  85596. * Gets the planes representing the frustum
  85597. * @param transform matrix to be applied to the returned planes
  85598. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  85599. */
  85600. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  85601. /**
  85602. * Gets the near frustum plane transformed by the transform matrix
  85603. * @param transform transformation matrix to be applied to the resulting frustum plane
  85604. * @param frustumPlane the resuling frustum plane
  85605. */
  85606. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85607. /**
  85608. * Gets the far frustum plane transformed by the transform matrix
  85609. * @param transform transformation matrix to be applied to the resulting frustum plane
  85610. * @param frustumPlane the resuling frustum plane
  85611. */
  85612. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85613. /**
  85614. * Gets the left frustum plane transformed by the transform matrix
  85615. * @param transform transformation matrix to be applied to the resulting frustum plane
  85616. * @param frustumPlane the resuling frustum plane
  85617. */
  85618. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85619. /**
  85620. * Gets the right frustum plane transformed by the transform matrix
  85621. * @param transform transformation matrix to be applied to the resulting frustum plane
  85622. * @param frustumPlane the resuling frustum plane
  85623. */
  85624. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85625. /**
  85626. * Gets the top frustum plane transformed by the transform matrix
  85627. * @param transform transformation matrix to be applied to the resulting frustum plane
  85628. * @param frustumPlane the resuling frustum plane
  85629. */
  85630. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85631. /**
  85632. * Gets the bottom frustum plane transformed by the transform matrix
  85633. * @param transform transformation matrix to be applied to the resulting frustum plane
  85634. * @param frustumPlane the resuling frustum plane
  85635. */
  85636. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85637. /**
  85638. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  85639. * @param transform transformation matrix to be applied to the resulting frustum planes
  85640. * @param frustumPlanes the resuling frustum planes
  85641. */
  85642. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  85643. }
  85644. }
  85645. declare module BABYLON {
  85646. interface Engine {
  85647. /**
  85648. * Creates a new multiview render target
  85649. * @param width defines the width of the texture
  85650. * @param height defines the height of the texture
  85651. * @returns the created multiview texture
  85652. */
  85653. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  85654. /**
  85655. * Binds a multiview framebuffer to be drawn to
  85656. * @param multiviewTexture texture to bind
  85657. */
  85658. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  85659. }
  85660. interface Camera {
  85661. /**
  85662. * @hidden
  85663. * 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)
  85664. */
  85665. _useMultiviewToSingleView: boolean;
  85666. /**
  85667. * @hidden
  85668. * 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)
  85669. */
  85670. _multiviewTexture: Nullable<RenderTargetTexture>;
  85671. /**
  85672. * @hidden
  85673. * ensures the multiview texture of the camera exists and has the specified width/height
  85674. * @param width height to set on the multiview texture
  85675. * @param height width to set on the multiview texture
  85676. */
  85677. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  85678. }
  85679. interface Scene {
  85680. /** @hidden */
  85681. _transformMatrixR: Matrix;
  85682. /** @hidden */
  85683. _multiviewSceneUbo: Nullable<UniformBuffer>;
  85684. /** @hidden */
  85685. _createMultiviewUbo(): void;
  85686. /** @hidden */
  85687. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  85688. /** @hidden */
  85689. _renderMultiviewToSingleView(camera: Camera): void;
  85690. }
  85691. }
  85692. declare module BABYLON {
  85693. /**
  85694. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  85695. * This will not be used for webXR as it supports displaying texture arrays directly
  85696. */
  85697. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  85698. /**
  85699. * Initializes a VRMultiviewToSingleview
  85700. * @param name name of the post process
  85701. * @param camera camera to be applied to
  85702. * @param scaleFactor scaling factor to the size of the output texture
  85703. */
  85704. constructor(name: string, camera: Camera, scaleFactor: number);
  85705. }
  85706. }
  85707. declare module BABYLON {
  85708. /**
  85709. * Interface used to define additional presentation attributes
  85710. */
  85711. export interface IVRPresentationAttributes {
  85712. /**
  85713. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  85714. */
  85715. highRefreshRate: boolean;
  85716. /**
  85717. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  85718. */
  85719. foveationLevel: number;
  85720. }
  85721. interface Engine {
  85722. /** @hidden */
  85723. _vrDisplay: any;
  85724. /** @hidden */
  85725. _vrSupported: boolean;
  85726. /** @hidden */
  85727. _oldSize: Size;
  85728. /** @hidden */
  85729. _oldHardwareScaleFactor: number;
  85730. /** @hidden */
  85731. _vrExclusivePointerMode: boolean;
  85732. /** @hidden */
  85733. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  85734. /** @hidden */
  85735. _onVRDisplayPointerRestricted: () => void;
  85736. /** @hidden */
  85737. _onVRDisplayPointerUnrestricted: () => void;
  85738. /** @hidden */
  85739. _onVrDisplayConnect: Nullable<(display: any) => void>;
  85740. /** @hidden */
  85741. _onVrDisplayDisconnect: Nullable<() => void>;
  85742. /** @hidden */
  85743. _onVrDisplayPresentChange: Nullable<() => void>;
  85744. /**
  85745. * Observable signaled when VR display mode changes
  85746. */
  85747. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  85748. /**
  85749. * Observable signaled when VR request present is complete
  85750. */
  85751. onVRRequestPresentComplete: Observable<boolean>;
  85752. /**
  85753. * Observable signaled when VR request present starts
  85754. */
  85755. onVRRequestPresentStart: Observable<Engine>;
  85756. /**
  85757. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  85758. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  85759. */
  85760. isInVRExclusivePointerMode: boolean;
  85761. /**
  85762. * Gets a boolean indicating if a webVR device was detected
  85763. * @returns true if a webVR device was detected
  85764. */
  85765. isVRDevicePresent(): boolean;
  85766. /**
  85767. * Gets the current webVR device
  85768. * @returns the current webVR device (or null)
  85769. */
  85770. getVRDevice(): any;
  85771. /**
  85772. * Initializes a webVR display and starts listening to display change events
  85773. * The onVRDisplayChangedObservable will be notified upon these changes
  85774. * @returns A promise containing a VRDisplay and if vr is supported
  85775. */
  85776. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  85777. /** @hidden */
  85778. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  85779. /**
  85780. * Gets or sets the presentation attributes used to configure VR rendering
  85781. */
  85782. vrPresentationAttributes?: IVRPresentationAttributes;
  85783. /**
  85784. * Call this function to switch to webVR mode
  85785. * Will do nothing if webVR is not supported or if there is no webVR device
  85786. * @param options the webvr options provided to the camera. mainly used for multiview
  85787. * @see http://doc.babylonjs.com/how_to/webvr_camera
  85788. */
  85789. enableVR(options: WebVROptions): void;
  85790. /** @hidden */
  85791. _onVRFullScreenTriggered(): void;
  85792. }
  85793. }
  85794. declare module BABYLON {
  85795. /**
  85796. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  85797. * IMPORTANT!! The data is right-hand data.
  85798. * @export
  85799. * @interface DevicePose
  85800. */
  85801. export interface DevicePose {
  85802. /**
  85803. * The position of the device, values in array are [x,y,z].
  85804. */
  85805. readonly position: Nullable<Float32Array>;
  85806. /**
  85807. * The linearVelocity of the device, values in array are [x,y,z].
  85808. */
  85809. readonly linearVelocity: Nullable<Float32Array>;
  85810. /**
  85811. * The linearAcceleration of the device, values in array are [x,y,z].
  85812. */
  85813. readonly linearAcceleration: Nullable<Float32Array>;
  85814. /**
  85815. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  85816. */
  85817. readonly orientation: Nullable<Float32Array>;
  85818. /**
  85819. * The angularVelocity of the device, values in array are [x,y,z].
  85820. */
  85821. readonly angularVelocity: Nullable<Float32Array>;
  85822. /**
  85823. * The angularAcceleration of the device, values in array are [x,y,z].
  85824. */
  85825. readonly angularAcceleration: Nullable<Float32Array>;
  85826. }
  85827. /**
  85828. * Interface representing a pose controlled object in Babylon.
  85829. * A pose controlled object has both regular pose values as well as pose values
  85830. * from an external device such as a VR head mounted display
  85831. */
  85832. export interface PoseControlled {
  85833. /**
  85834. * The position of the object in babylon space.
  85835. */
  85836. position: Vector3;
  85837. /**
  85838. * The rotation quaternion of the object in babylon space.
  85839. */
  85840. rotationQuaternion: Quaternion;
  85841. /**
  85842. * The position of the device in babylon space.
  85843. */
  85844. devicePosition?: Vector3;
  85845. /**
  85846. * The rotation quaternion of the device in babylon space.
  85847. */
  85848. deviceRotationQuaternion: Quaternion;
  85849. /**
  85850. * The raw pose coming from the device.
  85851. */
  85852. rawPose: Nullable<DevicePose>;
  85853. /**
  85854. * The scale of the device to be used when translating from device space to babylon space.
  85855. */
  85856. deviceScaleFactor: number;
  85857. /**
  85858. * Updates the poseControlled values based on the input device pose.
  85859. * @param poseData the pose data to update the object with
  85860. */
  85861. updateFromDevice(poseData: DevicePose): void;
  85862. }
  85863. /**
  85864. * Set of options to customize the webVRCamera
  85865. */
  85866. export interface WebVROptions {
  85867. /**
  85868. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  85869. */
  85870. trackPosition?: boolean;
  85871. /**
  85872. * Sets the scale of the vrDevice in babylon space. (default: 1)
  85873. */
  85874. positionScale?: number;
  85875. /**
  85876. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  85877. */
  85878. displayName?: string;
  85879. /**
  85880. * Should the native controller meshes be initialized. (default: true)
  85881. */
  85882. controllerMeshes?: boolean;
  85883. /**
  85884. * Creating a default HemiLight only on controllers. (default: true)
  85885. */
  85886. defaultLightingOnControllers?: boolean;
  85887. /**
  85888. * If you don't want to use the default VR button of the helper. (default: false)
  85889. */
  85890. useCustomVRButton?: boolean;
  85891. /**
  85892. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  85893. */
  85894. customVRButton?: HTMLButtonElement;
  85895. /**
  85896. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  85897. */
  85898. rayLength?: number;
  85899. /**
  85900. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  85901. */
  85902. defaultHeight?: number;
  85903. /**
  85904. * If multiview should be used if availible (default: false)
  85905. */
  85906. useMultiview?: boolean;
  85907. }
  85908. /**
  85909. * This represents a WebVR camera.
  85910. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  85911. * @example http://doc.babylonjs.com/how_to/webvr_camera
  85912. */
  85913. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  85914. private webVROptions;
  85915. /**
  85916. * @hidden
  85917. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  85918. */
  85919. _vrDevice: any;
  85920. /**
  85921. * The rawPose of the vrDevice.
  85922. */
  85923. rawPose: Nullable<DevicePose>;
  85924. private _onVREnabled;
  85925. private _specsVersion;
  85926. private _attached;
  85927. private _frameData;
  85928. protected _descendants: Array<Node>;
  85929. private _deviceRoomPosition;
  85930. /** @hidden */
  85931. _deviceRoomRotationQuaternion: Quaternion;
  85932. private _standingMatrix;
  85933. /**
  85934. * Represents device position in babylon space.
  85935. */
  85936. devicePosition: Vector3;
  85937. /**
  85938. * Represents device rotation in babylon space.
  85939. */
  85940. deviceRotationQuaternion: Quaternion;
  85941. /**
  85942. * The scale of the device to be used when translating from device space to babylon space.
  85943. */
  85944. deviceScaleFactor: number;
  85945. private _deviceToWorld;
  85946. private _worldToDevice;
  85947. /**
  85948. * References to the webVR controllers for the vrDevice.
  85949. */
  85950. controllers: Array<WebVRController>;
  85951. /**
  85952. * Emits an event when a controller is attached.
  85953. */
  85954. onControllersAttachedObservable: Observable<WebVRController[]>;
  85955. /**
  85956. * Emits an event when a controller's mesh has been loaded;
  85957. */
  85958. onControllerMeshLoadedObservable: Observable<WebVRController>;
  85959. /**
  85960. * Emits an event when the HMD's pose has been updated.
  85961. */
  85962. onPoseUpdatedFromDeviceObservable: Observable<any>;
  85963. private _poseSet;
  85964. /**
  85965. * If the rig cameras be used as parent instead of this camera.
  85966. */
  85967. rigParenting: boolean;
  85968. private _lightOnControllers;
  85969. private _defaultHeight?;
  85970. /**
  85971. * Instantiates a WebVRFreeCamera.
  85972. * @param name The name of the WebVRFreeCamera
  85973. * @param position The starting anchor position for the camera
  85974. * @param scene The scene the camera belongs to
  85975. * @param webVROptions a set of customizable options for the webVRCamera
  85976. */
  85977. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  85978. /**
  85979. * Gets the device distance from the ground in meters.
  85980. * @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.
  85981. */
  85982. deviceDistanceToRoomGround(): number;
  85983. /**
  85984. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  85985. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  85986. */
  85987. useStandingMatrix(callback?: (bool: boolean) => void): void;
  85988. /**
  85989. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  85990. * @returns A promise with a boolean set to if the standing matrix is supported.
  85991. */
  85992. useStandingMatrixAsync(): Promise<boolean>;
  85993. /**
  85994. * Disposes the camera
  85995. */
  85996. dispose(): void;
  85997. /**
  85998. * Gets a vrController by name.
  85999. * @param name The name of the controller to retreive
  86000. * @returns the controller matching the name specified or null if not found
  86001. */
  86002. getControllerByName(name: string): Nullable<WebVRController>;
  86003. private _leftController;
  86004. /**
  86005. * The controller corresponding to the users left hand.
  86006. */
  86007. get leftController(): Nullable<WebVRController>;
  86008. private _rightController;
  86009. /**
  86010. * The controller corresponding to the users right hand.
  86011. */
  86012. get rightController(): Nullable<WebVRController>;
  86013. /**
  86014. * Casts a ray forward from the vrCamera's gaze.
  86015. * @param length Length of the ray (default: 100)
  86016. * @returns the ray corresponding to the gaze
  86017. */
  86018. getForwardRay(length?: number): Ray;
  86019. /**
  86020. * @hidden
  86021. * Updates the camera based on device's frame data
  86022. */
  86023. _checkInputs(): void;
  86024. /**
  86025. * Updates the poseControlled values based on the input device pose.
  86026. * @param poseData Pose coming from the device
  86027. */
  86028. updateFromDevice(poseData: DevicePose): void;
  86029. private _htmlElementAttached;
  86030. private _detachIfAttached;
  86031. /**
  86032. * WebVR's attach control will start broadcasting frames to the device.
  86033. * Note that in certain browsers (chrome for example) this function must be called
  86034. * within a user-interaction callback. Example:
  86035. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  86036. *
  86037. * @param element html element to attach the vrDevice to
  86038. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  86039. */
  86040. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  86041. /**
  86042. * Detaches the camera from the html element and disables VR
  86043. *
  86044. * @param element html element to detach from
  86045. */
  86046. detachControl(element: HTMLElement): void;
  86047. /**
  86048. * @returns the name of this class
  86049. */
  86050. getClassName(): string;
  86051. /**
  86052. * Calls resetPose on the vrDisplay
  86053. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  86054. */
  86055. resetToCurrentRotation(): void;
  86056. /**
  86057. * @hidden
  86058. * Updates the rig cameras (left and right eye)
  86059. */
  86060. _updateRigCameras(): void;
  86061. private _workingVector;
  86062. private _oneVector;
  86063. private _workingMatrix;
  86064. private updateCacheCalled;
  86065. private _correctPositionIfNotTrackPosition;
  86066. /**
  86067. * @hidden
  86068. * Updates the cached values of the camera
  86069. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  86070. */
  86071. _updateCache(ignoreParentClass?: boolean): void;
  86072. /**
  86073. * @hidden
  86074. * Get current device position in babylon world
  86075. */
  86076. _computeDevicePosition(): void;
  86077. /**
  86078. * Updates the current device position and rotation in the babylon world
  86079. */
  86080. update(): void;
  86081. /**
  86082. * @hidden
  86083. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  86084. * @returns an identity matrix
  86085. */
  86086. _getViewMatrix(): Matrix;
  86087. private _tmpMatrix;
  86088. /**
  86089. * This function is called by the two RIG cameras.
  86090. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  86091. * @hidden
  86092. */
  86093. _getWebVRViewMatrix(): Matrix;
  86094. /** @hidden */
  86095. _getWebVRProjectionMatrix(): Matrix;
  86096. private _onGamepadConnectedObserver;
  86097. private _onGamepadDisconnectedObserver;
  86098. private _updateCacheWhenTrackingDisabledObserver;
  86099. /**
  86100. * Initializes the controllers and their meshes
  86101. */
  86102. initControllers(): void;
  86103. }
  86104. }
  86105. declare module BABYLON {
  86106. /**
  86107. * Size options for a post process
  86108. */
  86109. export type PostProcessOptions = {
  86110. width: number;
  86111. height: number;
  86112. };
  86113. /**
  86114. * PostProcess can be used to apply a shader to a texture after it has been rendered
  86115. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  86116. */
  86117. export class PostProcess {
  86118. /** Name of the PostProcess. */
  86119. name: string;
  86120. /**
  86121. * Gets or sets the unique id of the post process
  86122. */
  86123. uniqueId: number;
  86124. /**
  86125. * Width of the texture to apply the post process on
  86126. */
  86127. width: number;
  86128. /**
  86129. * Height of the texture to apply the post process on
  86130. */
  86131. height: number;
  86132. /**
  86133. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  86134. * @hidden
  86135. */
  86136. _outputTexture: Nullable<InternalTexture>;
  86137. /**
  86138. * Sampling mode used by the shader
  86139. * See https://doc.babylonjs.com/classes/3.1/texture
  86140. */
  86141. renderTargetSamplingMode: number;
  86142. /**
  86143. * Clear color to use when screen clearing
  86144. */
  86145. clearColor: Color4;
  86146. /**
  86147. * If the buffer needs to be cleared before applying the post process. (default: true)
  86148. * Should be set to false if shader will overwrite all previous pixels.
  86149. */
  86150. autoClear: boolean;
  86151. /**
  86152. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  86153. */
  86154. alphaMode: number;
  86155. /**
  86156. * Sets the setAlphaBlendConstants of the babylon engine
  86157. */
  86158. alphaConstants: Color4;
  86159. /**
  86160. * Animations to be used for the post processing
  86161. */
  86162. animations: Animation[];
  86163. /**
  86164. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  86165. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  86166. */
  86167. enablePixelPerfectMode: boolean;
  86168. /**
  86169. * Force the postprocess to be applied without taking in account viewport
  86170. */
  86171. forceFullscreenViewport: boolean;
  86172. /**
  86173. * List of inspectable custom properties (used by the Inspector)
  86174. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86175. */
  86176. inspectableCustomProperties: IInspectable[];
  86177. /**
  86178. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  86179. *
  86180. * | Value | Type | Description |
  86181. * | ----- | ----------------------------------- | ----------- |
  86182. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  86183. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  86184. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  86185. *
  86186. */
  86187. scaleMode: number;
  86188. /**
  86189. * Force textures to be a power of two (default: false)
  86190. */
  86191. alwaysForcePOT: boolean;
  86192. private _samples;
  86193. /**
  86194. * Number of sample textures (default: 1)
  86195. */
  86196. get samples(): number;
  86197. set samples(n: number);
  86198. /**
  86199. * Modify the scale of the post process to be the same as the viewport (default: false)
  86200. */
  86201. adaptScaleToCurrentViewport: boolean;
  86202. private _camera;
  86203. private _scene;
  86204. private _engine;
  86205. private _options;
  86206. private _reusable;
  86207. private _textureType;
  86208. /**
  86209. * Smart array of input and output textures for the post process.
  86210. * @hidden
  86211. */
  86212. _textures: SmartArray<InternalTexture>;
  86213. /**
  86214. * The index in _textures that corresponds to the output texture.
  86215. * @hidden
  86216. */
  86217. _currentRenderTextureInd: number;
  86218. private _effect;
  86219. private _samplers;
  86220. private _fragmentUrl;
  86221. private _vertexUrl;
  86222. private _parameters;
  86223. private _scaleRatio;
  86224. protected _indexParameters: any;
  86225. private _shareOutputWithPostProcess;
  86226. private _texelSize;
  86227. private _forcedOutputTexture;
  86228. /**
  86229. * Returns the fragment url or shader name used in the post process.
  86230. * @returns the fragment url or name in the shader store.
  86231. */
  86232. getEffectName(): string;
  86233. /**
  86234. * An event triggered when the postprocess is activated.
  86235. */
  86236. onActivateObservable: Observable<Camera>;
  86237. private _onActivateObserver;
  86238. /**
  86239. * A function that is added to the onActivateObservable
  86240. */
  86241. set onActivate(callback: Nullable<(camera: Camera) => void>);
  86242. /**
  86243. * An event triggered when the postprocess changes its size.
  86244. */
  86245. onSizeChangedObservable: Observable<PostProcess>;
  86246. private _onSizeChangedObserver;
  86247. /**
  86248. * A function that is added to the onSizeChangedObservable
  86249. */
  86250. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  86251. /**
  86252. * An event triggered when the postprocess applies its effect.
  86253. */
  86254. onApplyObservable: Observable<Effect>;
  86255. private _onApplyObserver;
  86256. /**
  86257. * A function that is added to the onApplyObservable
  86258. */
  86259. set onApply(callback: (effect: Effect) => void);
  86260. /**
  86261. * An event triggered before rendering the postprocess
  86262. */
  86263. onBeforeRenderObservable: Observable<Effect>;
  86264. private _onBeforeRenderObserver;
  86265. /**
  86266. * A function that is added to the onBeforeRenderObservable
  86267. */
  86268. set onBeforeRender(callback: (effect: Effect) => void);
  86269. /**
  86270. * An event triggered after rendering the postprocess
  86271. */
  86272. onAfterRenderObservable: Observable<Effect>;
  86273. private _onAfterRenderObserver;
  86274. /**
  86275. * A function that is added to the onAfterRenderObservable
  86276. */
  86277. set onAfterRender(callback: (efect: Effect) => void);
  86278. /**
  86279. * 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
  86280. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  86281. */
  86282. get inputTexture(): InternalTexture;
  86283. set inputTexture(value: InternalTexture);
  86284. /**
  86285. * Gets the camera which post process is applied to.
  86286. * @returns The camera the post process is applied to.
  86287. */
  86288. getCamera(): Camera;
  86289. /**
  86290. * Gets the texel size of the postprocess.
  86291. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  86292. */
  86293. get texelSize(): Vector2;
  86294. /**
  86295. * Creates a new instance PostProcess
  86296. * @param name The name of the PostProcess.
  86297. * @param fragmentUrl The url of the fragment shader to be used.
  86298. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  86299. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  86300. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  86301. * @param camera The camera to apply the render pass to.
  86302. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  86303. * @param engine The engine which the post process will be applied. (default: current engine)
  86304. * @param reusable If the post process can be reused on the same frame. (default: false)
  86305. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  86306. * @param textureType Type of textures used when performing the post process. (default: 0)
  86307. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  86308. * @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
  86309. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  86310. */
  86311. constructor(
  86312. /** Name of the PostProcess. */
  86313. 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);
  86314. /**
  86315. * Gets a string idenfifying the name of the class
  86316. * @returns "PostProcess" string
  86317. */
  86318. getClassName(): string;
  86319. /**
  86320. * Gets the engine which this post process belongs to.
  86321. * @returns The engine the post process was enabled with.
  86322. */
  86323. getEngine(): Engine;
  86324. /**
  86325. * The effect that is created when initializing the post process.
  86326. * @returns The created effect corresponding the the postprocess.
  86327. */
  86328. getEffect(): Effect;
  86329. /**
  86330. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  86331. * @param postProcess The post process to share the output with.
  86332. * @returns This post process.
  86333. */
  86334. shareOutputWith(postProcess: PostProcess): PostProcess;
  86335. /**
  86336. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  86337. * This should be called if the post process that shares output with this post process is disabled/disposed.
  86338. */
  86339. useOwnOutput(): void;
  86340. /**
  86341. * Updates the effect with the current post process compile time values and recompiles the shader.
  86342. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  86343. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  86344. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  86345. * @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
  86346. * @param onCompiled Called when the shader has been compiled.
  86347. * @param onError Called if there is an error when compiling a shader.
  86348. */
  86349. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  86350. /**
  86351. * The post process is reusable if it can be used multiple times within one frame.
  86352. * @returns If the post process is reusable
  86353. */
  86354. isReusable(): boolean;
  86355. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  86356. markTextureDirty(): void;
  86357. /**
  86358. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  86359. * 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.
  86360. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  86361. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  86362. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  86363. * @returns The target texture that was bound to be written to.
  86364. */
  86365. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  86366. /**
  86367. * If the post process is supported.
  86368. */
  86369. get isSupported(): boolean;
  86370. /**
  86371. * The aspect ratio of the output texture.
  86372. */
  86373. get aspectRatio(): number;
  86374. /**
  86375. * Get a value indicating if the post-process is ready to be used
  86376. * @returns true if the post-process is ready (shader is compiled)
  86377. */
  86378. isReady(): boolean;
  86379. /**
  86380. * Binds all textures and uniforms to the shader, this will be run on every pass.
  86381. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  86382. */
  86383. apply(): Nullable<Effect>;
  86384. private _disposeTextures;
  86385. /**
  86386. * Disposes the post process.
  86387. * @param camera The camera to dispose the post process on.
  86388. */
  86389. dispose(camera?: Camera): void;
  86390. }
  86391. }
  86392. declare module BABYLON {
  86393. /** @hidden */
  86394. export var kernelBlurVaryingDeclaration: {
  86395. name: string;
  86396. shader: string;
  86397. };
  86398. }
  86399. declare module BABYLON {
  86400. /** @hidden */
  86401. export var kernelBlurFragment: {
  86402. name: string;
  86403. shader: string;
  86404. };
  86405. }
  86406. declare module BABYLON {
  86407. /** @hidden */
  86408. export var kernelBlurFragment2: {
  86409. name: string;
  86410. shader: string;
  86411. };
  86412. }
  86413. declare module BABYLON {
  86414. /** @hidden */
  86415. export var kernelBlurPixelShader: {
  86416. name: string;
  86417. shader: string;
  86418. };
  86419. }
  86420. declare module BABYLON {
  86421. /** @hidden */
  86422. export var kernelBlurVertex: {
  86423. name: string;
  86424. shader: string;
  86425. };
  86426. }
  86427. declare module BABYLON {
  86428. /** @hidden */
  86429. export var kernelBlurVertexShader: {
  86430. name: string;
  86431. shader: string;
  86432. };
  86433. }
  86434. declare module BABYLON {
  86435. /**
  86436. * The Blur Post Process which blurs an image based on a kernel and direction.
  86437. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  86438. */
  86439. export class BlurPostProcess extends PostProcess {
  86440. /** The direction in which to blur the image. */
  86441. direction: Vector2;
  86442. private blockCompilation;
  86443. protected _kernel: number;
  86444. protected _idealKernel: number;
  86445. protected _packedFloat: boolean;
  86446. private _staticDefines;
  86447. /**
  86448. * Sets the length in pixels of the blur sample region
  86449. */
  86450. set kernel(v: number);
  86451. /**
  86452. * Gets the length in pixels of the blur sample region
  86453. */
  86454. get kernel(): number;
  86455. /**
  86456. * Sets wether or not the blur needs to unpack/repack floats
  86457. */
  86458. set packedFloat(v: boolean);
  86459. /**
  86460. * Gets wether or not the blur is unpacking/repacking floats
  86461. */
  86462. get packedFloat(): boolean;
  86463. /**
  86464. * Creates a new instance BlurPostProcess
  86465. * @param name The name of the effect.
  86466. * @param direction The direction in which to blur the image.
  86467. * @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.
  86468. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  86469. * @param camera The camera to apply the render pass to.
  86470. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  86471. * @param engine The engine which the post process will be applied. (default: current engine)
  86472. * @param reusable If the post process can be reused on the same frame. (default: false)
  86473. * @param textureType Type of textures used when performing the post process. (default: 0)
  86474. * @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)
  86475. */
  86476. constructor(name: string,
  86477. /** The direction in which to blur the image. */
  86478. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  86479. /**
  86480. * Updates the effect with the current post process compile time values and recompiles the shader.
  86481. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  86482. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  86483. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  86484. * @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
  86485. * @param onCompiled Called when the shader has been compiled.
  86486. * @param onError Called if there is an error when compiling a shader.
  86487. */
  86488. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  86489. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  86490. /**
  86491. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  86492. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  86493. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  86494. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  86495. * The gaps between physical kernels are compensated for in the weighting of the samples
  86496. * @param idealKernel Ideal blur kernel.
  86497. * @return Nearest best kernel.
  86498. */
  86499. protected _nearestBestKernel(idealKernel: number): number;
  86500. /**
  86501. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  86502. * @param x The point on the Gaussian distribution to sample.
  86503. * @return the value of the Gaussian function at x.
  86504. */
  86505. protected _gaussianWeight(x: number): number;
  86506. /**
  86507. * Generates a string that can be used as a floating point number in GLSL.
  86508. * @param x Value to print.
  86509. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  86510. * @return GLSL float string.
  86511. */
  86512. protected _glslFloat(x: number, decimalFigures?: number): string;
  86513. }
  86514. }
  86515. declare module BABYLON {
  86516. /**
  86517. * Mirror texture can be used to simulate the view from a mirror in a scene.
  86518. * It will dynamically be rendered every frame to adapt to the camera point of view.
  86519. * You can then easily use it as a reflectionTexture on a flat surface.
  86520. * In case the surface is not a plane, please consider relying on reflection probes.
  86521. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  86522. */
  86523. export class MirrorTexture extends RenderTargetTexture {
  86524. private scene;
  86525. /**
  86526. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  86527. * 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.
  86528. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  86529. */
  86530. mirrorPlane: Plane;
  86531. /**
  86532. * Define the blur ratio used to blur the reflection if needed.
  86533. */
  86534. set blurRatio(value: number);
  86535. get blurRatio(): number;
  86536. /**
  86537. * Define the adaptive blur kernel used to blur the reflection if needed.
  86538. * This will autocompute the closest best match for the `blurKernel`
  86539. */
  86540. set adaptiveBlurKernel(value: number);
  86541. /**
  86542. * Define the blur kernel used to blur the reflection if needed.
  86543. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  86544. */
  86545. set blurKernel(value: number);
  86546. /**
  86547. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  86548. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  86549. */
  86550. set blurKernelX(value: number);
  86551. get blurKernelX(): number;
  86552. /**
  86553. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  86554. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  86555. */
  86556. set blurKernelY(value: number);
  86557. get blurKernelY(): number;
  86558. private _autoComputeBlurKernel;
  86559. protected _onRatioRescale(): void;
  86560. private _updateGammaSpace;
  86561. private _imageProcessingConfigChangeObserver;
  86562. private _transformMatrix;
  86563. private _mirrorMatrix;
  86564. private _savedViewMatrix;
  86565. private _blurX;
  86566. private _blurY;
  86567. private _adaptiveBlurKernel;
  86568. private _blurKernelX;
  86569. private _blurKernelY;
  86570. private _blurRatio;
  86571. /**
  86572. * Instantiates a Mirror Texture.
  86573. * Mirror texture can be used to simulate the view from a mirror in a scene.
  86574. * It will dynamically be rendered every frame to adapt to the camera point of view.
  86575. * You can then easily use it as a reflectionTexture on a flat surface.
  86576. * In case the surface is not a plane, please consider relying on reflection probes.
  86577. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  86578. * @param name
  86579. * @param size
  86580. * @param scene
  86581. * @param generateMipMaps
  86582. * @param type
  86583. * @param samplingMode
  86584. * @param generateDepthBuffer
  86585. */
  86586. constructor(name: string, size: number | {
  86587. width: number;
  86588. height: number;
  86589. } | {
  86590. ratio: number;
  86591. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  86592. private _preparePostProcesses;
  86593. /**
  86594. * Clone the mirror texture.
  86595. * @returns the cloned texture
  86596. */
  86597. clone(): MirrorTexture;
  86598. /**
  86599. * Serialize the texture to a JSON representation you could use in Parse later on
  86600. * @returns the serialized JSON representation
  86601. */
  86602. serialize(): any;
  86603. /**
  86604. * Dispose the texture and release its associated resources.
  86605. */
  86606. dispose(): void;
  86607. }
  86608. }
  86609. declare module BABYLON {
  86610. /**
  86611. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  86612. * @see http://doc.babylonjs.com/babylon101/materials#texture
  86613. */
  86614. export class Texture extends BaseTexture {
  86615. /**
  86616. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  86617. */
  86618. static SerializeBuffers: boolean;
  86619. /** @hidden */
  86620. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  86621. /** @hidden */
  86622. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  86623. /** @hidden */
  86624. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  86625. /** nearest is mag = nearest and min = nearest and mip = linear */
  86626. static readonly NEAREST_SAMPLINGMODE: number;
  86627. /** nearest is mag = nearest and min = nearest and mip = linear */
  86628. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  86629. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86630. static readonly BILINEAR_SAMPLINGMODE: number;
  86631. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86632. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  86633. /** Trilinear is mag = linear and min = linear and mip = linear */
  86634. static readonly TRILINEAR_SAMPLINGMODE: number;
  86635. /** Trilinear is mag = linear and min = linear and mip = linear */
  86636. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  86637. /** mag = nearest and min = nearest and mip = nearest */
  86638. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  86639. /** mag = nearest and min = linear and mip = nearest */
  86640. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  86641. /** mag = nearest and min = linear and mip = linear */
  86642. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  86643. /** mag = nearest and min = linear and mip = none */
  86644. static readonly NEAREST_LINEAR: number;
  86645. /** mag = nearest and min = nearest and mip = none */
  86646. static readonly NEAREST_NEAREST: number;
  86647. /** mag = linear and min = nearest and mip = nearest */
  86648. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  86649. /** mag = linear and min = nearest and mip = linear */
  86650. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  86651. /** mag = linear and min = linear and mip = none */
  86652. static readonly LINEAR_LINEAR: number;
  86653. /** mag = linear and min = nearest and mip = none */
  86654. static readonly LINEAR_NEAREST: number;
  86655. /** Explicit coordinates mode */
  86656. static readonly EXPLICIT_MODE: number;
  86657. /** Spherical coordinates mode */
  86658. static readonly SPHERICAL_MODE: number;
  86659. /** Planar coordinates mode */
  86660. static readonly PLANAR_MODE: number;
  86661. /** Cubic coordinates mode */
  86662. static readonly CUBIC_MODE: number;
  86663. /** Projection coordinates mode */
  86664. static readonly PROJECTION_MODE: number;
  86665. /** Inverse Cubic coordinates mode */
  86666. static readonly SKYBOX_MODE: number;
  86667. /** Inverse Cubic coordinates mode */
  86668. static readonly INVCUBIC_MODE: number;
  86669. /** Equirectangular coordinates mode */
  86670. static readonly EQUIRECTANGULAR_MODE: number;
  86671. /** Equirectangular Fixed coordinates mode */
  86672. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  86673. /** Equirectangular Fixed Mirrored coordinates mode */
  86674. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  86675. /** Texture is not repeating outside of 0..1 UVs */
  86676. static readonly CLAMP_ADDRESSMODE: number;
  86677. /** Texture is repeating outside of 0..1 UVs */
  86678. static readonly WRAP_ADDRESSMODE: number;
  86679. /** Texture is repeating and mirrored */
  86680. static readonly MIRROR_ADDRESSMODE: number;
  86681. /**
  86682. * 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
  86683. */
  86684. static UseSerializedUrlIfAny: boolean;
  86685. /**
  86686. * Define the url of the texture.
  86687. */
  86688. url: Nullable<string>;
  86689. /**
  86690. * Define an offset on the texture to offset the u coordinates of the UVs
  86691. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  86692. */
  86693. uOffset: number;
  86694. /**
  86695. * Define an offset on the texture to offset the v coordinates of the UVs
  86696. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  86697. */
  86698. vOffset: number;
  86699. /**
  86700. * Define an offset on the texture to scale the u coordinates of the UVs
  86701. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  86702. */
  86703. uScale: number;
  86704. /**
  86705. * Define an offset on the texture to scale the v coordinates of the UVs
  86706. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  86707. */
  86708. vScale: number;
  86709. /**
  86710. * Define an offset on the texture to rotate around the u coordinates of the UVs
  86711. * @see http://doc.babylonjs.com/how_to/more_materials
  86712. */
  86713. uAng: number;
  86714. /**
  86715. * Define an offset on the texture to rotate around the v coordinates of the UVs
  86716. * @see http://doc.babylonjs.com/how_to/more_materials
  86717. */
  86718. vAng: number;
  86719. /**
  86720. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  86721. * @see http://doc.babylonjs.com/how_to/more_materials
  86722. */
  86723. wAng: number;
  86724. /**
  86725. * Defines the center of rotation (U)
  86726. */
  86727. uRotationCenter: number;
  86728. /**
  86729. * Defines the center of rotation (V)
  86730. */
  86731. vRotationCenter: number;
  86732. /**
  86733. * Defines the center of rotation (W)
  86734. */
  86735. wRotationCenter: number;
  86736. /**
  86737. * Are mip maps generated for this texture or not.
  86738. */
  86739. get noMipmap(): boolean;
  86740. /**
  86741. * List of inspectable custom properties (used by the Inspector)
  86742. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86743. */
  86744. inspectableCustomProperties: Nullable<IInspectable[]>;
  86745. private _noMipmap;
  86746. /** @hidden */
  86747. _invertY: boolean;
  86748. private _rowGenerationMatrix;
  86749. private _cachedTextureMatrix;
  86750. private _projectionModeMatrix;
  86751. private _t0;
  86752. private _t1;
  86753. private _t2;
  86754. private _cachedUOffset;
  86755. private _cachedVOffset;
  86756. private _cachedUScale;
  86757. private _cachedVScale;
  86758. private _cachedUAng;
  86759. private _cachedVAng;
  86760. private _cachedWAng;
  86761. private _cachedProjectionMatrixId;
  86762. private _cachedCoordinatesMode;
  86763. /** @hidden */
  86764. protected _initialSamplingMode: number;
  86765. /** @hidden */
  86766. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  86767. private _deleteBuffer;
  86768. protected _format: Nullable<number>;
  86769. private _delayedOnLoad;
  86770. private _delayedOnError;
  86771. private _mimeType?;
  86772. /**
  86773. * Observable triggered once the texture has been loaded.
  86774. */
  86775. onLoadObservable: Observable<Texture>;
  86776. protected _isBlocking: boolean;
  86777. /**
  86778. * Is the texture preventing material to render while loading.
  86779. * If false, a default texture will be used instead of the loading one during the preparation step.
  86780. */
  86781. set isBlocking(value: boolean);
  86782. get isBlocking(): boolean;
  86783. /**
  86784. * Get the current sampling mode associated with the texture.
  86785. */
  86786. get samplingMode(): number;
  86787. /**
  86788. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  86789. */
  86790. get invertY(): boolean;
  86791. /**
  86792. * Instantiates a new texture.
  86793. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  86794. * @see http://doc.babylonjs.com/babylon101/materials#texture
  86795. * @param url defines the url of the picture to load as a texture
  86796. * @param scene defines the scene or engine the texture will belong to
  86797. * @param noMipmap defines if the texture will require mip maps or not
  86798. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  86799. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  86800. * @param onLoad defines a callback triggered when the texture has been loaded
  86801. * @param onError defines a callback triggered when an error occurred during the loading session
  86802. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  86803. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  86804. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  86805. * @param mimeType defines an optional mime type information
  86806. */
  86807. 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);
  86808. /**
  86809. * Update the url (and optional buffer) of this texture if url was null during construction.
  86810. * @param url the url of the texture
  86811. * @param buffer the buffer of the texture (defaults to null)
  86812. * @param onLoad callback called when the texture is loaded (defaults to null)
  86813. */
  86814. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  86815. /**
  86816. * Finish the loading sequence of a texture flagged as delayed load.
  86817. * @hidden
  86818. */
  86819. delayLoad(): void;
  86820. private _prepareRowForTextureGeneration;
  86821. /**
  86822. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  86823. * @returns the transform matrix of the texture.
  86824. */
  86825. getTextureMatrix(uBase?: number): Matrix;
  86826. /**
  86827. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  86828. * @returns The reflection texture transform
  86829. */
  86830. getReflectionTextureMatrix(): Matrix;
  86831. /**
  86832. * Clones the texture.
  86833. * @returns the cloned texture
  86834. */
  86835. clone(): Texture;
  86836. /**
  86837. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  86838. * @returns The JSON representation of the texture
  86839. */
  86840. serialize(): any;
  86841. /**
  86842. * Get the current class name of the texture useful for serialization or dynamic coding.
  86843. * @returns "Texture"
  86844. */
  86845. getClassName(): string;
  86846. /**
  86847. * Dispose the texture and release its associated resources.
  86848. */
  86849. dispose(): void;
  86850. /**
  86851. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  86852. * @param parsedTexture Define the JSON representation of the texture
  86853. * @param scene Define the scene the parsed texture should be instantiated in
  86854. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  86855. * @returns The parsed texture if successful
  86856. */
  86857. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  86858. /**
  86859. * Creates a texture from its base 64 representation.
  86860. * @param data Define the base64 payload without the data: prefix
  86861. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  86862. * @param scene Define the scene the texture should belong to
  86863. * @param noMipmap Forces the texture to not create mip map information if true
  86864. * @param invertY define if the texture needs to be inverted on the y axis during loading
  86865. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  86866. * @param onLoad define a callback triggered when the texture has been loaded
  86867. * @param onError define a callback triggered when an error occurred during the loading session
  86868. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  86869. * @returns the created texture
  86870. */
  86871. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  86872. /**
  86873. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  86874. * @param data Define the base64 payload without the data: prefix
  86875. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  86876. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  86877. * @param scene Define the scene the texture should belong to
  86878. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  86879. * @param noMipmap Forces the texture to not create mip map information if true
  86880. * @param invertY define if the texture needs to be inverted on the y axis during loading
  86881. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  86882. * @param onLoad define a callback triggered when the texture has been loaded
  86883. * @param onError define a callback triggered when an error occurred during the loading session
  86884. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  86885. * @returns the created texture
  86886. */
  86887. 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;
  86888. }
  86889. }
  86890. declare module BABYLON {
  86891. /**
  86892. * PostProcessManager is used to manage one or more post processes or post process pipelines
  86893. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  86894. */
  86895. export class PostProcessManager {
  86896. private _scene;
  86897. private _indexBuffer;
  86898. private _vertexBuffers;
  86899. /**
  86900. * Creates a new instance PostProcess
  86901. * @param scene The scene that the post process is associated with.
  86902. */
  86903. constructor(scene: Scene);
  86904. private _prepareBuffers;
  86905. private _buildIndexBuffer;
  86906. /**
  86907. * Rebuilds the vertex buffers of the manager.
  86908. * @hidden
  86909. */
  86910. _rebuild(): void;
  86911. /**
  86912. * Prepares a frame to be run through a post process.
  86913. * @param sourceTexture The input texture to the post procesess. (default: null)
  86914. * @param postProcesses An array of post processes to be run. (default: null)
  86915. * @returns True if the post processes were able to be run.
  86916. * @hidden
  86917. */
  86918. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  86919. /**
  86920. * Manually render a set of post processes to a texture.
  86921. * @param postProcesses An array of post processes to be run.
  86922. * @param targetTexture The target texture to render to.
  86923. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  86924. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  86925. * @param lodLevel defines which lod of the texture to render to
  86926. */
  86927. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  86928. /**
  86929. * Finalize the result of the output of the postprocesses.
  86930. * @param doNotPresent If true the result will not be displayed to the screen.
  86931. * @param targetTexture The target texture to render to.
  86932. * @param faceIndex The index of the face to bind the target texture to.
  86933. * @param postProcesses The array of post processes to render.
  86934. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  86935. * @hidden
  86936. */
  86937. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  86938. /**
  86939. * Disposes of the post process manager.
  86940. */
  86941. dispose(): void;
  86942. }
  86943. }
  86944. declare module BABYLON {
  86945. /** Interface used by value gradients (color, factor, ...) */
  86946. export interface IValueGradient {
  86947. /**
  86948. * Gets or sets the gradient value (between 0 and 1)
  86949. */
  86950. gradient: number;
  86951. }
  86952. /** Class used to store color4 gradient */
  86953. export class ColorGradient implements IValueGradient {
  86954. /**
  86955. * Gets or sets the gradient value (between 0 and 1)
  86956. */
  86957. gradient: number;
  86958. /**
  86959. * Gets or sets first associated color
  86960. */
  86961. color1: Color4;
  86962. /**
  86963. * Gets or sets second associated color
  86964. */
  86965. color2?: Color4;
  86966. /**
  86967. * Will get a color picked randomly between color1 and color2.
  86968. * If color2 is undefined then color1 will be used
  86969. * @param result defines the target Color4 to store the result in
  86970. */
  86971. getColorToRef(result: Color4): void;
  86972. }
  86973. /** Class used to store color 3 gradient */
  86974. export class Color3Gradient implements IValueGradient {
  86975. /**
  86976. * Gets or sets the gradient value (between 0 and 1)
  86977. */
  86978. gradient: number;
  86979. /**
  86980. * Gets or sets the associated color
  86981. */
  86982. color: Color3;
  86983. }
  86984. /** Class used to store factor gradient */
  86985. export class FactorGradient implements IValueGradient {
  86986. /**
  86987. * Gets or sets the gradient value (between 0 and 1)
  86988. */
  86989. gradient: number;
  86990. /**
  86991. * Gets or sets first associated factor
  86992. */
  86993. factor1: number;
  86994. /**
  86995. * Gets or sets second associated factor
  86996. */
  86997. factor2?: number;
  86998. /**
  86999. * Will get a number picked randomly between factor1 and factor2.
  87000. * If factor2 is undefined then factor1 will be used
  87001. * @returns the picked number
  87002. */
  87003. getFactor(): number;
  87004. }
  87005. /**
  87006. * Helper used to simplify some generic gradient tasks
  87007. */
  87008. export class GradientHelper {
  87009. /**
  87010. * Gets the current gradient from an array of IValueGradient
  87011. * @param ratio defines the current ratio to get
  87012. * @param gradients defines the array of IValueGradient
  87013. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  87014. */
  87015. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  87016. }
  87017. }
  87018. declare module BABYLON {
  87019. interface ThinEngine {
  87020. /**
  87021. * Creates a dynamic texture
  87022. * @param width defines the width of the texture
  87023. * @param height defines the height of the texture
  87024. * @param generateMipMaps defines if the engine should generate the mip levels
  87025. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  87026. * @returns the dynamic texture inside an InternalTexture
  87027. */
  87028. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  87029. /**
  87030. * Update the content of a dynamic texture
  87031. * @param texture defines the texture to update
  87032. * @param canvas defines the canvas containing the source
  87033. * @param invertY defines if data must be stored with Y axis inverted
  87034. * @param premulAlpha defines if alpha is stored as premultiplied
  87035. * @param format defines the format of the data
  87036. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  87037. */
  87038. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  87039. }
  87040. }
  87041. declare module BABYLON {
  87042. /**
  87043. * Helper class used to generate a canvas to manipulate images
  87044. */
  87045. export class CanvasGenerator {
  87046. /**
  87047. * Create a new canvas (or offscreen canvas depending on the context)
  87048. * @param width defines the expected width
  87049. * @param height defines the expected height
  87050. * @return a new canvas or offscreen canvas
  87051. */
  87052. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  87053. }
  87054. }
  87055. declare module BABYLON {
  87056. /**
  87057. * A class extending Texture allowing drawing on a texture
  87058. * @see http://doc.babylonjs.com/how_to/dynamictexture
  87059. */
  87060. export class DynamicTexture extends Texture {
  87061. private _generateMipMaps;
  87062. private _canvas;
  87063. private _context;
  87064. private _engine;
  87065. /**
  87066. * Creates a DynamicTexture
  87067. * @param name defines the name of the texture
  87068. * @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
  87069. * @param scene defines the scene where you want the texture
  87070. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  87071. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  87072. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  87073. */
  87074. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  87075. /**
  87076. * Get the current class name of the texture useful for serialization or dynamic coding.
  87077. * @returns "DynamicTexture"
  87078. */
  87079. getClassName(): string;
  87080. /**
  87081. * Gets the current state of canRescale
  87082. */
  87083. get canRescale(): boolean;
  87084. private _recreate;
  87085. /**
  87086. * Scales the texture
  87087. * @param ratio the scale factor to apply to both width and height
  87088. */
  87089. scale(ratio: number): void;
  87090. /**
  87091. * Resizes the texture
  87092. * @param width the new width
  87093. * @param height the new height
  87094. */
  87095. scaleTo(width: number, height: number): void;
  87096. /**
  87097. * Gets the context of the canvas used by the texture
  87098. * @returns the canvas context of the dynamic texture
  87099. */
  87100. getContext(): CanvasRenderingContext2D;
  87101. /**
  87102. * Clears the texture
  87103. */
  87104. clear(): void;
  87105. /**
  87106. * Updates the texture
  87107. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  87108. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  87109. */
  87110. update(invertY?: boolean, premulAlpha?: boolean): void;
  87111. /**
  87112. * Draws text onto the texture
  87113. * @param text defines the text to be drawn
  87114. * @param x defines the placement of the text from the left
  87115. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  87116. * @param font defines the font to be used with font-style, font-size, font-name
  87117. * @param color defines the color used for the text
  87118. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  87119. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  87120. * @param update defines whether texture is immediately update (default is true)
  87121. */
  87122. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  87123. /**
  87124. * Clones the texture
  87125. * @returns the clone of the texture.
  87126. */
  87127. clone(): DynamicTexture;
  87128. /**
  87129. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  87130. * @returns a serialized dynamic texture object
  87131. */
  87132. serialize(): any;
  87133. /** @hidden */
  87134. _rebuild(): void;
  87135. }
  87136. }
  87137. declare module BABYLON {
  87138. interface AbstractScene {
  87139. /**
  87140. * The list of procedural textures added to the scene
  87141. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  87142. */
  87143. proceduralTextures: Array<ProceduralTexture>;
  87144. }
  87145. /**
  87146. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  87147. * in a given scene.
  87148. */
  87149. export class ProceduralTextureSceneComponent implements ISceneComponent {
  87150. /**
  87151. * The component name helpfull to identify the component in the list of scene components.
  87152. */
  87153. readonly name: string;
  87154. /**
  87155. * The scene the component belongs to.
  87156. */
  87157. scene: Scene;
  87158. /**
  87159. * Creates a new instance of the component for the given scene
  87160. * @param scene Defines the scene to register the component in
  87161. */
  87162. constructor(scene: Scene);
  87163. /**
  87164. * Registers the component in a given scene
  87165. */
  87166. register(): void;
  87167. /**
  87168. * Rebuilds the elements related to this component in case of
  87169. * context lost for instance.
  87170. */
  87171. rebuild(): void;
  87172. /**
  87173. * Disposes the component and the associated ressources.
  87174. */
  87175. dispose(): void;
  87176. private _beforeClear;
  87177. }
  87178. }
  87179. declare module BABYLON {
  87180. interface ThinEngine {
  87181. /**
  87182. * Creates a new render target cube texture
  87183. * @param size defines the size of the texture
  87184. * @param options defines the options used to create the texture
  87185. * @returns a new render target cube texture stored in an InternalTexture
  87186. */
  87187. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  87188. }
  87189. }
  87190. declare module BABYLON {
  87191. /** @hidden */
  87192. export var proceduralVertexShader: {
  87193. name: string;
  87194. shader: string;
  87195. };
  87196. }
  87197. declare module BABYLON {
  87198. /**
  87199. * 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.
  87200. * This is the base class of any Procedural texture and contains most of the shareable code.
  87201. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  87202. */
  87203. export class ProceduralTexture extends Texture {
  87204. isCube: boolean;
  87205. /**
  87206. * Define if the texture is enabled or not (disabled texture will not render)
  87207. */
  87208. isEnabled: boolean;
  87209. /**
  87210. * Define if the texture must be cleared before rendering (default is true)
  87211. */
  87212. autoClear: boolean;
  87213. /**
  87214. * Callback called when the texture is generated
  87215. */
  87216. onGenerated: () => void;
  87217. /**
  87218. * Event raised when the texture is generated
  87219. */
  87220. onGeneratedObservable: Observable<ProceduralTexture>;
  87221. /** @hidden */
  87222. _generateMipMaps: boolean;
  87223. /** @hidden **/
  87224. _effect: Effect;
  87225. /** @hidden */
  87226. _textures: {
  87227. [key: string]: Texture;
  87228. };
  87229. private _size;
  87230. private _currentRefreshId;
  87231. private _frameId;
  87232. private _refreshRate;
  87233. private _vertexBuffers;
  87234. private _indexBuffer;
  87235. private _uniforms;
  87236. private _samplers;
  87237. private _fragment;
  87238. private _floats;
  87239. private _ints;
  87240. private _floatsArrays;
  87241. private _colors3;
  87242. private _colors4;
  87243. private _vectors2;
  87244. private _vectors3;
  87245. private _matrices;
  87246. private _fallbackTexture;
  87247. private _fallbackTextureUsed;
  87248. private _engine;
  87249. private _cachedDefines;
  87250. private _contentUpdateId;
  87251. private _contentData;
  87252. /**
  87253. * Instantiates a new procedural texture.
  87254. * 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.
  87255. * This is the base class of any Procedural texture and contains most of the shareable code.
  87256. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  87257. * @param name Define the name of the texture
  87258. * @param size Define the size of the texture to create
  87259. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  87260. * @param scene Define the scene the texture belongs to
  87261. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  87262. * @param generateMipMaps Define if the texture should creates mip maps or not
  87263. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  87264. */
  87265. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  87266. /**
  87267. * The effect that is created when initializing the post process.
  87268. * @returns The created effect corresponding the the postprocess.
  87269. */
  87270. getEffect(): Effect;
  87271. /**
  87272. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  87273. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  87274. */
  87275. getContent(): Nullable<ArrayBufferView>;
  87276. private _createIndexBuffer;
  87277. /** @hidden */
  87278. _rebuild(): void;
  87279. /**
  87280. * Resets the texture in order to recreate its associated resources.
  87281. * This can be called in case of context loss
  87282. */
  87283. reset(): void;
  87284. protected _getDefines(): string;
  87285. /**
  87286. * Is the texture ready to be used ? (rendered at least once)
  87287. * @returns true if ready, otherwise, false.
  87288. */
  87289. isReady(): boolean;
  87290. /**
  87291. * Resets the refresh counter of the texture and start bak from scratch.
  87292. * Could be useful to regenerate the texture if it is setup to render only once.
  87293. */
  87294. resetRefreshCounter(): void;
  87295. /**
  87296. * Set the fragment shader to use in order to render the texture.
  87297. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  87298. */
  87299. setFragment(fragment: any): void;
  87300. /**
  87301. * Define the refresh rate of the texture or the rendering frequency.
  87302. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  87303. */
  87304. get refreshRate(): number;
  87305. set refreshRate(value: number);
  87306. /** @hidden */
  87307. _shouldRender(): boolean;
  87308. /**
  87309. * Get the size the texture is rendering at.
  87310. * @returns the size (texture is always squared)
  87311. */
  87312. getRenderSize(): number;
  87313. /**
  87314. * Resize the texture to new value.
  87315. * @param size Define the new size the texture should have
  87316. * @param generateMipMaps Define whether the new texture should create mip maps
  87317. */
  87318. resize(size: number, generateMipMaps: boolean): void;
  87319. private _checkUniform;
  87320. /**
  87321. * Set a texture in the shader program used to render.
  87322. * @param name Define the name of the uniform samplers as defined in the shader
  87323. * @param texture Define the texture to bind to this sampler
  87324. * @return the texture itself allowing "fluent" like uniform updates
  87325. */
  87326. setTexture(name: string, texture: Texture): ProceduralTexture;
  87327. /**
  87328. * Set a float in the shader.
  87329. * @param name Define the name of the uniform as defined in the shader
  87330. * @param value Define the value to give to the uniform
  87331. * @return the texture itself allowing "fluent" like uniform updates
  87332. */
  87333. setFloat(name: string, value: number): ProceduralTexture;
  87334. /**
  87335. * Set a int in the shader.
  87336. * @param name Define the name of the uniform as defined in the shader
  87337. * @param value Define the value to give to the uniform
  87338. * @return the texture itself allowing "fluent" like uniform updates
  87339. */
  87340. setInt(name: string, value: number): ProceduralTexture;
  87341. /**
  87342. * Set an array of floats in the shader.
  87343. * @param name Define the name of the uniform as defined in the shader
  87344. * @param value Define the value to give to the uniform
  87345. * @return the texture itself allowing "fluent" like uniform updates
  87346. */
  87347. setFloats(name: string, value: number[]): ProceduralTexture;
  87348. /**
  87349. * Set a vec3 in the shader from a Color3.
  87350. * @param name Define the name of the uniform as defined in the shader
  87351. * @param value Define the value to give to the uniform
  87352. * @return the texture itself allowing "fluent" like uniform updates
  87353. */
  87354. setColor3(name: string, value: Color3): ProceduralTexture;
  87355. /**
  87356. * Set a vec4 in the shader from a Color4.
  87357. * @param name Define the name of the uniform as defined in the shader
  87358. * @param value Define the value to give to the uniform
  87359. * @return the texture itself allowing "fluent" like uniform updates
  87360. */
  87361. setColor4(name: string, value: Color4): ProceduralTexture;
  87362. /**
  87363. * Set a vec2 in the shader from a Vector2.
  87364. * @param name Define the name of the uniform as defined in the shader
  87365. * @param value Define the value to give to the uniform
  87366. * @return the texture itself allowing "fluent" like uniform updates
  87367. */
  87368. setVector2(name: string, value: Vector2): ProceduralTexture;
  87369. /**
  87370. * Set a vec3 in the shader from a Vector3.
  87371. * @param name Define the name of the uniform as defined in the shader
  87372. * @param value Define the value to give to the uniform
  87373. * @return the texture itself allowing "fluent" like uniform updates
  87374. */
  87375. setVector3(name: string, value: Vector3): ProceduralTexture;
  87376. /**
  87377. * Set a mat4 in the shader from a MAtrix.
  87378. * @param name Define the name of the uniform as defined in the shader
  87379. * @param value Define the value to give to the uniform
  87380. * @return the texture itself allowing "fluent" like uniform updates
  87381. */
  87382. setMatrix(name: string, value: Matrix): ProceduralTexture;
  87383. /**
  87384. * Render the texture to its associated render target.
  87385. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  87386. */
  87387. render(useCameraPostProcess?: boolean): void;
  87388. /**
  87389. * Clone the texture.
  87390. * @returns the cloned texture
  87391. */
  87392. clone(): ProceduralTexture;
  87393. /**
  87394. * Dispose the texture and release its asoociated resources.
  87395. */
  87396. dispose(): void;
  87397. }
  87398. }
  87399. declare module BABYLON {
  87400. /**
  87401. * This represents the base class for particle system in Babylon.
  87402. * 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.
  87403. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  87404. * @example https://doc.babylonjs.com/babylon101/particles
  87405. */
  87406. export class BaseParticleSystem {
  87407. /**
  87408. * Source color is added to the destination color without alpha affecting the result
  87409. */
  87410. static BLENDMODE_ONEONE: number;
  87411. /**
  87412. * Blend current color and particle color using particle’s alpha
  87413. */
  87414. static BLENDMODE_STANDARD: number;
  87415. /**
  87416. * Add current color and particle color multiplied by particle’s alpha
  87417. */
  87418. static BLENDMODE_ADD: number;
  87419. /**
  87420. * Multiply current color with particle color
  87421. */
  87422. static BLENDMODE_MULTIPLY: number;
  87423. /**
  87424. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  87425. */
  87426. static BLENDMODE_MULTIPLYADD: number;
  87427. /**
  87428. * List of animations used by the particle system.
  87429. */
  87430. animations: Animation[];
  87431. /**
  87432. * The id of the Particle system.
  87433. */
  87434. id: string;
  87435. /**
  87436. * The friendly name of the Particle system.
  87437. */
  87438. name: string;
  87439. /**
  87440. * The rendering group used by the Particle system to chose when to render.
  87441. */
  87442. renderingGroupId: number;
  87443. /**
  87444. * The emitter represents the Mesh or position we are attaching the particle system to.
  87445. */
  87446. emitter: Nullable<AbstractMesh | Vector3>;
  87447. /**
  87448. * The maximum number of particles to emit per frame
  87449. */
  87450. emitRate: number;
  87451. /**
  87452. * If you want to launch only a few particles at once, that can be done, as well.
  87453. */
  87454. manualEmitCount: number;
  87455. /**
  87456. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  87457. */
  87458. updateSpeed: number;
  87459. /**
  87460. * The amount of time the particle system is running (depends of the overall update speed).
  87461. */
  87462. targetStopDuration: number;
  87463. /**
  87464. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  87465. */
  87466. disposeOnStop: boolean;
  87467. /**
  87468. * Minimum power of emitting particles.
  87469. */
  87470. minEmitPower: number;
  87471. /**
  87472. * Maximum power of emitting particles.
  87473. */
  87474. maxEmitPower: number;
  87475. /**
  87476. * Minimum life time of emitting particles.
  87477. */
  87478. minLifeTime: number;
  87479. /**
  87480. * Maximum life time of emitting particles.
  87481. */
  87482. maxLifeTime: number;
  87483. /**
  87484. * Minimum Size of emitting particles.
  87485. */
  87486. minSize: number;
  87487. /**
  87488. * Maximum Size of emitting particles.
  87489. */
  87490. maxSize: number;
  87491. /**
  87492. * Minimum scale of emitting particles on X axis.
  87493. */
  87494. minScaleX: number;
  87495. /**
  87496. * Maximum scale of emitting particles on X axis.
  87497. */
  87498. maxScaleX: number;
  87499. /**
  87500. * Minimum scale of emitting particles on Y axis.
  87501. */
  87502. minScaleY: number;
  87503. /**
  87504. * Maximum scale of emitting particles on Y axis.
  87505. */
  87506. maxScaleY: number;
  87507. /**
  87508. * Gets or sets the minimal initial rotation in radians.
  87509. */
  87510. minInitialRotation: number;
  87511. /**
  87512. * Gets or sets the maximal initial rotation in radians.
  87513. */
  87514. maxInitialRotation: number;
  87515. /**
  87516. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  87517. */
  87518. minAngularSpeed: number;
  87519. /**
  87520. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  87521. */
  87522. maxAngularSpeed: number;
  87523. /**
  87524. * The texture used to render each particle. (this can be a spritesheet)
  87525. */
  87526. particleTexture: Nullable<Texture>;
  87527. /**
  87528. * The layer mask we are rendering the particles through.
  87529. */
  87530. layerMask: number;
  87531. /**
  87532. * This can help using your own shader to render the particle system.
  87533. * The according effect will be created
  87534. */
  87535. customShader: any;
  87536. /**
  87537. * By default particle system starts as soon as they are created. This prevents the
  87538. * automatic start to happen and let you decide when to start emitting particles.
  87539. */
  87540. preventAutoStart: boolean;
  87541. private _noiseTexture;
  87542. /**
  87543. * Gets or sets a texture used to add random noise to particle positions
  87544. */
  87545. get noiseTexture(): Nullable<ProceduralTexture>;
  87546. set noiseTexture(value: Nullable<ProceduralTexture>);
  87547. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  87548. noiseStrength: Vector3;
  87549. /**
  87550. * Callback triggered when the particle animation is ending.
  87551. */
  87552. onAnimationEnd: Nullable<() => void>;
  87553. /**
  87554. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  87555. */
  87556. blendMode: number;
  87557. /**
  87558. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  87559. * to override the particles.
  87560. */
  87561. forceDepthWrite: boolean;
  87562. /** 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 */
  87563. preWarmCycles: number;
  87564. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  87565. preWarmStepOffset: number;
  87566. /**
  87567. * 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)
  87568. */
  87569. spriteCellChangeSpeed: number;
  87570. /**
  87571. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  87572. */
  87573. startSpriteCellID: number;
  87574. /**
  87575. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  87576. */
  87577. endSpriteCellID: number;
  87578. /**
  87579. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  87580. */
  87581. spriteCellWidth: number;
  87582. /**
  87583. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  87584. */
  87585. spriteCellHeight: number;
  87586. /**
  87587. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  87588. */
  87589. spriteRandomStartCell: boolean;
  87590. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  87591. translationPivot: Vector2;
  87592. /** @hidden */
  87593. protected _isAnimationSheetEnabled: boolean;
  87594. /**
  87595. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  87596. */
  87597. beginAnimationOnStart: boolean;
  87598. /**
  87599. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  87600. */
  87601. beginAnimationFrom: number;
  87602. /**
  87603. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  87604. */
  87605. beginAnimationTo: number;
  87606. /**
  87607. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  87608. */
  87609. beginAnimationLoop: boolean;
  87610. /**
  87611. * Gets or sets a world offset applied to all particles
  87612. */
  87613. worldOffset: Vector3;
  87614. /**
  87615. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  87616. */
  87617. get isAnimationSheetEnabled(): boolean;
  87618. set isAnimationSheetEnabled(value: boolean);
  87619. /**
  87620. * Get hosting scene
  87621. * @returns the scene
  87622. */
  87623. getScene(): Scene;
  87624. /**
  87625. * You can use gravity if you want to give an orientation to your particles.
  87626. */
  87627. gravity: Vector3;
  87628. protected _colorGradients: Nullable<Array<ColorGradient>>;
  87629. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  87630. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  87631. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  87632. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  87633. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  87634. protected _dragGradients: Nullable<Array<FactorGradient>>;
  87635. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  87636. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  87637. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  87638. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  87639. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  87640. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  87641. /**
  87642. * Defines the delay in milliseconds before starting the system (0 by default)
  87643. */
  87644. startDelay: number;
  87645. /**
  87646. * Gets the current list of drag gradients.
  87647. * You must use addDragGradient and removeDragGradient to udpate this list
  87648. * @returns the list of drag gradients
  87649. */
  87650. getDragGradients(): Nullable<Array<FactorGradient>>;
  87651. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  87652. limitVelocityDamping: number;
  87653. /**
  87654. * Gets the current list of limit velocity gradients.
  87655. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  87656. * @returns the list of limit velocity gradients
  87657. */
  87658. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  87659. /**
  87660. * Gets the current list of color gradients.
  87661. * You must use addColorGradient and removeColorGradient to udpate this list
  87662. * @returns the list of color gradients
  87663. */
  87664. getColorGradients(): Nullable<Array<ColorGradient>>;
  87665. /**
  87666. * Gets the current list of size gradients.
  87667. * You must use addSizeGradient and removeSizeGradient to udpate this list
  87668. * @returns the list of size gradients
  87669. */
  87670. getSizeGradients(): Nullable<Array<FactorGradient>>;
  87671. /**
  87672. * Gets the current list of color remap gradients.
  87673. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87674. * @returns the list of color remap gradients
  87675. */
  87676. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87677. /**
  87678. * Gets the current list of alpha remap gradients.
  87679. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87680. * @returns the list of alpha remap gradients
  87681. */
  87682. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87683. /**
  87684. * Gets the current list of life time gradients.
  87685. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  87686. * @returns the list of life time gradients
  87687. */
  87688. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  87689. /**
  87690. * Gets the current list of angular speed gradients.
  87691. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  87692. * @returns the list of angular speed gradients
  87693. */
  87694. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  87695. /**
  87696. * Gets the current list of velocity gradients.
  87697. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  87698. * @returns the list of velocity gradients
  87699. */
  87700. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  87701. /**
  87702. * Gets the current list of start size gradients.
  87703. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  87704. * @returns the list of start size gradients
  87705. */
  87706. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  87707. /**
  87708. * Gets the current list of emit rate gradients.
  87709. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  87710. * @returns the list of emit rate gradients
  87711. */
  87712. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  87713. /**
  87714. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87715. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87716. */
  87717. get direction1(): Vector3;
  87718. set direction1(value: Vector3);
  87719. /**
  87720. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87721. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87722. */
  87723. get direction2(): Vector3;
  87724. set direction2(value: Vector3);
  87725. /**
  87726. * 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.
  87727. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87728. */
  87729. get minEmitBox(): Vector3;
  87730. set minEmitBox(value: Vector3);
  87731. /**
  87732. * 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.
  87733. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87734. */
  87735. get maxEmitBox(): Vector3;
  87736. set maxEmitBox(value: Vector3);
  87737. /**
  87738. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  87739. */
  87740. color1: Color4;
  87741. /**
  87742. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  87743. */
  87744. color2: Color4;
  87745. /**
  87746. * Color the particle will have at the end of its lifetime
  87747. */
  87748. colorDead: Color4;
  87749. /**
  87750. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  87751. */
  87752. textureMask: Color4;
  87753. /**
  87754. * The particle emitter type defines the emitter used by the particle system.
  87755. * It can be for example box, sphere, or cone...
  87756. */
  87757. particleEmitterType: IParticleEmitterType;
  87758. /** @hidden */
  87759. _isSubEmitter: boolean;
  87760. /**
  87761. * Gets or sets the billboard mode to use when isBillboardBased = true.
  87762. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  87763. */
  87764. billboardMode: number;
  87765. protected _isBillboardBased: boolean;
  87766. /**
  87767. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  87768. */
  87769. get isBillboardBased(): boolean;
  87770. set isBillboardBased(value: boolean);
  87771. /**
  87772. * The scene the particle system belongs to.
  87773. */
  87774. protected _scene: Scene;
  87775. /**
  87776. * Local cache of defines for image processing.
  87777. */
  87778. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  87779. /**
  87780. * Default configuration related to image processing available in the standard Material.
  87781. */
  87782. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  87783. /**
  87784. * Gets the image processing configuration used either in this material.
  87785. */
  87786. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  87787. /**
  87788. * Sets the Default image processing configuration used either in the this material.
  87789. *
  87790. * If sets to null, the scene one is in use.
  87791. */
  87792. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  87793. /**
  87794. * Attaches a new image processing configuration to the Standard Material.
  87795. * @param configuration
  87796. */
  87797. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  87798. /** @hidden */
  87799. protected _reset(): void;
  87800. /** @hidden */
  87801. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  87802. /**
  87803. * Instantiates a particle system.
  87804. * 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.
  87805. * @param name The name of the particle system
  87806. */
  87807. constructor(name: string);
  87808. /**
  87809. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87810. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87811. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87812. * @returns the emitter
  87813. */
  87814. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87815. /**
  87816. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87817. * @param radius The radius of the hemisphere to emit from
  87818. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87819. * @returns the emitter
  87820. */
  87821. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  87822. /**
  87823. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87824. * @param radius The radius of the sphere to emit from
  87825. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87826. * @returns the emitter
  87827. */
  87828. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  87829. /**
  87830. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87831. * @param radius The radius of the sphere to emit from
  87832. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87833. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87834. * @returns the emitter
  87835. */
  87836. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  87837. /**
  87838. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87839. * @param radius The radius of the emission cylinder
  87840. * @param height The height of the emission cylinder
  87841. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87842. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87843. * @returns the emitter
  87844. */
  87845. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  87846. /**
  87847. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87848. * @param radius The radius of the cylinder to emit from
  87849. * @param height The height of the emission cylinder
  87850. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87851. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87852. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87853. * @returns the emitter
  87854. */
  87855. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  87856. /**
  87857. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87858. * @param radius The radius of the cone to emit from
  87859. * @param angle The base angle of the cone
  87860. * @returns the emitter
  87861. */
  87862. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  87863. /**
  87864. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87865. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87866. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87867. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87868. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87869. * @returns the emitter
  87870. */
  87871. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87872. }
  87873. }
  87874. declare module BABYLON {
  87875. /**
  87876. * Type of sub emitter
  87877. */
  87878. export enum SubEmitterType {
  87879. /**
  87880. * Attached to the particle over it's lifetime
  87881. */
  87882. ATTACHED = 0,
  87883. /**
  87884. * Created when the particle dies
  87885. */
  87886. END = 1
  87887. }
  87888. /**
  87889. * Sub emitter class used to emit particles from an existing particle
  87890. */
  87891. export class SubEmitter {
  87892. /**
  87893. * the particle system to be used by the sub emitter
  87894. */
  87895. particleSystem: ParticleSystem;
  87896. /**
  87897. * Type of the submitter (Default: END)
  87898. */
  87899. type: SubEmitterType;
  87900. /**
  87901. * 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)
  87902. * Note: This only is supported when using an emitter of type Mesh
  87903. */
  87904. inheritDirection: boolean;
  87905. /**
  87906. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  87907. */
  87908. inheritedVelocityAmount: number;
  87909. /**
  87910. * Creates a sub emitter
  87911. * @param particleSystem the particle system to be used by the sub emitter
  87912. */
  87913. constructor(
  87914. /**
  87915. * the particle system to be used by the sub emitter
  87916. */
  87917. particleSystem: ParticleSystem);
  87918. /**
  87919. * Clones the sub emitter
  87920. * @returns the cloned sub emitter
  87921. */
  87922. clone(): SubEmitter;
  87923. /**
  87924. * Serialize current object to a JSON object
  87925. * @returns the serialized object
  87926. */
  87927. serialize(): any;
  87928. /** @hidden */
  87929. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  87930. /**
  87931. * Creates a new SubEmitter from a serialized JSON version
  87932. * @param serializationObject defines the JSON object to read from
  87933. * @param scene defines the hosting scene
  87934. * @param rootUrl defines the rootUrl for data loading
  87935. * @returns a new SubEmitter
  87936. */
  87937. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  87938. /** Release associated resources */
  87939. dispose(): void;
  87940. }
  87941. }
  87942. declare module BABYLON {
  87943. /** @hidden */
  87944. export var clipPlaneFragmentDeclaration: {
  87945. name: string;
  87946. shader: string;
  87947. };
  87948. }
  87949. declare module BABYLON {
  87950. /** @hidden */
  87951. export var imageProcessingDeclaration: {
  87952. name: string;
  87953. shader: string;
  87954. };
  87955. }
  87956. declare module BABYLON {
  87957. /** @hidden */
  87958. export var imageProcessingFunctions: {
  87959. name: string;
  87960. shader: string;
  87961. };
  87962. }
  87963. declare module BABYLON {
  87964. /** @hidden */
  87965. export var clipPlaneFragment: {
  87966. name: string;
  87967. shader: string;
  87968. };
  87969. }
  87970. declare module BABYLON {
  87971. /** @hidden */
  87972. export var particlesPixelShader: {
  87973. name: string;
  87974. shader: string;
  87975. };
  87976. }
  87977. declare module BABYLON {
  87978. /** @hidden */
  87979. export var clipPlaneVertexDeclaration: {
  87980. name: string;
  87981. shader: string;
  87982. };
  87983. }
  87984. declare module BABYLON {
  87985. /** @hidden */
  87986. export var clipPlaneVertex: {
  87987. name: string;
  87988. shader: string;
  87989. };
  87990. }
  87991. declare module BABYLON {
  87992. /** @hidden */
  87993. export var particlesVertexShader: {
  87994. name: string;
  87995. shader: string;
  87996. };
  87997. }
  87998. declare module BABYLON {
  87999. /**
  88000. * This represents a particle system in Babylon.
  88001. * 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.
  88002. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  88003. * @example https://doc.babylonjs.com/babylon101/particles
  88004. */
  88005. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  88006. /**
  88007. * Billboard mode will only apply to Y axis
  88008. */
  88009. static readonly BILLBOARDMODE_Y: number;
  88010. /**
  88011. * Billboard mode will apply to all axes
  88012. */
  88013. static readonly BILLBOARDMODE_ALL: number;
  88014. /**
  88015. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  88016. */
  88017. static readonly BILLBOARDMODE_STRETCHED: number;
  88018. /**
  88019. * This function can be defined to provide custom update for active particles.
  88020. * This function will be called instead of regular update (age, position, color, etc.).
  88021. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  88022. */
  88023. updateFunction: (particles: Particle[]) => void;
  88024. private _emitterWorldMatrix;
  88025. /**
  88026. * This function can be defined to specify initial direction for every new particle.
  88027. * It by default use the emitterType defined function
  88028. */
  88029. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  88030. /**
  88031. * This function can be defined to specify initial position for every new particle.
  88032. * It by default use the emitterType defined function
  88033. */
  88034. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  88035. /**
  88036. * @hidden
  88037. */
  88038. _inheritedVelocityOffset: Vector3;
  88039. /**
  88040. * An event triggered when the system is disposed
  88041. */
  88042. onDisposeObservable: Observable<ParticleSystem>;
  88043. private _onDisposeObserver;
  88044. /**
  88045. * Sets a callback that will be triggered when the system is disposed
  88046. */
  88047. set onDispose(callback: () => void);
  88048. private _particles;
  88049. private _epsilon;
  88050. private _capacity;
  88051. private _stockParticles;
  88052. private _newPartsExcess;
  88053. private _vertexData;
  88054. private _vertexBuffer;
  88055. private _vertexBuffers;
  88056. private _spriteBuffer;
  88057. private _indexBuffer;
  88058. private _effect;
  88059. private _customEffect;
  88060. private _cachedDefines;
  88061. private _scaledColorStep;
  88062. private _colorDiff;
  88063. private _scaledDirection;
  88064. private _scaledGravity;
  88065. private _currentRenderId;
  88066. private _alive;
  88067. private _useInstancing;
  88068. private _started;
  88069. private _stopped;
  88070. private _actualFrame;
  88071. private _scaledUpdateSpeed;
  88072. private _vertexBufferSize;
  88073. /** @hidden */
  88074. _currentEmitRateGradient: Nullable<FactorGradient>;
  88075. /** @hidden */
  88076. _currentEmitRate1: number;
  88077. /** @hidden */
  88078. _currentEmitRate2: number;
  88079. /** @hidden */
  88080. _currentStartSizeGradient: Nullable<FactorGradient>;
  88081. /** @hidden */
  88082. _currentStartSize1: number;
  88083. /** @hidden */
  88084. _currentStartSize2: number;
  88085. private readonly _rawTextureWidth;
  88086. private _rampGradientsTexture;
  88087. private _useRampGradients;
  88088. /** Gets or sets a boolean indicating that ramp gradients must be used
  88089. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  88090. */
  88091. get useRampGradients(): boolean;
  88092. set useRampGradients(value: boolean);
  88093. /**
  88094. * 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.
  88095. * 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: [])
  88096. */
  88097. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  88098. private _subEmitters;
  88099. /**
  88100. * @hidden
  88101. * If the particle systems emitter should be disposed when the particle system is disposed
  88102. */
  88103. _disposeEmitterOnDispose: boolean;
  88104. /**
  88105. * The current active Sub-systems, this property is used by the root particle system only.
  88106. */
  88107. activeSubSystems: Array<ParticleSystem>;
  88108. private _rootParticleSystem;
  88109. /**
  88110. * Gets the current list of active particles
  88111. */
  88112. get particles(): Particle[];
  88113. /**
  88114. * Returns the string "ParticleSystem"
  88115. * @returns a string containing the class name
  88116. */
  88117. getClassName(): string;
  88118. /**
  88119. * Instantiates a particle system.
  88120. * 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.
  88121. * @param name The name of the particle system
  88122. * @param capacity The max number of particles alive at the same time
  88123. * @param scene The scene the particle system belongs to
  88124. * @param customEffect a custom effect used to change the way particles are rendered by default
  88125. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  88126. * @param epsilon Offset used to render the particles
  88127. */
  88128. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  88129. private _addFactorGradient;
  88130. private _removeFactorGradient;
  88131. /**
  88132. * Adds a new life time gradient
  88133. * @param gradient defines the gradient to use (between 0 and 1)
  88134. * @param factor defines the life time factor to affect to the specified gradient
  88135. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88136. * @returns the current particle system
  88137. */
  88138. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88139. /**
  88140. * Remove a specific life time gradient
  88141. * @param gradient defines the gradient to remove
  88142. * @returns the current particle system
  88143. */
  88144. removeLifeTimeGradient(gradient: number): IParticleSystem;
  88145. /**
  88146. * Adds a new size gradient
  88147. * @param gradient defines the gradient to use (between 0 and 1)
  88148. * @param factor defines the size factor to affect to the specified gradient
  88149. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88150. * @returns the current particle system
  88151. */
  88152. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88153. /**
  88154. * Remove a specific size gradient
  88155. * @param gradient defines the gradient to remove
  88156. * @returns the current particle system
  88157. */
  88158. removeSizeGradient(gradient: number): IParticleSystem;
  88159. /**
  88160. * Adds a new color remap gradient
  88161. * @param gradient defines the gradient to use (between 0 and 1)
  88162. * @param min defines the color remap minimal range
  88163. * @param max defines the color remap maximal range
  88164. * @returns the current particle system
  88165. */
  88166. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  88167. /**
  88168. * Remove a specific color remap gradient
  88169. * @param gradient defines the gradient to remove
  88170. * @returns the current particle system
  88171. */
  88172. removeColorRemapGradient(gradient: number): IParticleSystem;
  88173. /**
  88174. * Adds a new alpha remap gradient
  88175. * @param gradient defines the gradient to use (between 0 and 1)
  88176. * @param min defines the alpha remap minimal range
  88177. * @param max defines the alpha remap maximal range
  88178. * @returns the current particle system
  88179. */
  88180. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  88181. /**
  88182. * Remove a specific alpha remap gradient
  88183. * @param gradient defines the gradient to remove
  88184. * @returns the current particle system
  88185. */
  88186. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  88187. /**
  88188. * Adds a new angular speed gradient
  88189. * @param gradient defines the gradient to use (between 0 and 1)
  88190. * @param factor defines the angular speed to affect to the specified gradient
  88191. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88192. * @returns the current particle system
  88193. */
  88194. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88195. /**
  88196. * Remove a specific angular speed gradient
  88197. * @param gradient defines the gradient to remove
  88198. * @returns the current particle system
  88199. */
  88200. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  88201. /**
  88202. * Adds a new velocity gradient
  88203. * @param gradient defines the gradient to use (between 0 and 1)
  88204. * @param factor defines the velocity to affect to the specified gradient
  88205. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88206. * @returns the current particle system
  88207. */
  88208. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88209. /**
  88210. * Remove a specific velocity gradient
  88211. * @param gradient defines the gradient to remove
  88212. * @returns the current particle system
  88213. */
  88214. removeVelocityGradient(gradient: number): IParticleSystem;
  88215. /**
  88216. * Adds a new limit velocity gradient
  88217. * @param gradient defines the gradient to use (between 0 and 1)
  88218. * @param factor defines the limit velocity value to affect to the specified gradient
  88219. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88220. * @returns the current particle system
  88221. */
  88222. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88223. /**
  88224. * Remove a specific limit velocity gradient
  88225. * @param gradient defines the gradient to remove
  88226. * @returns the current particle system
  88227. */
  88228. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  88229. /**
  88230. * Adds a new drag gradient
  88231. * @param gradient defines the gradient to use (between 0 and 1)
  88232. * @param factor defines the drag value to affect to the specified gradient
  88233. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88234. * @returns the current particle system
  88235. */
  88236. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88237. /**
  88238. * Remove a specific drag gradient
  88239. * @param gradient defines the gradient to remove
  88240. * @returns the current particle system
  88241. */
  88242. removeDragGradient(gradient: number): IParticleSystem;
  88243. /**
  88244. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  88245. * @param gradient defines the gradient to use (between 0 and 1)
  88246. * @param factor defines the emit rate value to affect to the specified gradient
  88247. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88248. * @returns the current particle system
  88249. */
  88250. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88251. /**
  88252. * Remove a specific emit rate gradient
  88253. * @param gradient defines the gradient to remove
  88254. * @returns the current particle system
  88255. */
  88256. removeEmitRateGradient(gradient: number): IParticleSystem;
  88257. /**
  88258. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  88259. * @param gradient defines the gradient to use (between 0 and 1)
  88260. * @param factor defines the start size value to affect to the specified gradient
  88261. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88262. * @returns the current particle system
  88263. */
  88264. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88265. /**
  88266. * Remove a specific start size gradient
  88267. * @param gradient defines the gradient to remove
  88268. * @returns the current particle system
  88269. */
  88270. removeStartSizeGradient(gradient: number): IParticleSystem;
  88271. private _createRampGradientTexture;
  88272. /**
  88273. * Gets the current list of ramp gradients.
  88274. * You must use addRampGradient and removeRampGradient to udpate this list
  88275. * @returns the list of ramp gradients
  88276. */
  88277. getRampGradients(): Nullable<Array<Color3Gradient>>;
  88278. /**
  88279. * Adds a new ramp gradient used to remap particle colors
  88280. * @param gradient defines the gradient to use (between 0 and 1)
  88281. * @param color defines the color to affect to the specified gradient
  88282. * @returns the current particle system
  88283. */
  88284. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  88285. /**
  88286. * Remove a specific ramp gradient
  88287. * @param gradient defines the gradient to remove
  88288. * @returns the current particle system
  88289. */
  88290. removeRampGradient(gradient: number): ParticleSystem;
  88291. /**
  88292. * Adds a new color gradient
  88293. * @param gradient defines the gradient to use (between 0 and 1)
  88294. * @param color1 defines the color to affect to the specified gradient
  88295. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  88296. * @returns this particle system
  88297. */
  88298. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  88299. /**
  88300. * Remove a specific color gradient
  88301. * @param gradient defines the gradient to remove
  88302. * @returns this particle system
  88303. */
  88304. removeColorGradient(gradient: number): IParticleSystem;
  88305. private _fetchR;
  88306. protected _reset(): void;
  88307. private _resetEffect;
  88308. private _createVertexBuffers;
  88309. private _createIndexBuffer;
  88310. /**
  88311. * Gets the maximum number of particles active at the same time.
  88312. * @returns The max number of active particles.
  88313. */
  88314. getCapacity(): number;
  88315. /**
  88316. * Gets whether there are still active particles in the system.
  88317. * @returns True if it is alive, otherwise false.
  88318. */
  88319. isAlive(): boolean;
  88320. /**
  88321. * Gets if the system has been started. (Note: this will still be true after stop is called)
  88322. * @returns True if it has been started, otherwise false.
  88323. */
  88324. isStarted(): boolean;
  88325. private _prepareSubEmitterInternalArray;
  88326. /**
  88327. * Starts the particle system and begins to emit
  88328. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  88329. */
  88330. start(delay?: number): void;
  88331. /**
  88332. * Stops the particle system.
  88333. * @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.
  88334. */
  88335. stop(stopSubEmitters?: boolean): void;
  88336. /**
  88337. * Remove all active particles
  88338. */
  88339. reset(): void;
  88340. /**
  88341. * @hidden (for internal use only)
  88342. */
  88343. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  88344. /**
  88345. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  88346. * Its lifetime will start back at 0.
  88347. */
  88348. recycleParticle: (particle: Particle) => void;
  88349. private _stopSubEmitters;
  88350. private _createParticle;
  88351. private _removeFromRoot;
  88352. private _emitFromParticle;
  88353. private _update;
  88354. /** @hidden */
  88355. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  88356. /** @hidden */
  88357. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  88358. /** @hidden */
  88359. private _getEffect;
  88360. /**
  88361. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  88362. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  88363. */
  88364. animate(preWarmOnly?: boolean): void;
  88365. private _appendParticleVertices;
  88366. /**
  88367. * Rebuilds the particle system.
  88368. */
  88369. rebuild(): void;
  88370. /**
  88371. * Is this system ready to be used/rendered
  88372. * @return true if the system is ready
  88373. */
  88374. isReady(): boolean;
  88375. private _render;
  88376. /**
  88377. * Renders the particle system in its current state.
  88378. * @returns the current number of particles
  88379. */
  88380. render(): number;
  88381. /**
  88382. * Disposes the particle system and free the associated resources
  88383. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  88384. */
  88385. dispose(disposeTexture?: boolean): void;
  88386. /**
  88387. * Clones the particle system.
  88388. * @param name The name of the cloned object
  88389. * @param newEmitter The new emitter to use
  88390. * @returns the cloned particle system
  88391. */
  88392. clone(name: string, newEmitter: any): ParticleSystem;
  88393. /**
  88394. * Serializes the particle system to a JSON object.
  88395. * @returns the JSON object
  88396. */
  88397. serialize(): any;
  88398. /** @hidden */
  88399. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  88400. /** @hidden */
  88401. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  88402. /**
  88403. * Parses a JSON object to create a particle system.
  88404. * @param parsedParticleSystem The JSON object to parse
  88405. * @param scene The scene to create the particle system in
  88406. * @param rootUrl The root url to use to load external dependencies like texture
  88407. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  88408. * @returns the Parsed particle system
  88409. */
  88410. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  88411. }
  88412. }
  88413. declare module BABYLON {
  88414. /**
  88415. * A particle represents one of the element emitted by a particle system.
  88416. * This is mainly define by its coordinates, direction, velocity and age.
  88417. */
  88418. export class Particle {
  88419. /**
  88420. * The particle system the particle belongs to.
  88421. */
  88422. particleSystem: ParticleSystem;
  88423. private static _Count;
  88424. /**
  88425. * Unique ID of the particle
  88426. */
  88427. id: number;
  88428. /**
  88429. * The world position of the particle in the scene.
  88430. */
  88431. position: Vector3;
  88432. /**
  88433. * The world direction of the particle in the scene.
  88434. */
  88435. direction: Vector3;
  88436. /**
  88437. * The color of the particle.
  88438. */
  88439. color: Color4;
  88440. /**
  88441. * The color change of the particle per step.
  88442. */
  88443. colorStep: Color4;
  88444. /**
  88445. * Defines how long will the life of the particle be.
  88446. */
  88447. lifeTime: number;
  88448. /**
  88449. * The current age of the particle.
  88450. */
  88451. age: number;
  88452. /**
  88453. * The current size of the particle.
  88454. */
  88455. size: number;
  88456. /**
  88457. * The current scale of the particle.
  88458. */
  88459. scale: Vector2;
  88460. /**
  88461. * The current angle of the particle.
  88462. */
  88463. angle: number;
  88464. /**
  88465. * Defines how fast is the angle changing.
  88466. */
  88467. angularSpeed: number;
  88468. /**
  88469. * Defines the cell index used by the particle to be rendered from a sprite.
  88470. */
  88471. cellIndex: number;
  88472. /**
  88473. * The information required to support color remapping
  88474. */
  88475. remapData: Vector4;
  88476. /** @hidden */
  88477. _randomCellOffset?: number;
  88478. /** @hidden */
  88479. _initialDirection: Nullable<Vector3>;
  88480. /** @hidden */
  88481. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  88482. /** @hidden */
  88483. _initialStartSpriteCellID: number;
  88484. /** @hidden */
  88485. _initialEndSpriteCellID: number;
  88486. /** @hidden */
  88487. _currentColorGradient: Nullable<ColorGradient>;
  88488. /** @hidden */
  88489. _currentColor1: Color4;
  88490. /** @hidden */
  88491. _currentColor2: Color4;
  88492. /** @hidden */
  88493. _currentSizeGradient: Nullable<FactorGradient>;
  88494. /** @hidden */
  88495. _currentSize1: number;
  88496. /** @hidden */
  88497. _currentSize2: number;
  88498. /** @hidden */
  88499. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  88500. /** @hidden */
  88501. _currentAngularSpeed1: number;
  88502. /** @hidden */
  88503. _currentAngularSpeed2: number;
  88504. /** @hidden */
  88505. _currentVelocityGradient: Nullable<FactorGradient>;
  88506. /** @hidden */
  88507. _currentVelocity1: number;
  88508. /** @hidden */
  88509. _currentVelocity2: number;
  88510. /** @hidden */
  88511. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  88512. /** @hidden */
  88513. _currentLimitVelocity1: number;
  88514. /** @hidden */
  88515. _currentLimitVelocity2: number;
  88516. /** @hidden */
  88517. _currentDragGradient: Nullable<FactorGradient>;
  88518. /** @hidden */
  88519. _currentDrag1: number;
  88520. /** @hidden */
  88521. _currentDrag2: number;
  88522. /** @hidden */
  88523. _randomNoiseCoordinates1: Vector3;
  88524. /** @hidden */
  88525. _randomNoiseCoordinates2: Vector3;
  88526. /**
  88527. * Creates a new instance Particle
  88528. * @param particleSystem the particle system the particle belongs to
  88529. */
  88530. constructor(
  88531. /**
  88532. * The particle system the particle belongs to.
  88533. */
  88534. particleSystem: ParticleSystem);
  88535. private updateCellInfoFromSystem;
  88536. /**
  88537. * Defines how the sprite cell index is updated for the particle
  88538. */
  88539. updateCellIndex(): void;
  88540. /** @hidden */
  88541. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  88542. /** @hidden */
  88543. _inheritParticleInfoToSubEmitters(): void;
  88544. /** @hidden */
  88545. _reset(): void;
  88546. /**
  88547. * Copy the properties of particle to another one.
  88548. * @param other the particle to copy the information to.
  88549. */
  88550. copyTo(other: Particle): void;
  88551. }
  88552. }
  88553. declare module BABYLON {
  88554. /**
  88555. * Particle emitter represents a volume emitting particles.
  88556. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  88557. */
  88558. export interface IParticleEmitterType {
  88559. /**
  88560. * Called by the particle System when the direction is computed for the created particle.
  88561. * @param worldMatrix is the world matrix of the particle system
  88562. * @param directionToUpdate is the direction vector to update with the result
  88563. * @param particle is the particle we are computed the direction for
  88564. */
  88565. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88566. /**
  88567. * Called by the particle System when the position is computed for the created particle.
  88568. * @param worldMatrix is the world matrix of the particle system
  88569. * @param positionToUpdate is the position vector to update with the result
  88570. * @param particle is the particle we are computed the position for
  88571. */
  88572. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88573. /**
  88574. * Clones the current emitter and returns a copy of it
  88575. * @returns the new emitter
  88576. */
  88577. clone(): IParticleEmitterType;
  88578. /**
  88579. * Called by the GPUParticleSystem to setup the update shader
  88580. * @param effect defines the update shader
  88581. */
  88582. applyToShader(effect: Effect): void;
  88583. /**
  88584. * Returns a string to use to update the GPU particles update shader
  88585. * @returns the effect defines string
  88586. */
  88587. getEffectDefines(): string;
  88588. /**
  88589. * Returns a string representing the class name
  88590. * @returns a string containing the class name
  88591. */
  88592. getClassName(): string;
  88593. /**
  88594. * Serializes the particle system to a JSON object.
  88595. * @returns the JSON object
  88596. */
  88597. serialize(): any;
  88598. /**
  88599. * Parse properties from a JSON object
  88600. * @param serializationObject defines the JSON object
  88601. */
  88602. parse(serializationObject: any): void;
  88603. }
  88604. }
  88605. declare module BABYLON {
  88606. /**
  88607. * Particle emitter emitting particles from the inside of a box.
  88608. * It emits the particles randomly between 2 given directions.
  88609. */
  88610. export class BoxParticleEmitter implements IParticleEmitterType {
  88611. /**
  88612. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88613. */
  88614. direction1: Vector3;
  88615. /**
  88616. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88617. */
  88618. direction2: Vector3;
  88619. /**
  88620. * 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.
  88621. */
  88622. minEmitBox: Vector3;
  88623. /**
  88624. * 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.
  88625. */
  88626. maxEmitBox: Vector3;
  88627. /**
  88628. * Creates a new instance BoxParticleEmitter
  88629. */
  88630. constructor();
  88631. /**
  88632. * Called by the particle System when the direction is computed for the created particle.
  88633. * @param worldMatrix is the world matrix of the particle system
  88634. * @param directionToUpdate is the direction vector to update with the result
  88635. * @param particle is the particle we are computed the direction for
  88636. */
  88637. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88638. /**
  88639. * Called by the particle System when the position is computed for the created particle.
  88640. * @param worldMatrix is the world matrix of the particle system
  88641. * @param positionToUpdate is the position vector to update with the result
  88642. * @param particle is the particle we are computed the position for
  88643. */
  88644. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88645. /**
  88646. * Clones the current emitter and returns a copy of it
  88647. * @returns the new emitter
  88648. */
  88649. clone(): BoxParticleEmitter;
  88650. /**
  88651. * Called by the GPUParticleSystem to setup the update shader
  88652. * @param effect defines the update shader
  88653. */
  88654. applyToShader(effect: Effect): void;
  88655. /**
  88656. * Returns a string to use to update the GPU particles update shader
  88657. * @returns a string containng the defines string
  88658. */
  88659. getEffectDefines(): string;
  88660. /**
  88661. * Returns the string "BoxParticleEmitter"
  88662. * @returns a string containing the class name
  88663. */
  88664. getClassName(): string;
  88665. /**
  88666. * Serializes the particle system to a JSON object.
  88667. * @returns the JSON object
  88668. */
  88669. serialize(): any;
  88670. /**
  88671. * Parse properties from a JSON object
  88672. * @param serializationObject defines the JSON object
  88673. */
  88674. parse(serializationObject: any): void;
  88675. }
  88676. }
  88677. declare module BABYLON {
  88678. /**
  88679. * Particle emitter emitting particles from the inside of a cone.
  88680. * It emits the particles alongside the cone volume from the base to the particle.
  88681. * The emission direction might be randomized.
  88682. */
  88683. export class ConeParticleEmitter implements IParticleEmitterType {
  88684. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  88685. directionRandomizer: number;
  88686. private _radius;
  88687. private _angle;
  88688. private _height;
  88689. /**
  88690. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  88691. */
  88692. radiusRange: number;
  88693. /**
  88694. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  88695. */
  88696. heightRange: number;
  88697. /**
  88698. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  88699. */
  88700. emitFromSpawnPointOnly: boolean;
  88701. /**
  88702. * Gets or sets the radius of the emission cone
  88703. */
  88704. get radius(): number;
  88705. set radius(value: number);
  88706. /**
  88707. * Gets or sets the angle of the emission cone
  88708. */
  88709. get angle(): number;
  88710. set angle(value: number);
  88711. private _buildHeight;
  88712. /**
  88713. * Creates a new instance ConeParticleEmitter
  88714. * @param radius the radius of the emission cone (1 by default)
  88715. * @param angle the cone base angle (PI by default)
  88716. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  88717. */
  88718. constructor(radius?: number, angle?: number,
  88719. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  88720. directionRandomizer?: number);
  88721. /**
  88722. * Called by the particle System when the direction is computed for the created particle.
  88723. * @param worldMatrix is the world matrix of the particle system
  88724. * @param directionToUpdate is the direction vector to update with the result
  88725. * @param particle is the particle we are computed the direction for
  88726. */
  88727. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88728. /**
  88729. * Called by the particle System when the position is computed for the created particle.
  88730. * @param worldMatrix is the world matrix of the particle system
  88731. * @param positionToUpdate is the position vector to update with the result
  88732. * @param particle is the particle we are computed the position for
  88733. */
  88734. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88735. /**
  88736. * Clones the current emitter and returns a copy of it
  88737. * @returns the new emitter
  88738. */
  88739. clone(): ConeParticleEmitter;
  88740. /**
  88741. * Called by the GPUParticleSystem to setup the update shader
  88742. * @param effect defines the update shader
  88743. */
  88744. applyToShader(effect: Effect): void;
  88745. /**
  88746. * Returns a string to use to update the GPU particles update shader
  88747. * @returns a string containng the defines string
  88748. */
  88749. getEffectDefines(): string;
  88750. /**
  88751. * Returns the string "ConeParticleEmitter"
  88752. * @returns a string containing the class name
  88753. */
  88754. getClassName(): string;
  88755. /**
  88756. * Serializes the particle system to a JSON object.
  88757. * @returns the JSON object
  88758. */
  88759. serialize(): any;
  88760. /**
  88761. * Parse properties from a JSON object
  88762. * @param serializationObject defines the JSON object
  88763. */
  88764. parse(serializationObject: any): void;
  88765. }
  88766. }
  88767. declare module BABYLON {
  88768. /**
  88769. * Particle emitter emitting particles from the inside of a cylinder.
  88770. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  88771. */
  88772. export class CylinderParticleEmitter implements IParticleEmitterType {
  88773. /**
  88774. * The radius of the emission cylinder.
  88775. */
  88776. radius: number;
  88777. /**
  88778. * The height of the emission cylinder.
  88779. */
  88780. height: number;
  88781. /**
  88782. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88783. */
  88784. radiusRange: number;
  88785. /**
  88786. * How much to randomize the particle direction [0-1].
  88787. */
  88788. directionRandomizer: number;
  88789. /**
  88790. * Creates a new instance CylinderParticleEmitter
  88791. * @param radius the radius of the emission cylinder (1 by default)
  88792. * @param height the height of the emission cylinder (1 by default)
  88793. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88794. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88795. */
  88796. constructor(
  88797. /**
  88798. * The radius of the emission cylinder.
  88799. */
  88800. radius?: number,
  88801. /**
  88802. * The height of the emission cylinder.
  88803. */
  88804. height?: number,
  88805. /**
  88806. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88807. */
  88808. radiusRange?: number,
  88809. /**
  88810. * How much to randomize the particle direction [0-1].
  88811. */
  88812. directionRandomizer?: number);
  88813. /**
  88814. * Called by the particle System when the direction is computed for the created particle.
  88815. * @param worldMatrix is the world matrix of the particle system
  88816. * @param directionToUpdate is the direction vector to update with the result
  88817. * @param particle is the particle we are computed the direction for
  88818. */
  88819. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88820. /**
  88821. * Called by the particle System when the position is computed for the created particle.
  88822. * @param worldMatrix is the world matrix of the particle system
  88823. * @param positionToUpdate is the position vector to update with the result
  88824. * @param particle is the particle we are computed the position for
  88825. */
  88826. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88827. /**
  88828. * Clones the current emitter and returns a copy of it
  88829. * @returns the new emitter
  88830. */
  88831. clone(): CylinderParticleEmitter;
  88832. /**
  88833. * Called by the GPUParticleSystem to setup the update shader
  88834. * @param effect defines the update shader
  88835. */
  88836. applyToShader(effect: Effect): void;
  88837. /**
  88838. * Returns a string to use to update the GPU particles update shader
  88839. * @returns a string containng the defines string
  88840. */
  88841. getEffectDefines(): string;
  88842. /**
  88843. * Returns the string "CylinderParticleEmitter"
  88844. * @returns a string containing the class name
  88845. */
  88846. getClassName(): string;
  88847. /**
  88848. * Serializes the particle system to a JSON object.
  88849. * @returns the JSON object
  88850. */
  88851. serialize(): any;
  88852. /**
  88853. * Parse properties from a JSON object
  88854. * @param serializationObject defines the JSON object
  88855. */
  88856. parse(serializationObject: any): void;
  88857. }
  88858. /**
  88859. * Particle emitter emitting particles from the inside of a cylinder.
  88860. * It emits the particles randomly between two vectors.
  88861. */
  88862. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  88863. /**
  88864. * The min limit of the emission direction.
  88865. */
  88866. direction1: Vector3;
  88867. /**
  88868. * The max limit of the emission direction.
  88869. */
  88870. direction2: Vector3;
  88871. /**
  88872. * Creates a new instance CylinderDirectedParticleEmitter
  88873. * @param radius the radius of the emission cylinder (1 by default)
  88874. * @param height the height of the emission cylinder (1 by default)
  88875. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88876. * @param direction1 the min limit of the emission direction (up vector by default)
  88877. * @param direction2 the max limit of the emission direction (up vector by default)
  88878. */
  88879. constructor(radius?: number, height?: number, radiusRange?: number,
  88880. /**
  88881. * The min limit of the emission direction.
  88882. */
  88883. direction1?: Vector3,
  88884. /**
  88885. * The max limit of the emission direction.
  88886. */
  88887. direction2?: Vector3);
  88888. /**
  88889. * Called by the particle System when the direction is computed for the created particle.
  88890. * @param worldMatrix is the world matrix of the particle system
  88891. * @param directionToUpdate is the direction vector to update with the result
  88892. * @param particle is the particle we are computed the direction for
  88893. */
  88894. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88895. /**
  88896. * Clones the current emitter and returns a copy of it
  88897. * @returns the new emitter
  88898. */
  88899. clone(): CylinderDirectedParticleEmitter;
  88900. /**
  88901. * Called by the GPUParticleSystem to setup the update shader
  88902. * @param effect defines the update shader
  88903. */
  88904. applyToShader(effect: Effect): void;
  88905. /**
  88906. * Returns a string to use to update the GPU particles update shader
  88907. * @returns a string containng the defines string
  88908. */
  88909. getEffectDefines(): string;
  88910. /**
  88911. * Returns the string "CylinderDirectedParticleEmitter"
  88912. * @returns a string containing the class name
  88913. */
  88914. getClassName(): string;
  88915. /**
  88916. * Serializes the particle system to a JSON object.
  88917. * @returns the JSON object
  88918. */
  88919. serialize(): any;
  88920. /**
  88921. * Parse properties from a JSON object
  88922. * @param serializationObject defines the JSON object
  88923. */
  88924. parse(serializationObject: any): void;
  88925. }
  88926. }
  88927. declare module BABYLON {
  88928. /**
  88929. * Particle emitter emitting particles from the inside of a hemisphere.
  88930. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  88931. */
  88932. export class HemisphericParticleEmitter implements IParticleEmitterType {
  88933. /**
  88934. * The radius of the emission hemisphere.
  88935. */
  88936. radius: number;
  88937. /**
  88938. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88939. */
  88940. radiusRange: number;
  88941. /**
  88942. * How much to randomize the particle direction [0-1].
  88943. */
  88944. directionRandomizer: number;
  88945. /**
  88946. * Creates a new instance HemisphericParticleEmitter
  88947. * @param radius the radius of the emission hemisphere (1 by default)
  88948. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88949. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88950. */
  88951. constructor(
  88952. /**
  88953. * The radius of the emission hemisphere.
  88954. */
  88955. radius?: number,
  88956. /**
  88957. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88958. */
  88959. radiusRange?: number,
  88960. /**
  88961. * How much to randomize the particle direction [0-1].
  88962. */
  88963. directionRandomizer?: number);
  88964. /**
  88965. * Called by the particle System when the direction is computed for the created particle.
  88966. * @param worldMatrix is the world matrix of the particle system
  88967. * @param directionToUpdate is the direction vector to update with the result
  88968. * @param particle is the particle we are computed the direction for
  88969. */
  88970. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88971. /**
  88972. * Called by the particle System when the position is computed for the created particle.
  88973. * @param worldMatrix is the world matrix of the particle system
  88974. * @param positionToUpdate is the position vector to update with the result
  88975. * @param particle is the particle we are computed the position for
  88976. */
  88977. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88978. /**
  88979. * Clones the current emitter and returns a copy of it
  88980. * @returns the new emitter
  88981. */
  88982. clone(): HemisphericParticleEmitter;
  88983. /**
  88984. * Called by the GPUParticleSystem to setup the update shader
  88985. * @param effect defines the update shader
  88986. */
  88987. applyToShader(effect: Effect): void;
  88988. /**
  88989. * Returns a string to use to update the GPU particles update shader
  88990. * @returns a string containng the defines string
  88991. */
  88992. getEffectDefines(): string;
  88993. /**
  88994. * Returns the string "HemisphericParticleEmitter"
  88995. * @returns a string containing the class name
  88996. */
  88997. getClassName(): string;
  88998. /**
  88999. * Serializes the particle system to a JSON object.
  89000. * @returns the JSON object
  89001. */
  89002. serialize(): any;
  89003. /**
  89004. * Parse properties from a JSON object
  89005. * @param serializationObject defines the JSON object
  89006. */
  89007. parse(serializationObject: any): void;
  89008. }
  89009. }
  89010. declare module BABYLON {
  89011. /**
  89012. * Particle emitter emitting particles from a point.
  89013. * It emits the particles randomly between 2 given directions.
  89014. */
  89015. export class PointParticleEmitter implements IParticleEmitterType {
  89016. /**
  89017. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89018. */
  89019. direction1: Vector3;
  89020. /**
  89021. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89022. */
  89023. direction2: Vector3;
  89024. /**
  89025. * Creates a new instance PointParticleEmitter
  89026. */
  89027. constructor();
  89028. /**
  89029. * Called by the particle System when the direction is computed for the created particle.
  89030. * @param worldMatrix is the world matrix of the particle system
  89031. * @param directionToUpdate is the direction vector to update with the result
  89032. * @param particle is the particle we are computed the direction for
  89033. */
  89034. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89035. /**
  89036. * Called by the particle System when the position is computed for the created particle.
  89037. * @param worldMatrix is the world matrix of the particle system
  89038. * @param positionToUpdate is the position vector to update with the result
  89039. * @param particle is the particle we are computed the position for
  89040. */
  89041. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89042. /**
  89043. * Clones the current emitter and returns a copy of it
  89044. * @returns the new emitter
  89045. */
  89046. clone(): PointParticleEmitter;
  89047. /**
  89048. * Called by the GPUParticleSystem to setup the update shader
  89049. * @param effect defines the update shader
  89050. */
  89051. applyToShader(effect: Effect): void;
  89052. /**
  89053. * Returns a string to use to update the GPU particles update shader
  89054. * @returns a string containng the defines string
  89055. */
  89056. getEffectDefines(): string;
  89057. /**
  89058. * Returns the string "PointParticleEmitter"
  89059. * @returns a string containing the class name
  89060. */
  89061. getClassName(): string;
  89062. /**
  89063. * Serializes the particle system to a JSON object.
  89064. * @returns the JSON object
  89065. */
  89066. serialize(): any;
  89067. /**
  89068. * Parse properties from a JSON object
  89069. * @param serializationObject defines the JSON object
  89070. */
  89071. parse(serializationObject: any): void;
  89072. }
  89073. }
  89074. declare module BABYLON {
  89075. /**
  89076. * Particle emitter emitting particles from the inside of a sphere.
  89077. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  89078. */
  89079. export class SphereParticleEmitter implements IParticleEmitterType {
  89080. /**
  89081. * The radius of the emission sphere.
  89082. */
  89083. radius: number;
  89084. /**
  89085. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89086. */
  89087. radiusRange: number;
  89088. /**
  89089. * How much to randomize the particle direction [0-1].
  89090. */
  89091. directionRandomizer: number;
  89092. /**
  89093. * Creates a new instance SphereParticleEmitter
  89094. * @param radius the radius of the emission sphere (1 by default)
  89095. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89096. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  89097. */
  89098. constructor(
  89099. /**
  89100. * The radius of the emission sphere.
  89101. */
  89102. radius?: number,
  89103. /**
  89104. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89105. */
  89106. radiusRange?: number,
  89107. /**
  89108. * How much to randomize the particle direction [0-1].
  89109. */
  89110. directionRandomizer?: number);
  89111. /**
  89112. * Called by the particle System when the direction is computed for the created particle.
  89113. * @param worldMatrix is the world matrix of the particle system
  89114. * @param directionToUpdate is the direction vector to update with the result
  89115. * @param particle is the particle we are computed the direction for
  89116. */
  89117. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89118. /**
  89119. * Called by the particle System when the position is computed for the created particle.
  89120. * @param worldMatrix is the world matrix of the particle system
  89121. * @param positionToUpdate is the position vector to update with the result
  89122. * @param particle is the particle we are computed the position for
  89123. */
  89124. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89125. /**
  89126. * Clones the current emitter and returns a copy of it
  89127. * @returns the new emitter
  89128. */
  89129. clone(): SphereParticleEmitter;
  89130. /**
  89131. * Called by the GPUParticleSystem to setup the update shader
  89132. * @param effect defines the update shader
  89133. */
  89134. applyToShader(effect: Effect): void;
  89135. /**
  89136. * Returns a string to use to update the GPU particles update shader
  89137. * @returns a string containng the defines string
  89138. */
  89139. getEffectDefines(): string;
  89140. /**
  89141. * Returns the string "SphereParticleEmitter"
  89142. * @returns a string containing the class name
  89143. */
  89144. getClassName(): string;
  89145. /**
  89146. * Serializes the particle system to a JSON object.
  89147. * @returns the JSON object
  89148. */
  89149. serialize(): any;
  89150. /**
  89151. * Parse properties from a JSON object
  89152. * @param serializationObject defines the JSON object
  89153. */
  89154. parse(serializationObject: any): void;
  89155. }
  89156. /**
  89157. * Particle emitter emitting particles from the inside of a sphere.
  89158. * It emits the particles randomly between two vectors.
  89159. */
  89160. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  89161. /**
  89162. * The min limit of the emission direction.
  89163. */
  89164. direction1: Vector3;
  89165. /**
  89166. * The max limit of the emission direction.
  89167. */
  89168. direction2: Vector3;
  89169. /**
  89170. * Creates a new instance SphereDirectedParticleEmitter
  89171. * @param radius the radius of the emission sphere (1 by default)
  89172. * @param direction1 the min limit of the emission direction (up vector by default)
  89173. * @param direction2 the max limit of the emission direction (up vector by default)
  89174. */
  89175. constructor(radius?: number,
  89176. /**
  89177. * The min limit of the emission direction.
  89178. */
  89179. direction1?: Vector3,
  89180. /**
  89181. * The max limit of the emission direction.
  89182. */
  89183. direction2?: Vector3);
  89184. /**
  89185. * Called by the particle System when the direction is computed for the created particle.
  89186. * @param worldMatrix is the world matrix of the particle system
  89187. * @param directionToUpdate is the direction vector to update with the result
  89188. * @param particle is the particle we are computed the direction for
  89189. */
  89190. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89191. /**
  89192. * Clones the current emitter and returns a copy of it
  89193. * @returns the new emitter
  89194. */
  89195. clone(): SphereDirectedParticleEmitter;
  89196. /**
  89197. * Called by the GPUParticleSystem to setup the update shader
  89198. * @param effect defines the update shader
  89199. */
  89200. applyToShader(effect: Effect): void;
  89201. /**
  89202. * Returns a string to use to update the GPU particles update shader
  89203. * @returns a string containng the defines string
  89204. */
  89205. getEffectDefines(): string;
  89206. /**
  89207. * Returns the string "SphereDirectedParticleEmitter"
  89208. * @returns a string containing the class name
  89209. */
  89210. getClassName(): string;
  89211. /**
  89212. * Serializes the particle system to a JSON object.
  89213. * @returns the JSON object
  89214. */
  89215. serialize(): any;
  89216. /**
  89217. * Parse properties from a JSON object
  89218. * @param serializationObject defines the JSON object
  89219. */
  89220. parse(serializationObject: any): void;
  89221. }
  89222. }
  89223. declare module BABYLON {
  89224. /**
  89225. * Interface representing a particle system in Babylon.js.
  89226. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  89227. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  89228. */
  89229. export interface IParticleSystem {
  89230. /**
  89231. * List of animations used by the particle system.
  89232. */
  89233. animations: Animation[];
  89234. /**
  89235. * The id of the Particle system.
  89236. */
  89237. id: string;
  89238. /**
  89239. * The name of the Particle system.
  89240. */
  89241. name: string;
  89242. /**
  89243. * The emitter represents the Mesh or position we are attaching the particle system to.
  89244. */
  89245. emitter: Nullable<AbstractMesh | Vector3>;
  89246. /**
  89247. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  89248. */
  89249. isBillboardBased: boolean;
  89250. /**
  89251. * The rendering group used by the Particle system to chose when to render.
  89252. */
  89253. renderingGroupId: number;
  89254. /**
  89255. * The layer mask we are rendering the particles through.
  89256. */
  89257. layerMask: number;
  89258. /**
  89259. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  89260. */
  89261. updateSpeed: number;
  89262. /**
  89263. * The amount of time the particle system is running (depends of the overall update speed).
  89264. */
  89265. targetStopDuration: number;
  89266. /**
  89267. * The texture used to render each particle. (this can be a spritesheet)
  89268. */
  89269. particleTexture: Nullable<Texture>;
  89270. /**
  89271. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  89272. */
  89273. blendMode: number;
  89274. /**
  89275. * Minimum life time of emitting particles.
  89276. */
  89277. minLifeTime: number;
  89278. /**
  89279. * Maximum life time of emitting particles.
  89280. */
  89281. maxLifeTime: number;
  89282. /**
  89283. * Minimum Size of emitting particles.
  89284. */
  89285. minSize: number;
  89286. /**
  89287. * Maximum Size of emitting particles.
  89288. */
  89289. maxSize: number;
  89290. /**
  89291. * Minimum scale of emitting particles on X axis.
  89292. */
  89293. minScaleX: number;
  89294. /**
  89295. * Maximum scale of emitting particles on X axis.
  89296. */
  89297. maxScaleX: number;
  89298. /**
  89299. * Minimum scale of emitting particles on Y axis.
  89300. */
  89301. minScaleY: number;
  89302. /**
  89303. * Maximum scale of emitting particles on Y axis.
  89304. */
  89305. maxScaleY: number;
  89306. /**
  89307. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  89308. */
  89309. color1: Color4;
  89310. /**
  89311. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  89312. */
  89313. color2: Color4;
  89314. /**
  89315. * Color the particle will have at the end of its lifetime.
  89316. */
  89317. colorDead: Color4;
  89318. /**
  89319. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  89320. */
  89321. emitRate: number;
  89322. /**
  89323. * You can use gravity if you want to give an orientation to your particles.
  89324. */
  89325. gravity: Vector3;
  89326. /**
  89327. * Minimum power of emitting particles.
  89328. */
  89329. minEmitPower: number;
  89330. /**
  89331. * Maximum power of emitting particles.
  89332. */
  89333. maxEmitPower: number;
  89334. /**
  89335. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  89336. */
  89337. minAngularSpeed: number;
  89338. /**
  89339. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  89340. */
  89341. maxAngularSpeed: number;
  89342. /**
  89343. * Gets or sets the minimal initial rotation in radians.
  89344. */
  89345. minInitialRotation: number;
  89346. /**
  89347. * Gets or sets the maximal initial rotation in radians.
  89348. */
  89349. maxInitialRotation: number;
  89350. /**
  89351. * The particle emitter type defines the emitter used by the particle system.
  89352. * It can be for example box, sphere, or cone...
  89353. */
  89354. particleEmitterType: Nullable<IParticleEmitterType>;
  89355. /**
  89356. * Defines the delay in milliseconds before starting the system (0 by default)
  89357. */
  89358. startDelay: number;
  89359. /**
  89360. * 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
  89361. */
  89362. preWarmCycles: number;
  89363. /**
  89364. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  89365. */
  89366. preWarmStepOffset: number;
  89367. /**
  89368. * 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)
  89369. */
  89370. spriteCellChangeSpeed: number;
  89371. /**
  89372. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  89373. */
  89374. startSpriteCellID: number;
  89375. /**
  89376. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  89377. */
  89378. endSpriteCellID: number;
  89379. /**
  89380. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  89381. */
  89382. spriteCellWidth: number;
  89383. /**
  89384. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  89385. */
  89386. spriteCellHeight: number;
  89387. /**
  89388. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  89389. */
  89390. spriteRandomStartCell: boolean;
  89391. /**
  89392. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  89393. */
  89394. isAnimationSheetEnabled: boolean;
  89395. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  89396. translationPivot: Vector2;
  89397. /**
  89398. * Gets or sets a texture used to add random noise to particle positions
  89399. */
  89400. noiseTexture: Nullable<BaseTexture>;
  89401. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  89402. noiseStrength: Vector3;
  89403. /**
  89404. * Gets or sets the billboard mode to use when isBillboardBased = true.
  89405. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  89406. */
  89407. billboardMode: number;
  89408. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  89409. limitVelocityDamping: number;
  89410. /**
  89411. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  89412. */
  89413. beginAnimationOnStart: boolean;
  89414. /**
  89415. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  89416. */
  89417. beginAnimationFrom: number;
  89418. /**
  89419. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  89420. */
  89421. beginAnimationTo: number;
  89422. /**
  89423. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  89424. */
  89425. beginAnimationLoop: boolean;
  89426. /**
  89427. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  89428. */
  89429. disposeOnStop: boolean;
  89430. /**
  89431. * Gets the maximum number of particles active at the same time.
  89432. * @returns The max number of active particles.
  89433. */
  89434. getCapacity(): number;
  89435. /**
  89436. * Gets if the system has been started. (Note: this will still be true after stop is called)
  89437. * @returns True if it has been started, otherwise false.
  89438. */
  89439. isStarted(): boolean;
  89440. /**
  89441. * Animates the particle system for this frame.
  89442. */
  89443. animate(): void;
  89444. /**
  89445. * Renders the particle system in its current state.
  89446. * @returns the current number of particles
  89447. */
  89448. render(): number;
  89449. /**
  89450. * Dispose the particle system and frees its associated resources.
  89451. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  89452. */
  89453. dispose(disposeTexture?: boolean): void;
  89454. /**
  89455. * Clones the particle system.
  89456. * @param name The name of the cloned object
  89457. * @param newEmitter The new emitter to use
  89458. * @returns the cloned particle system
  89459. */
  89460. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  89461. /**
  89462. * Serializes the particle system to a JSON object.
  89463. * @returns the JSON object
  89464. */
  89465. serialize(): any;
  89466. /**
  89467. * Rebuild the particle system
  89468. */
  89469. rebuild(): void;
  89470. /**
  89471. * Starts the particle system and begins to emit
  89472. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  89473. */
  89474. start(delay?: number): void;
  89475. /**
  89476. * Stops the particle system.
  89477. */
  89478. stop(): void;
  89479. /**
  89480. * Remove all active particles
  89481. */
  89482. reset(): void;
  89483. /**
  89484. * Is this system ready to be used/rendered
  89485. * @return true if the system is ready
  89486. */
  89487. isReady(): boolean;
  89488. /**
  89489. * Adds a new color gradient
  89490. * @param gradient defines the gradient to use (between 0 and 1)
  89491. * @param color1 defines the color to affect to the specified gradient
  89492. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  89493. * @returns the current particle system
  89494. */
  89495. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  89496. /**
  89497. * Remove a specific color gradient
  89498. * @param gradient defines the gradient to remove
  89499. * @returns the current particle system
  89500. */
  89501. removeColorGradient(gradient: number): IParticleSystem;
  89502. /**
  89503. * Adds a new size gradient
  89504. * @param gradient defines the gradient to use (between 0 and 1)
  89505. * @param factor defines the size factor to affect to the specified gradient
  89506. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89507. * @returns the current particle system
  89508. */
  89509. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89510. /**
  89511. * Remove a specific size gradient
  89512. * @param gradient defines the gradient to remove
  89513. * @returns the current particle system
  89514. */
  89515. removeSizeGradient(gradient: number): IParticleSystem;
  89516. /**
  89517. * Gets the current list of color gradients.
  89518. * You must use addColorGradient and removeColorGradient to udpate this list
  89519. * @returns the list of color gradients
  89520. */
  89521. getColorGradients(): Nullable<Array<ColorGradient>>;
  89522. /**
  89523. * Gets the current list of size gradients.
  89524. * You must use addSizeGradient and removeSizeGradient to udpate this list
  89525. * @returns the list of size gradients
  89526. */
  89527. getSizeGradients(): Nullable<Array<FactorGradient>>;
  89528. /**
  89529. * Gets the current list of angular speed gradients.
  89530. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  89531. * @returns the list of angular speed gradients
  89532. */
  89533. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  89534. /**
  89535. * Adds a new angular speed gradient
  89536. * @param gradient defines the gradient to use (between 0 and 1)
  89537. * @param factor defines the angular speed to affect to the specified gradient
  89538. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89539. * @returns the current particle system
  89540. */
  89541. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89542. /**
  89543. * Remove a specific angular speed gradient
  89544. * @param gradient defines the gradient to remove
  89545. * @returns the current particle system
  89546. */
  89547. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  89548. /**
  89549. * Gets the current list of velocity gradients.
  89550. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  89551. * @returns the list of velocity gradients
  89552. */
  89553. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  89554. /**
  89555. * Adds a new velocity gradient
  89556. * @param gradient defines the gradient to use (between 0 and 1)
  89557. * @param factor defines the velocity to affect to the specified gradient
  89558. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89559. * @returns the current particle system
  89560. */
  89561. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89562. /**
  89563. * Remove a specific velocity gradient
  89564. * @param gradient defines the gradient to remove
  89565. * @returns the current particle system
  89566. */
  89567. removeVelocityGradient(gradient: number): IParticleSystem;
  89568. /**
  89569. * Gets the current list of limit velocity gradients.
  89570. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  89571. * @returns the list of limit velocity gradients
  89572. */
  89573. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  89574. /**
  89575. * Adds a new limit velocity gradient
  89576. * @param gradient defines the gradient to use (between 0 and 1)
  89577. * @param factor defines the limit velocity to affect to the specified gradient
  89578. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89579. * @returns the current particle system
  89580. */
  89581. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89582. /**
  89583. * Remove a specific limit velocity gradient
  89584. * @param gradient defines the gradient to remove
  89585. * @returns the current particle system
  89586. */
  89587. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  89588. /**
  89589. * Adds a new drag gradient
  89590. * @param gradient defines the gradient to use (between 0 and 1)
  89591. * @param factor defines the drag to affect to the specified gradient
  89592. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89593. * @returns the current particle system
  89594. */
  89595. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89596. /**
  89597. * Remove a specific drag gradient
  89598. * @param gradient defines the gradient to remove
  89599. * @returns the current particle system
  89600. */
  89601. removeDragGradient(gradient: number): IParticleSystem;
  89602. /**
  89603. * Gets the current list of drag gradients.
  89604. * You must use addDragGradient and removeDragGradient to udpate this list
  89605. * @returns the list of drag gradients
  89606. */
  89607. getDragGradients(): Nullable<Array<FactorGradient>>;
  89608. /**
  89609. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  89610. * @param gradient defines the gradient to use (between 0 and 1)
  89611. * @param factor defines the emit rate to affect to the specified gradient
  89612. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89613. * @returns the current particle system
  89614. */
  89615. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89616. /**
  89617. * Remove a specific emit rate gradient
  89618. * @param gradient defines the gradient to remove
  89619. * @returns the current particle system
  89620. */
  89621. removeEmitRateGradient(gradient: number): IParticleSystem;
  89622. /**
  89623. * Gets the current list of emit rate gradients.
  89624. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  89625. * @returns the list of emit rate gradients
  89626. */
  89627. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  89628. /**
  89629. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  89630. * @param gradient defines the gradient to use (between 0 and 1)
  89631. * @param factor defines the start size to affect to the specified gradient
  89632. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89633. * @returns the current particle system
  89634. */
  89635. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89636. /**
  89637. * Remove a specific start size gradient
  89638. * @param gradient defines the gradient to remove
  89639. * @returns the current particle system
  89640. */
  89641. removeStartSizeGradient(gradient: number): IParticleSystem;
  89642. /**
  89643. * Gets the current list of start size gradients.
  89644. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  89645. * @returns the list of start size gradients
  89646. */
  89647. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  89648. /**
  89649. * Adds a new life time gradient
  89650. * @param gradient defines the gradient to use (between 0 and 1)
  89651. * @param factor defines the life time factor to affect to the specified gradient
  89652. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89653. * @returns the current particle system
  89654. */
  89655. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89656. /**
  89657. * Remove a specific life time gradient
  89658. * @param gradient defines the gradient to remove
  89659. * @returns the current particle system
  89660. */
  89661. removeLifeTimeGradient(gradient: number): IParticleSystem;
  89662. /**
  89663. * Gets the current list of life time gradients.
  89664. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  89665. * @returns the list of life time gradients
  89666. */
  89667. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  89668. /**
  89669. * Gets the current list of color gradients.
  89670. * You must use addColorGradient and removeColorGradient to udpate this list
  89671. * @returns the list of color gradients
  89672. */
  89673. getColorGradients(): Nullable<Array<ColorGradient>>;
  89674. /**
  89675. * Adds a new ramp gradient used to remap particle colors
  89676. * @param gradient defines the gradient to use (between 0 and 1)
  89677. * @param color defines the color to affect to the specified gradient
  89678. * @returns the current particle system
  89679. */
  89680. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  89681. /**
  89682. * Gets the current list of ramp gradients.
  89683. * You must use addRampGradient and removeRampGradient to udpate this list
  89684. * @returns the list of ramp gradients
  89685. */
  89686. getRampGradients(): Nullable<Array<Color3Gradient>>;
  89687. /** Gets or sets a boolean indicating that ramp gradients must be used
  89688. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  89689. */
  89690. useRampGradients: boolean;
  89691. /**
  89692. * Adds a new color remap gradient
  89693. * @param gradient defines the gradient to use (between 0 and 1)
  89694. * @param min defines the color remap minimal range
  89695. * @param max defines the color remap maximal range
  89696. * @returns the current particle system
  89697. */
  89698. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89699. /**
  89700. * Gets the current list of color remap gradients.
  89701. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  89702. * @returns the list of color remap gradients
  89703. */
  89704. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  89705. /**
  89706. * Adds a new alpha remap gradient
  89707. * @param gradient defines the gradient to use (between 0 and 1)
  89708. * @param min defines the alpha remap minimal range
  89709. * @param max defines the alpha remap maximal range
  89710. * @returns the current particle system
  89711. */
  89712. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89713. /**
  89714. * Gets the current list of alpha remap gradients.
  89715. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  89716. * @returns the list of alpha remap gradients
  89717. */
  89718. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  89719. /**
  89720. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  89721. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89722. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89723. * @returns the emitter
  89724. */
  89725. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  89726. /**
  89727. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  89728. * @param radius The radius of the hemisphere to emit from
  89729. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89730. * @returns the emitter
  89731. */
  89732. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  89733. /**
  89734. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  89735. * @param radius The radius of the sphere to emit from
  89736. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89737. * @returns the emitter
  89738. */
  89739. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  89740. /**
  89741. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  89742. * @param radius The radius of the sphere to emit from
  89743. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  89744. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  89745. * @returns the emitter
  89746. */
  89747. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  89748. /**
  89749. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  89750. * @param radius The radius of the emission cylinder
  89751. * @param height The height of the emission cylinder
  89752. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  89753. * @param directionRandomizer How much to randomize the particle direction [0-1]
  89754. * @returns the emitter
  89755. */
  89756. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  89757. /**
  89758. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  89759. * @param radius The radius of the cylinder to emit from
  89760. * @param height The height of the emission cylinder
  89761. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89762. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  89763. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  89764. * @returns the emitter
  89765. */
  89766. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  89767. /**
  89768. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  89769. * @param radius The radius of the cone to emit from
  89770. * @param angle The base angle of the cone
  89771. * @returns the emitter
  89772. */
  89773. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  89774. /**
  89775. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  89776. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89777. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89778. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89779. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89780. * @returns the emitter
  89781. */
  89782. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  89783. /**
  89784. * Get hosting scene
  89785. * @returns the scene
  89786. */
  89787. getScene(): Scene;
  89788. }
  89789. }
  89790. declare module BABYLON {
  89791. /**
  89792. * Creates an instance based on a source mesh.
  89793. */
  89794. export class InstancedMesh extends AbstractMesh {
  89795. private _sourceMesh;
  89796. private _currentLOD;
  89797. /** @hidden */
  89798. _indexInSourceMeshInstanceArray: number;
  89799. constructor(name: string, source: Mesh);
  89800. /**
  89801. * Returns the string "InstancedMesh".
  89802. */
  89803. getClassName(): string;
  89804. /** Gets the list of lights affecting that mesh */
  89805. get lightSources(): Light[];
  89806. _resyncLightSources(): void;
  89807. _resyncLightSource(light: Light): void;
  89808. _removeLightSource(light: Light, dispose: boolean): void;
  89809. /**
  89810. * If the source mesh receives shadows
  89811. */
  89812. get receiveShadows(): boolean;
  89813. /**
  89814. * The material of the source mesh
  89815. */
  89816. get material(): Nullable<Material>;
  89817. /**
  89818. * Visibility of the source mesh
  89819. */
  89820. get visibility(): number;
  89821. /**
  89822. * Skeleton of the source mesh
  89823. */
  89824. get skeleton(): Nullable<Skeleton>;
  89825. /**
  89826. * Rendering ground id of the source mesh
  89827. */
  89828. get renderingGroupId(): number;
  89829. set renderingGroupId(value: number);
  89830. /**
  89831. * Returns the total number of vertices (integer).
  89832. */
  89833. getTotalVertices(): number;
  89834. /**
  89835. * Returns a positive integer : the total number of indices in this mesh geometry.
  89836. * @returns the numner of indices or zero if the mesh has no geometry.
  89837. */
  89838. getTotalIndices(): number;
  89839. /**
  89840. * The source mesh of the instance
  89841. */
  89842. get sourceMesh(): Mesh;
  89843. /**
  89844. * Is this node ready to be used/rendered
  89845. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  89846. * @return {boolean} is it ready
  89847. */
  89848. isReady(completeCheck?: boolean): boolean;
  89849. /**
  89850. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89851. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  89852. * @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.
  89853. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  89854. */
  89855. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  89856. /**
  89857. * Sets the vertex data of the mesh geometry for the requested `kind`.
  89858. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  89859. * The `data` are either a numeric array either a Float32Array.
  89860. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  89861. * 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).
  89862. * Note that a new underlying VertexBuffer object is created each call.
  89863. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  89864. *
  89865. * Possible `kind` values :
  89866. * - VertexBuffer.PositionKind
  89867. * - VertexBuffer.UVKind
  89868. * - VertexBuffer.UV2Kind
  89869. * - VertexBuffer.UV3Kind
  89870. * - VertexBuffer.UV4Kind
  89871. * - VertexBuffer.UV5Kind
  89872. * - VertexBuffer.UV6Kind
  89873. * - VertexBuffer.ColorKind
  89874. * - VertexBuffer.MatricesIndicesKind
  89875. * - VertexBuffer.MatricesIndicesExtraKind
  89876. * - VertexBuffer.MatricesWeightsKind
  89877. * - VertexBuffer.MatricesWeightsExtraKind
  89878. *
  89879. * Returns the Mesh.
  89880. */
  89881. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89882. /**
  89883. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  89884. * If the mesh has no geometry, it is simply returned as it is.
  89885. * The `data` are either a numeric array either a Float32Array.
  89886. * No new underlying VertexBuffer object is created.
  89887. * 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.
  89888. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  89889. *
  89890. * Possible `kind` values :
  89891. * - VertexBuffer.PositionKind
  89892. * - VertexBuffer.UVKind
  89893. * - VertexBuffer.UV2Kind
  89894. * - VertexBuffer.UV3Kind
  89895. * - VertexBuffer.UV4Kind
  89896. * - VertexBuffer.UV5Kind
  89897. * - VertexBuffer.UV6Kind
  89898. * - VertexBuffer.ColorKind
  89899. * - VertexBuffer.MatricesIndicesKind
  89900. * - VertexBuffer.MatricesIndicesExtraKind
  89901. * - VertexBuffer.MatricesWeightsKind
  89902. * - VertexBuffer.MatricesWeightsExtraKind
  89903. *
  89904. * Returns the Mesh.
  89905. */
  89906. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  89907. /**
  89908. * Sets the mesh indices.
  89909. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  89910. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  89911. * This method creates a new index buffer each call.
  89912. * Returns the Mesh.
  89913. */
  89914. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  89915. /**
  89916. * Boolean : True if the mesh owns the requested kind of data.
  89917. */
  89918. isVerticesDataPresent(kind: string): boolean;
  89919. /**
  89920. * Returns an array of indices (IndicesArray).
  89921. */
  89922. getIndices(): Nullable<IndicesArray>;
  89923. get _positions(): Nullable<Vector3[]>;
  89924. /**
  89925. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89926. * This means the mesh underlying bounding box and sphere are recomputed.
  89927. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89928. * @returns the current mesh
  89929. */
  89930. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  89931. /** @hidden */
  89932. _preActivate(): InstancedMesh;
  89933. /** @hidden */
  89934. _activate(renderId: number, intermediateRendering: boolean): boolean;
  89935. /** @hidden */
  89936. _postActivate(): void;
  89937. getWorldMatrix(): Matrix;
  89938. get isAnInstance(): boolean;
  89939. /**
  89940. * Returns the current associated LOD AbstractMesh.
  89941. */
  89942. getLOD(camera: Camera): AbstractMesh;
  89943. /** @hidden */
  89944. _syncSubMeshes(): InstancedMesh;
  89945. /** @hidden */
  89946. _generatePointsArray(): boolean;
  89947. /**
  89948. * Creates a new InstancedMesh from the current mesh.
  89949. * - name (string) : the cloned mesh name
  89950. * - newParent (optional Node) : the optional Node to parent the clone to.
  89951. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  89952. *
  89953. * Returns the clone.
  89954. */
  89955. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  89956. /**
  89957. * Disposes the InstancedMesh.
  89958. * Returns nothing.
  89959. */
  89960. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89961. }
  89962. interface Mesh {
  89963. /**
  89964. * Register a custom buffer that will be instanced
  89965. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  89966. * @param kind defines the buffer kind
  89967. * @param stride defines the stride in floats
  89968. */
  89969. registerInstancedBuffer(kind: string, stride: number): void;
  89970. /** @hidden */
  89971. _userInstancedBuffersStorage: {
  89972. data: {
  89973. [key: string]: Float32Array;
  89974. };
  89975. sizes: {
  89976. [key: string]: number;
  89977. };
  89978. vertexBuffers: {
  89979. [key: string]: Nullable<VertexBuffer>;
  89980. };
  89981. strides: {
  89982. [key: string]: number;
  89983. };
  89984. };
  89985. }
  89986. interface AbstractMesh {
  89987. /**
  89988. * Object used to store instanced buffers defined by user
  89989. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  89990. */
  89991. instancedBuffers: {
  89992. [key: string]: any;
  89993. };
  89994. }
  89995. }
  89996. declare module BABYLON {
  89997. /**
  89998. * Defines the options associated with the creation of a shader material.
  89999. */
  90000. export interface IShaderMaterialOptions {
  90001. /**
  90002. * Does the material work in alpha blend mode
  90003. */
  90004. needAlphaBlending: boolean;
  90005. /**
  90006. * Does the material work in alpha test mode
  90007. */
  90008. needAlphaTesting: boolean;
  90009. /**
  90010. * The list of attribute names used in the shader
  90011. */
  90012. attributes: string[];
  90013. /**
  90014. * The list of unifrom names used in the shader
  90015. */
  90016. uniforms: string[];
  90017. /**
  90018. * The list of UBO names used in the shader
  90019. */
  90020. uniformBuffers: string[];
  90021. /**
  90022. * The list of sampler names used in the shader
  90023. */
  90024. samplers: string[];
  90025. /**
  90026. * The list of defines used in the shader
  90027. */
  90028. defines: string[];
  90029. }
  90030. /**
  90031. * 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.
  90032. *
  90033. * This returned material effects how the mesh will look based on the code in the shaders.
  90034. *
  90035. * @see http://doc.babylonjs.com/how_to/shader_material
  90036. */
  90037. export class ShaderMaterial extends Material {
  90038. private _shaderPath;
  90039. private _options;
  90040. private _textures;
  90041. private _textureArrays;
  90042. private _floats;
  90043. private _ints;
  90044. private _floatsArrays;
  90045. private _colors3;
  90046. private _colors3Arrays;
  90047. private _colors4;
  90048. private _colors4Arrays;
  90049. private _vectors2;
  90050. private _vectors3;
  90051. private _vectors4;
  90052. private _matrices;
  90053. private _matrixArrays;
  90054. private _matrices3x3;
  90055. private _matrices2x2;
  90056. private _vectors2Arrays;
  90057. private _vectors3Arrays;
  90058. private _vectors4Arrays;
  90059. private _cachedWorldViewMatrix;
  90060. private _cachedWorldViewProjectionMatrix;
  90061. private _renderId;
  90062. private _multiview;
  90063. /**
  90064. * Instantiate a new shader material.
  90065. * 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.
  90066. * This returned material effects how the mesh will look based on the code in the shaders.
  90067. * @see http://doc.babylonjs.com/how_to/shader_material
  90068. * @param name Define the name of the material in the scene
  90069. * @param scene Define the scene the material belongs to
  90070. * @param shaderPath Defines the route to the shader code in one of three ways:
  90071. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  90072. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  90073. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  90074. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  90075. * @param options Define the options used to create the shader
  90076. */
  90077. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  90078. /**
  90079. * Gets the shader path used to define the shader code
  90080. * It can be modified to trigger a new compilation
  90081. */
  90082. get shaderPath(): any;
  90083. /**
  90084. * Sets the shader path used to define the shader code
  90085. * It can be modified to trigger a new compilation
  90086. */
  90087. set shaderPath(shaderPath: any);
  90088. /**
  90089. * Gets the options used to compile the shader.
  90090. * They can be modified to trigger a new compilation
  90091. */
  90092. get options(): IShaderMaterialOptions;
  90093. /**
  90094. * Gets the current class name of the material e.g. "ShaderMaterial"
  90095. * Mainly use in serialization.
  90096. * @returns the class name
  90097. */
  90098. getClassName(): string;
  90099. /**
  90100. * Specifies if the material will require alpha blending
  90101. * @returns a boolean specifying if alpha blending is needed
  90102. */
  90103. needAlphaBlending(): boolean;
  90104. /**
  90105. * Specifies if this material should be rendered in alpha test mode
  90106. * @returns a boolean specifying if an alpha test is needed.
  90107. */
  90108. needAlphaTesting(): boolean;
  90109. private _checkUniform;
  90110. /**
  90111. * Set a texture in the shader.
  90112. * @param name Define the name of the uniform samplers as defined in the shader
  90113. * @param texture Define the texture to bind to this sampler
  90114. * @return the material itself allowing "fluent" like uniform updates
  90115. */
  90116. setTexture(name: string, texture: Texture): ShaderMaterial;
  90117. /**
  90118. * Set a texture array in the shader.
  90119. * @param name Define the name of the uniform sampler array as defined in the shader
  90120. * @param textures Define the list of textures to bind to this sampler
  90121. * @return the material itself allowing "fluent" like uniform updates
  90122. */
  90123. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  90124. /**
  90125. * Set a float in the shader.
  90126. * @param name Define the name of the uniform as defined in the shader
  90127. * @param value Define the value to give to the uniform
  90128. * @return the material itself allowing "fluent" like uniform updates
  90129. */
  90130. setFloat(name: string, value: number): ShaderMaterial;
  90131. /**
  90132. * Set a int in the shader.
  90133. * @param name Define the name of the uniform as defined in the shader
  90134. * @param value Define the value to give to the uniform
  90135. * @return the material itself allowing "fluent" like uniform updates
  90136. */
  90137. setInt(name: string, value: number): ShaderMaterial;
  90138. /**
  90139. * Set an array of floats in the shader.
  90140. * @param name Define the name of the uniform as defined in the shader
  90141. * @param value Define the value to give to the uniform
  90142. * @return the material itself allowing "fluent" like uniform updates
  90143. */
  90144. setFloats(name: string, value: number[]): ShaderMaterial;
  90145. /**
  90146. * Set a vec3 in the shader from a Color3.
  90147. * @param name Define the name of the uniform as defined in the shader
  90148. * @param value Define the value to give to the uniform
  90149. * @return the material itself allowing "fluent" like uniform updates
  90150. */
  90151. setColor3(name: string, value: Color3): ShaderMaterial;
  90152. /**
  90153. * Set a vec3 array in the shader from a Color3 array.
  90154. * @param name Define the name of the uniform as defined in the shader
  90155. * @param value Define the value to give to the uniform
  90156. * @return the material itself allowing "fluent" like uniform updates
  90157. */
  90158. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  90159. /**
  90160. * Set a vec4 in the shader from a Color4.
  90161. * @param name Define the name of the uniform as defined in the shader
  90162. * @param value Define the value to give to the uniform
  90163. * @return the material itself allowing "fluent" like uniform updates
  90164. */
  90165. setColor4(name: string, value: Color4): ShaderMaterial;
  90166. /**
  90167. * Set a vec4 array in the shader from a Color4 array.
  90168. * @param name Define the name of the uniform as defined in the shader
  90169. * @param value Define the value to give to the uniform
  90170. * @return the material itself allowing "fluent" like uniform updates
  90171. */
  90172. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  90173. /**
  90174. * Set a vec2 in the shader from a Vector2.
  90175. * @param name Define the name of the uniform as defined in the shader
  90176. * @param value Define the value to give to the uniform
  90177. * @return the material itself allowing "fluent" like uniform updates
  90178. */
  90179. setVector2(name: string, value: Vector2): ShaderMaterial;
  90180. /**
  90181. * Set a vec3 in the shader from a Vector3.
  90182. * @param name Define the name of the uniform as defined in the shader
  90183. * @param value Define the value to give to the uniform
  90184. * @return the material itself allowing "fluent" like uniform updates
  90185. */
  90186. setVector3(name: string, value: Vector3): ShaderMaterial;
  90187. /**
  90188. * Set a vec4 in the shader from a Vector4.
  90189. * @param name Define the name of the uniform as defined in the shader
  90190. * @param value Define the value to give to the uniform
  90191. * @return the material itself allowing "fluent" like uniform updates
  90192. */
  90193. setVector4(name: string, value: Vector4): ShaderMaterial;
  90194. /**
  90195. * Set a mat4 in the shader from a Matrix.
  90196. * @param name Define the name of the uniform as defined in the shader
  90197. * @param value Define the value to give to the uniform
  90198. * @return the material itself allowing "fluent" like uniform updates
  90199. */
  90200. setMatrix(name: string, value: Matrix): ShaderMaterial;
  90201. /**
  90202. * Set a float32Array in the shader from a matrix array.
  90203. * @param name Define the name of the uniform as defined in the shader
  90204. * @param value Define the value to give to the uniform
  90205. * @return the material itself allowing "fluent" like uniform updates
  90206. */
  90207. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  90208. /**
  90209. * Set a mat3 in the shader from a Float32Array.
  90210. * @param name Define the name of the uniform as defined in the shader
  90211. * @param value Define the value to give to the uniform
  90212. * @return the material itself allowing "fluent" like uniform updates
  90213. */
  90214. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  90215. /**
  90216. * Set a mat2 in the shader from a Float32Array.
  90217. * @param name Define the name of the uniform as defined in the shader
  90218. * @param value Define the value to give to the uniform
  90219. * @return the material itself allowing "fluent" like uniform updates
  90220. */
  90221. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  90222. /**
  90223. * Set a vec2 array in the shader from a number array.
  90224. * @param name Define the name of the uniform as defined in the shader
  90225. * @param value Define the value to give to the uniform
  90226. * @return the material itself allowing "fluent" like uniform updates
  90227. */
  90228. setArray2(name: string, value: number[]): ShaderMaterial;
  90229. /**
  90230. * Set a vec3 array in the shader from a number array.
  90231. * @param name Define the name of the uniform as defined in the shader
  90232. * @param value Define the value to give to the uniform
  90233. * @return the material itself allowing "fluent" like uniform updates
  90234. */
  90235. setArray3(name: string, value: number[]): ShaderMaterial;
  90236. /**
  90237. * Set a vec4 array in the shader from a number array.
  90238. * @param name Define the name of the uniform as defined in the shader
  90239. * @param value Define the value to give to the uniform
  90240. * @return the material itself allowing "fluent" like uniform updates
  90241. */
  90242. setArray4(name: string, value: number[]): ShaderMaterial;
  90243. private _checkCache;
  90244. /**
  90245. * Specifies that the submesh is ready to be used
  90246. * @param mesh defines the mesh to check
  90247. * @param subMesh defines which submesh to check
  90248. * @param useInstances specifies that instances should be used
  90249. * @returns a boolean indicating that the submesh is ready or not
  90250. */
  90251. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  90252. /**
  90253. * Checks if the material is ready to render the requested mesh
  90254. * @param mesh Define the mesh to render
  90255. * @param useInstances Define whether or not the material is used with instances
  90256. * @returns true if ready, otherwise false
  90257. */
  90258. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  90259. /**
  90260. * Binds the world matrix to the material
  90261. * @param world defines the world transformation matrix
  90262. */
  90263. bindOnlyWorldMatrix(world: Matrix): void;
  90264. /**
  90265. * Binds the material to the mesh
  90266. * @param world defines the world transformation matrix
  90267. * @param mesh defines the mesh to bind the material to
  90268. */
  90269. bind(world: Matrix, mesh?: Mesh): void;
  90270. /**
  90271. * Gets the active textures from the material
  90272. * @returns an array of textures
  90273. */
  90274. getActiveTextures(): BaseTexture[];
  90275. /**
  90276. * Specifies if the material uses a texture
  90277. * @param texture defines the texture to check against the material
  90278. * @returns a boolean specifying if the material uses the texture
  90279. */
  90280. hasTexture(texture: BaseTexture): boolean;
  90281. /**
  90282. * Makes a duplicate of the material, and gives it a new name
  90283. * @param name defines the new name for the duplicated material
  90284. * @returns the cloned material
  90285. */
  90286. clone(name: string): ShaderMaterial;
  90287. /**
  90288. * Disposes the material
  90289. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  90290. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  90291. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  90292. */
  90293. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  90294. /**
  90295. * Serializes this material in a JSON representation
  90296. * @returns the serialized material object
  90297. */
  90298. serialize(): any;
  90299. /**
  90300. * Creates a shader material from parsed shader material data
  90301. * @param source defines the JSON represnetation of the material
  90302. * @param scene defines the hosting scene
  90303. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90304. * @returns a new material
  90305. */
  90306. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  90307. }
  90308. }
  90309. declare module BABYLON {
  90310. /** @hidden */
  90311. export var colorPixelShader: {
  90312. name: string;
  90313. shader: string;
  90314. };
  90315. }
  90316. declare module BABYLON {
  90317. /** @hidden */
  90318. export var colorVertexShader: {
  90319. name: string;
  90320. shader: string;
  90321. };
  90322. }
  90323. declare module BABYLON {
  90324. /**
  90325. * Line mesh
  90326. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  90327. */
  90328. export class LinesMesh extends Mesh {
  90329. /**
  90330. * If vertex color should be applied to the mesh
  90331. */
  90332. readonly useVertexColor?: boolean | undefined;
  90333. /**
  90334. * If vertex alpha should be applied to the mesh
  90335. */
  90336. readonly useVertexAlpha?: boolean | undefined;
  90337. /**
  90338. * Color of the line (Default: White)
  90339. */
  90340. color: Color3;
  90341. /**
  90342. * Alpha of the line (Default: 1)
  90343. */
  90344. alpha: number;
  90345. /**
  90346. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  90347. * This margin is expressed in world space coordinates, so its value may vary.
  90348. * Default value is 0.1
  90349. */
  90350. intersectionThreshold: number;
  90351. private _colorShader;
  90352. private color4;
  90353. /**
  90354. * Creates a new LinesMesh
  90355. * @param name defines the name
  90356. * @param scene defines the hosting scene
  90357. * @param parent defines the parent mesh if any
  90358. * @param source defines the optional source LinesMesh used to clone data from
  90359. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  90360. * When false, achieved by calling a clone(), also passing False.
  90361. * This will make creation of children, recursive.
  90362. * @param useVertexColor defines if this LinesMesh supports vertex color
  90363. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  90364. */
  90365. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  90366. /**
  90367. * If vertex color should be applied to the mesh
  90368. */
  90369. useVertexColor?: boolean | undefined,
  90370. /**
  90371. * If vertex alpha should be applied to the mesh
  90372. */
  90373. useVertexAlpha?: boolean | undefined);
  90374. private _addClipPlaneDefine;
  90375. private _removeClipPlaneDefine;
  90376. isReady(): boolean;
  90377. /**
  90378. * Returns the string "LineMesh"
  90379. */
  90380. getClassName(): string;
  90381. /**
  90382. * @hidden
  90383. */
  90384. get material(): Material;
  90385. /**
  90386. * @hidden
  90387. */
  90388. set material(value: Material);
  90389. /**
  90390. * @hidden
  90391. */
  90392. get checkCollisions(): boolean;
  90393. /** @hidden */
  90394. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  90395. /** @hidden */
  90396. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  90397. /**
  90398. * Disposes of the line mesh
  90399. * @param doNotRecurse If children should be disposed
  90400. */
  90401. dispose(doNotRecurse?: boolean): void;
  90402. /**
  90403. * Returns a new LineMesh object cloned from the current one.
  90404. */
  90405. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  90406. /**
  90407. * Creates a new InstancedLinesMesh object from the mesh model.
  90408. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90409. * @param name defines the name of the new instance
  90410. * @returns a new InstancedLinesMesh
  90411. */
  90412. createInstance(name: string): InstancedLinesMesh;
  90413. }
  90414. /**
  90415. * Creates an instance based on a source LinesMesh
  90416. */
  90417. export class InstancedLinesMesh extends InstancedMesh {
  90418. /**
  90419. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  90420. * This margin is expressed in world space coordinates, so its value may vary.
  90421. * Initilized with the intersectionThreshold value of the source LinesMesh
  90422. */
  90423. intersectionThreshold: number;
  90424. constructor(name: string, source: LinesMesh);
  90425. /**
  90426. * Returns the string "InstancedLinesMesh".
  90427. */
  90428. getClassName(): string;
  90429. }
  90430. }
  90431. declare module BABYLON {
  90432. /** @hidden */
  90433. export var linePixelShader: {
  90434. name: string;
  90435. shader: string;
  90436. };
  90437. }
  90438. declare module BABYLON {
  90439. /** @hidden */
  90440. export var lineVertexShader: {
  90441. name: string;
  90442. shader: string;
  90443. };
  90444. }
  90445. declare module BABYLON {
  90446. interface AbstractMesh {
  90447. /**
  90448. * Gets the edgesRenderer associated with the mesh
  90449. */
  90450. edgesRenderer: Nullable<EdgesRenderer>;
  90451. }
  90452. interface LinesMesh {
  90453. /**
  90454. * Enables the edge rendering mode on the mesh.
  90455. * This mode makes the mesh edges visible
  90456. * @param epsilon defines the maximal distance between two angles to detect a face
  90457. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90458. * @returns the currentAbstractMesh
  90459. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90460. */
  90461. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  90462. }
  90463. interface InstancedLinesMesh {
  90464. /**
  90465. * Enables the edge rendering mode on the mesh.
  90466. * This mode makes the mesh edges visible
  90467. * @param epsilon defines the maximal distance between two angles to detect a face
  90468. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90469. * @returns the current InstancedLinesMesh
  90470. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90471. */
  90472. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  90473. }
  90474. /**
  90475. * Defines the minimum contract an Edges renderer should follow.
  90476. */
  90477. export interface IEdgesRenderer extends IDisposable {
  90478. /**
  90479. * Gets or sets a boolean indicating if the edgesRenderer is active
  90480. */
  90481. isEnabled: boolean;
  90482. /**
  90483. * Renders the edges of the attached mesh,
  90484. */
  90485. render(): void;
  90486. /**
  90487. * Checks wether or not the edges renderer is ready to render.
  90488. * @return true if ready, otherwise false.
  90489. */
  90490. isReady(): boolean;
  90491. }
  90492. /**
  90493. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  90494. */
  90495. export class EdgesRenderer implements IEdgesRenderer {
  90496. /**
  90497. * Define the size of the edges with an orthographic camera
  90498. */
  90499. edgesWidthScalerForOrthographic: number;
  90500. /**
  90501. * Define the size of the edges with a perspective camera
  90502. */
  90503. edgesWidthScalerForPerspective: number;
  90504. protected _source: AbstractMesh;
  90505. protected _linesPositions: number[];
  90506. protected _linesNormals: number[];
  90507. protected _linesIndices: number[];
  90508. protected _epsilon: number;
  90509. protected _indicesCount: number;
  90510. protected _lineShader: ShaderMaterial;
  90511. protected _ib: DataBuffer;
  90512. protected _buffers: {
  90513. [key: string]: Nullable<VertexBuffer>;
  90514. };
  90515. protected _checkVerticesInsteadOfIndices: boolean;
  90516. private _meshRebuildObserver;
  90517. private _meshDisposeObserver;
  90518. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  90519. isEnabled: boolean;
  90520. /**
  90521. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  90522. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  90523. * @param source Mesh used to create edges
  90524. * @param epsilon sum of angles in adjacency to check for edge
  90525. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  90526. * @param generateEdgesLines - should generate Lines or only prepare resources.
  90527. */
  90528. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  90529. protected _prepareRessources(): void;
  90530. /** @hidden */
  90531. _rebuild(): void;
  90532. /**
  90533. * Releases the required resources for the edges renderer
  90534. */
  90535. dispose(): void;
  90536. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  90537. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  90538. /**
  90539. * Checks if the pair of p0 and p1 is en edge
  90540. * @param faceIndex
  90541. * @param edge
  90542. * @param faceNormals
  90543. * @param p0
  90544. * @param p1
  90545. * @private
  90546. */
  90547. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  90548. /**
  90549. * push line into the position, normal and index buffer
  90550. * @protected
  90551. */
  90552. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  90553. /**
  90554. * Generates lines edges from adjacencjes
  90555. * @private
  90556. */
  90557. _generateEdgesLines(): void;
  90558. /**
  90559. * Checks wether or not the edges renderer is ready to render.
  90560. * @return true if ready, otherwise false.
  90561. */
  90562. isReady(): boolean;
  90563. /**
  90564. * Renders the edges of the attached mesh,
  90565. */
  90566. render(): void;
  90567. }
  90568. /**
  90569. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  90570. */
  90571. export class LineEdgesRenderer extends EdgesRenderer {
  90572. /**
  90573. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  90574. * @param source LineMesh used to generate edges
  90575. * @param epsilon not important (specified angle for edge detection)
  90576. * @param checkVerticesInsteadOfIndices not important for LineMesh
  90577. */
  90578. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  90579. /**
  90580. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  90581. */
  90582. _generateEdgesLines(): void;
  90583. }
  90584. }
  90585. declare module BABYLON {
  90586. /**
  90587. * This represents the object necessary to create a rendering group.
  90588. * This is exclusively used and created by the rendering manager.
  90589. * To modify the behavior, you use the available helpers in your scene or meshes.
  90590. * @hidden
  90591. */
  90592. export class RenderingGroup {
  90593. index: number;
  90594. private static _zeroVector;
  90595. private _scene;
  90596. private _opaqueSubMeshes;
  90597. private _transparentSubMeshes;
  90598. private _alphaTestSubMeshes;
  90599. private _depthOnlySubMeshes;
  90600. private _particleSystems;
  90601. private _spriteManagers;
  90602. private _opaqueSortCompareFn;
  90603. private _alphaTestSortCompareFn;
  90604. private _transparentSortCompareFn;
  90605. private _renderOpaque;
  90606. private _renderAlphaTest;
  90607. private _renderTransparent;
  90608. /** @hidden */
  90609. _edgesRenderers: SmartArray<IEdgesRenderer>;
  90610. onBeforeTransparentRendering: () => void;
  90611. /**
  90612. * Set the opaque sort comparison function.
  90613. * If null the sub meshes will be render in the order they were created
  90614. */
  90615. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90616. /**
  90617. * Set the alpha test sort comparison function.
  90618. * If null the sub meshes will be render in the order they were created
  90619. */
  90620. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90621. /**
  90622. * Set the transparent sort comparison function.
  90623. * If null the sub meshes will be render in the order they were created
  90624. */
  90625. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90626. /**
  90627. * Creates a new rendering group.
  90628. * @param index The rendering group index
  90629. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  90630. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  90631. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  90632. */
  90633. 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>);
  90634. /**
  90635. * Render all the sub meshes contained in the group.
  90636. * @param customRenderFunction Used to override the default render behaviour of the group.
  90637. * @returns true if rendered some submeshes.
  90638. */
  90639. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  90640. /**
  90641. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  90642. * @param subMeshes The submeshes to render
  90643. */
  90644. private renderOpaqueSorted;
  90645. /**
  90646. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  90647. * @param subMeshes The submeshes to render
  90648. */
  90649. private renderAlphaTestSorted;
  90650. /**
  90651. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  90652. * @param subMeshes The submeshes to render
  90653. */
  90654. private renderTransparentSorted;
  90655. /**
  90656. * Renders the submeshes in a specified order.
  90657. * @param subMeshes The submeshes to sort before render
  90658. * @param sortCompareFn The comparison function use to sort
  90659. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  90660. * @param transparent Specifies to activate blending if true
  90661. */
  90662. private static renderSorted;
  90663. /**
  90664. * Renders the submeshes in the order they were dispatched (no sort applied).
  90665. * @param subMeshes The submeshes to render
  90666. */
  90667. private static renderUnsorted;
  90668. /**
  90669. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90670. * are rendered back to front if in the same alpha index.
  90671. *
  90672. * @param a The first submesh
  90673. * @param b The second submesh
  90674. * @returns The result of the comparison
  90675. */
  90676. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  90677. /**
  90678. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90679. * are rendered back to front.
  90680. *
  90681. * @param a The first submesh
  90682. * @param b The second submesh
  90683. * @returns The result of the comparison
  90684. */
  90685. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  90686. /**
  90687. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90688. * are rendered front to back (prevent overdraw).
  90689. *
  90690. * @param a The first submesh
  90691. * @param b The second submesh
  90692. * @returns The result of the comparison
  90693. */
  90694. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  90695. /**
  90696. * Resets the different lists of submeshes to prepare a new frame.
  90697. */
  90698. prepare(): void;
  90699. dispose(): void;
  90700. /**
  90701. * Inserts the submesh in its correct queue depending on its material.
  90702. * @param subMesh The submesh to dispatch
  90703. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  90704. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  90705. */
  90706. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  90707. dispatchSprites(spriteManager: ISpriteManager): void;
  90708. dispatchParticles(particleSystem: IParticleSystem): void;
  90709. private _renderParticles;
  90710. private _renderSprites;
  90711. }
  90712. }
  90713. declare module BABYLON {
  90714. /**
  90715. * Interface describing the different options available in the rendering manager
  90716. * regarding Auto Clear between groups.
  90717. */
  90718. export interface IRenderingManagerAutoClearSetup {
  90719. /**
  90720. * Defines whether or not autoclear is enable.
  90721. */
  90722. autoClear: boolean;
  90723. /**
  90724. * Defines whether or not to autoclear the depth buffer.
  90725. */
  90726. depth: boolean;
  90727. /**
  90728. * Defines whether or not to autoclear the stencil buffer.
  90729. */
  90730. stencil: boolean;
  90731. }
  90732. /**
  90733. * This class is used by the onRenderingGroupObservable
  90734. */
  90735. export class RenderingGroupInfo {
  90736. /**
  90737. * The Scene that being rendered
  90738. */
  90739. scene: Scene;
  90740. /**
  90741. * The camera currently used for the rendering pass
  90742. */
  90743. camera: Nullable<Camera>;
  90744. /**
  90745. * The ID of the renderingGroup being processed
  90746. */
  90747. renderingGroupId: number;
  90748. }
  90749. /**
  90750. * This is the manager responsible of all the rendering for meshes sprites and particles.
  90751. * It is enable to manage the different groups as well as the different necessary sort functions.
  90752. * This should not be used directly aside of the few static configurations
  90753. */
  90754. export class RenderingManager {
  90755. /**
  90756. * The max id used for rendering groups (not included)
  90757. */
  90758. static MAX_RENDERINGGROUPS: number;
  90759. /**
  90760. * The min id used for rendering groups (included)
  90761. */
  90762. static MIN_RENDERINGGROUPS: number;
  90763. /**
  90764. * Used to globally prevent autoclearing scenes.
  90765. */
  90766. static AUTOCLEAR: boolean;
  90767. /**
  90768. * @hidden
  90769. */
  90770. _useSceneAutoClearSetup: boolean;
  90771. private _scene;
  90772. private _renderingGroups;
  90773. private _depthStencilBufferAlreadyCleaned;
  90774. private _autoClearDepthStencil;
  90775. private _customOpaqueSortCompareFn;
  90776. private _customAlphaTestSortCompareFn;
  90777. private _customTransparentSortCompareFn;
  90778. private _renderingGroupInfo;
  90779. /**
  90780. * Instantiates a new rendering group for a particular scene
  90781. * @param scene Defines the scene the groups belongs to
  90782. */
  90783. constructor(scene: Scene);
  90784. private _clearDepthStencilBuffer;
  90785. /**
  90786. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  90787. * @hidden
  90788. */
  90789. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  90790. /**
  90791. * Resets the different information of the group to prepare a new frame
  90792. * @hidden
  90793. */
  90794. reset(): void;
  90795. /**
  90796. * Dispose and release the group and its associated resources.
  90797. * @hidden
  90798. */
  90799. dispose(): void;
  90800. /**
  90801. * Clear the info related to rendering groups preventing retention points during dispose.
  90802. */
  90803. freeRenderingGroups(): void;
  90804. private _prepareRenderingGroup;
  90805. /**
  90806. * Add a sprite manager to the rendering manager in order to render it this frame.
  90807. * @param spriteManager Define the sprite manager to render
  90808. */
  90809. dispatchSprites(spriteManager: ISpriteManager): void;
  90810. /**
  90811. * Add a particle system to the rendering manager in order to render it this frame.
  90812. * @param particleSystem Define the particle system to render
  90813. */
  90814. dispatchParticles(particleSystem: IParticleSystem): void;
  90815. /**
  90816. * Add a submesh to the manager in order to render it this frame
  90817. * @param subMesh The submesh to dispatch
  90818. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  90819. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  90820. */
  90821. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  90822. /**
  90823. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  90824. * This allowed control for front to back rendering or reversly depending of the special needs.
  90825. *
  90826. * @param renderingGroupId The rendering group id corresponding to its index
  90827. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  90828. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  90829. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  90830. */
  90831. 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;
  90832. /**
  90833. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  90834. *
  90835. * @param renderingGroupId The rendering group id corresponding to its index
  90836. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  90837. * @param depth Automatically clears depth between groups if true and autoClear is true.
  90838. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  90839. */
  90840. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  90841. /**
  90842. * Gets the current auto clear configuration for one rendering group of the rendering
  90843. * manager.
  90844. * @param index the rendering group index to get the information for
  90845. * @returns The auto clear setup for the requested rendering group
  90846. */
  90847. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  90848. }
  90849. }
  90850. declare module BABYLON {
  90851. /**
  90852. * This Helps creating a texture that will be created from a camera in your scene.
  90853. * It is basically a dynamic texture that could be used to create special effects for instance.
  90854. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  90855. */
  90856. export class RenderTargetTexture extends Texture {
  90857. isCube: boolean;
  90858. /**
  90859. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  90860. */
  90861. static readonly REFRESHRATE_RENDER_ONCE: number;
  90862. /**
  90863. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  90864. */
  90865. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  90866. /**
  90867. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  90868. * the central point of your effect and can save a lot of performances.
  90869. */
  90870. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  90871. /**
  90872. * Use this predicate to dynamically define the list of mesh you want to render.
  90873. * If set, the renderList property will be overwritten.
  90874. */
  90875. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  90876. private _renderList;
  90877. /**
  90878. * Use this list to define the list of mesh you want to render.
  90879. */
  90880. get renderList(): Nullable<Array<AbstractMesh>>;
  90881. set renderList(value: Nullable<Array<AbstractMesh>>);
  90882. private _hookArray;
  90883. /**
  90884. * Define if particles should be rendered in your texture.
  90885. */
  90886. renderParticles: boolean;
  90887. /**
  90888. * Define if sprites should be rendered in your texture.
  90889. */
  90890. renderSprites: boolean;
  90891. /**
  90892. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  90893. */
  90894. coordinatesMode: number;
  90895. /**
  90896. * Define the camera used to render the texture.
  90897. */
  90898. activeCamera: Nullable<Camera>;
  90899. /**
  90900. * Override the render function of the texture with your own one.
  90901. */
  90902. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  90903. /**
  90904. * Define if camera post processes should be use while rendering the texture.
  90905. */
  90906. useCameraPostProcesses: boolean;
  90907. /**
  90908. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  90909. */
  90910. ignoreCameraViewport: boolean;
  90911. private _postProcessManager;
  90912. private _postProcesses;
  90913. private _resizeObserver;
  90914. /**
  90915. * An event triggered when the texture is unbind.
  90916. */
  90917. onBeforeBindObservable: Observable<RenderTargetTexture>;
  90918. /**
  90919. * An event triggered when the texture is unbind.
  90920. */
  90921. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  90922. private _onAfterUnbindObserver;
  90923. /**
  90924. * Set a after unbind callback in the texture.
  90925. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  90926. */
  90927. set onAfterUnbind(callback: () => void);
  90928. /**
  90929. * An event triggered before rendering the texture
  90930. */
  90931. onBeforeRenderObservable: Observable<number>;
  90932. private _onBeforeRenderObserver;
  90933. /**
  90934. * Set a before render callback in the texture.
  90935. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  90936. */
  90937. set onBeforeRender(callback: (faceIndex: number) => void);
  90938. /**
  90939. * An event triggered after rendering the texture
  90940. */
  90941. onAfterRenderObservable: Observable<number>;
  90942. private _onAfterRenderObserver;
  90943. /**
  90944. * Set a after render callback in the texture.
  90945. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  90946. */
  90947. set onAfterRender(callback: (faceIndex: number) => void);
  90948. /**
  90949. * An event triggered after the texture clear
  90950. */
  90951. onClearObservable: Observable<Engine>;
  90952. private _onClearObserver;
  90953. /**
  90954. * Set a clear callback in the texture.
  90955. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  90956. */
  90957. set onClear(callback: (Engine: Engine) => void);
  90958. /**
  90959. * An event triggered when the texture is resized.
  90960. */
  90961. onResizeObservable: Observable<RenderTargetTexture>;
  90962. /**
  90963. * Define the clear color of the Render Target if it should be different from the scene.
  90964. */
  90965. clearColor: Color4;
  90966. protected _size: number | {
  90967. width: number;
  90968. height: number;
  90969. };
  90970. protected _initialSizeParameter: number | {
  90971. width: number;
  90972. height: number;
  90973. } | {
  90974. ratio: number;
  90975. };
  90976. protected _sizeRatio: Nullable<number>;
  90977. /** @hidden */
  90978. _generateMipMaps: boolean;
  90979. protected _renderingManager: RenderingManager;
  90980. /** @hidden */
  90981. _waitingRenderList: string[];
  90982. protected _doNotChangeAspectRatio: boolean;
  90983. protected _currentRefreshId: number;
  90984. protected _refreshRate: number;
  90985. protected _textureMatrix: Matrix;
  90986. protected _samples: number;
  90987. protected _renderTargetOptions: RenderTargetCreationOptions;
  90988. /**
  90989. * Gets render target creation options that were used.
  90990. */
  90991. get renderTargetOptions(): RenderTargetCreationOptions;
  90992. protected _engine: Engine;
  90993. protected _onRatioRescale(): void;
  90994. /**
  90995. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  90996. * It must define where the camera used to render the texture is set
  90997. */
  90998. boundingBoxPosition: Vector3;
  90999. private _boundingBoxSize;
  91000. /**
  91001. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  91002. * When defined, the cubemap will switch to local mode
  91003. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  91004. * @example https://www.babylonjs-playground.com/#RNASML
  91005. */
  91006. set boundingBoxSize(value: Vector3);
  91007. get boundingBoxSize(): Vector3;
  91008. /**
  91009. * In case the RTT has been created with a depth texture, get the associated
  91010. * depth texture.
  91011. * Otherwise, return null.
  91012. */
  91013. depthStencilTexture: Nullable<InternalTexture>;
  91014. /**
  91015. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  91016. * or used a shadow, depth texture...
  91017. * @param name The friendly name of the texture
  91018. * @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)
  91019. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  91020. * @param generateMipMaps True if mip maps need to be generated after render.
  91021. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  91022. * @param type The type of the buffer in the RTT (int, half float, float...)
  91023. * @param isCube True if a cube texture needs to be created
  91024. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  91025. * @param generateDepthBuffer True to generate a depth buffer
  91026. * @param generateStencilBuffer True to generate a stencil buffer
  91027. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  91028. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  91029. * @param delayAllocation if the texture allocation should be delayed (default: false)
  91030. */
  91031. constructor(name: string, size: number | {
  91032. width: number;
  91033. height: number;
  91034. } | {
  91035. ratio: number;
  91036. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  91037. /**
  91038. * Creates a depth stencil texture.
  91039. * This is only available in WebGL 2 or with the depth texture extension available.
  91040. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  91041. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  91042. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  91043. */
  91044. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  91045. private _processSizeParameter;
  91046. /**
  91047. * Define the number of samples to use in case of MSAA.
  91048. * It defaults to one meaning no MSAA has been enabled.
  91049. */
  91050. get samples(): number;
  91051. set samples(value: number);
  91052. /**
  91053. * Resets the refresh counter of the texture and start bak from scratch.
  91054. * Could be useful to regenerate the texture if it is setup to render only once.
  91055. */
  91056. resetRefreshCounter(): void;
  91057. /**
  91058. * Define the refresh rate of the texture or the rendering frequency.
  91059. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  91060. */
  91061. get refreshRate(): number;
  91062. set refreshRate(value: number);
  91063. /**
  91064. * Adds a post process to the render target rendering passes.
  91065. * @param postProcess define the post process to add
  91066. */
  91067. addPostProcess(postProcess: PostProcess): void;
  91068. /**
  91069. * Clear all the post processes attached to the render target
  91070. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  91071. */
  91072. clearPostProcesses(dispose?: boolean): void;
  91073. /**
  91074. * Remove one of the post process from the list of attached post processes to the texture
  91075. * @param postProcess define the post process to remove from the list
  91076. */
  91077. removePostProcess(postProcess: PostProcess): void;
  91078. /** @hidden */
  91079. _shouldRender(): boolean;
  91080. /**
  91081. * Gets the actual render size of the texture.
  91082. * @returns the width of the render size
  91083. */
  91084. getRenderSize(): number;
  91085. /**
  91086. * Gets the actual render width of the texture.
  91087. * @returns the width of the render size
  91088. */
  91089. getRenderWidth(): number;
  91090. /**
  91091. * Gets the actual render height of the texture.
  91092. * @returns the height of the render size
  91093. */
  91094. getRenderHeight(): number;
  91095. /**
  91096. * Get if the texture can be rescaled or not.
  91097. */
  91098. get canRescale(): boolean;
  91099. /**
  91100. * Resize the texture using a ratio.
  91101. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  91102. */
  91103. scale(ratio: number): void;
  91104. /**
  91105. * Get the texture reflection matrix used to rotate/transform the reflection.
  91106. * @returns the reflection matrix
  91107. */
  91108. getReflectionTextureMatrix(): Matrix;
  91109. /**
  91110. * Resize the texture to a new desired size.
  91111. * Be carrefull as it will recreate all the data in the new texture.
  91112. * @param size Define the new size. It can be:
  91113. * - a number for squared texture,
  91114. * - an object containing { width: number, height: number }
  91115. * - or an object containing a ratio { ratio: number }
  91116. */
  91117. resize(size: number | {
  91118. width: number;
  91119. height: number;
  91120. } | {
  91121. ratio: number;
  91122. }): void;
  91123. /**
  91124. * Renders all the objects from the render list into the texture.
  91125. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  91126. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  91127. */
  91128. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  91129. private _bestReflectionRenderTargetDimension;
  91130. /**
  91131. * @hidden
  91132. * @param faceIndex face index to bind to if this is a cubetexture
  91133. */
  91134. _bindFrameBuffer(faceIndex?: number): void;
  91135. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  91136. private renderToTarget;
  91137. /**
  91138. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  91139. * This allowed control for front to back rendering or reversly depending of the special needs.
  91140. *
  91141. * @param renderingGroupId The rendering group id corresponding to its index
  91142. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  91143. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  91144. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  91145. */
  91146. 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;
  91147. /**
  91148. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  91149. *
  91150. * @param renderingGroupId The rendering group id corresponding to its index
  91151. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  91152. */
  91153. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  91154. /**
  91155. * Clones the texture.
  91156. * @returns the cloned texture
  91157. */
  91158. clone(): RenderTargetTexture;
  91159. /**
  91160. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  91161. * @returns The JSON representation of the texture
  91162. */
  91163. serialize(): any;
  91164. /**
  91165. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  91166. */
  91167. disposeFramebufferObjects(): void;
  91168. /**
  91169. * Dispose the texture and release its associated resources.
  91170. */
  91171. dispose(): void;
  91172. /** @hidden */
  91173. _rebuild(): void;
  91174. /**
  91175. * Clear the info related to rendering groups preventing retention point in material dispose.
  91176. */
  91177. freeRenderingGroups(): void;
  91178. /**
  91179. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  91180. * @returns the view count
  91181. */
  91182. getViewCount(): number;
  91183. }
  91184. }
  91185. declare module BABYLON {
  91186. /**
  91187. * Options for compiling materials.
  91188. */
  91189. export interface IMaterialCompilationOptions {
  91190. /**
  91191. * Defines whether clip planes are enabled.
  91192. */
  91193. clipPlane: boolean;
  91194. /**
  91195. * Defines whether instances are enabled.
  91196. */
  91197. useInstances: boolean;
  91198. }
  91199. /**
  91200. * Base class for the main features of a material in Babylon.js
  91201. */
  91202. export class Material implements IAnimatable {
  91203. /**
  91204. * Returns the triangle fill mode
  91205. */
  91206. static readonly TriangleFillMode: number;
  91207. /**
  91208. * Returns the wireframe mode
  91209. */
  91210. static readonly WireFrameFillMode: number;
  91211. /**
  91212. * Returns the point fill mode
  91213. */
  91214. static readonly PointFillMode: number;
  91215. /**
  91216. * Returns the point list draw mode
  91217. */
  91218. static readonly PointListDrawMode: number;
  91219. /**
  91220. * Returns the line list draw mode
  91221. */
  91222. static readonly LineListDrawMode: number;
  91223. /**
  91224. * Returns the line loop draw mode
  91225. */
  91226. static readonly LineLoopDrawMode: number;
  91227. /**
  91228. * Returns the line strip draw mode
  91229. */
  91230. static readonly LineStripDrawMode: number;
  91231. /**
  91232. * Returns the triangle strip draw mode
  91233. */
  91234. static readonly TriangleStripDrawMode: number;
  91235. /**
  91236. * Returns the triangle fan draw mode
  91237. */
  91238. static readonly TriangleFanDrawMode: number;
  91239. /**
  91240. * Stores the clock-wise side orientation
  91241. */
  91242. static readonly ClockWiseSideOrientation: number;
  91243. /**
  91244. * Stores the counter clock-wise side orientation
  91245. */
  91246. static readonly CounterClockWiseSideOrientation: number;
  91247. /**
  91248. * The dirty texture flag value
  91249. */
  91250. static readonly TextureDirtyFlag: number;
  91251. /**
  91252. * The dirty light flag value
  91253. */
  91254. static readonly LightDirtyFlag: number;
  91255. /**
  91256. * The dirty fresnel flag value
  91257. */
  91258. static readonly FresnelDirtyFlag: number;
  91259. /**
  91260. * The dirty attribute flag value
  91261. */
  91262. static readonly AttributesDirtyFlag: number;
  91263. /**
  91264. * The dirty misc flag value
  91265. */
  91266. static readonly MiscDirtyFlag: number;
  91267. /**
  91268. * The all dirty flag value
  91269. */
  91270. static readonly AllDirtyFlag: number;
  91271. /**
  91272. * The ID of the material
  91273. */
  91274. id: string;
  91275. /**
  91276. * Gets or sets the unique id of the material
  91277. */
  91278. uniqueId: number;
  91279. /**
  91280. * The name of the material
  91281. */
  91282. name: string;
  91283. /**
  91284. * Gets or sets user defined metadata
  91285. */
  91286. metadata: any;
  91287. /**
  91288. * For internal use only. Please do not use.
  91289. */
  91290. reservedDataStore: any;
  91291. /**
  91292. * Specifies if the ready state should be checked on each call
  91293. */
  91294. checkReadyOnEveryCall: boolean;
  91295. /**
  91296. * Specifies if the ready state should be checked once
  91297. */
  91298. checkReadyOnlyOnce: boolean;
  91299. /**
  91300. * The state of the material
  91301. */
  91302. state: string;
  91303. /**
  91304. * The alpha value of the material
  91305. */
  91306. protected _alpha: number;
  91307. /**
  91308. * List of inspectable custom properties (used by the Inspector)
  91309. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  91310. */
  91311. inspectableCustomProperties: IInspectable[];
  91312. /**
  91313. * Sets the alpha value of the material
  91314. */
  91315. set alpha(value: number);
  91316. /**
  91317. * Gets the alpha value of the material
  91318. */
  91319. get alpha(): number;
  91320. /**
  91321. * Specifies if back face culling is enabled
  91322. */
  91323. protected _backFaceCulling: boolean;
  91324. /**
  91325. * Sets the back-face culling state
  91326. */
  91327. set backFaceCulling(value: boolean);
  91328. /**
  91329. * Gets the back-face culling state
  91330. */
  91331. get backFaceCulling(): boolean;
  91332. /**
  91333. * Stores the value for side orientation
  91334. */
  91335. sideOrientation: number;
  91336. /**
  91337. * Callback triggered when the material is compiled
  91338. */
  91339. onCompiled: Nullable<(effect: Effect) => void>;
  91340. /**
  91341. * Callback triggered when an error occurs
  91342. */
  91343. onError: Nullable<(effect: Effect, errors: string) => void>;
  91344. /**
  91345. * Callback triggered to get the render target textures
  91346. */
  91347. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  91348. /**
  91349. * Gets a boolean indicating that current material needs to register RTT
  91350. */
  91351. get hasRenderTargetTextures(): boolean;
  91352. /**
  91353. * Specifies if the material should be serialized
  91354. */
  91355. doNotSerialize: boolean;
  91356. /**
  91357. * @hidden
  91358. */
  91359. _storeEffectOnSubMeshes: boolean;
  91360. /**
  91361. * Stores the animations for the material
  91362. */
  91363. animations: Nullable<Array<Animation>>;
  91364. /**
  91365. * An event triggered when the material is disposed
  91366. */
  91367. onDisposeObservable: Observable<Material>;
  91368. /**
  91369. * An observer which watches for dispose events
  91370. */
  91371. private _onDisposeObserver;
  91372. private _onUnBindObservable;
  91373. /**
  91374. * Called during a dispose event
  91375. */
  91376. set onDispose(callback: () => void);
  91377. private _onBindObservable;
  91378. /**
  91379. * An event triggered when the material is bound
  91380. */
  91381. get onBindObservable(): Observable<AbstractMesh>;
  91382. /**
  91383. * An observer which watches for bind events
  91384. */
  91385. private _onBindObserver;
  91386. /**
  91387. * Called during a bind event
  91388. */
  91389. set onBind(callback: (Mesh: AbstractMesh) => void);
  91390. /**
  91391. * An event triggered when the material is unbound
  91392. */
  91393. get onUnBindObservable(): Observable<Material>;
  91394. /**
  91395. * Stores the value of the alpha mode
  91396. */
  91397. private _alphaMode;
  91398. /**
  91399. * Sets the value of the alpha mode.
  91400. *
  91401. * | Value | Type | Description |
  91402. * | --- | --- | --- |
  91403. * | 0 | ALPHA_DISABLE | |
  91404. * | 1 | ALPHA_ADD | |
  91405. * | 2 | ALPHA_COMBINE | |
  91406. * | 3 | ALPHA_SUBTRACT | |
  91407. * | 4 | ALPHA_MULTIPLY | |
  91408. * | 5 | ALPHA_MAXIMIZED | |
  91409. * | 6 | ALPHA_ONEONE | |
  91410. * | 7 | ALPHA_PREMULTIPLIED | |
  91411. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  91412. * | 9 | ALPHA_INTERPOLATE | |
  91413. * | 10 | ALPHA_SCREENMODE | |
  91414. *
  91415. */
  91416. set alphaMode(value: number);
  91417. /**
  91418. * Gets the value of the alpha mode
  91419. */
  91420. get alphaMode(): number;
  91421. /**
  91422. * Stores the state of the need depth pre-pass value
  91423. */
  91424. private _needDepthPrePass;
  91425. /**
  91426. * Sets the need depth pre-pass value
  91427. */
  91428. set needDepthPrePass(value: boolean);
  91429. /**
  91430. * Gets the depth pre-pass value
  91431. */
  91432. get needDepthPrePass(): boolean;
  91433. /**
  91434. * Specifies if depth writing should be disabled
  91435. */
  91436. disableDepthWrite: boolean;
  91437. /**
  91438. * Specifies if depth writing should be forced
  91439. */
  91440. forceDepthWrite: boolean;
  91441. /**
  91442. * Specifies the depth function that should be used. 0 means the default engine function
  91443. */
  91444. depthFunction: number;
  91445. /**
  91446. * Specifies if there should be a separate pass for culling
  91447. */
  91448. separateCullingPass: boolean;
  91449. /**
  91450. * Stores the state specifing if fog should be enabled
  91451. */
  91452. private _fogEnabled;
  91453. /**
  91454. * Sets the state for enabling fog
  91455. */
  91456. set fogEnabled(value: boolean);
  91457. /**
  91458. * Gets the value of the fog enabled state
  91459. */
  91460. get fogEnabled(): boolean;
  91461. /**
  91462. * Stores the size of points
  91463. */
  91464. pointSize: number;
  91465. /**
  91466. * Stores the z offset value
  91467. */
  91468. zOffset: number;
  91469. /**
  91470. * Gets a value specifying if wireframe mode is enabled
  91471. */
  91472. get wireframe(): boolean;
  91473. /**
  91474. * Sets the state of wireframe mode
  91475. */
  91476. set wireframe(value: boolean);
  91477. /**
  91478. * Gets the value specifying if point clouds are enabled
  91479. */
  91480. get pointsCloud(): boolean;
  91481. /**
  91482. * Sets the state of point cloud mode
  91483. */
  91484. set pointsCloud(value: boolean);
  91485. /**
  91486. * Gets the material fill mode
  91487. */
  91488. get fillMode(): number;
  91489. /**
  91490. * Sets the material fill mode
  91491. */
  91492. set fillMode(value: number);
  91493. /**
  91494. * @hidden
  91495. * Stores the effects for the material
  91496. */
  91497. _effect: Nullable<Effect>;
  91498. /**
  91499. * @hidden
  91500. * Specifies if the material was previously ready
  91501. */
  91502. _wasPreviouslyReady: boolean;
  91503. /**
  91504. * Specifies if uniform buffers should be used
  91505. */
  91506. private _useUBO;
  91507. /**
  91508. * Stores a reference to the scene
  91509. */
  91510. private _scene;
  91511. /**
  91512. * Stores the fill mode state
  91513. */
  91514. private _fillMode;
  91515. /**
  91516. * Specifies if the depth write state should be cached
  91517. */
  91518. private _cachedDepthWriteState;
  91519. /**
  91520. * Specifies if the depth function state should be cached
  91521. */
  91522. private _cachedDepthFunctionState;
  91523. /**
  91524. * Stores the uniform buffer
  91525. */
  91526. protected _uniformBuffer: UniformBuffer;
  91527. /** @hidden */
  91528. _indexInSceneMaterialArray: number;
  91529. /** @hidden */
  91530. meshMap: Nullable<{
  91531. [id: string]: AbstractMesh | undefined;
  91532. }>;
  91533. /**
  91534. * Creates a material instance
  91535. * @param name defines the name of the material
  91536. * @param scene defines the scene to reference
  91537. * @param doNotAdd specifies if the material should be added to the scene
  91538. */
  91539. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  91540. /**
  91541. * Returns a string representation of the current material
  91542. * @param fullDetails defines a boolean indicating which levels of logging is desired
  91543. * @returns a string with material information
  91544. */
  91545. toString(fullDetails?: boolean): string;
  91546. /**
  91547. * Gets the class name of the material
  91548. * @returns a string with the class name of the material
  91549. */
  91550. getClassName(): string;
  91551. /**
  91552. * Specifies if updates for the material been locked
  91553. */
  91554. get isFrozen(): boolean;
  91555. /**
  91556. * Locks updates for the material
  91557. */
  91558. freeze(): void;
  91559. /**
  91560. * Unlocks updates for the material
  91561. */
  91562. unfreeze(): void;
  91563. /**
  91564. * Specifies if the material is ready to be used
  91565. * @param mesh defines the mesh to check
  91566. * @param useInstances specifies if instances should be used
  91567. * @returns a boolean indicating if the material is ready to be used
  91568. */
  91569. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  91570. /**
  91571. * Specifies that the submesh is ready to be used
  91572. * @param mesh defines the mesh to check
  91573. * @param subMesh defines which submesh to check
  91574. * @param useInstances specifies that instances should be used
  91575. * @returns a boolean indicating that the submesh is ready or not
  91576. */
  91577. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  91578. /**
  91579. * Returns the material effect
  91580. * @returns the effect associated with the material
  91581. */
  91582. getEffect(): Nullable<Effect>;
  91583. /**
  91584. * Returns the current scene
  91585. * @returns a Scene
  91586. */
  91587. getScene(): Scene;
  91588. /**
  91589. * Specifies if the material will require alpha blending
  91590. * @returns a boolean specifying if alpha blending is needed
  91591. */
  91592. needAlphaBlending(): boolean;
  91593. /**
  91594. * Specifies if the mesh will require alpha blending
  91595. * @param mesh defines the mesh to check
  91596. * @returns a boolean specifying if alpha blending is needed for the mesh
  91597. */
  91598. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  91599. /**
  91600. * Specifies if this material should be rendered in alpha test mode
  91601. * @returns a boolean specifying if an alpha test is needed.
  91602. */
  91603. needAlphaTesting(): boolean;
  91604. /**
  91605. * Gets the texture used for the alpha test
  91606. * @returns the texture to use for alpha testing
  91607. */
  91608. getAlphaTestTexture(): Nullable<BaseTexture>;
  91609. /**
  91610. * Marks the material to indicate that it needs to be re-calculated
  91611. */
  91612. markDirty(): void;
  91613. /** @hidden */
  91614. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  91615. /**
  91616. * Binds the material to the mesh
  91617. * @param world defines the world transformation matrix
  91618. * @param mesh defines the mesh to bind the material to
  91619. */
  91620. bind(world: Matrix, mesh?: Mesh): void;
  91621. /**
  91622. * Binds the submesh to the material
  91623. * @param world defines the world transformation matrix
  91624. * @param mesh defines the mesh containing the submesh
  91625. * @param subMesh defines the submesh to bind the material to
  91626. */
  91627. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  91628. /**
  91629. * Binds the world matrix to the material
  91630. * @param world defines the world transformation matrix
  91631. */
  91632. bindOnlyWorldMatrix(world: Matrix): void;
  91633. /**
  91634. * Binds the scene's uniform buffer to the effect.
  91635. * @param effect defines the effect to bind to the scene uniform buffer
  91636. * @param sceneUbo defines the uniform buffer storing scene data
  91637. */
  91638. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  91639. /**
  91640. * Binds the view matrix to the effect
  91641. * @param effect defines the effect to bind the view matrix to
  91642. */
  91643. bindView(effect: Effect): void;
  91644. /**
  91645. * Binds the view projection matrix to the effect
  91646. * @param effect defines the effect to bind the view projection matrix to
  91647. */
  91648. bindViewProjection(effect: Effect): void;
  91649. /**
  91650. * Specifies if material alpha testing should be turned on for the mesh
  91651. * @param mesh defines the mesh to check
  91652. */
  91653. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  91654. /**
  91655. * Processes to execute after binding the material to a mesh
  91656. * @param mesh defines the rendered mesh
  91657. */
  91658. protected _afterBind(mesh?: Mesh): void;
  91659. /**
  91660. * Unbinds the material from the mesh
  91661. */
  91662. unbind(): void;
  91663. /**
  91664. * Gets the active textures from the material
  91665. * @returns an array of textures
  91666. */
  91667. getActiveTextures(): BaseTexture[];
  91668. /**
  91669. * Specifies if the material uses a texture
  91670. * @param texture defines the texture to check against the material
  91671. * @returns a boolean specifying if the material uses the texture
  91672. */
  91673. hasTexture(texture: BaseTexture): boolean;
  91674. /**
  91675. * Makes a duplicate of the material, and gives it a new name
  91676. * @param name defines the new name for the duplicated material
  91677. * @returns the cloned material
  91678. */
  91679. clone(name: string): Nullable<Material>;
  91680. /**
  91681. * Gets the meshes bound to the material
  91682. * @returns an array of meshes bound to the material
  91683. */
  91684. getBindedMeshes(): AbstractMesh[];
  91685. /**
  91686. * Force shader compilation
  91687. * @param mesh defines the mesh associated with this material
  91688. * @param onCompiled defines a function to execute once the material is compiled
  91689. * @param options defines the options to configure the compilation
  91690. * @param onError defines a function to execute if the material fails compiling
  91691. */
  91692. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  91693. /**
  91694. * Force shader compilation
  91695. * @param mesh defines the mesh that will use this material
  91696. * @param options defines additional options for compiling the shaders
  91697. * @returns a promise that resolves when the compilation completes
  91698. */
  91699. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  91700. private static readonly _AllDirtyCallBack;
  91701. private static readonly _ImageProcessingDirtyCallBack;
  91702. private static readonly _TextureDirtyCallBack;
  91703. private static readonly _FresnelDirtyCallBack;
  91704. private static readonly _MiscDirtyCallBack;
  91705. private static readonly _LightsDirtyCallBack;
  91706. private static readonly _AttributeDirtyCallBack;
  91707. private static _FresnelAndMiscDirtyCallBack;
  91708. private static _TextureAndMiscDirtyCallBack;
  91709. private static readonly _DirtyCallbackArray;
  91710. private static readonly _RunDirtyCallBacks;
  91711. /**
  91712. * Marks a define in the material to indicate that it needs to be re-computed
  91713. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  91714. */
  91715. markAsDirty(flag: number): void;
  91716. /**
  91717. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  91718. * @param func defines a function which checks material defines against the submeshes
  91719. */
  91720. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  91721. /**
  91722. * Indicates that we need to re-calculated for all submeshes
  91723. */
  91724. protected _markAllSubMeshesAsAllDirty(): void;
  91725. /**
  91726. * Indicates that image processing needs to be re-calculated for all submeshes
  91727. */
  91728. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  91729. /**
  91730. * Indicates that textures need to be re-calculated for all submeshes
  91731. */
  91732. protected _markAllSubMeshesAsTexturesDirty(): void;
  91733. /**
  91734. * Indicates that fresnel needs to be re-calculated for all submeshes
  91735. */
  91736. protected _markAllSubMeshesAsFresnelDirty(): void;
  91737. /**
  91738. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  91739. */
  91740. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  91741. /**
  91742. * Indicates that lights need to be re-calculated for all submeshes
  91743. */
  91744. protected _markAllSubMeshesAsLightsDirty(): void;
  91745. /**
  91746. * Indicates that attributes need to be re-calculated for all submeshes
  91747. */
  91748. protected _markAllSubMeshesAsAttributesDirty(): void;
  91749. /**
  91750. * Indicates that misc needs to be re-calculated for all submeshes
  91751. */
  91752. protected _markAllSubMeshesAsMiscDirty(): void;
  91753. /**
  91754. * Indicates that textures and misc need to be re-calculated for all submeshes
  91755. */
  91756. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  91757. /**
  91758. * Disposes the material
  91759. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  91760. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  91761. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  91762. */
  91763. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  91764. /** @hidden */
  91765. private releaseVertexArrayObject;
  91766. /**
  91767. * Serializes this material
  91768. * @returns the serialized material object
  91769. */
  91770. serialize(): any;
  91771. /**
  91772. * Creates a material from parsed material data
  91773. * @param parsedMaterial defines parsed material data
  91774. * @param scene defines the hosting scene
  91775. * @param rootUrl defines the root URL to use to load textures
  91776. * @returns a new material
  91777. */
  91778. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  91779. }
  91780. }
  91781. declare module BABYLON {
  91782. /**
  91783. * A multi-material is used to apply different materials to different parts of the same object without the need of
  91784. * separate meshes. This can be use to improve performances.
  91785. * @see http://doc.babylonjs.com/how_to/multi_materials
  91786. */
  91787. export class MultiMaterial extends Material {
  91788. private _subMaterials;
  91789. /**
  91790. * Gets or Sets the list of Materials used within the multi material.
  91791. * They need to be ordered according to the submeshes order in the associated mesh
  91792. */
  91793. get subMaterials(): Nullable<Material>[];
  91794. set subMaterials(value: Nullable<Material>[]);
  91795. /**
  91796. * Function used to align with Node.getChildren()
  91797. * @returns the list of Materials used within the multi material
  91798. */
  91799. getChildren(): Nullable<Material>[];
  91800. /**
  91801. * Instantiates a new Multi Material
  91802. * A multi-material is used to apply different materials to different parts of the same object without the need of
  91803. * separate meshes. This can be use to improve performances.
  91804. * @see http://doc.babylonjs.com/how_to/multi_materials
  91805. * @param name Define the name in the scene
  91806. * @param scene Define the scene the material belongs to
  91807. */
  91808. constructor(name: string, scene: Scene);
  91809. private _hookArray;
  91810. /**
  91811. * Get one of the submaterial by its index in the submaterials array
  91812. * @param index The index to look the sub material at
  91813. * @returns The Material if the index has been defined
  91814. */
  91815. getSubMaterial(index: number): Nullable<Material>;
  91816. /**
  91817. * Get the list of active textures for the whole sub materials list.
  91818. * @returns All the textures that will be used during the rendering
  91819. */
  91820. getActiveTextures(): BaseTexture[];
  91821. /**
  91822. * Gets the current class name of the material e.g. "MultiMaterial"
  91823. * Mainly use in serialization.
  91824. * @returns the class name
  91825. */
  91826. getClassName(): string;
  91827. /**
  91828. * Checks if the material is ready to render the requested sub mesh
  91829. * @param mesh Define the mesh the submesh belongs to
  91830. * @param subMesh Define the sub mesh to look readyness for
  91831. * @param useInstances Define whether or not the material is used with instances
  91832. * @returns true if ready, otherwise false
  91833. */
  91834. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  91835. /**
  91836. * Clones the current material and its related sub materials
  91837. * @param name Define the name of the newly cloned material
  91838. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  91839. * @returns the cloned material
  91840. */
  91841. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  91842. /**
  91843. * Serializes the materials into a JSON representation.
  91844. * @returns the JSON representation
  91845. */
  91846. serialize(): any;
  91847. /**
  91848. * Dispose the material and release its associated resources
  91849. * @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)
  91850. * @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)
  91851. * @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)
  91852. */
  91853. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  91854. /**
  91855. * Creates a MultiMaterial from parsed MultiMaterial data.
  91856. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  91857. * @param scene defines the hosting scene
  91858. * @returns a new MultiMaterial
  91859. */
  91860. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  91861. }
  91862. }
  91863. declare module BABYLON {
  91864. /**
  91865. * Base class for submeshes
  91866. */
  91867. export class BaseSubMesh {
  91868. /** @hidden */
  91869. _materialDefines: Nullable<MaterialDefines>;
  91870. /** @hidden */
  91871. _materialEffect: Nullable<Effect>;
  91872. /**
  91873. * Gets material defines used by the effect associated to the sub mesh
  91874. */
  91875. get materialDefines(): Nullable<MaterialDefines>;
  91876. /**
  91877. * Sets material defines used by the effect associated to the sub mesh
  91878. */
  91879. set materialDefines(defines: Nullable<MaterialDefines>);
  91880. /**
  91881. * Gets associated effect
  91882. */
  91883. get effect(): Nullable<Effect>;
  91884. /**
  91885. * Sets associated effect (effect used to render this submesh)
  91886. * @param effect defines the effect to associate with
  91887. * @param defines defines the set of defines used to compile this effect
  91888. */
  91889. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  91890. }
  91891. /**
  91892. * Defines a subdivision inside a mesh
  91893. */
  91894. export class SubMesh extends BaseSubMesh implements ICullable {
  91895. /** the material index to use */
  91896. materialIndex: number;
  91897. /** vertex index start */
  91898. verticesStart: number;
  91899. /** vertices count */
  91900. verticesCount: number;
  91901. /** index start */
  91902. indexStart: number;
  91903. /** indices count */
  91904. indexCount: number;
  91905. /** @hidden */
  91906. _linesIndexCount: number;
  91907. private _mesh;
  91908. private _renderingMesh;
  91909. private _boundingInfo;
  91910. private _linesIndexBuffer;
  91911. /** @hidden */
  91912. _lastColliderWorldVertices: Nullable<Vector3[]>;
  91913. /** @hidden */
  91914. _trianglePlanes: Plane[];
  91915. /** @hidden */
  91916. _lastColliderTransformMatrix: Nullable<Matrix>;
  91917. /** @hidden */
  91918. _renderId: number;
  91919. /** @hidden */
  91920. _alphaIndex: number;
  91921. /** @hidden */
  91922. _distanceToCamera: number;
  91923. /** @hidden */
  91924. _id: number;
  91925. private _currentMaterial;
  91926. /**
  91927. * Add a new submesh to a mesh
  91928. * @param materialIndex defines the material index to use
  91929. * @param verticesStart defines vertex index start
  91930. * @param verticesCount defines vertices count
  91931. * @param indexStart defines index start
  91932. * @param indexCount defines indices count
  91933. * @param mesh defines the parent mesh
  91934. * @param renderingMesh defines an optional rendering mesh
  91935. * @param createBoundingBox defines if bounding box should be created for this submesh
  91936. * @returns the new submesh
  91937. */
  91938. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  91939. /**
  91940. * Creates a new submesh
  91941. * @param materialIndex defines the material index to use
  91942. * @param verticesStart defines vertex index start
  91943. * @param verticesCount defines vertices count
  91944. * @param indexStart defines index start
  91945. * @param indexCount defines indices count
  91946. * @param mesh defines the parent mesh
  91947. * @param renderingMesh defines an optional rendering mesh
  91948. * @param createBoundingBox defines if bounding box should be created for this submesh
  91949. */
  91950. constructor(
  91951. /** the material index to use */
  91952. materialIndex: number,
  91953. /** vertex index start */
  91954. verticesStart: number,
  91955. /** vertices count */
  91956. verticesCount: number,
  91957. /** index start */
  91958. indexStart: number,
  91959. /** indices count */
  91960. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  91961. /**
  91962. * Returns true if this submesh covers the entire parent mesh
  91963. * @ignorenaming
  91964. */
  91965. get IsGlobal(): boolean;
  91966. /**
  91967. * Returns the submesh BoudingInfo object
  91968. * @returns current bounding info (or mesh's one if the submesh is global)
  91969. */
  91970. getBoundingInfo(): BoundingInfo;
  91971. /**
  91972. * Sets the submesh BoundingInfo
  91973. * @param boundingInfo defines the new bounding info to use
  91974. * @returns the SubMesh
  91975. */
  91976. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  91977. /**
  91978. * Returns the mesh of the current submesh
  91979. * @return the parent mesh
  91980. */
  91981. getMesh(): AbstractMesh;
  91982. /**
  91983. * Returns the rendering mesh of the submesh
  91984. * @returns the rendering mesh (could be different from parent mesh)
  91985. */
  91986. getRenderingMesh(): Mesh;
  91987. /**
  91988. * Returns the submesh material
  91989. * @returns null or the current material
  91990. */
  91991. getMaterial(): Nullable<Material>;
  91992. /**
  91993. * Sets a new updated BoundingInfo object to the submesh
  91994. * @param data defines an optional position array to use to determine the bounding info
  91995. * @returns the SubMesh
  91996. */
  91997. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  91998. /** @hidden */
  91999. _checkCollision(collider: Collider): boolean;
  92000. /**
  92001. * Updates the submesh BoundingInfo
  92002. * @param world defines the world matrix to use to update the bounding info
  92003. * @returns the submesh
  92004. */
  92005. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  92006. /**
  92007. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  92008. * @param frustumPlanes defines the frustum planes
  92009. * @returns true if the submesh is intersecting with the frustum
  92010. */
  92011. isInFrustum(frustumPlanes: Plane[]): boolean;
  92012. /**
  92013. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  92014. * @param frustumPlanes defines the frustum planes
  92015. * @returns true if the submesh is inside the frustum
  92016. */
  92017. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  92018. /**
  92019. * Renders the submesh
  92020. * @param enableAlphaMode defines if alpha needs to be used
  92021. * @returns the submesh
  92022. */
  92023. render(enableAlphaMode: boolean): SubMesh;
  92024. /**
  92025. * @hidden
  92026. */
  92027. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  92028. /**
  92029. * Checks if the submesh intersects with a ray
  92030. * @param ray defines the ray to test
  92031. * @returns true is the passed ray intersects the submesh bounding box
  92032. */
  92033. canIntersects(ray: Ray): boolean;
  92034. /**
  92035. * Intersects current submesh with a ray
  92036. * @param ray defines the ray to test
  92037. * @param positions defines mesh's positions array
  92038. * @param indices defines mesh's indices array
  92039. * @param fastCheck defines if only bounding info should be used
  92040. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92041. * @returns intersection info or null if no intersection
  92042. */
  92043. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  92044. /** @hidden */
  92045. private _intersectLines;
  92046. /** @hidden */
  92047. private _intersectUnIndexedLines;
  92048. /** @hidden */
  92049. private _intersectTriangles;
  92050. /** @hidden */
  92051. private _intersectUnIndexedTriangles;
  92052. /** @hidden */
  92053. _rebuild(): void;
  92054. /**
  92055. * Creates a new submesh from the passed mesh
  92056. * @param newMesh defines the new hosting mesh
  92057. * @param newRenderingMesh defines an optional rendering mesh
  92058. * @returns the new submesh
  92059. */
  92060. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  92061. /**
  92062. * Release associated resources
  92063. */
  92064. dispose(): void;
  92065. /**
  92066. * Gets the class name
  92067. * @returns the string "SubMesh".
  92068. */
  92069. getClassName(): string;
  92070. /**
  92071. * Creates a new submesh from indices data
  92072. * @param materialIndex the index of the main mesh material
  92073. * @param startIndex the index where to start the copy in the mesh indices array
  92074. * @param indexCount the number of indices to copy then from the startIndex
  92075. * @param mesh the main mesh to create the submesh from
  92076. * @param renderingMesh the optional rendering mesh
  92077. * @returns a new submesh
  92078. */
  92079. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  92080. }
  92081. }
  92082. declare module BABYLON {
  92083. /**
  92084. * Class used to represent data loading progression
  92085. */
  92086. export class SceneLoaderFlags {
  92087. private static _ForceFullSceneLoadingForIncremental;
  92088. private static _ShowLoadingScreen;
  92089. private static _CleanBoneMatrixWeights;
  92090. private static _loggingLevel;
  92091. /**
  92092. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  92093. */
  92094. static get ForceFullSceneLoadingForIncremental(): boolean;
  92095. static set ForceFullSceneLoadingForIncremental(value: boolean);
  92096. /**
  92097. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  92098. */
  92099. static get ShowLoadingScreen(): boolean;
  92100. static set ShowLoadingScreen(value: boolean);
  92101. /**
  92102. * Defines the current logging level (while loading the scene)
  92103. * @ignorenaming
  92104. */
  92105. static get loggingLevel(): number;
  92106. static set loggingLevel(value: number);
  92107. /**
  92108. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  92109. */
  92110. static get CleanBoneMatrixWeights(): boolean;
  92111. static set CleanBoneMatrixWeights(value: boolean);
  92112. }
  92113. }
  92114. declare module BABYLON {
  92115. /**
  92116. * Class used to store geometry data (vertex buffers + index buffer)
  92117. */
  92118. export class Geometry implements IGetSetVerticesData {
  92119. /**
  92120. * Gets or sets the ID of the geometry
  92121. */
  92122. id: string;
  92123. /**
  92124. * Gets or sets the unique ID of the geometry
  92125. */
  92126. uniqueId: number;
  92127. /**
  92128. * Gets the delay loading state of the geometry (none by default which means not delayed)
  92129. */
  92130. delayLoadState: number;
  92131. /**
  92132. * Gets the file containing the data to load when running in delay load state
  92133. */
  92134. delayLoadingFile: Nullable<string>;
  92135. /**
  92136. * Callback called when the geometry is updated
  92137. */
  92138. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  92139. private _scene;
  92140. private _engine;
  92141. private _meshes;
  92142. private _totalVertices;
  92143. /** @hidden */
  92144. _indices: IndicesArray;
  92145. /** @hidden */
  92146. _vertexBuffers: {
  92147. [key: string]: VertexBuffer;
  92148. };
  92149. private _isDisposed;
  92150. private _extend;
  92151. private _boundingBias;
  92152. /** @hidden */
  92153. _delayInfo: Array<string>;
  92154. private _indexBuffer;
  92155. private _indexBufferIsUpdatable;
  92156. /** @hidden */
  92157. _boundingInfo: Nullable<BoundingInfo>;
  92158. /** @hidden */
  92159. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  92160. /** @hidden */
  92161. _softwareSkinningFrameId: number;
  92162. private _vertexArrayObjects;
  92163. private _updatable;
  92164. /** @hidden */
  92165. _positions: Nullable<Vector3[]>;
  92166. /**
  92167. * 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
  92168. */
  92169. get boundingBias(): Vector2;
  92170. /**
  92171. * 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
  92172. */
  92173. set boundingBias(value: Vector2);
  92174. /**
  92175. * Static function used to attach a new empty geometry to a mesh
  92176. * @param mesh defines the mesh to attach the geometry to
  92177. * @returns the new Geometry
  92178. */
  92179. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  92180. /**
  92181. * Creates a new geometry
  92182. * @param id defines the unique ID
  92183. * @param scene defines the hosting scene
  92184. * @param vertexData defines the VertexData used to get geometry data
  92185. * @param updatable defines if geometry must be updatable (false by default)
  92186. * @param mesh defines the mesh that will be associated with the geometry
  92187. */
  92188. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  92189. /**
  92190. * Gets the current extend of the geometry
  92191. */
  92192. get extend(): {
  92193. minimum: Vector3;
  92194. maximum: Vector3;
  92195. };
  92196. /**
  92197. * Gets the hosting scene
  92198. * @returns the hosting Scene
  92199. */
  92200. getScene(): Scene;
  92201. /**
  92202. * Gets the hosting engine
  92203. * @returns the hosting Engine
  92204. */
  92205. getEngine(): Engine;
  92206. /**
  92207. * Defines if the geometry is ready to use
  92208. * @returns true if the geometry is ready to be used
  92209. */
  92210. isReady(): boolean;
  92211. /**
  92212. * Gets a value indicating that the geometry should not be serialized
  92213. */
  92214. get doNotSerialize(): boolean;
  92215. /** @hidden */
  92216. _rebuild(): void;
  92217. /**
  92218. * Affects all geometry data in one call
  92219. * @param vertexData defines the geometry data
  92220. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  92221. */
  92222. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  92223. /**
  92224. * Set specific vertex data
  92225. * @param kind defines the data kind (Position, normal, etc...)
  92226. * @param data defines the vertex data to use
  92227. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  92228. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  92229. */
  92230. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  92231. /**
  92232. * Removes a specific vertex data
  92233. * @param kind defines the data kind (Position, normal, etc...)
  92234. */
  92235. removeVerticesData(kind: string): void;
  92236. /**
  92237. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  92238. * @param buffer defines the vertex buffer to use
  92239. * @param totalVertices defines the total number of vertices for position kind (could be null)
  92240. */
  92241. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  92242. /**
  92243. * Update a specific vertex buffer
  92244. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  92245. * It will do nothing if the buffer is not updatable
  92246. * @param kind defines the data kind (Position, normal, etc...)
  92247. * @param data defines the data to use
  92248. * @param offset defines the offset in the target buffer where to store the data
  92249. * @param useBytes set to true if the offset is in bytes
  92250. */
  92251. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  92252. /**
  92253. * Update a specific vertex buffer
  92254. * This function will create a new buffer if the current one is not updatable
  92255. * @param kind defines the data kind (Position, normal, etc...)
  92256. * @param data defines the data to use
  92257. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  92258. */
  92259. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  92260. private _updateBoundingInfo;
  92261. /** @hidden */
  92262. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  92263. /**
  92264. * Gets total number of vertices
  92265. * @returns the total number of vertices
  92266. */
  92267. getTotalVertices(): number;
  92268. /**
  92269. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  92270. * @param kind defines the data kind (Position, normal, etc...)
  92271. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  92272. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92273. * @returns a float array containing vertex data
  92274. */
  92275. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  92276. /**
  92277. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  92278. * @param kind defines the data kind (Position, normal, etc...)
  92279. * @returns true if the vertex buffer with the specified kind is updatable
  92280. */
  92281. isVertexBufferUpdatable(kind: string): boolean;
  92282. /**
  92283. * Gets a specific vertex buffer
  92284. * @param kind defines the data kind (Position, normal, etc...)
  92285. * @returns a VertexBuffer
  92286. */
  92287. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  92288. /**
  92289. * Returns all vertex buffers
  92290. * @return an object holding all vertex buffers indexed by kind
  92291. */
  92292. getVertexBuffers(): Nullable<{
  92293. [key: string]: VertexBuffer;
  92294. }>;
  92295. /**
  92296. * Gets a boolean indicating if specific vertex buffer is present
  92297. * @param kind defines the data kind (Position, normal, etc...)
  92298. * @returns true if data is present
  92299. */
  92300. isVerticesDataPresent(kind: string): boolean;
  92301. /**
  92302. * Gets a list of all attached data kinds (Position, normal, etc...)
  92303. * @returns a list of string containing all kinds
  92304. */
  92305. getVerticesDataKinds(): string[];
  92306. /**
  92307. * Update index buffer
  92308. * @param indices defines the indices to store in the index buffer
  92309. * @param offset defines the offset in the target buffer where to store the data
  92310. * @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)
  92311. */
  92312. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  92313. /**
  92314. * Creates a new index buffer
  92315. * @param indices defines the indices to store in the index buffer
  92316. * @param totalVertices defines the total number of vertices (could be null)
  92317. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  92318. */
  92319. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  92320. /**
  92321. * Return the total number of indices
  92322. * @returns the total number of indices
  92323. */
  92324. getTotalIndices(): number;
  92325. /**
  92326. * Gets the index buffer array
  92327. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  92328. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92329. * @returns the index buffer array
  92330. */
  92331. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  92332. /**
  92333. * Gets the index buffer
  92334. * @return the index buffer
  92335. */
  92336. getIndexBuffer(): Nullable<DataBuffer>;
  92337. /** @hidden */
  92338. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  92339. /**
  92340. * Release the associated resources for a specific mesh
  92341. * @param mesh defines the source mesh
  92342. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  92343. */
  92344. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  92345. /**
  92346. * Apply current geometry to a given mesh
  92347. * @param mesh defines the mesh to apply geometry to
  92348. */
  92349. applyToMesh(mesh: Mesh): void;
  92350. private _updateExtend;
  92351. private _applyToMesh;
  92352. private notifyUpdate;
  92353. /**
  92354. * Load the geometry if it was flagged as delay loaded
  92355. * @param scene defines the hosting scene
  92356. * @param onLoaded defines a callback called when the geometry is loaded
  92357. */
  92358. load(scene: Scene, onLoaded?: () => void): void;
  92359. private _queueLoad;
  92360. /**
  92361. * Invert the geometry to move from a right handed system to a left handed one.
  92362. */
  92363. toLeftHanded(): void;
  92364. /** @hidden */
  92365. _resetPointsArrayCache(): void;
  92366. /** @hidden */
  92367. _generatePointsArray(): boolean;
  92368. /**
  92369. * Gets a value indicating if the geometry is disposed
  92370. * @returns true if the geometry was disposed
  92371. */
  92372. isDisposed(): boolean;
  92373. private _disposeVertexArrayObjects;
  92374. /**
  92375. * Free all associated resources
  92376. */
  92377. dispose(): void;
  92378. /**
  92379. * Clone the current geometry into a new geometry
  92380. * @param id defines the unique ID of the new geometry
  92381. * @returns a new geometry object
  92382. */
  92383. copy(id: string): Geometry;
  92384. /**
  92385. * Serialize the current geometry info (and not the vertices data) into a JSON object
  92386. * @return a JSON representation of the current geometry data (without the vertices data)
  92387. */
  92388. serialize(): any;
  92389. private toNumberArray;
  92390. /**
  92391. * Serialize all vertices data into a JSON oject
  92392. * @returns a JSON representation of the current geometry data
  92393. */
  92394. serializeVerticeData(): any;
  92395. /**
  92396. * Extracts a clone of a mesh geometry
  92397. * @param mesh defines the source mesh
  92398. * @param id defines the unique ID of the new geometry object
  92399. * @returns the new geometry object
  92400. */
  92401. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  92402. /**
  92403. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  92404. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  92405. * Be aware Math.random() could cause collisions, but:
  92406. * "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"
  92407. * @returns a string containing a new GUID
  92408. */
  92409. static RandomId(): string;
  92410. /** @hidden */
  92411. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  92412. private static _CleanMatricesWeights;
  92413. /**
  92414. * Create a new geometry from persisted data (Using .babylon file format)
  92415. * @param parsedVertexData defines the persisted data
  92416. * @param scene defines the hosting scene
  92417. * @param rootUrl defines the root url to use to load assets (like delayed data)
  92418. * @returns the new geometry object
  92419. */
  92420. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  92421. }
  92422. }
  92423. declare module BABYLON {
  92424. /**
  92425. * Define an interface for all classes that will get and set the data on vertices
  92426. */
  92427. export interface IGetSetVerticesData {
  92428. /**
  92429. * Gets a boolean indicating if specific vertex data is present
  92430. * @param kind defines the vertex data kind to use
  92431. * @returns true is data kind is present
  92432. */
  92433. isVerticesDataPresent(kind: string): boolean;
  92434. /**
  92435. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  92436. * @param kind defines the data kind (Position, normal, etc...)
  92437. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  92438. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92439. * @returns a float array containing vertex data
  92440. */
  92441. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  92442. /**
  92443. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  92444. * @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.
  92445. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92446. * @returns the indices array or an empty array if the mesh has no geometry
  92447. */
  92448. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  92449. /**
  92450. * Set specific vertex data
  92451. * @param kind defines the data kind (Position, normal, etc...)
  92452. * @param data defines the vertex data to use
  92453. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  92454. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  92455. */
  92456. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  92457. /**
  92458. * Update a specific associated vertex buffer
  92459. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  92460. * - VertexBuffer.PositionKind
  92461. * - VertexBuffer.UVKind
  92462. * - VertexBuffer.UV2Kind
  92463. * - VertexBuffer.UV3Kind
  92464. * - VertexBuffer.UV4Kind
  92465. * - VertexBuffer.UV5Kind
  92466. * - VertexBuffer.UV6Kind
  92467. * - VertexBuffer.ColorKind
  92468. * - VertexBuffer.MatricesIndicesKind
  92469. * - VertexBuffer.MatricesIndicesExtraKind
  92470. * - VertexBuffer.MatricesWeightsKind
  92471. * - VertexBuffer.MatricesWeightsExtraKind
  92472. * @param data defines the data source
  92473. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  92474. * @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)
  92475. */
  92476. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  92477. /**
  92478. * Creates a new index buffer
  92479. * @param indices defines the indices to store in the index buffer
  92480. * @param totalVertices defines the total number of vertices (could be null)
  92481. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  92482. */
  92483. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  92484. }
  92485. /**
  92486. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  92487. */
  92488. export class VertexData {
  92489. /**
  92490. * Mesh side orientation : usually the external or front surface
  92491. */
  92492. static readonly FRONTSIDE: number;
  92493. /**
  92494. * Mesh side orientation : usually the internal or back surface
  92495. */
  92496. static readonly BACKSIDE: number;
  92497. /**
  92498. * Mesh side orientation : both internal and external or front and back surfaces
  92499. */
  92500. static readonly DOUBLESIDE: number;
  92501. /**
  92502. * Mesh side orientation : by default, `FRONTSIDE`
  92503. */
  92504. static readonly DEFAULTSIDE: number;
  92505. /**
  92506. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  92507. */
  92508. positions: Nullable<FloatArray>;
  92509. /**
  92510. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  92511. */
  92512. normals: Nullable<FloatArray>;
  92513. /**
  92514. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  92515. */
  92516. tangents: Nullable<FloatArray>;
  92517. /**
  92518. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92519. */
  92520. uvs: Nullable<FloatArray>;
  92521. /**
  92522. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92523. */
  92524. uvs2: Nullable<FloatArray>;
  92525. /**
  92526. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92527. */
  92528. uvs3: Nullable<FloatArray>;
  92529. /**
  92530. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92531. */
  92532. uvs4: Nullable<FloatArray>;
  92533. /**
  92534. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92535. */
  92536. uvs5: Nullable<FloatArray>;
  92537. /**
  92538. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92539. */
  92540. uvs6: Nullable<FloatArray>;
  92541. /**
  92542. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  92543. */
  92544. colors: Nullable<FloatArray>;
  92545. /**
  92546. * 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).
  92547. */
  92548. matricesIndices: Nullable<FloatArray>;
  92549. /**
  92550. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  92551. */
  92552. matricesWeights: Nullable<FloatArray>;
  92553. /**
  92554. * An array extending the number of possible indices
  92555. */
  92556. matricesIndicesExtra: Nullable<FloatArray>;
  92557. /**
  92558. * An array extending the number of possible weights when the number of indices is extended
  92559. */
  92560. matricesWeightsExtra: Nullable<FloatArray>;
  92561. /**
  92562. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  92563. */
  92564. indices: Nullable<IndicesArray>;
  92565. /**
  92566. * Uses the passed data array to set the set the values for the specified kind of data
  92567. * @param data a linear array of floating numbers
  92568. * @param kind the type of data that is being set, eg positions, colors etc
  92569. */
  92570. set(data: FloatArray, kind: string): void;
  92571. /**
  92572. * Associates the vertexData to the passed Mesh.
  92573. * Sets it as updatable or not (default `false`)
  92574. * @param mesh the mesh the vertexData is applied to
  92575. * @param updatable when used and having the value true allows new data to update the vertexData
  92576. * @returns the VertexData
  92577. */
  92578. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  92579. /**
  92580. * Associates the vertexData to the passed Geometry.
  92581. * Sets it as updatable or not (default `false`)
  92582. * @param geometry the geometry the vertexData is applied to
  92583. * @param updatable when used and having the value true allows new data to update the vertexData
  92584. * @returns VertexData
  92585. */
  92586. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  92587. /**
  92588. * Updates the associated mesh
  92589. * @param mesh the mesh to be updated
  92590. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  92591. * @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
  92592. * @returns VertexData
  92593. */
  92594. updateMesh(mesh: Mesh): VertexData;
  92595. /**
  92596. * Updates the associated geometry
  92597. * @param geometry the geometry to be updated
  92598. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  92599. * @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
  92600. * @returns VertexData.
  92601. */
  92602. updateGeometry(geometry: Geometry): VertexData;
  92603. private _applyTo;
  92604. private _update;
  92605. /**
  92606. * Transforms each position and each normal of the vertexData according to the passed Matrix
  92607. * @param matrix the transforming matrix
  92608. * @returns the VertexData
  92609. */
  92610. transform(matrix: Matrix): VertexData;
  92611. /**
  92612. * Merges the passed VertexData into the current one
  92613. * @param other the VertexData to be merged into the current one
  92614. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  92615. * @returns the modified VertexData
  92616. */
  92617. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  92618. private _mergeElement;
  92619. private _validate;
  92620. /**
  92621. * Serializes the VertexData
  92622. * @returns a serialized object
  92623. */
  92624. serialize(): any;
  92625. /**
  92626. * Extracts the vertexData from a mesh
  92627. * @param mesh the mesh from which to extract the VertexData
  92628. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  92629. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  92630. * @returns the object VertexData associated to the passed mesh
  92631. */
  92632. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  92633. /**
  92634. * Extracts the vertexData from the geometry
  92635. * @param geometry the geometry from which to extract the VertexData
  92636. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  92637. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  92638. * @returns the object VertexData associated to the passed mesh
  92639. */
  92640. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  92641. private static _ExtractFrom;
  92642. /**
  92643. * Creates the VertexData for a Ribbon
  92644. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  92645. * * pathArray array of paths, each of which an array of successive Vector3
  92646. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  92647. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  92648. * * 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
  92649. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92650. * * 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)
  92651. * * 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)
  92652. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  92653. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  92654. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  92655. * @returns the VertexData of the ribbon
  92656. */
  92657. static CreateRibbon(options: {
  92658. pathArray: Vector3[][];
  92659. closeArray?: boolean;
  92660. closePath?: boolean;
  92661. offset?: number;
  92662. sideOrientation?: number;
  92663. frontUVs?: Vector4;
  92664. backUVs?: Vector4;
  92665. invertUV?: boolean;
  92666. uvs?: Vector2[];
  92667. colors?: Color4[];
  92668. }): VertexData;
  92669. /**
  92670. * Creates the VertexData for a box
  92671. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92672. * * size sets the width, height and depth of the box to the value of size, optional default 1
  92673. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  92674. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  92675. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  92676. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  92677. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  92678. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92679. * * 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)
  92680. * * 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)
  92681. * @returns the VertexData of the box
  92682. */
  92683. static CreateBox(options: {
  92684. size?: number;
  92685. width?: number;
  92686. height?: number;
  92687. depth?: number;
  92688. faceUV?: Vector4[];
  92689. faceColors?: Color4[];
  92690. sideOrientation?: number;
  92691. frontUVs?: Vector4;
  92692. backUVs?: Vector4;
  92693. }): VertexData;
  92694. /**
  92695. * Creates the VertexData for a tiled box
  92696. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92697. * * faceTiles sets the pattern, tile size and number of tiles for a face
  92698. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  92699. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  92700. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92701. * @returns the VertexData of the box
  92702. */
  92703. static CreateTiledBox(options: {
  92704. pattern?: number;
  92705. width?: number;
  92706. height?: number;
  92707. depth?: number;
  92708. tileSize?: number;
  92709. tileWidth?: number;
  92710. tileHeight?: number;
  92711. alignHorizontal?: number;
  92712. alignVertical?: number;
  92713. faceUV?: Vector4[];
  92714. faceColors?: Color4[];
  92715. sideOrientation?: number;
  92716. }): VertexData;
  92717. /**
  92718. * Creates the VertexData for a tiled plane
  92719. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92720. * * pattern a limited pattern arrangement depending on the number
  92721. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  92722. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  92723. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  92724. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92725. * * 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)
  92726. * * 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)
  92727. * @returns the VertexData of the tiled plane
  92728. */
  92729. static CreateTiledPlane(options: {
  92730. pattern?: number;
  92731. tileSize?: number;
  92732. tileWidth?: number;
  92733. tileHeight?: number;
  92734. size?: number;
  92735. width?: number;
  92736. height?: number;
  92737. alignHorizontal?: number;
  92738. alignVertical?: number;
  92739. sideOrientation?: number;
  92740. frontUVs?: Vector4;
  92741. backUVs?: Vector4;
  92742. }): VertexData;
  92743. /**
  92744. * Creates the VertexData for an ellipsoid, defaults to a sphere
  92745. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92746. * * segments sets the number of horizontal strips optional, default 32
  92747. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  92748. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  92749. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  92750. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  92751. * * 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
  92752. * * 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
  92753. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92754. * * 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)
  92755. * * 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)
  92756. * @returns the VertexData of the ellipsoid
  92757. */
  92758. static CreateSphere(options: {
  92759. segments?: number;
  92760. diameter?: number;
  92761. diameterX?: number;
  92762. diameterY?: number;
  92763. diameterZ?: number;
  92764. arc?: number;
  92765. slice?: number;
  92766. sideOrientation?: number;
  92767. frontUVs?: Vector4;
  92768. backUVs?: Vector4;
  92769. }): VertexData;
  92770. /**
  92771. * Creates the VertexData for a cylinder, cone or prism
  92772. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92773. * * height sets the height (y direction) of the cylinder, optional, default 2
  92774. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  92775. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  92776. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  92777. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  92778. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  92779. * * 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
  92780. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  92781. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  92782. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  92783. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  92784. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92785. * * 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)
  92786. * * 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)
  92787. * @returns the VertexData of the cylinder, cone or prism
  92788. */
  92789. static CreateCylinder(options: {
  92790. height?: number;
  92791. diameterTop?: number;
  92792. diameterBottom?: number;
  92793. diameter?: number;
  92794. tessellation?: number;
  92795. subdivisions?: number;
  92796. arc?: number;
  92797. faceColors?: Color4[];
  92798. faceUV?: Vector4[];
  92799. hasRings?: boolean;
  92800. enclose?: boolean;
  92801. sideOrientation?: number;
  92802. frontUVs?: Vector4;
  92803. backUVs?: Vector4;
  92804. }): VertexData;
  92805. /**
  92806. * Creates the VertexData for a torus
  92807. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92808. * * diameter the diameter of the torus, optional default 1
  92809. * * thickness the diameter of the tube forming the torus, optional default 0.5
  92810. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  92811. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92812. * * 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)
  92813. * * 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)
  92814. * @returns the VertexData of the torus
  92815. */
  92816. static CreateTorus(options: {
  92817. diameter?: number;
  92818. thickness?: number;
  92819. tessellation?: number;
  92820. sideOrientation?: number;
  92821. frontUVs?: Vector4;
  92822. backUVs?: Vector4;
  92823. }): VertexData;
  92824. /**
  92825. * Creates the VertexData of the LineSystem
  92826. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  92827. * - lines an array of lines, each line being an array of successive Vector3
  92828. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  92829. * @returns the VertexData of the LineSystem
  92830. */
  92831. static CreateLineSystem(options: {
  92832. lines: Vector3[][];
  92833. colors?: Nullable<Color4[][]>;
  92834. }): VertexData;
  92835. /**
  92836. * Create the VertexData for a DashedLines
  92837. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  92838. * - points an array successive Vector3
  92839. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  92840. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  92841. * - dashNb the intended total number of dashes, optional, default 200
  92842. * @returns the VertexData for the DashedLines
  92843. */
  92844. static CreateDashedLines(options: {
  92845. points: Vector3[];
  92846. dashSize?: number;
  92847. gapSize?: number;
  92848. dashNb?: number;
  92849. }): VertexData;
  92850. /**
  92851. * Creates the VertexData for a Ground
  92852. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  92853. * - width the width (x direction) of the ground, optional, default 1
  92854. * - height the height (z direction) of the ground, optional, default 1
  92855. * - subdivisions the number of subdivisions per side, optional, default 1
  92856. * @returns the VertexData of the Ground
  92857. */
  92858. static CreateGround(options: {
  92859. width?: number;
  92860. height?: number;
  92861. subdivisions?: number;
  92862. subdivisionsX?: number;
  92863. subdivisionsY?: number;
  92864. }): VertexData;
  92865. /**
  92866. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  92867. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  92868. * * xmin the ground minimum X coordinate, optional, default -1
  92869. * * zmin the ground minimum Z coordinate, optional, default -1
  92870. * * xmax the ground maximum X coordinate, optional, default 1
  92871. * * zmax the ground maximum Z coordinate, optional, default 1
  92872. * * 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}
  92873. * * 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}
  92874. * @returns the VertexData of the TiledGround
  92875. */
  92876. static CreateTiledGround(options: {
  92877. xmin: number;
  92878. zmin: number;
  92879. xmax: number;
  92880. zmax: number;
  92881. subdivisions?: {
  92882. w: number;
  92883. h: number;
  92884. };
  92885. precision?: {
  92886. w: number;
  92887. h: number;
  92888. };
  92889. }): VertexData;
  92890. /**
  92891. * Creates the VertexData of the Ground designed from a heightmap
  92892. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  92893. * * width the width (x direction) of the ground
  92894. * * height the height (z direction) of the ground
  92895. * * subdivisions the number of subdivisions per side
  92896. * * minHeight the minimum altitude on the ground, optional, default 0
  92897. * * maxHeight the maximum altitude on the ground, optional default 1
  92898. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  92899. * * buffer the array holding the image color data
  92900. * * bufferWidth the width of image
  92901. * * bufferHeight the height of image
  92902. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  92903. * @returns the VertexData of the Ground designed from a heightmap
  92904. */
  92905. static CreateGroundFromHeightMap(options: {
  92906. width: number;
  92907. height: number;
  92908. subdivisions: number;
  92909. minHeight: number;
  92910. maxHeight: number;
  92911. colorFilter: Color3;
  92912. buffer: Uint8Array;
  92913. bufferWidth: number;
  92914. bufferHeight: number;
  92915. alphaFilter: number;
  92916. }): VertexData;
  92917. /**
  92918. * Creates the VertexData for a Plane
  92919. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  92920. * * size sets the width and height of the plane to the value of size, optional default 1
  92921. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  92922. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  92923. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92924. * * 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)
  92925. * * 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)
  92926. * @returns the VertexData of the box
  92927. */
  92928. static CreatePlane(options: {
  92929. size?: number;
  92930. width?: number;
  92931. height?: number;
  92932. sideOrientation?: number;
  92933. frontUVs?: Vector4;
  92934. backUVs?: Vector4;
  92935. }): VertexData;
  92936. /**
  92937. * Creates the VertexData of the Disc or regular Polygon
  92938. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  92939. * * radius the radius of the disc, optional default 0.5
  92940. * * tessellation the number of polygon sides, optional, default 64
  92941. * * 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
  92942. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92943. * * 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)
  92944. * * 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)
  92945. * @returns the VertexData of the box
  92946. */
  92947. static CreateDisc(options: {
  92948. radius?: number;
  92949. tessellation?: number;
  92950. arc?: number;
  92951. sideOrientation?: number;
  92952. frontUVs?: Vector4;
  92953. backUVs?: Vector4;
  92954. }): VertexData;
  92955. /**
  92956. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  92957. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  92958. * @param polygon a mesh built from polygonTriangulation.build()
  92959. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92960. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  92961. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  92962. * @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)
  92963. * @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)
  92964. * @returns the VertexData of the Polygon
  92965. */
  92966. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  92967. /**
  92968. * Creates the VertexData of the IcoSphere
  92969. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  92970. * * radius the radius of the IcoSphere, optional default 1
  92971. * * radiusX allows stretching in the x direction, optional, default radius
  92972. * * radiusY allows stretching in the y direction, optional, default radius
  92973. * * radiusZ allows stretching in the z direction, optional, default radius
  92974. * * flat when true creates a flat shaded mesh, optional, default true
  92975. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  92976. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92977. * * 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)
  92978. * * 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)
  92979. * @returns the VertexData of the IcoSphere
  92980. */
  92981. static CreateIcoSphere(options: {
  92982. radius?: number;
  92983. radiusX?: number;
  92984. radiusY?: number;
  92985. radiusZ?: number;
  92986. flat?: boolean;
  92987. subdivisions?: number;
  92988. sideOrientation?: number;
  92989. frontUVs?: Vector4;
  92990. backUVs?: Vector4;
  92991. }): VertexData;
  92992. /**
  92993. * Creates the VertexData for a Polyhedron
  92994. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  92995. * * type provided types are:
  92996. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  92997. * * 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)
  92998. * * size the size of the IcoSphere, optional default 1
  92999. * * sizeX allows stretching in the x direction, optional, default size
  93000. * * sizeY allows stretching in the y direction, optional, default size
  93001. * * sizeZ allows stretching in the z direction, optional, default size
  93002. * * 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
  93003. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  93004. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  93005. * * flat when true creates a flat shaded mesh, optional, default true
  93006. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  93007. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93008. * * 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)
  93009. * * 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)
  93010. * @returns the VertexData of the Polyhedron
  93011. */
  93012. static CreatePolyhedron(options: {
  93013. type?: number;
  93014. size?: number;
  93015. sizeX?: number;
  93016. sizeY?: number;
  93017. sizeZ?: number;
  93018. custom?: any;
  93019. faceUV?: Vector4[];
  93020. faceColors?: Color4[];
  93021. flat?: boolean;
  93022. sideOrientation?: number;
  93023. frontUVs?: Vector4;
  93024. backUVs?: Vector4;
  93025. }): VertexData;
  93026. /**
  93027. * Creates the VertexData for a TorusKnot
  93028. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  93029. * * radius the radius of the torus knot, optional, default 2
  93030. * * tube the thickness of the tube, optional, default 0.5
  93031. * * radialSegments the number of sides on each tube segments, optional, default 32
  93032. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  93033. * * p the number of windings around the z axis, optional, default 2
  93034. * * q the number of windings around the x axis, optional, default 3
  93035. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93036. * * 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)
  93037. * * 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)
  93038. * @returns the VertexData of the Torus Knot
  93039. */
  93040. static CreateTorusKnot(options: {
  93041. radius?: number;
  93042. tube?: number;
  93043. radialSegments?: number;
  93044. tubularSegments?: number;
  93045. p?: number;
  93046. q?: number;
  93047. sideOrientation?: number;
  93048. frontUVs?: Vector4;
  93049. backUVs?: Vector4;
  93050. }): VertexData;
  93051. /**
  93052. * Compute normals for given positions and indices
  93053. * @param positions an array of vertex positions, [...., x, y, z, ......]
  93054. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  93055. * @param normals an array of vertex normals, [...., x, y, z, ......]
  93056. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  93057. * * facetNormals : optional array of facet normals (vector3)
  93058. * * facetPositions : optional array of facet positions (vector3)
  93059. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  93060. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  93061. * * bInfo : optional bounding info, required for facetPartitioning computation
  93062. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  93063. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  93064. * * useRightHandedSystem: optional boolean to for right handed system computation
  93065. * * depthSort : optional boolean to enable the facet depth sort computation
  93066. * * distanceTo : optional Vector3 to compute the facet depth from this location
  93067. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  93068. */
  93069. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  93070. facetNormals?: any;
  93071. facetPositions?: any;
  93072. facetPartitioning?: any;
  93073. ratio?: number;
  93074. bInfo?: any;
  93075. bbSize?: Vector3;
  93076. subDiv?: any;
  93077. useRightHandedSystem?: boolean;
  93078. depthSort?: boolean;
  93079. distanceTo?: Vector3;
  93080. depthSortedFacets?: any;
  93081. }): void;
  93082. /** @hidden */
  93083. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  93084. /**
  93085. * Applies VertexData created from the imported parameters to the geometry
  93086. * @param parsedVertexData the parsed data from an imported file
  93087. * @param geometry the geometry to apply the VertexData to
  93088. */
  93089. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  93090. }
  93091. }
  93092. declare module BABYLON {
  93093. /**
  93094. * Defines a target to use with MorphTargetManager
  93095. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  93096. */
  93097. export class MorphTarget implements IAnimatable {
  93098. /** defines the name of the target */
  93099. name: string;
  93100. /**
  93101. * Gets or sets the list of animations
  93102. */
  93103. animations: Animation[];
  93104. private _scene;
  93105. private _positions;
  93106. private _normals;
  93107. private _tangents;
  93108. private _uvs;
  93109. private _influence;
  93110. private _uniqueId;
  93111. /**
  93112. * Observable raised when the influence changes
  93113. */
  93114. onInfluenceChanged: Observable<boolean>;
  93115. /** @hidden */
  93116. _onDataLayoutChanged: Observable<void>;
  93117. /**
  93118. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  93119. */
  93120. get influence(): number;
  93121. set influence(influence: number);
  93122. /**
  93123. * Gets or sets the id of the morph Target
  93124. */
  93125. id: string;
  93126. private _animationPropertiesOverride;
  93127. /**
  93128. * Gets or sets the animation properties override
  93129. */
  93130. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  93131. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  93132. /**
  93133. * Creates a new MorphTarget
  93134. * @param name defines the name of the target
  93135. * @param influence defines the influence to use
  93136. * @param scene defines the scene the morphtarget belongs to
  93137. */
  93138. constructor(
  93139. /** defines the name of the target */
  93140. name: string, influence?: number, scene?: Nullable<Scene>);
  93141. /**
  93142. * Gets the unique ID of this manager
  93143. */
  93144. get uniqueId(): number;
  93145. /**
  93146. * Gets a boolean defining if the target contains position data
  93147. */
  93148. get hasPositions(): boolean;
  93149. /**
  93150. * Gets a boolean defining if the target contains normal data
  93151. */
  93152. get hasNormals(): boolean;
  93153. /**
  93154. * Gets a boolean defining if the target contains tangent data
  93155. */
  93156. get hasTangents(): boolean;
  93157. /**
  93158. * Gets a boolean defining if the target contains texture coordinates data
  93159. */
  93160. get hasUVs(): boolean;
  93161. /**
  93162. * Affects position data to this target
  93163. * @param data defines the position data to use
  93164. */
  93165. setPositions(data: Nullable<FloatArray>): void;
  93166. /**
  93167. * Gets the position data stored in this target
  93168. * @returns a FloatArray containing the position data (or null if not present)
  93169. */
  93170. getPositions(): Nullable<FloatArray>;
  93171. /**
  93172. * Affects normal data to this target
  93173. * @param data defines the normal data to use
  93174. */
  93175. setNormals(data: Nullable<FloatArray>): void;
  93176. /**
  93177. * Gets the normal data stored in this target
  93178. * @returns a FloatArray containing the normal data (or null if not present)
  93179. */
  93180. getNormals(): Nullable<FloatArray>;
  93181. /**
  93182. * Affects tangent data to this target
  93183. * @param data defines the tangent data to use
  93184. */
  93185. setTangents(data: Nullable<FloatArray>): void;
  93186. /**
  93187. * Gets the tangent data stored in this target
  93188. * @returns a FloatArray containing the tangent data (or null if not present)
  93189. */
  93190. getTangents(): Nullable<FloatArray>;
  93191. /**
  93192. * Affects texture coordinates data to this target
  93193. * @param data defines the texture coordinates data to use
  93194. */
  93195. setUVs(data: Nullable<FloatArray>): void;
  93196. /**
  93197. * Gets the texture coordinates data stored in this target
  93198. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  93199. */
  93200. getUVs(): Nullable<FloatArray>;
  93201. /**
  93202. * Clone the current target
  93203. * @returns a new MorphTarget
  93204. */
  93205. clone(): MorphTarget;
  93206. /**
  93207. * Serializes the current target into a Serialization object
  93208. * @returns the serialized object
  93209. */
  93210. serialize(): any;
  93211. /**
  93212. * Returns the string "MorphTarget"
  93213. * @returns "MorphTarget"
  93214. */
  93215. getClassName(): string;
  93216. /**
  93217. * Creates a new target from serialized data
  93218. * @param serializationObject defines the serialized data to use
  93219. * @returns a new MorphTarget
  93220. */
  93221. static Parse(serializationObject: any): MorphTarget;
  93222. /**
  93223. * Creates a MorphTarget from mesh data
  93224. * @param mesh defines the source mesh
  93225. * @param name defines the name to use for the new target
  93226. * @param influence defines the influence to attach to the target
  93227. * @returns a new MorphTarget
  93228. */
  93229. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  93230. }
  93231. }
  93232. declare module BABYLON {
  93233. /**
  93234. * This class is used to deform meshes using morphing between different targets
  93235. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  93236. */
  93237. export class MorphTargetManager {
  93238. private _targets;
  93239. private _targetInfluenceChangedObservers;
  93240. private _targetDataLayoutChangedObservers;
  93241. private _activeTargets;
  93242. private _scene;
  93243. private _influences;
  93244. private _supportsNormals;
  93245. private _supportsTangents;
  93246. private _supportsUVs;
  93247. private _vertexCount;
  93248. private _uniqueId;
  93249. private _tempInfluences;
  93250. /**
  93251. * Gets or sets a boolean indicating if normals must be morphed
  93252. */
  93253. enableNormalMorphing: boolean;
  93254. /**
  93255. * Gets or sets a boolean indicating if tangents must be morphed
  93256. */
  93257. enableTangentMorphing: boolean;
  93258. /**
  93259. * Gets or sets a boolean indicating if UV must be morphed
  93260. */
  93261. enableUVMorphing: boolean;
  93262. /**
  93263. * Creates a new MorphTargetManager
  93264. * @param scene defines the current scene
  93265. */
  93266. constructor(scene?: Nullable<Scene>);
  93267. /**
  93268. * Gets the unique ID of this manager
  93269. */
  93270. get uniqueId(): number;
  93271. /**
  93272. * Gets the number of vertices handled by this manager
  93273. */
  93274. get vertexCount(): number;
  93275. /**
  93276. * Gets a boolean indicating if this manager supports morphing of normals
  93277. */
  93278. get supportsNormals(): boolean;
  93279. /**
  93280. * Gets a boolean indicating if this manager supports morphing of tangents
  93281. */
  93282. get supportsTangents(): boolean;
  93283. /**
  93284. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  93285. */
  93286. get supportsUVs(): boolean;
  93287. /**
  93288. * Gets the number of targets stored in this manager
  93289. */
  93290. get numTargets(): number;
  93291. /**
  93292. * Gets the number of influencers (ie. the number of targets with influences > 0)
  93293. */
  93294. get numInfluencers(): number;
  93295. /**
  93296. * Gets the list of influences (one per target)
  93297. */
  93298. get influences(): Float32Array;
  93299. /**
  93300. * Gets the active target at specified index. An active target is a target with an influence > 0
  93301. * @param index defines the index to check
  93302. * @returns the requested target
  93303. */
  93304. getActiveTarget(index: number): MorphTarget;
  93305. /**
  93306. * Gets the target at specified index
  93307. * @param index defines the index to check
  93308. * @returns the requested target
  93309. */
  93310. getTarget(index: number): MorphTarget;
  93311. /**
  93312. * Add a new target to this manager
  93313. * @param target defines the target to add
  93314. */
  93315. addTarget(target: MorphTarget): void;
  93316. /**
  93317. * Removes a target from the manager
  93318. * @param target defines the target to remove
  93319. */
  93320. removeTarget(target: MorphTarget): void;
  93321. /**
  93322. * Clone the current manager
  93323. * @returns a new MorphTargetManager
  93324. */
  93325. clone(): MorphTargetManager;
  93326. /**
  93327. * Serializes the current manager into a Serialization object
  93328. * @returns the serialized object
  93329. */
  93330. serialize(): any;
  93331. private _syncActiveTargets;
  93332. /**
  93333. * Syncrhonize the targets with all the meshes using this morph target manager
  93334. */
  93335. synchronize(): void;
  93336. /**
  93337. * Creates a new MorphTargetManager from serialized data
  93338. * @param serializationObject defines the serialized data
  93339. * @param scene defines the hosting scene
  93340. * @returns the new MorphTargetManager
  93341. */
  93342. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  93343. }
  93344. }
  93345. declare module BABYLON {
  93346. /**
  93347. * Class used to represent a specific level of detail of a mesh
  93348. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  93349. */
  93350. export class MeshLODLevel {
  93351. /** Defines the distance where this level should start being displayed */
  93352. distance: number;
  93353. /** Defines the mesh to use to render this level */
  93354. mesh: Nullable<Mesh>;
  93355. /**
  93356. * Creates a new LOD level
  93357. * @param distance defines the distance where this level should star being displayed
  93358. * @param mesh defines the mesh to use to render this level
  93359. */
  93360. constructor(
  93361. /** Defines the distance where this level should start being displayed */
  93362. distance: number,
  93363. /** Defines the mesh to use to render this level */
  93364. mesh: Nullable<Mesh>);
  93365. }
  93366. }
  93367. declare module BABYLON {
  93368. /**
  93369. * Mesh representing the gorund
  93370. */
  93371. export class GroundMesh extends Mesh {
  93372. /** If octree should be generated */
  93373. generateOctree: boolean;
  93374. private _heightQuads;
  93375. /** @hidden */
  93376. _subdivisionsX: number;
  93377. /** @hidden */
  93378. _subdivisionsY: number;
  93379. /** @hidden */
  93380. _width: number;
  93381. /** @hidden */
  93382. _height: number;
  93383. /** @hidden */
  93384. _minX: number;
  93385. /** @hidden */
  93386. _maxX: number;
  93387. /** @hidden */
  93388. _minZ: number;
  93389. /** @hidden */
  93390. _maxZ: number;
  93391. constructor(name: string, scene: Scene);
  93392. /**
  93393. * "GroundMesh"
  93394. * @returns "GroundMesh"
  93395. */
  93396. getClassName(): string;
  93397. /**
  93398. * The minimum of x and y subdivisions
  93399. */
  93400. get subdivisions(): number;
  93401. /**
  93402. * X subdivisions
  93403. */
  93404. get subdivisionsX(): number;
  93405. /**
  93406. * Y subdivisions
  93407. */
  93408. get subdivisionsY(): number;
  93409. /**
  93410. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  93411. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  93412. * @param chunksCount the number of subdivisions for x and y
  93413. * @param octreeBlocksSize (Default: 32)
  93414. */
  93415. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  93416. /**
  93417. * Returns a height (y) value in the Worl system :
  93418. * the ground altitude at the coordinates (x, z) expressed in the World system.
  93419. * @param x x coordinate
  93420. * @param z z coordinate
  93421. * @returns the ground y position if (x, z) are outside the ground surface.
  93422. */
  93423. getHeightAtCoordinates(x: number, z: number): number;
  93424. /**
  93425. * Returns a normalized vector (Vector3) orthogonal to the ground
  93426. * at the ground coordinates (x, z) expressed in the World system.
  93427. * @param x x coordinate
  93428. * @param z z coordinate
  93429. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  93430. */
  93431. getNormalAtCoordinates(x: number, z: number): Vector3;
  93432. /**
  93433. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  93434. * at the ground coordinates (x, z) expressed in the World system.
  93435. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  93436. * @param x x coordinate
  93437. * @param z z coordinate
  93438. * @param ref vector to store the result
  93439. * @returns the GroundMesh.
  93440. */
  93441. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  93442. /**
  93443. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  93444. * if the ground has been updated.
  93445. * This can be used in the render loop.
  93446. * @returns the GroundMesh.
  93447. */
  93448. updateCoordinateHeights(): GroundMesh;
  93449. private _getFacetAt;
  93450. private _initHeightQuads;
  93451. private _computeHeightQuads;
  93452. /**
  93453. * Serializes this ground mesh
  93454. * @param serializationObject object to write serialization to
  93455. */
  93456. serialize(serializationObject: any): void;
  93457. /**
  93458. * Parses a serialized ground mesh
  93459. * @param parsedMesh the serialized mesh
  93460. * @param scene the scene to create the ground mesh in
  93461. * @returns the created ground mesh
  93462. */
  93463. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  93464. }
  93465. }
  93466. declare module BABYLON {
  93467. /**
  93468. * Interface for Physics-Joint data
  93469. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93470. */
  93471. export interface PhysicsJointData {
  93472. /**
  93473. * The main pivot of the joint
  93474. */
  93475. mainPivot?: Vector3;
  93476. /**
  93477. * The connected pivot of the joint
  93478. */
  93479. connectedPivot?: Vector3;
  93480. /**
  93481. * The main axis of the joint
  93482. */
  93483. mainAxis?: Vector3;
  93484. /**
  93485. * The connected axis of the joint
  93486. */
  93487. connectedAxis?: Vector3;
  93488. /**
  93489. * The collision of the joint
  93490. */
  93491. collision?: boolean;
  93492. /**
  93493. * Native Oimo/Cannon/Energy data
  93494. */
  93495. nativeParams?: any;
  93496. }
  93497. /**
  93498. * This is a holder class for the physics joint created by the physics plugin
  93499. * It holds a set of functions to control the underlying joint
  93500. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93501. */
  93502. export class PhysicsJoint {
  93503. /**
  93504. * The type of the physics joint
  93505. */
  93506. type: number;
  93507. /**
  93508. * The data for the physics joint
  93509. */
  93510. jointData: PhysicsJointData;
  93511. private _physicsJoint;
  93512. protected _physicsPlugin: IPhysicsEnginePlugin;
  93513. /**
  93514. * Initializes the physics joint
  93515. * @param type The type of the physics joint
  93516. * @param jointData The data for the physics joint
  93517. */
  93518. constructor(
  93519. /**
  93520. * The type of the physics joint
  93521. */
  93522. type: number,
  93523. /**
  93524. * The data for the physics joint
  93525. */
  93526. jointData: PhysicsJointData);
  93527. /**
  93528. * Gets the physics joint
  93529. */
  93530. get physicsJoint(): any;
  93531. /**
  93532. * Sets the physics joint
  93533. */
  93534. set physicsJoint(newJoint: any);
  93535. /**
  93536. * Sets the physics plugin
  93537. */
  93538. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  93539. /**
  93540. * Execute a function that is physics-plugin specific.
  93541. * @param {Function} func the function that will be executed.
  93542. * It accepts two parameters: the physics world and the physics joint
  93543. */
  93544. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  93545. /**
  93546. * Distance-Joint type
  93547. */
  93548. static DistanceJoint: number;
  93549. /**
  93550. * Hinge-Joint type
  93551. */
  93552. static HingeJoint: number;
  93553. /**
  93554. * Ball-and-Socket joint type
  93555. */
  93556. static BallAndSocketJoint: number;
  93557. /**
  93558. * Wheel-Joint type
  93559. */
  93560. static WheelJoint: number;
  93561. /**
  93562. * Slider-Joint type
  93563. */
  93564. static SliderJoint: number;
  93565. /**
  93566. * Prismatic-Joint type
  93567. */
  93568. static PrismaticJoint: number;
  93569. /**
  93570. * Universal-Joint type
  93571. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  93572. */
  93573. static UniversalJoint: number;
  93574. /**
  93575. * Hinge-Joint 2 type
  93576. */
  93577. static Hinge2Joint: number;
  93578. /**
  93579. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  93580. */
  93581. static PointToPointJoint: number;
  93582. /**
  93583. * Spring-Joint type
  93584. */
  93585. static SpringJoint: number;
  93586. /**
  93587. * Lock-Joint type
  93588. */
  93589. static LockJoint: number;
  93590. }
  93591. /**
  93592. * A class representing a physics distance joint
  93593. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93594. */
  93595. export class DistanceJoint extends PhysicsJoint {
  93596. /**
  93597. *
  93598. * @param jointData The data for the Distance-Joint
  93599. */
  93600. constructor(jointData: DistanceJointData);
  93601. /**
  93602. * Update the predefined distance.
  93603. * @param maxDistance The maximum preferred distance
  93604. * @param minDistance The minimum preferred distance
  93605. */
  93606. updateDistance(maxDistance: number, minDistance?: number): void;
  93607. }
  93608. /**
  93609. * Represents a Motor-Enabled Joint
  93610. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93611. */
  93612. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  93613. /**
  93614. * Initializes the Motor-Enabled Joint
  93615. * @param type The type of the joint
  93616. * @param jointData The physica joint data for the joint
  93617. */
  93618. constructor(type: number, jointData: PhysicsJointData);
  93619. /**
  93620. * Set the motor values.
  93621. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93622. * @param force the force to apply
  93623. * @param maxForce max force for this motor.
  93624. */
  93625. setMotor(force?: number, maxForce?: number): void;
  93626. /**
  93627. * Set the motor's limits.
  93628. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93629. * @param upperLimit The upper limit of the motor
  93630. * @param lowerLimit The lower limit of the motor
  93631. */
  93632. setLimit(upperLimit: number, lowerLimit?: number): void;
  93633. }
  93634. /**
  93635. * This class represents a single physics Hinge-Joint
  93636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93637. */
  93638. export class HingeJoint extends MotorEnabledJoint {
  93639. /**
  93640. * Initializes the Hinge-Joint
  93641. * @param jointData The joint data for the Hinge-Joint
  93642. */
  93643. constructor(jointData: PhysicsJointData);
  93644. /**
  93645. * Set the motor values.
  93646. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93647. * @param {number} force the force to apply
  93648. * @param {number} maxForce max force for this motor.
  93649. */
  93650. setMotor(force?: number, maxForce?: number): void;
  93651. /**
  93652. * Set the motor's limits.
  93653. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93654. * @param upperLimit The upper limit of the motor
  93655. * @param lowerLimit The lower limit of the motor
  93656. */
  93657. setLimit(upperLimit: number, lowerLimit?: number): void;
  93658. }
  93659. /**
  93660. * This class represents a dual hinge physics joint (same as wheel joint)
  93661. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93662. */
  93663. export class Hinge2Joint extends MotorEnabledJoint {
  93664. /**
  93665. * Initializes the Hinge2-Joint
  93666. * @param jointData The joint data for the Hinge2-Joint
  93667. */
  93668. constructor(jointData: PhysicsJointData);
  93669. /**
  93670. * Set the motor values.
  93671. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93672. * @param {number} targetSpeed the speed the motor is to reach
  93673. * @param {number} maxForce max force for this motor.
  93674. * @param {motorIndex} the motor's index, 0 or 1.
  93675. */
  93676. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  93677. /**
  93678. * Set the motor limits.
  93679. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93680. * @param {number} upperLimit the upper limit
  93681. * @param {number} lowerLimit lower limit
  93682. * @param {motorIndex} the motor's index, 0 or 1.
  93683. */
  93684. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  93685. }
  93686. /**
  93687. * Interface for a motor enabled joint
  93688. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93689. */
  93690. export interface IMotorEnabledJoint {
  93691. /**
  93692. * Physics joint
  93693. */
  93694. physicsJoint: any;
  93695. /**
  93696. * Sets the motor of the motor-enabled joint
  93697. * @param force The force of the motor
  93698. * @param maxForce The maximum force of the motor
  93699. * @param motorIndex The index of the motor
  93700. */
  93701. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  93702. /**
  93703. * Sets the limit of the motor
  93704. * @param upperLimit The upper limit of the motor
  93705. * @param lowerLimit The lower limit of the motor
  93706. * @param motorIndex The index of the motor
  93707. */
  93708. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  93709. }
  93710. /**
  93711. * Joint data for a Distance-Joint
  93712. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93713. */
  93714. export interface DistanceJointData extends PhysicsJointData {
  93715. /**
  93716. * Max distance the 2 joint objects can be apart
  93717. */
  93718. maxDistance: number;
  93719. }
  93720. /**
  93721. * Joint data from a spring joint
  93722. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93723. */
  93724. export interface SpringJointData extends PhysicsJointData {
  93725. /**
  93726. * Length of the spring
  93727. */
  93728. length: number;
  93729. /**
  93730. * Stiffness of the spring
  93731. */
  93732. stiffness: number;
  93733. /**
  93734. * Damping of the spring
  93735. */
  93736. damping: number;
  93737. /** this callback will be called when applying the force to the impostors. */
  93738. forceApplicationCallback: () => void;
  93739. }
  93740. }
  93741. declare module BABYLON {
  93742. /**
  93743. * Holds the data for the raycast result
  93744. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93745. */
  93746. export class PhysicsRaycastResult {
  93747. private _hasHit;
  93748. private _hitDistance;
  93749. private _hitNormalWorld;
  93750. private _hitPointWorld;
  93751. private _rayFromWorld;
  93752. private _rayToWorld;
  93753. /**
  93754. * Gets if there was a hit
  93755. */
  93756. get hasHit(): boolean;
  93757. /**
  93758. * Gets the distance from the hit
  93759. */
  93760. get hitDistance(): number;
  93761. /**
  93762. * Gets the hit normal/direction in the world
  93763. */
  93764. get hitNormalWorld(): Vector3;
  93765. /**
  93766. * Gets the hit point in the world
  93767. */
  93768. get hitPointWorld(): Vector3;
  93769. /**
  93770. * Gets the ray "start point" of the ray in the world
  93771. */
  93772. get rayFromWorld(): Vector3;
  93773. /**
  93774. * Gets the ray "end point" of the ray in the world
  93775. */
  93776. get rayToWorld(): Vector3;
  93777. /**
  93778. * Sets the hit data (normal & point in world space)
  93779. * @param hitNormalWorld defines the normal in world space
  93780. * @param hitPointWorld defines the point in world space
  93781. */
  93782. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  93783. /**
  93784. * Sets the distance from the start point to the hit point
  93785. * @param distance
  93786. */
  93787. setHitDistance(distance: number): void;
  93788. /**
  93789. * Calculates the distance manually
  93790. */
  93791. calculateHitDistance(): void;
  93792. /**
  93793. * Resets all the values to default
  93794. * @param from The from point on world space
  93795. * @param to The to point on world space
  93796. */
  93797. reset(from?: Vector3, to?: Vector3): void;
  93798. }
  93799. /**
  93800. * Interface for the size containing width and height
  93801. */
  93802. interface IXYZ {
  93803. /**
  93804. * X
  93805. */
  93806. x: number;
  93807. /**
  93808. * Y
  93809. */
  93810. y: number;
  93811. /**
  93812. * Z
  93813. */
  93814. z: number;
  93815. }
  93816. }
  93817. declare module BABYLON {
  93818. /**
  93819. * Interface used to describe a physics joint
  93820. */
  93821. export interface PhysicsImpostorJoint {
  93822. /** Defines the main impostor to which the joint is linked */
  93823. mainImpostor: PhysicsImpostor;
  93824. /** Defines the impostor that is connected to the main impostor using this joint */
  93825. connectedImpostor: PhysicsImpostor;
  93826. /** Defines the joint itself */
  93827. joint: PhysicsJoint;
  93828. }
  93829. /** @hidden */
  93830. export interface IPhysicsEnginePlugin {
  93831. world: any;
  93832. name: string;
  93833. setGravity(gravity: Vector3): void;
  93834. setTimeStep(timeStep: number): void;
  93835. getTimeStep(): number;
  93836. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  93837. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  93838. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  93839. generatePhysicsBody(impostor: PhysicsImpostor): void;
  93840. removePhysicsBody(impostor: PhysicsImpostor): void;
  93841. generateJoint(joint: PhysicsImpostorJoint): void;
  93842. removeJoint(joint: PhysicsImpostorJoint): void;
  93843. isSupported(): boolean;
  93844. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  93845. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  93846. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  93847. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  93848. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  93849. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  93850. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  93851. getBodyMass(impostor: PhysicsImpostor): number;
  93852. getBodyFriction(impostor: PhysicsImpostor): number;
  93853. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  93854. getBodyRestitution(impostor: PhysicsImpostor): number;
  93855. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  93856. getBodyPressure?(impostor: PhysicsImpostor): number;
  93857. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  93858. getBodyStiffness?(impostor: PhysicsImpostor): number;
  93859. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  93860. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  93861. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  93862. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  93863. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  93864. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  93865. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  93866. sleepBody(impostor: PhysicsImpostor): void;
  93867. wakeUpBody(impostor: PhysicsImpostor): void;
  93868. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  93869. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  93870. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  93871. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  93872. getRadius(impostor: PhysicsImpostor): number;
  93873. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  93874. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  93875. dispose(): void;
  93876. }
  93877. /**
  93878. * Interface used to define a physics engine
  93879. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  93880. */
  93881. export interface IPhysicsEngine {
  93882. /**
  93883. * Gets the gravity vector used by the simulation
  93884. */
  93885. gravity: Vector3;
  93886. /**
  93887. * Sets the gravity vector used by the simulation
  93888. * @param gravity defines the gravity vector to use
  93889. */
  93890. setGravity(gravity: Vector3): void;
  93891. /**
  93892. * Set the time step of the physics engine.
  93893. * Default is 1/60.
  93894. * To slow it down, enter 1/600 for example.
  93895. * To speed it up, 1/30
  93896. * @param newTimeStep the new timestep to apply to this world.
  93897. */
  93898. setTimeStep(newTimeStep: number): void;
  93899. /**
  93900. * Get the time step of the physics engine.
  93901. * @returns the current time step
  93902. */
  93903. getTimeStep(): number;
  93904. /**
  93905. * Set the sub time step of the physics engine.
  93906. * Default is 0 meaning there is no sub steps
  93907. * To increase physics resolution precision, set a small value (like 1 ms)
  93908. * @param subTimeStep defines the new sub timestep used for physics resolution.
  93909. */
  93910. setSubTimeStep(subTimeStep: number): void;
  93911. /**
  93912. * Get the sub time step of the physics engine.
  93913. * @returns the current sub time step
  93914. */
  93915. getSubTimeStep(): number;
  93916. /**
  93917. * Release all resources
  93918. */
  93919. dispose(): void;
  93920. /**
  93921. * Gets the name of the current physics plugin
  93922. * @returns the name of the plugin
  93923. */
  93924. getPhysicsPluginName(): string;
  93925. /**
  93926. * Adding a new impostor for the impostor tracking.
  93927. * This will be done by the impostor itself.
  93928. * @param impostor the impostor to add
  93929. */
  93930. addImpostor(impostor: PhysicsImpostor): void;
  93931. /**
  93932. * Remove an impostor from the engine.
  93933. * This impostor and its mesh will not longer be updated by the physics engine.
  93934. * @param impostor the impostor to remove
  93935. */
  93936. removeImpostor(impostor: PhysicsImpostor): void;
  93937. /**
  93938. * Add a joint to the physics engine
  93939. * @param mainImpostor defines the main impostor to which the joint is added.
  93940. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  93941. * @param joint defines the joint that will connect both impostors.
  93942. */
  93943. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  93944. /**
  93945. * Removes a joint from the simulation
  93946. * @param mainImpostor defines the impostor used with the joint
  93947. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  93948. * @param joint defines the joint to remove
  93949. */
  93950. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  93951. /**
  93952. * Gets the current plugin used to run the simulation
  93953. * @returns current plugin
  93954. */
  93955. getPhysicsPlugin(): IPhysicsEnginePlugin;
  93956. /**
  93957. * Gets the list of physic impostors
  93958. * @returns an array of PhysicsImpostor
  93959. */
  93960. getImpostors(): Array<PhysicsImpostor>;
  93961. /**
  93962. * Gets the impostor for a physics enabled object
  93963. * @param object defines the object impersonated by the impostor
  93964. * @returns the PhysicsImpostor or null if not found
  93965. */
  93966. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  93967. /**
  93968. * Gets the impostor for a physics body object
  93969. * @param body defines physics body used by the impostor
  93970. * @returns the PhysicsImpostor or null if not found
  93971. */
  93972. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  93973. /**
  93974. * Does a raycast in the physics world
  93975. * @param from when should the ray start?
  93976. * @param to when should the ray end?
  93977. * @returns PhysicsRaycastResult
  93978. */
  93979. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  93980. /**
  93981. * Called by the scene. No need to call it.
  93982. * @param delta defines the timespam between frames
  93983. */
  93984. _step(delta: number): void;
  93985. }
  93986. }
  93987. declare module BABYLON {
  93988. /**
  93989. * The interface for the physics imposter parameters
  93990. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93991. */
  93992. export interface PhysicsImpostorParameters {
  93993. /**
  93994. * The mass of the physics imposter
  93995. */
  93996. mass: number;
  93997. /**
  93998. * The friction of the physics imposter
  93999. */
  94000. friction?: number;
  94001. /**
  94002. * The coefficient of restitution of the physics imposter
  94003. */
  94004. restitution?: number;
  94005. /**
  94006. * The native options of the physics imposter
  94007. */
  94008. nativeOptions?: any;
  94009. /**
  94010. * Specifies if the parent should be ignored
  94011. */
  94012. ignoreParent?: boolean;
  94013. /**
  94014. * Specifies if bi-directional transformations should be disabled
  94015. */
  94016. disableBidirectionalTransformation?: boolean;
  94017. /**
  94018. * The pressure inside the physics imposter, soft object only
  94019. */
  94020. pressure?: number;
  94021. /**
  94022. * The stiffness the physics imposter, soft object only
  94023. */
  94024. stiffness?: number;
  94025. /**
  94026. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  94027. */
  94028. velocityIterations?: number;
  94029. /**
  94030. * The number of iterations used in maintaining consistent vertex positions, soft object only
  94031. */
  94032. positionIterations?: number;
  94033. /**
  94034. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  94035. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  94036. * Add to fix multiple points
  94037. */
  94038. fixedPoints?: number;
  94039. /**
  94040. * The collision margin around a soft object
  94041. */
  94042. margin?: number;
  94043. /**
  94044. * The collision margin around a soft object
  94045. */
  94046. damping?: number;
  94047. /**
  94048. * The path for a rope based on an extrusion
  94049. */
  94050. path?: any;
  94051. /**
  94052. * The shape of an extrusion used for a rope based on an extrusion
  94053. */
  94054. shape?: any;
  94055. }
  94056. /**
  94057. * Interface for a physics-enabled object
  94058. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94059. */
  94060. export interface IPhysicsEnabledObject {
  94061. /**
  94062. * The position of the physics-enabled object
  94063. */
  94064. position: Vector3;
  94065. /**
  94066. * The rotation of the physics-enabled object
  94067. */
  94068. rotationQuaternion: Nullable<Quaternion>;
  94069. /**
  94070. * The scale of the physics-enabled object
  94071. */
  94072. scaling: Vector3;
  94073. /**
  94074. * The rotation of the physics-enabled object
  94075. */
  94076. rotation?: Vector3;
  94077. /**
  94078. * The parent of the physics-enabled object
  94079. */
  94080. parent?: any;
  94081. /**
  94082. * The bounding info of the physics-enabled object
  94083. * @returns The bounding info of the physics-enabled object
  94084. */
  94085. getBoundingInfo(): BoundingInfo;
  94086. /**
  94087. * Computes the world matrix
  94088. * @param force Specifies if the world matrix should be computed by force
  94089. * @returns A world matrix
  94090. */
  94091. computeWorldMatrix(force: boolean): Matrix;
  94092. /**
  94093. * Gets the world matrix
  94094. * @returns A world matrix
  94095. */
  94096. getWorldMatrix?(): Matrix;
  94097. /**
  94098. * Gets the child meshes
  94099. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  94100. * @returns An array of abstract meshes
  94101. */
  94102. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  94103. /**
  94104. * Gets the vertex data
  94105. * @param kind The type of vertex data
  94106. * @returns A nullable array of numbers, or a float32 array
  94107. */
  94108. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  94109. /**
  94110. * Gets the indices from the mesh
  94111. * @returns A nullable array of index arrays
  94112. */
  94113. getIndices?(): Nullable<IndicesArray>;
  94114. /**
  94115. * Gets the scene from the mesh
  94116. * @returns the indices array or null
  94117. */
  94118. getScene?(): Scene;
  94119. /**
  94120. * Gets the absolute position from the mesh
  94121. * @returns the absolute position
  94122. */
  94123. getAbsolutePosition(): Vector3;
  94124. /**
  94125. * Gets the absolute pivot point from the mesh
  94126. * @returns the absolute pivot point
  94127. */
  94128. getAbsolutePivotPoint(): Vector3;
  94129. /**
  94130. * Rotates the mesh
  94131. * @param axis The axis of rotation
  94132. * @param amount The amount of rotation
  94133. * @param space The space of the rotation
  94134. * @returns The rotation transform node
  94135. */
  94136. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  94137. /**
  94138. * Translates the mesh
  94139. * @param axis The axis of translation
  94140. * @param distance The distance of translation
  94141. * @param space The space of the translation
  94142. * @returns The transform node
  94143. */
  94144. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  94145. /**
  94146. * Sets the absolute position of the mesh
  94147. * @param absolutePosition The absolute position of the mesh
  94148. * @returns The transform node
  94149. */
  94150. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  94151. /**
  94152. * Gets the class name of the mesh
  94153. * @returns The class name
  94154. */
  94155. getClassName(): string;
  94156. }
  94157. /**
  94158. * Represents a physics imposter
  94159. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94160. */
  94161. export class PhysicsImpostor {
  94162. /**
  94163. * The physics-enabled object used as the physics imposter
  94164. */
  94165. object: IPhysicsEnabledObject;
  94166. /**
  94167. * The type of the physics imposter
  94168. */
  94169. type: number;
  94170. private _options;
  94171. private _scene?;
  94172. /**
  94173. * The default object size of the imposter
  94174. */
  94175. static DEFAULT_OBJECT_SIZE: Vector3;
  94176. /**
  94177. * The identity quaternion of the imposter
  94178. */
  94179. static IDENTITY_QUATERNION: Quaternion;
  94180. /** @hidden */
  94181. _pluginData: any;
  94182. private _physicsEngine;
  94183. private _physicsBody;
  94184. private _bodyUpdateRequired;
  94185. private _onBeforePhysicsStepCallbacks;
  94186. private _onAfterPhysicsStepCallbacks;
  94187. /** @hidden */
  94188. _onPhysicsCollideCallbacks: Array<{
  94189. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  94190. otherImpostors: Array<PhysicsImpostor>;
  94191. }>;
  94192. private _deltaPosition;
  94193. private _deltaRotation;
  94194. private _deltaRotationConjugated;
  94195. /** @hidden */
  94196. _isFromLine: boolean;
  94197. private _parent;
  94198. private _isDisposed;
  94199. private static _tmpVecs;
  94200. private static _tmpQuat;
  94201. /**
  94202. * Specifies if the physics imposter is disposed
  94203. */
  94204. get isDisposed(): boolean;
  94205. /**
  94206. * Gets the mass of the physics imposter
  94207. */
  94208. get mass(): number;
  94209. set mass(value: number);
  94210. /**
  94211. * Gets the coefficient of friction
  94212. */
  94213. get friction(): number;
  94214. /**
  94215. * Sets the coefficient of friction
  94216. */
  94217. set friction(value: number);
  94218. /**
  94219. * Gets the coefficient of restitution
  94220. */
  94221. get restitution(): number;
  94222. /**
  94223. * Sets the coefficient of restitution
  94224. */
  94225. set restitution(value: number);
  94226. /**
  94227. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  94228. */
  94229. get pressure(): number;
  94230. /**
  94231. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  94232. */
  94233. set pressure(value: number);
  94234. /**
  94235. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  94236. */
  94237. get stiffness(): number;
  94238. /**
  94239. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  94240. */
  94241. set stiffness(value: number);
  94242. /**
  94243. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  94244. */
  94245. get velocityIterations(): number;
  94246. /**
  94247. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  94248. */
  94249. set velocityIterations(value: number);
  94250. /**
  94251. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  94252. */
  94253. get positionIterations(): number;
  94254. /**
  94255. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  94256. */
  94257. set positionIterations(value: number);
  94258. /**
  94259. * The unique id of the physics imposter
  94260. * set by the physics engine when adding this impostor to the array
  94261. */
  94262. uniqueId: number;
  94263. /**
  94264. * @hidden
  94265. */
  94266. soft: boolean;
  94267. /**
  94268. * @hidden
  94269. */
  94270. segments: number;
  94271. private _joints;
  94272. /**
  94273. * Initializes the physics imposter
  94274. * @param object The physics-enabled object used as the physics imposter
  94275. * @param type The type of the physics imposter
  94276. * @param _options The options for the physics imposter
  94277. * @param _scene The Babylon scene
  94278. */
  94279. constructor(
  94280. /**
  94281. * The physics-enabled object used as the physics imposter
  94282. */
  94283. object: IPhysicsEnabledObject,
  94284. /**
  94285. * The type of the physics imposter
  94286. */
  94287. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  94288. /**
  94289. * This function will completly initialize this impostor.
  94290. * It will create a new body - but only if this mesh has no parent.
  94291. * If it has, this impostor will not be used other than to define the impostor
  94292. * of the child mesh.
  94293. * @hidden
  94294. */
  94295. _init(): void;
  94296. private _getPhysicsParent;
  94297. /**
  94298. * Should a new body be generated.
  94299. * @returns boolean specifying if body initialization is required
  94300. */
  94301. isBodyInitRequired(): boolean;
  94302. /**
  94303. * Sets the updated scaling
  94304. * @param updated Specifies if the scaling is updated
  94305. */
  94306. setScalingUpdated(): void;
  94307. /**
  94308. * Force a regeneration of this or the parent's impostor's body.
  94309. * Use under cautious - This will remove all joints already implemented.
  94310. */
  94311. forceUpdate(): void;
  94312. /**
  94313. * Gets the body that holds this impostor. Either its own, or its parent.
  94314. */
  94315. get physicsBody(): any;
  94316. /**
  94317. * Get the parent of the physics imposter
  94318. * @returns Physics imposter or null
  94319. */
  94320. get parent(): Nullable<PhysicsImpostor>;
  94321. /**
  94322. * Sets the parent of the physics imposter
  94323. */
  94324. set parent(value: Nullable<PhysicsImpostor>);
  94325. /**
  94326. * Set the physics body. Used mainly by the physics engine/plugin
  94327. */
  94328. set physicsBody(physicsBody: any);
  94329. /**
  94330. * Resets the update flags
  94331. */
  94332. resetUpdateFlags(): void;
  94333. /**
  94334. * Gets the object extend size
  94335. * @returns the object extend size
  94336. */
  94337. getObjectExtendSize(): Vector3;
  94338. /**
  94339. * Gets the object center
  94340. * @returns The object center
  94341. */
  94342. getObjectCenter(): Vector3;
  94343. /**
  94344. * Get a specific parametes from the options parameter
  94345. * @param paramName The object parameter name
  94346. * @returns The object parameter
  94347. */
  94348. getParam(paramName: string): any;
  94349. /**
  94350. * Sets a specific parameter in the options given to the physics plugin
  94351. * @param paramName The parameter name
  94352. * @param value The value of the parameter
  94353. */
  94354. setParam(paramName: string, value: number): void;
  94355. /**
  94356. * Specifically change the body's mass option. Won't recreate the physics body object
  94357. * @param mass The mass of the physics imposter
  94358. */
  94359. setMass(mass: number): void;
  94360. /**
  94361. * Gets the linear velocity
  94362. * @returns linear velocity or null
  94363. */
  94364. getLinearVelocity(): Nullable<Vector3>;
  94365. /**
  94366. * Sets the linear velocity
  94367. * @param velocity linear velocity or null
  94368. */
  94369. setLinearVelocity(velocity: Nullable<Vector3>): void;
  94370. /**
  94371. * Gets the angular velocity
  94372. * @returns angular velocity or null
  94373. */
  94374. getAngularVelocity(): Nullable<Vector3>;
  94375. /**
  94376. * Sets the angular velocity
  94377. * @param velocity The velocity or null
  94378. */
  94379. setAngularVelocity(velocity: Nullable<Vector3>): void;
  94380. /**
  94381. * Execute a function with the physics plugin native code
  94382. * Provide a function the will have two variables - the world object and the physics body object
  94383. * @param func The function to execute with the physics plugin native code
  94384. */
  94385. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  94386. /**
  94387. * Register a function that will be executed before the physics world is stepping forward
  94388. * @param func The function to execute before the physics world is stepped forward
  94389. */
  94390. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  94391. /**
  94392. * Unregister a function that will be executed before the physics world is stepping forward
  94393. * @param func The function to execute before the physics world is stepped forward
  94394. */
  94395. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  94396. /**
  94397. * Register a function that will be executed after the physics step
  94398. * @param func The function to execute after physics step
  94399. */
  94400. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  94401. /**
  94402. * Unregisters a function that will be executed after the physics step
  94403. * @param func The function to execute after physics step
  94404. */
  94405. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  94406. /**
  94407. * register a function that will be executed when this impostor collides against a different body
  94408. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  94409. * @param func Callback that is executed on collision
  94410. */
  94411. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  94412. /**
  94413. * Unregisters the physics imposter on contact
  94414. * @param collideAgainst The physics object to collide against
  94415. * @param func Callback to execute on collision
  94416. */
  94417. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  94418. private _tmpQuat;
  94419. private _tmpQuat2;
  94420. /**
  94421. * Get the parent rotation
  94422. * @returns The parent rotation
  94423. */
  94424. getParentsRotation(): Quaternion;
  94425. /**
  94426. * this function is executed by the physics engine.
  94427. */
  94428. beforeStep: () => void;
  94429. /**
  94430. * this function is executed by the physics engine
  94431. */
  94432. afterStep: () => void;
  94433. /**
  94434. * Legacy collision detection event support
  94435. */
  94436. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  94437. /**
  94438. * event and body object due to cannon's event-based architecture.
  94439. */
  94440. onCollide: (e: {
  94441. body: any;
  94442. }) => void;
  94443. /**
  94444. * Apply a force
  94445. * @param force The force to apply
  94446. * @param contactPoint The contact point for the force
  94447. * @returns The physics imposter
  94448. */
  94449. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  94450. /**
  94451. * Apply an impulse
  94452. * @param force The impulse force
  94453. * @param contactPoint The contact point for the impulse force
  94454. * @returns The physics imposter
  94455. */
  94456. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  94457. /**
  94458. * A help function to create a joint
  94459. * @param otherImpostor A physics imposter used to create a joint
  94460. * @param jointType The type of joint
  94461. * @param jointData The data for the joint
  94462. * @returns The physics imposter
  94463. */
  94464. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  94465. /**
  94466. * Add a joint to this impostor with a different impostor
  94467. * @param otherImpostor A physics imposter used to add a joint
  94468. * @param joint The joint to add
  94469. * @returns The physics imposter
  94470. */
  94471. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  94472. /**
  94473. * Add an anchor to a cloth impostor
  94474. * @param otherImpostor rigid impostor to anchor to
  94475. * @param width ratio across width from 0 to 1
  94476. * @param height ratio up height from 0 to 1
  94477. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  94478. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  94479. * @returns impostor the soft imposter
  94480. */
  94481. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  94482. /**
  94483. * Add a hook to a rope impostor
  94484. * @param otherImpostor rigid impostor to anchor to
  94485. * @param length ratio across rope from 0 to 1
  94486. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  94487. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  94488. * @returns impostor the rope imposter
  94489. */
  94490. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  94491. /**
  94492. * Will keep this body still, in a sleep mode.
  94493. * @returns the physics imposter
  94494. */
  94495. sleep(): PhysicsImpostor;
  94496. /**
  94497. * Wake the body up.
  94498. * @returns The physics imposter
  94499. */
  94500. wakeUp(): PhysicsImpostor;
  94501. /**
  94502. * Clones the physics imposter
  94503. * @param newObject The physics imposter clones to this physics-enabled object
  94504. * @returns A nullable physics imposter
  94505. */
  94506. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  94507. /**
  94508. * Disposes the physics imposter
  94509. */
  94510. dispose(): void;
  94511. /**
  94512. * Sets the delta position
  94513. * @param position The delta position amount
  94514. */
  94515. setDeltaPosition(position: Vector3): void;
  94516. /**
  94517. * Sets the delta rotation
  94518. * @param rotation The delta rotation amount
  94519. */
  94520. setDeltaRotation(rotation: Quaternion): void;
  94521. /**
  94522. * Gets the box size of the physics imposter and stores the result in the input parameter
  94523. * @param result Stores the box size
  94524. * @returns The physics imposter
  94525. */
  94526. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  94527. /**
  94528. * Gets the radius of the physics imposter
  94529. * @returns Radius of the physics imposter
  94530. */
  94531. getRadius(): number;
  94532. /**
  94533. * Sync a bone with this impostor
  94534. * @param bone The bone to sync to the impostor.
  94535. * @param boneMesh The mesh that the bone is influencing.
  94536. * @param jointPivot The pivot of the joint / bone in local space.
  94537. * @param distToJoint Optional distance from the impostor to the joint.
  94538. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  94539. */
  94540. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  94541. /**
  94542. * Sync impostor to a bone
  94543. * @param bone The bone that the impostor will be synced to.
  94544. * @param boneMesh The mesh that the bone is influencing.
  94545. * @param jointPivot The pivot of the joint / bone in local space.
  94546. * @param distToJoint Optional distance from the impostor to the joint.
  94547. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  94548. * @param boneAxis Optional vector3 axis the bone is aligned with
  94549. */
  94550. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  94551. /**
  94552. * No-Imposter type
  94553. */
  94554. static NoImpostor: number;
  94555. /**
  94556. * Sphere-Imposter type
  94557. */
  94558. static SphereImpostor: number;
  94559. /**
  94560. * Box-Imposter type
  94561. */
  94562. static BoxImpostor: number;
  94563. /**
  94564. * Plane-Imposter type
  94565. */
  94566. static PlaneImpostor: number;
  94567. /**
  94568. * Mesh-imposter type
  94569. */
  94570. static MeshImpostor: number;
  94571. /**
  94572. * Capsule-Impostor type (Ammo.js plugin only)
  94573. */
  94574. static CapsuleImpostor: number;
  94575. /**
  94576. * Cylinder-Imposter type
  94577. */
  94578. static CylinderImpostor: number;
  94579. /**
  94580. * Particle-Imposter type
  94581. */
  94582. static ParticleImpostor: number;
  94583. /**
  94584. * Heightmap-Imposter type
  94585. */
  94586. static HeightmapImpostor: number;
  94587. /**
  94588. * ConvexHull-Impostor type (Ammo.js plugin only)
  94589. */
  94590. static ConvexHullImpostor: number;
  94591. /**
  94592. * Custom-Imposter type (Ammo.js plugin only)
  94593. */
  94594. static CustomImpostor: number;
  94595. /**
  94596. * Rope-Imposter type
  94597. */
  94598. static RopeImpostor: number;
  94599. /**
  94600. * Cloth-Imposter type
  94601. */
  94602. static ClothImpostor: number;
  94603. /**
  94604. * Softbody-Imposter type
  94605. */
  94606. static SoftbodyImpostor: number;
  94607. }
  94608. }
  94609. declare module BABYLON {
  94610. /**
  94611. * @hidden
  94612. **/
  94613. export class _CreationDataStorage {
  94614. closePath?: boolean;
  94615. closeArray?: boolean;
  94616. idx: number[];
  94617. dashSize: number;
  94618. gapSize: number;
  94619. path3D: Path3D;
  94620. pathArray: Vector3[][];
  94621. arc: number;
  94622. radius: number;
  94623. cap: number;
  94624. tessellation: number;
  94625. }
  94626. /**
  94627. * @hidden
  94628. **/
  94629. class _InstanceDataStorage {
  94630. visibleInstances: any;
  94631. batchCache: _InstancesBatch;
  94632. instancesBufferSize: number;
  94633. instancesBuffer: Nullable<Buffer>;
  94634. instancesData: Float32Array;
  94635. overridenInstanceCount: number;
  94636. isFrozen: boolean;
  94637. previousBatch: Nullable<_InstancesBatch>;
  94638. hardwareInstancedRendering: boolean;
  94639. sideOrientation: number;
  94640. manualUpdate: boolean;
  94641. }
  94642. /**
  94643. * @hidden
  94644. **/
  94645. export class _InstancesBatch {
  94646. mustReturn: boolean;
  94647. visibleInstances: Nullable<InstancedMesh[]>[];
  94648. renderSelf: boolean[];
  94649. hardwareInstancedRendering: boolean[];
  94650. }
  94651. /**
  94652. * Class used to represent renderable models
  94653. */
  94654. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  94655. /**
  94656. * Mesh side orientation : usually the external or front surface
  94657. */
  94658. static readonly FRONTSIDE: number;
  94659. /**
  94660. * Mesh side orientation : usually the internal or back surface
  94661. */
  94662. static readonly BACKSIDE: number;
  94663. /**
  94664. * Mesh side orientation : both internal and external or front and back surfaces
  94665. */
  94666. static readonly DOUBLESIDE: number;
  94667. /**
  94668. * Mesh side orientation : by default, `FRONTSIDE`
  94669. */
  94670. static readonly DEFAULTSIDE: number;
  94671. /**
  94672. * Mesh cap setting : no cap
  94673. */
  94674. static readonly NO_CAP: number;
  94675. /**
  94676. * Mesh cap setting : one cap at the beginning of the mesh
  94677. */
  94678. static readonly CAP_START: number;
  94679. /**
  94680. * Mesh cap setting : one cap at the end of the mesh
  94681. */
  94682. static readonly CAP_END: number;
  94683. /**
  94684. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  94685. */
  94686. static readonly CAP_ALL: number;
  94687. /**
  94688. * Mesh pattern setting : no flip or rotate
  94689. */
  94690. static readonly NO_FLIP: number;
  94691. /**
  94692. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  94693. */
  94694. static readonly FLIP_TILE: number;
  94695. /**
  94696. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  94697. */
  94698. static readonly ROTATE_TILE: number;
  94699. /**
  94700. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  94701. */
  94702. static readonly FLIP_ROW: number;
  94703. /**
  94704. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  94705. */
  94706. static readonly ROTATE_ROW: number;
  94707. /**
  94708. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  94709. */
  94710. static readonly FLIP_N_ROTATE_TILE: number;
  94711. /**
  94712. * Mesh pattern setting : rotate pattern and rotate
  94713. */
  94714. static readonly FLIP_N_ROTATE_ROW: number;
  94715. /**
  94716. * Mesh tile positioning : part tiles same on left/right or top/bottom
  94717. */
  94718. static readonly CENTER: number;
  94719. /**
  94720. * Mesh tile positioning : part tiles on left
  94721. */
  94722. static readonly LEFT: number;
  94723. /**
  94724. * Mesh tile positioning : part tiles on right
  94725. */
  94726. static readonly RIGHT: number;
  94727. /**
  94728. * Mesh tile positioning : part tiles on top
  94729. */
  94730. static readonly TOP: number;
  94731. /**
  94732. * Mesh tile positioning : part tiles on bottom
  94733. */
  94734. static readonly BOTTOM: number;
  94735. /**
  94736. * Gets the default side orientation.
  94737. * @param orientation the orientation to value to attempt to get
  94738. * @returns the default orientation
  94739. * @hidden
  94740. */
  94741. static _GetDefaultSideOrientation(orientation?: number): number;
  94742. private _internalMeshDataInfo;
  94743. /**
  94744. * An event triggered before rendering the mesh
  94745. */
  94746. get onBeforeRenderObservable(): Observable<Mesh>;
  94747. /**
  94748. * An event triggered before binding the mesh
  94749. */
  94750. get onBeforeBindObservable(): Observable<Mesh>;
  94751. /**
  94752. * An event triggered after rendering the mesh
  94753. */
  94754. get onAfterRenderObservable(): Observable<Mesh>;
  94755. /**
  94756. * An event triggered before drawing the mesh
  94757. */
  94758. get onBeforeDrawObservable(): Observable<Mesh>;
  94759. private _onBeforeDrawObserver;
  94760. /**
  94761. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  94762. */
  94763. set onBeforeDraw(callback: () => void);
  94764. get hasInstances(): boolean;
  94765. /**
  94766. * Gets the delay loading state of the mesh (when delay loading is turned on)
  94767. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  94768. */
  94769. delayLoadState: number;
  94770. /**
  94771. * Gets the list of instances created from this mesh
  94772. * it is not supposed to be modified manually.
  94773. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  94774. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  94775. */
  94776. instances: InstancedMesh[];
  94777. /**
  94778. * Gets the file containing delay loading data for this mesh
  94779. */
  94780. delayLoadingFile: string;
  94781. /** @hidden */
  94782. _binaryInfo: any;
  94783. /**
  94784. * User defined function used to change how LOD level selection is done
  94785. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  94786. */
  94787. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  94788. /**
  94789. * Gets or sets the morph target manager
  94790. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  94791. */
  94792. get morphTargetManager(): Nullable<MorphTargetManager>;
  94793. set morphTargetManager(value: Nullable<MorphTargetManager>);
  94794. /** @hidden */
  94795. _creationDataStorage: Nullable<_CreationDataStorage>;
  94796. /** @hidden */
  94797. _geometry: Nullable<Geometry>;
  94798. /** @hidden */
  94799. _delayInfo: Array<string>;
  94800. /** @hidden */
  94801. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  94802. /** @hidden */
  94803. _instanceDataStorage: _InstanceDataStorage;
  94804. private _effectiveMaterial;
  94805. /** @hidden */
  94806. _shouldGenerateFlatShading: boolean;
  94807. /** @hidden */
  94808. _originalBuilderSideOrientation: number;
  94809. /**
  94810. * Use this property to change the original side orientation defined at construction time
  94811. */
  94812. overrideMaterialSideOrientation: Nullable<number>;
  94813. /**
  94814. * Gets the source mesh (the one used to clone this one from)
  94815. */
  94816. get source(): Nullable<Mesh>;
  94817. /**
  94818. * Gets or sets a boolean indicating that this mesh does not use index buffer
  94819. */
  94820. get isUnIndexed(): boolean;
  94821. set isUnIndexed(value: boolean);
  94822. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  94823. get worldMatrixInstancedBuffer(): Float32Array;
  94824. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  94825. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  94826. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  94827. /**
  94828. * @constructor
  94829. * @param name The value used by scene.getMeshByName() to do a lookup.
  94830. * @param scene The scene to add this mesh to.
  94831. * @param parent The parent of this mesh, if it has one
  94832. * @param source An optional Mesh from which geometry is shared, cloned.
  94833. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  94834. * When false, achieved by calling a clone(), also passing False.
  94835. * This will make creation of children, recursive.
  94836. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  94837. */
  94838. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  94839. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  94840. doNotInstantiate: boolean;
  94841. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  94842. /**
  94843. * Gets the class name
  94844. * @returns the string "Mesh".
  94845. */
  94846. getClassName(): string;
  94847. /** @hidden */
  94848. get _isMesh(): boolean;
  94849. /**
  94850. * Returns a description of this mesh
  94851. * @param fullDetails define if full details about this mesh must be used
  94852. * @returns a descriptive string representing this mesh
  94853. */
  94854. toString(fullDetails?: boolean): string;
  94855. /** @hidden */
  94856. _unBindEffect(): void;
  94857. /**
  94858. * Gets a boolean indicating if this mesh has LOD
  94859. */
  94860. get hasLODLevels(): boolean;
  94861. /**
  94862. * Gets the list of MeshLODLevel associated with the current mesh
  94863. * @returns an array of MeshLODLevel
  94864. */
  94865. getLODLevels(): MeshLODLevel[];
  94866. private _sortLODLevels;
  94867. /**
  94868. * Add a mesh as LOD level triggered at the given distance.
  94869. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94870. * @param distance The distance from the center of the object to show this level
  94871. * @param mesh The mesh to be added as LOD level (can be null)
  94872. * @return This mesh (for chaining)
  94873. */
  94874. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  94875. /**
  94876. * Returns the LOD level mesh at the passed distance or null if not found.
  94877. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94878. * @param distance The distance from the center of the object to show this level
  94879. * @returns a Mesh or `null`
  94880. */
  94881. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  94882. /**
  94883. * Remove a mesh from the LOD array
  94884. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94885. * @param mesh defines the mesh to be removed
  94886. * @return This mesh (for chaining)
  94887. */
  94888. removeLODLevel(mesh: Mesh): Mesh;
  94889. /**
  94890. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  94891. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94892. * @param camera defines the camera to use to compute distance
  94893. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  94894. * @return This mesh (for chaining)
  94895. */
  94896. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  94897. /**
  94898. * Gets the mesh internal Geometry object
  94899. */
  94900. get geometry(): Nullable<Geometry>;
  94901. /**
  94902. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  94903. * @returns the total number of vertices
  94904. */
  94905. getTotalVertices(): number;
  94906. /**
  94907. * Returns the content of an associated vertex buffer
  94908. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  94909. * - VertexBuffer.PositionKind
  94910. * - VertexBuffer.UVKind
  94911. * - VertexBuffer.UV2Kind
  94912. * - VertexBuffer.UV3Kind
  94913. * - VertexBuffer.UV4Kind
  94914. * - VertexBuffer.UV5Kind
  94915. * - VertexBuffer.UV6Kind
  94916. * - VertexBuffer.ColorKind
  94917. * - VertexBuffer.MatricesIndicesKind
  94918. * - VertexBuffer.MatricesIndicesExtraKind
  94919. * - VertexBuffer.MatricesWeightsKind
  94920. * - VertexBuffer.MatricesWeightsExtraKind
  94921. * @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
  94922. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  94923. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  94924. */
  94925. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  94926. /**
  94927. * Returns the mesh VertexBuffer object from the requested `kind`
  94928. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  94929. * - VertexBuffer.PositionKind
  94930. * - VertexBuffer.NormalKind
  94931. * - VertexBuffer.UVKind
  94932. * - VertexBuffer.UV2Kind
  94933. * - VertexBuffer.UV3Kind
  94934. * - VertexBuffer.UV4Kind
  94935. * - VertexBuffer.UV5Kind
  94936. * - VertexBuffer.UV6Kind
  94937. * - VertexBuffer.ColorKind
  94938. * - VertexBuffer.MatricesIndicesKind
  94939. * - VertexBuffer.MatricesIndicesExtraKind
  94940. * - VertexBuffer.MatricesWeightsKind
  94941. * - VertexBuffer.MatricesWeightsExtraKind
  94942. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  94943. */
  94944. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  94945. /**
  94946. * Tests if a specific vertex buffer is associated with this mesh
  94947. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  94948. * - VertexBuffer.PositionKind
  94949. * - VertexBuffer.NormalKind
  94950. * - VertexBuffer.UVKind
  94951. * - VertexBuffer.UV2Kind
  94952. * - VertexBuffer.UV3Kind
  94953. * - VertexBuffer.UV4Kind
  94954. * - VertexBuffer.UV5Kind
  94955. * - VertexBuffer.UV6Kind
  94956. * - VertexBuffer.ColorKind
  94957. * - VertexBuffer.MatricesIndicesKind
  94958. * - VertexBuffer.MatricesIndicesExtraKind
  94959. * - VertexBuffer.MatricesWeightsKind
  94960. * - VertexBuffer.MatricesWeightsExtraKind
  94961. * @returns a boolean
  94962. */
  94963. isVerticesDataPresent(kind: string): boolean;
  94964. /**
  94965. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  94966. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  94967. * - VertexBuffer.PositionKind
  94968. * - VertexBuffer.UVKind
  94969. * - VertexBuffer.UV2Kind
  94970. * - VertexBuffer.UV3Kind
  94971. * - VertexBuffer.UV4Kind
  94972. * - VertexBuffer.UV5Kind
  94973. * - VertexBuffer.UV6Kind
  94974. * - VertexBuffer.ColorKind
  94975. * - VertexBuffer.MatricesIndicesKind
  94976. * - VertexBuffer.MatricesIndicesExtraKind
  94977. * - VertexBuffer.MatricesWeightsKind
  94978. * - VertexBuffer.MatricesWeightsExtraKind
  94979. * @returns a boolean
  94980. */
  94981. isVertexBufferUpdatable(kind: string): boolean;
  94982. /**
  94983. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  94984. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  94985. * - VertexBuffer.PositionKind
  94986. * - VertexBuffer.NormalKind
  94987. * - VertexBuffer.UVKind
  94988. * - VertexBuffer.UV2Kind
  94989. * - VertexBuffer.UV3Kind
  94990. * - VertexBuffer.UV4Kind
  94991. * - VertexBuffer.UV5Kind
  94992. * - VertexBuffer.UV6Kind
  94993. * - VertexBuffer.ColorKind
  94994. * - VertexBuffer.MatricesIndicesKind
  94995. * - VertexBuffer.MatricesIndicesExtraKind
  94996. * - VertexBuffer.MatricesWeightsKind
  94997. * - VertexBuffer.MatricesWeightsExtraKind
  94998. * @returns an array of strings
  94999. */
  95000. getVerticesDataKinds(): string[];
  95001. /**
  95002. * Returns a positive integer : the total number of indices in this mesh geometry.
  95003. * @returns the numner of indices or zero if the mesh has no geometry.
  95004. */
  95005. getTotalIndices(): number;
  95006. /**
  95007. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95008. * @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.
  95009. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95010. * @returns the indices array or an empty array if the mesh has no geometry
  95011. */
  95012. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95013. get isBlocked(): boolean;
  95014. /**
  95015. * Determine if the current mesh is ready to be rendered
  95016. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  95017. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  95018. * @returns true if all associated assets are ready (material, textures, shaders)
  95019. */
  95020. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  95021. /**
  95022. * 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.
  95023. */
  95024. get areNormalsFrozen(): boolean;
  95025. /**
  95026. * 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.
  95027. * @returns the current mesh
  95028. */
  95029. freezeNormals(): Mesh;
  95030. /**
  95031. * 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
  95032. * @returns the current mesh
  95033. */
  95034. unfreezeNormals(): Mesh;
  95035. /**
  95036. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  95037. */
  95038. set overridenInstanceCount(count: number);
  95039. /** @hidden */
  95040. _preActivate(): Mesh;
  95041. /** @hidden */
  95042. _preActivateForIntermediateRendering(renderId: number): Mesh;
  95043. /** @hidden */
  95044. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  95045. /**
  95046. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  95047. * This means the mesh underlying bounding box and sphere are recomputed.
  95048. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  95049. * @returns the current mesh
  95050. */
  95051. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  95052. /** @hidden */
  95053. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  95054. /**
  95055. * This function will subdivide the mesh into multiple submeshes
  95056. * @param count defines the expected number of submeshes
  95057. */
  95058. subdivide(count: number): void;
  95059. /**
  95060. * Copy a FloatArray into a specific associated vertex buffer
  95061. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95062. * - VertexBuffer.PositionKind
  95063. * - VertexBuffer.UVKind
  95064. * - VertexBuffer.UV2Kind
  95065. * - VertexBuffer.UV3Kind
  95066. * - VertexBuffer.UV4Kind
  95067. * - VertexBuffer.UV5Kind
  95068. * - VertexBuffer.UV6Kind
  95069. * - VertexBuffer.ColorKind
  95070. * - VertexBuffer.MatricesIndicesKind
  95071. * - VertexBuffer.MatricesIndicesExtraKind
  95072. * - VertexBuffer.MatricesWeightsKind
  95073. * - VertexBuffer.MatricesWeightsExtraKind
  95074. * @param data defines the data source
  95075. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  95076. * @param stride defines the data stride size (can be null)
  95077. * @returns the current mesh
  95078. */
  95079. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  95080. /**
  95081. * Delete a vertex buffer associated with this mesh
  95082. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  95083. * - VertexBuffer.PositionKind
  95084. * - VertexBuffer.UVKind
  95085. * - VertexBuffer.UV2Kind
  95086. * - VertexBuffer.UV3Kind
  95087. * - VertexBuffer.UV4Kind
  95088. * - VertexBuffer.UV5Kind
  95089. * - VertexBuffer.UV6Kind
  95090. * - VertexBuffer.ColorKind
  95091. * - VertexBuffer.MatricesIndicesKind
  95092. * - VertexBuffer.MatricesIndicesExtraKind
  95093. * - VertexBuffer.MatricesWeightsKind
  95094. * - VertexBuffer.MatricesWeightsExtraKind
  95095. */
  95096. removeVerticesData(kind: string): void;
  95097. /**
  95098. * Flags an associated vertex buffer as updatable
  95099. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  95100. * - VertexBuffer.PositionKind
  95101. * - VertexBuffer.UVKind
  95102. * - VertexBuffer.UV2Kind
  95103. * - VertexBuffer.UV3Kind
  95104. * - VertexBuffer.UV4Kind
  95105. * - VertexBuffer.UV5Kind
  95106. * - VertexBuffer.UV6Kind
  95107. * - VertexBuffer.ColorKind
  95108. * - VertexBuffer.MatricesIndicesKind
  95109. * - VertexBuffer.MatricesIndicesExtraKind
  95110. * - VertexBuffer.MatricesWeightsKind
  95111. * - VertexBuffer.MatricesWeightsExtraKind
  95112. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  95113. */
  95114. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  95115. /**
  95116. * Sets the mesh global Vertex Buffer
  95117. * @param buffer defines the buffer to use
  95118. * @returns the current mesh
  95119. */
  95120. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  95121. /**
  95122. * Update a specific associated vertex buffer
  95123. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95124. * - VertexBuffer.PositionKind
  95125. * - VertexBuffer.UVKind
  95126. * - VertexBuffer.UV2Kind
  95127. * - VertexBuffer.UV3Kind
  95128. * - VertexBuffer.UV4Kind
  95129. * - VertexBuffer.UV5Kind
  95130. * - VertexBuffer.UV6Kind
  95131. * - VertexBuffer.ColorKind
  95132. * - VertexBuffer.MatricesIndicesKind
  95133. * - VertexBuffer.MatricesIndicesExtraKind
  95134. * - VertexBuffer.MatricesWeightsKind
  95135. * - VertexBuffer.MatricesWeightsExtraKind
  95136. * @param data defines the data source
  95137. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  95138. * @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)
  95139. * @returns the current mesh
  95140. */
  95141. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  95142. /**
  95143. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  95144. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  95145. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  95146. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  95147. * @returns the current mesh
  95148. */
  95149. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  95150. /**
  95151. * Creates a un-shared specific occurence of the geometry for the mesh.
  95152. * @returns the current mesh
  95153. */
  95154. makeGeometryUnique(): Mesh;
  95155. /**
  95156. * Set the index buffer of this mesh
  95157. * @param indices defines the source data
  95158. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  95159. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  95160. * @returns the current mesh
  95161. */
  95162. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  95163. /**
  95164. * Update the current index buffer
  95165. * @param indices defines the source data
  95166. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  95167. * @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)
  95168. * @returns the current mesh
  95169. */
  95170. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  95171. /**
  95172. * Invert the geometry to move from a right handed system to a left handed one.
  95173. * @returns the current mesh
  95174. */
  95175. toLeftHanded(): Mesh;
  95176. /** @hidden */
  95177. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  95178. /** @hidden */
  95179. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  95180. /**
  95181. * Registers for this mesh a javascript function called just before the rendering process
  95182. * @param func defines the function to call before rendering this mesh
  95183. * @returns the current mesh
  95184. */
  95185. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  95186. /**
  95187. * Disposes a previously registered javascript function called before the rendering
  95188. * @param func defines the function to remove
  95189. * @returns the current mesh
  95190. */
  95191. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  95192. /**
  95193. * Registers for this mesh a javascript function called just after the rendering is complete
  95194. * @param func defines the function to call after rendering this mesh
  95195. * @returns the current mesh
  95196. */
  95197. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  95198. /**
  95199. * Disposes a previously registered javascript function called after the rendering.
  95200. * @param func defines the function to remove
  95201. * @returns the current mesh
  95202. */
  95203. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  95204. /** @hidden */
  95205. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  95206. /** @hidden */
  95207. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  95208. /** @hidden */
  95209. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  95210. /** @hidden */
  95211. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  95212. /** @hidden */
  95213. _rebuild(): void;
  95214. /** @hidden */
  95215. _freeze(): void;
  95216. /** @hidden */
  95217. _unFreeze(): void;
  95218. /**
  95219. * 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
  95220. * @param subMesh defines the subMesh to render
  95221. * @param enableAlphaMode defines if alpha mode can be changed
  95222. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  95223. * @returns the current mesh
  95224. */
  95225. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  95226. private _onBeforeDraw;
  95227. /**
  95228. * Renormalize the mesh and patch it up if there are no weights
  95229. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  95230. * However in the case of zero weights then we set just a single influence to 1.
  95231. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  95232. */
  95233. cleanMatrixWeights(): void;
  95234. private normalizeSkinFourWeights;
  95235. private normalizeSkinWeightsAndExtra;
  95236. /**
  95237. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  95238. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  95239. * the user know there was an issue with importing the mesh
  95240. * @returns a validation object with skinned, valid and report string
  95241. */
  95242. validateSkinning(): {
  95243. skinned: boolean;
  95244. valid: boolean;
  95245. report: string;
  95246. };
  95247. /** @hidden */
  95248. _checkDelayState(): Mesh;
  95249. private _queueLoad;
  95250. /**
  95251. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  95252. * A mesh is in the frustum if its bounding box intersects the frustum
  95253. * @param frustumPlanes defines the frustum to test
  95254. * @returns true if the mesh is in the frustum planes
  95255. */
  95256. isInFrustum(frustumPlanes: Plane[]): boolean;
  95257. /**
  95258. * Sets the mesh material by the material or multiMaterial `id` property
  95259. * @param id is a string identifying the material or the multiMaterial
  95260. * @returns the current mesh
  95261. */
  95262. setMaterialByID(id: string): Mesh;
  95263. /**
  95264. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  95265. * @returns an array of IAnimatable
  95266. */
  95267. getAnimatables(): IAnimatable[];
  95268. /**
  95269. * Modifies the mesh geometry according to the passed transformation matrix.
  95270. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  95271. * The mesh normals are modified using the same transformation.
  95272. * Note that, under the hood, this method sets a new VertexBuffer each call.
  95273. * @param transform defines the transform matrix to use
  95274. * @see http://doc.babylonjs.com/resources/baking_transformations
  95275. * @returns the current mesh
  95276. */
  95277. bakeTransformIntoVertices(transform: Matrix): Mesh;
  95278. /**
  95279. * Modifies the mesh geometry according to its own current World Matrix.
  95280. * The mesh World Matrix is then reset.
  95281. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  95282. * Note that, under the hood, this method sets a new VertexBuffer each call.
  95283. * @see http://doc.babylonjs.com/resources/baking_transformations
  95284. * @returns the current mesh
  95285. */
  95286. bakeCurrentTransformIntoVertices(): Mesh;
  95287. /** @hidden */
  95288. get _positions(): Nullable<Vector3[]>;
  95289. /** @hidden */
  95290. _resetPointsArrayCache(): Mesh;
  95291. /** @hidden */
  95292. _generatePointsArray(): boolean;
  95293. /**
  95294. * Returns a new Mesh object generated from the current mesh properties.
  95295. * This method must not get confused with createInstance()
  95296. * @param name is a string, the name given to the new mesh
  95297. * @param newParent can be any Node object (default `null`)
  95298. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  95299. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  95300. * @returns a new mesh
  95301. */
  95302. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  95303. /**
  95304. * Releases resources associated with this mesh.
  95305. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95306. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95307. */
  95308. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95309. /** @hidden */
  95310. _disposeInstanceSpecificData(): void;
  95311. /**
  95312. * Modifies the mesh geometry according to a displacement map.
  95313. * 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.
  95314. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  95315. * @param url is a string, the URL from the image file is to be downloaded.
  95316. * @param minHeight is the lower limit of the displacement.
  95317. * @param maxHeight is the upper limit of the displacement.
  95318. * @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.
  95319. * @param uvOffset is an optional vector2 used to offset UV.
  95320. * @param uvScale is an optional vector2 used to scale UV.
  95321. * @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.
  95322. * @returns the Mesh.
  95323. */
  95324. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  95325. /**
  95326. * Modifies the mesh geometry according to a displacementMap buffer.
  95327. * 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.
  95328. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  95329. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  95330. * @param heightMapWidth is the width of the buffer image.
  95331. * @param heightMapHeight is the height of the buffer image.
  95332. * @param minHeight is the lower limit of the displacement.
  95333. * @param maxHeight is the upper limit of the displacement.
  95334. * @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.
  95335. * @param uvOffset is an optional vector2 used to offset UV.
  95336. * @param uvScale is an optional vector2 used to scale UV.
  95337. * @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.
  95338. * @returns the Mesh.
  95339. */
  95340. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  95341. /**
  95342. * Modify the mesh to get a flat shading rendering.
  95343. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  95344. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  95345. * @returns current mesh
  95346. */
  95347. convertToFlatShadedMesh(): Mesh;
  95348. /**
  95349. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  95350. * In other words, more vertices, no more indices and a single bigger VBO.
  95351. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  95352. * @returns current mesh
  95353. */
  95354. convertToUnIndexedMesh(): Mesh;
  95355. /**
  95356. * Inverses facet orientations.
  95357. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  95358. * @param flipNormals will also inverts the normals
  95359. * @returns current mesh
  95360. */
  95361. flipFaces(flipNormals?: boolean): Mesh;
  95362. /**
  95363. * Increase the number of facets and hence vertices in a mesh
  95364. * Vertex normals are interpolated from existing vertex normals
  95365. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  95366. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  95367. */
  95368. increaseVertices(numberPerEdge: number): void;
  95369. /**
  95370. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  95371. * This will undo any application of covertToFlatShadedMesh
  95372. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  95373. */
  95374. forceSharedVertices(): void;
  95375. /** @hidden */
  95376. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  95377. /** @hidden */
  95378. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  95379. /**
  95380. * Creates a new InstancedMesh object from the mesh model.
  95381. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  95382. * @param name defines the name of the new instance
  95383. * @returns a new InstancedMesh
  95384. */
  95385. createInstance(name: string): InstancedMesh;
  95386. /**
  95387. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  95388. * After this call, all the mesh instances have the same submeshes than the current mesh.
  95389. * @returns the current mesh
  95390. */
  95391. synchronizeInstances(): Mesh;
  95392. /**
  95393. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  95394. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  95395. * This should be used together with the simplification to avoid disappearing triangles.
  95396. * @param successCallback an optional success callback to be called after the optimization finished.
  95397. * @returns the current mesh
  95398. */
  95399. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  95400. /**
  95401. * Serialize current mesh
  95402. * @param serializationObject defines the object which will receive the serialization data
  95403. */
  95404. serialize(serializationObject: any): void;
  95405. /** @hidden */
  95406. _syncGeometryWithMorphTargetManager(): void;
  95407. /** @hidden */
  95408. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  95409. /**
  95410. * Returns a new Mesh object parsed from the source provided.
  95411. * @param parsedMesh is the source
  95412. * @param scene defines the hosting scene
  95413. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  95414. * @returns a new Mesh
  95415. */
  95416. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  95417. /**
  95418. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  95419. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  95420. * @param name defines the name of the mesh to create
  95421. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  95422. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  95423. * @param closePath creates a seam between the first and the last points of each path of the path array
  95424. * @param offset is taken in account only if the `pathArray` is containing a single path
  95425. * @param scene defines the hosting scene
  95426. * @param updatable defines if the mesh must be flagged as updatable
  95427. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95428. * @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)
  95429. * @returns a new Mesh
  95430. */
  95431. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  95432. /**
  95433. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  95434. * @param name defines the name of the mesh to create
  95435. * @param radius sets the radius size (float) of the polygon (default 0.5)
  95436. * @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
  95437. * @param scene defines the hosting scene
  95438. * @param updatable defines if the mesh must be flagged as updatable
  95439. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95440. * @returns a new Mesh
  95441. */
  95442. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  95443. /**
  95444. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  95445. * @param name defines the name of the mesh to create
  95446. * @param size sets the size (float) of each box side (default 1)
  95447. * @param scene defines the hosting scene
  95448. * @param updatable defines if the mesh must be flagged as updatable
  95449. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95450. * @returns a new Mesh
  95451. */
  95452. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  95453. /**
  95454. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  95455. * @param name defines the name of the mesh to create
  95456. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  95457. * @param diameter sets the diameter size (float) of the sphere (default 1)
  95458. * @param scene defines the hosting scene
  95459. * @param updatable defines if the mesh must be flagged as updatable
  95460. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95461. * @returns a new Mesh
  95462. */
  95463. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95464. /**
  95465. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  95466. * @param name defines the name of the mesh to create
  95467. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  95468. * @param diameter sets the diameter size (float) of the sphere (default 1)
  95469. * @param scene defines the hosting scene
  95470. * @returns a new Mesh
  95471. */
  95472. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  95473. /**
  95474. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  95475. * @param name defines the name of the mesh to create
  95476. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  95477. * @param diameterTop set the top cap diameter (floats, default 1)
  95478. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  95479. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  95480. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  95481. * @param scene defines the hosting scene
  95482. * @param updatable defines if the mesh must be flagged as updatable
  95483. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95484. * @returns a new Mesh
  95485. */
  95486. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  95487. /**
  95488. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  95489. * @param name defines the name of the mesh to create
  95490. * @param diameter sets the diameter size (float) of the torus (default 1)
  95491. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  95492. * @param tessellation sets the number of torus sides (postive integer, default 16)
  95493. * @param scene defines the hosting scene
  95494. * @param updatable defines if the mesh must be flagged as updatable
  95495. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95496. * @returns a new Mesh
  95497. */
  95498. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95499. /**
  95500. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  95501. * @param name defines the name of the mesh to create
  95502. * @param radius sets the global radius size (float) of the torus knot (default 2)
  95503. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  95504. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  95505. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  95506. * @param p the number of windings on X axis (positive integers, default 2)
  95507. * @param q the number of windings on Y axis (positive integers, default 3)
  95508. * @param scene defines the hosting scene
  95509. * @param updatable defines if the mesh must be flagged as updatable
  95510. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95511. * @returns a new Mesh
  95512. */
  95513. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95514. /**
  95515. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  95516. * @param name defines the name of the mesh to create
  95517. * @param points is an array successive Vector3
  95518. * @param scene defines the hosting scene
  95519. * @param updatable defines if the mesh must be flagged as updatable
  95520. * @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).
  95521. * @returns a new Mesh
  95522. */
  95523. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  95524. /**
  95525. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  95526. * @param name defines the name of the mesh to create
  95527. * @param points is an array successive Vector3
  95528. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  95529. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  95530. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  95531. * @param scene defines the hosting scene
  95532. * @param updatable defines if the mesh must be flagged as updatable
  95533. * @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)
  95534. * @returns a new Mesh
  95535. */
  95536. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  95537. /**
  95538. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  95539. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  95540. * 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.
  95541. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95542. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95543. * Remember you can only change the shape positions, not their number when updating a polygon.
  95544. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  95545. * @param name defines the name of the mesh to create
  95546. * @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
  95547. * @param scene defines the hosting scene
  95548. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  95549. * @param updatable defines if the mesh must be flagged as updatable
  95550. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95551. * @param earcutInjection can be used to inject your own earcut reference
  95552. * @returns a new Mesh
  95553. */
  95554. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  95555. /**
  95556. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  95557. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  95558. * @param name defines the name of the mesh to create
  95559. * @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
  95560. * @param depth defines the height of extrusion
  95561. * @param scene defines the hosting scene
  95562. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  95563. * @param updatable defines if the mesh must be flagged as updatable
  95564. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95565. * @param earcutInjection can be used to inject your own earcut reference
  95566. * @returns a new Mesh
  95567. */
  95568. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  95569. /**
  95570. * Creates an extruded shape mesh.
  95571. * 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
  95572. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  95573. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  95574. * @param name defines the name of the mesh to create
  95575. * @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
  95576. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  95577. * @param scale is the value to scale the shape
  95578. * @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
  95579. * @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
  95580. * @param scene defines the hosting scene
  95581. * @param updatable defines if the mesh must be flagged as updatable
  95582. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95583. * @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)
  95584. * @returns a new Mesh
  95585. */
  95586. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  95587. /**
  95588. * Creates an custom extruded shape mesh.
  95589. * The custom extrusion is a parametric shape.
  95590. * It has no predefined shape. Its final shape will depend on the input parameters.
  95591. * Please consider using the same method from the MeshBuilder class instead
  95592. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  95593. * @param name defines the name of the mesh to create
  95594. * @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
  95595. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  95596. * @param scaleFunction is a custom Javascript function called on each path point
  95597. * @param rotationFunction is a custom Javascript function called on each path point
  95598. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  95599. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  95600. * @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
  95601. * @param scene defines the hosting scene
  95602. * @param updatable defines if the mesh must be flagged as updatable
  95603. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95604. * @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)
  95605. * @returns a new Mesh
  95606. */
  95607. 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;
  95608. /**
  95609. * Creates lathe mesh.
  95610. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  95611. * Please consider using the same method from the MeshBuilder class instead
  95612. * @param name defines the name of the mesh to create
  95613. * @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
  95614. * @param radius is the radius value of the lathe
  95615. * @param tessellation is the side number of the lathe.
  95616. * @param scene defines the hosting scene
  95617. * @param updatable defines if the mesh must be flagged as updatable
  95618. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95619. * @returns a new Mesh
  95620. */
  95621. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95622. /**
  95623. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  95624. * @param name defines the name of the mesh to create
  95625. * @param size sets the size (float) of both sides of the plane at once (default 1)
  95626. * @param scene defines the hosting scene
  95627. * @param updatable defines if the mesh must be flagged as updatable
  95628. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95629. * @returns a new Mesh
  95630. */
  95631. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95632. /**
  95633. * Creates a ground mesh.
  95634. * Please consider using the same method from the MeshBuilder class instead
  95635. * @param name defines the name of the mesh to create
  95636. * @param width set the width of the ground
  95637. * @param height set the height of the ground
  95638. * @param subdivisions sets the number of subdivisions per side
  95639. * @param scene defines the hosting scene
  95640. * @param updatable defines if the mesh must be flagged as updatable
  95641. * @returns a new Mesh
  95642. */
  95643. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  95644. /**
  95645. * Creates a tiled ground mesh.
  95646. * Please consider using the same method from the MeshBuilder class instead
  95647. * @param name defines the name of the mesh to create
  95648. * @param xmin set the ground minimum X coordinate
  95649. * @param zmin set the ground minimum Y coordinate
  95650. * @param xmax set the ground maximum X coordinate
  95651. * @param zmax set the ground maximum Z coordinate
  95652. * @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
  95653. * @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
  95654. * @param scene defines the hosting scene
  95655. * @param updatable defines if the mesh must be flagged as updatable
  95656. * @returns a new Mesh
  95657. */
  95658. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  95659. w: number;
  95660. h: number;
  95661. }, precision: {
  95662. w: number;
  95663. h: number;
  95664. }, scene: Scene, updatable?: boolean): Mesh;
  95665. /**
  95666. * Creates a ground mesh from a height map.
  95667. * Please consider using the same method from the MeshBuilder class instead
  95668. * @see http://doc.babylonjs.com/babylon101/height_map
  95669. * @param name defines the name of the mesh to create
  95670. * @param url sets the URL of the height map image resource
  95671. * @param width set the ground width size
  95672. * @param height set the ground height size
  95673. * @param subdivisions sets the number of subdivision per side
  95674. * @param minHeight is the minimum altitude on the ground
  95675. * @param maxHeight is the maximum altitude on the ground
  95676. * @param scene defines the hosting scene
  95677. * @param updatable defines if the mesh must be flagged as updatable
  95678. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  95679. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  95680. * @returns a new Mesh
  95681. */
  95682. 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;
  95683. /**
  95684. * Creates a tube mesh.
  95685. * The tube is a parametric shape.
  95686. * It has no predefined shape. Its final shape will depend on the input parameters.
  95687. * Please consider using the same method from the MeshBuilder class instead
  95688. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  95689. * @param name defines the name of the mesh to create
  95690. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  95691. * @param radius sets the tube radius size
  95692. * @param tessellation is the number of sides on the tubular surface
  95693. * @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
  95694. * @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
  95695. * @param scene defines the hosting scene
  95696. * @param updatable defines if the mesh must be flagged as updatable
  95697. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95698. * @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)
  95699. * @returns a new Mesh
  95700. */
  95701. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  95702. (i: number, distance: number): number;
  95703. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  95704. /**
  95705. * Creates a polyhedron mesh.
  95706. * Please consider using the same method from the MeshBuilder class instead.
  95707. * * 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
  95708. * * The parameter `size` (positive float, default 1) sets the polygon size
  95709. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  95710. * * 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`
  95711. * * 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
  95712. * * 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)`)
  95713. * * 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
  95714. * * 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
  95715. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95716. * * If you create a double-sided mesh, you can choose what parts of 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
  95717. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95718. * @param name defines the name of the mesh to create
  95719. * @param options defines the options used to create the mesh
  95720. * @param scene defines the hosting scene
  95721. * @returns a new Mesh
  95722. */
  95723. static CreatePolyhedron(name: string, options: {
  95724. type?: number;
  95725. size?: number;
  95726. sizeX?: number;
  95727. sizeY?: number;
  95728. sizeZ?: number;
  95729. custom?: any;
  95730. faceUV?: Vector4[];
  95731. faceColors?: Color4[];
  95732. updatable?: boolean;
  95733. sideOrientation?: number;
  95734. }, scene: Scene): Mesh;
  95735. /**
  95736. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  95737. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  95738. * * 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`)
  95739. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  95740. * * 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
  95741. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95742. * * If you create a double-sided mesh, you can choose what parts of 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
  95743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95744. * @param name defines the name of the mesh
  95745. * @param options defines the options used to create the mesh
  95746. * @param scene defines the hosting scene
  95747. * @returns a new Mesh
  95748. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  95749. */
  95750. static CreateIcoSphere(name: string, options: {
  95751. radius?: number;
  95752. flat?: boolean;
  95753. subdivisions?: number;
  95754. sideOrientation?: number;
  95755. updatable?: boolean;
  95756. }, scene: Scene): Mesh;
  95757. /**
  95758. * Creates a decal mesh.
  95759. * Please consider using the same method from the MeshBuilder class instead.
  95760. * A decal is a mesh usually applied as a model onto the surface of another mesh
  95761. * @param name defines the name of the mesh
  95762. * @param sourceMesh defines the mesh receiving the decal
  95763. * @param position sets the position of the decal in world coordinates
  95764. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  95765. * @param size sets the decal scaling
  95766. * @param angle sets the angle to rotate the decal
  95767. * @returns a new Mesh
  95768. */
  95769. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  95770. /**
  95771. * Prepare internal position array for software CPU skinning
  95772. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  95773. */
  95774. setPositionsForCPUSkinning(): Float32Array;
  95775. /**
  95776. * Prepare internal normal array for software CPU skinning
  95777. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  95778. */
  95779. setNormalsForCPUSkinning(): Float32Array;
  95780. /**
  95781. * Updates the vertex buffer by applying transformation from the bones
  95782. * @param skeleton defines the skeleton to apply to current mesh
  95783. * @returns the current mesh
  95784. */
  95785. applySkeleton(skeleton: Skeleton): Mesh;
  95786. /**
  95787. * 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
  95788. * @param meshes defines the list of meshes to scan
  95789. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  95790. */
  95791. static MinMax(meshes: AbstractMesh[]): {
  95792. min: Vector3;
  95793. max: Vector3;
  95794. };
  95795. /**
  95796. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  95797. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  95798. * @returns a vector3
  95799. */
  95800. static Center(meshesOrMinMaxVector: {
  95801. min: Vector3;
  95802. max: Vector3;
  95803. } | AbstractMesh[]): Vector3;
  95804. /**
  95805. * Merge the array of meshes into a single mesh for performance reasons.
  95806. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  95807. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  95808. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  95809. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  95810. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  95811. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  95812. * @returns a new mesh
  95813. */
  95814. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  95815. /** @hidden */
  95816. addInstance(instance: InstancedMesh): void;
  95817. /** @hidden */
  95818. removeInstance(instance: InstancedMesh): void;
  95819. }
  95820. }
  95821. declare module BABYLON {
  95822. /**
  95823. * This is the base class of all the camera used in the application.
  95824. * @see http://doc.babylonjs.com/features/cameras
  95825. */
  95826. export class Camera extends Node {
  95827. /** @hidden */
  95828. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  95829. /**
  95830. * This is the default projection mode used by the cameras.
  95831. * It helps recreating a feeling of perspective and better appreciate depth.
  95832. * This is the best way to simulate real life cameras.
  95833. */
  95834. static readonly PERSPECTIVE_CAMERA: number;
  95835. /**
  95836. * This helps creating camera with an orthographic mode.
  95837. * 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.
  95838. */
  95839. static readonly ORTHOGRAPHIC_CAMERA: number;
  95840. /**
  95841. * This is the default FOV mode for perspective cameras.
  95842. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  95843. */
  95844. static readonly FOVMODE_VERTICAL_FIXED: number;
  95845. /**
  95846. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  95847. */
  95848. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  95849. /**
  95850. * This specifies ther is no need for a camera rig.
  95851. * Basically only one eye is rendered corresponding to the camera.
  95852. */
  95853. static readonly RIG_MODE_NONE: number;
  95854. /**
  95855. * Simulates a camera Rig with one blue eye and one red eye.
  95856. * This can be use with 3d blue and red glasses.
  95857. */
  95858. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  95859. /**
  95860. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  95861. */
  95862. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  95863. /**
  95864. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  95865. */
  95866. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  95867. /**
  95868. * Defines that both eyes of the camera will be rendered over under each other.
  95869. */
  95870. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  95871. /**
  95872. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  95873. */
  95874. static readonly RIG_MODE_VR: number;
  95875. /**
  95876. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  95877. */
  95878. static readonly RIG_MODE_WEBVR: number;
  95879. /**
  95880. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  95881. */
  95882. static readonly RIG_MODE_CUSTOM: number;
  95883. /**
  95884. * Defines if by default attaching controls should prevent the default javascript event to continue.
  95885. */
  95886. static ForceAttachControlToAlwaysPreventDefault: boolean;
  95887. /**
  95888. * Define the input manager associated with the camera.
  95889. */
  95890. inputs: CameraInputsManager<Camera>;
  95891. /** @hidden */
  95892. _position: Vector3;
  95893. /**
  95894. * Define the current local position of the camera in the scene
  95895. */
  95896. get position(): Vector3;
  95897. set position(newPosition: Vector3);
  95898. /**
  95899. * The vector the camera should consider as up.
  95900. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  95901. */
  95902. upVector: Vector3;
  95903. /**
  95904. * Define the current limit on the left side for an orthographic camera
  95905. * In scene unit
  95906. */
  95907. orthoLeft: Nullable<number>;
  95908. /**
  95909. * Define the current limit on the right side for an orthographic camera
  95910. * In scene unit
  95911. */
  95912. orthoRight: Nullable<number>;
  95913. /**
  95914. * Define the current limit on the bottom side for an orthographic camera
  95915. * In scene unit
  95916. */
  95917. orthoBottom: Nullable<number>;
  95918. /**
  95919. * Define the current limit on the top side for an orthographic camera
  95920. * In scene unit
  95921. */
  95922. orthoTop: Nullable<number>;
  95923. /**
  95924. * Field Of View is set in Radians. (default is 0.8)
  95925. */
  95926. fov: number;
  95927. /**
  95928. * Define the minimum distance the camera can see from.
  95929. * This is important to note that the depth buffer are not infinite and the closer it starts
  95930. * the more your scene might encounter depth fighting issue.
  95931. */
  95932. minZ: number;
  95933. /**
  95934. * Define the maximum distance the camera can see to.
  95935. * This is important to note that the depth buffer are not infinite and the further it end
  95936. * the more your scene might encounter depth fighting issue.
  95937. */
  95938. maxZ: number;
  95939. /**
  95940. * Define the default inertia of the camera.
  95941. * This helps giving a smooth feeling to the camera movement.
  95942. */
  95943. inertia: number;
  95944. /**
  95945. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  95946. */
  95947. mode: number;
  95948. /**
  95949. * Define wether the camera is intermediate.
  95950. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  95951. */
  95952. isIntermediate: boolean;
  95953. /**
  95954. * Define the viewport of the camera.
  95955. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  95956. */
  95957. viewport: Viewport;
  95958. /**
  95959. * Restricts the camera to viewing objects with the same layerMask.
  95960. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  95961. */
  95962. layerMask: number;
  95963. /**
  95964. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  95965. */
  95966. fovMode: number;
  95967. /**
  95968. * Rig mode of the camera.
  95969. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  95970. * This is normally controlled byt the camera themselves as internal use.
  95971. */
  95972. cameraRigMode: number;
  95973. /**
  95974. * Defines the distance between both "eyes" in case of a RIG
  95975. */
  95976. interaxialDistance: number;
  95977. /**
  95978. * Defines if stereoscopic rendering is done side by side or over under.
  95979. */
  95980. isStereoscopicSideBySide: boolean;
  95981. /**
  95982. * 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
  95983. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  95984. * else in the scene. (Eg. security camera)
  95985. *
  95986. * 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)
  95987. */
  95988. customRenderTargets: RenderTargetTexture[];
  95989. /**
  95990. * When set, the camera will render to this render target instead of the default canvas
  95991. *
  95992. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  95993. */
  95994. outputRenderTarget: Nullable<RenderTargetTexture>;
  95995. /**
  95996. * Observable triggered when the camera view matrix has changed.
  95997. */
  95998. onViewMatrixChangedObservable: Observable<Camera>;
  95999. /**
  96000. * Observable triggered when the camera Projection matrix has changed.
  96001. */
  96002. onProjectionMatrixChangedObservable: Observable<Camera>;
  96003. /**
  96004. * Observable triggered when the inputs have been processed.
  96005. */
  96006. onAfterCheckInputsObservable: Observable<Camera>;
  96007. /**
  96008. * Observable triggered when reset has been called and applied to the camera.
  96009. */
  96010. onRestoreStateObservable: Observable<Camera>;
  96011. /** @hidden */
  96012. _cameraRigParams: any;
  96013. /** @hidden */
  96014. _rigCameras: Camera[];
  96015. /** @hidden */
  96016. _rigPostProcess: Nullable<PostProcess>;
  96017. protected _webvrViewMatrix: Matrix;
  96018. /** @hidden */
  96019. _skipRendering: boolean;
  96020. /** @hidden */
  96021. _projectionMatrix: Matrix;
  96022. /** @hidden */
  96023. _postProcesses: Nullable<PostProcess>[];
  96024. /** @hidden */
  96025. _activeMeshes: SmartArray<AbstractMesh>;
  96026. protected _globalPosition: Vector3;
  96027. /** @hidden */
  96028. _computedViewMatrix: Matrix;
  96029. private _doNotComputeProjectionMatrix;
  96030. private _transformMatrix;
  96031. private _frustumPlanes;
  96032. private _refreshFrustumPlanes;
  96033. private _storedFov;
  96034. private _stateStored;
  96035. /**
  96036. * Instantiates a new camera object.
  96037. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  96038. * @see http://doc.babylonjs.com/features/cameras
  96039. * @param name Defines the name of the camera in the scene
  96040. * @param position Defines the position of the camera
  96041. * @param scene Defines the scene the camera belongs too
  96042. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  96043. */
  96044. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96045. /**
  96046. * Store current camera state (fov, position, etc..)
  96047. * @returns the camera
  96048. */
  96049. storeState(): Camera;
  96050. /**
  96051. * Restores the camera state values if it has been stored. You must call storeState() first
  96052. */
  96053. protected _restoreStateValues(): boolean;
  96054. /**
  96055. * Restored camera state. You must call storeState() first.
  96056. * @returns true if restored and false otherwise
  96057. */
  96058. restoreState(): boolean;
  96059. /**
  96060. * Gets the class name of the camera.
  96061. * @returns the class name
  96062. */
  96063. getClassName(): string;
  96064. /** @hidden */
  96065. readonly _isCamera: boolean;
  96066. /**
  96067. * Gets a string representation of the camera useful for debug purpose.
  96068. * @param fullDetails Defines that a more verboe level of logging is required
  96069. * @returns the string representation
  96070. */
  96071. toString(fullDetails?: boolean): string;
  96072. /**
  96073. * Gets the current world space position of the camera.
  96074. */
  96075. get globalPosition(): Vector3;
  96076. /**
  96077. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  96078. * @returns the active meshe list
  96079. */
  96080. getActiveMeshes(): SmartArray<AbstractMesh>;
  96081. /**
  96082. * Check wether a mesh is part of the current active mesh list of the camera
  96083. * @param mesh Defines the mesh to check
  96084. * @returns true if active, false otherwise
  96085. */
  96086. isActiveMesh(mesh: Mesh): boolean;
  96087. /**
  96088. * Is this camera ready to be used/rendered
  96089. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  96090. * @return true if the camera is ready
  96091. */
  96092. isReady(completeCheck?: boolean): boolean;
  96093. /** @hidden */
  96094. _initCache(): void;
  96095. /** @hidden */
  96096. _updateCache(ignoreParentClass?: boolean): void;
  96097. /** @hidden */
  96098. _isSynchronized(): boolean;
  96099. /** @hidden */
  96100. _isSynchronizedViewMatrix(): boolean;
  96101. /** @hidden */
  96102. _isSynchronizedProjectionMatrix(): boolean;
  96103. /**
  96104. * Attach the input controls to a specific dom element to get the input from.
  96105. * @param element Defines the element the controls should be listened from
  96106. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96107. */
  96108. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96109. /**
  96110. * Detach the current controls from the specified dom element.
  96111. * @param element Defines the element to stop listening the inputs from
  96112. */
  96113. detachControl(element: HTMLElement): void;
  96114. /**
  96115. * Update the camera state according to the different inputs gathered during the frame.
  96116. */
  96117. update(): void;
  96118. /** @hidden */
  96119. _checkInputs(): void;
  96120. /** @hidden */
  96121. get rigCameras(): Camera[];
  96122. /**
  96123. * Gets the post process used by the rig cameras
  96124. */
  96125. get rigPostProcess(): Nullable<PostProcess>;
  96126. /**
  96127. * Internal, gets the first post proces.
  96128. * @returns the first post process to be run on this camera.
  96129. */
  96130. _getFirstPostProcess(): Nullable<PostProcess>;
  96131. private _cascadePostProcessesToRigCams;
  96132. /**
  96133. * Attach a post process to the camera.
  96134. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  96135. * @param postProcess The post process to attach to the camera
  96136. * @param insertAt The position of the post process in case several of them are in use in the scene
  96137. * @returns the position the post process has been inserted at
  96138. */
  96139. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  96140. /**
  96141. * Detach a post process to the camera.
  96142. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  96143. * @param postProcess The post process to detach from the camera
  96144. */
  96145. detachPostProcess(postProcess: PostProcess): void;
  96146. /**
  96147. * Gets the current world matrix of the camera
  96148. */
  96149. getWorldMatrix(): Matrix;
  96150. /** @hidden */
  96151. _getViewMatrix(): Matrix;
  96152. /**
  96153. * Gets the current view matrix of the camera.
  96154. * @param force forces the camera to recompute the matrix without looking at the cached state
  96155. * @returns the view matrix
  96156. */
  96157. getViewMatrix(force?: boolean): Matrix;
  96158. /**
  96159. * Freeze the projection matrix.
  96160. * It will prevent the cache check of the camera projection compute and can speed up perf
  96161. * if no parameter of the camera are meant to change
  96162. * @param projection Defines manually a projection if necessary
  96163. */
  96164. freezeProjectionMatrix(projection?: Matrix): void;
  96165. /**
  96166. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  96167. */
  96168. unfreezeProjectionMatrix(): void;
  96169. /**
  96170. * Gets the current projection matrix of the camera.
  96171. * @param force forces the camera to recompute the matrix without looking at the cached state
  96172. * @returns the projection matrix
  96173. */
  96174. getProjectionMatrix(force?: boolean): Matrix;
  96175. /**
  96176. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  96177. * @returns a Matrix
  96178. */
  96179. getTransformationMatrix(): Matrix;
  96180. private _updateFrustumPlanes;
  96181. /**
  96182. * Checks if a cullable object (mesh...) is in the camera frustum
  96183. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  96184. * @param target The object to check
  96185. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  96186. * @returns true if the object is in frustum otherwise false
  96187. */
  96188. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  96189. /**
  96190. * Checks if a cullable object (mesh...) is in the camera frustum
  96191. * Unlike isInFrustum this cheks the full bounding box
  96192. * @param target The object to check
  96193. * @returns true if the object is in frustum otherwise false
  96194. */
  96195. isCompletelyInFrustum(target: ICullable): boolean;
  96196. /**
  96197. * Gets a ray in the forward direction from the camera.
  96198. * @param length Defines the length of the ray to create
  96199. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  96200. * @param origin Defines the start point of the ray which defaults to the camera position
  96201. * @returns the forward ray
  96202. */
  96203. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  96204. /**
  96205. * Releases resources associated with this node.
  96206. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96207. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96208. */
  96209. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96210. /** @hidden */
  96211. _isLeftCamera: boolean;
  96212. /**
  96213. * Gets the left camera of a rig setup in case of Rigged Camera
  96214. */
  96215. get isLeftCamera(): boolean;
  96216. /** @hidden */
  96217. _isRightCamera: boolean;
  96218. /**
  96219. * Gets the right camera of a rig setup in case of Rigged Camera
  96220. */
  96221. get isRightCamera(): boolean;
  96222. /**
  96223. * Gets the left camera of a rig setup in case of Rigged Camera
  96224. */
  96225. get leftCamera(): Nullable<FreeCamera>;
  96226. /**
  96227. * Gets the right camera of a rig setup in case of Rigged Camera
  96228. */
  96229. get rightCamera(): Nullable<FreeCamera>;
  96230. /**
  96231. * Gets the left camera target of a rig setup in case of Rigged Camera
  96232. * @returns the target position
  96233. */
  96234. getLeftTarget(): Nullable<Vector3>;
  96235. /**
  96236. * Gets the right camera target of a rig setup in case of Rigged Camera
  96237. * @returns the target position
  96238. */
  96239. getRightTarget(): Nullable<Vector3>;
  96240. /**
  96241. * @hidden
  96242. */
  96243. setCameraRigMode(mode: number, rigParams: any): void;
  96244. /** @hidden */
  96245. static _setStereoscopicRigMode(camera: Camera): void;
  96246. /** @hidden */
  96247. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  96248. /** @hidden */
  96249. static _setVRRigMode(camera: Camera, rigParams: any): void;
  96250. /** @hidden */
  96251. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  96252. /** @hidden */
  96253. _getVRProjectionMatrix(): Matrix;
  96254. protected _updateCameraRotationMatrix(): void;
  96255. protected _updateWebVRCameraRotationMatrix(): void;
  96256. /**
  96257. * This function MUST be overwritten by the different WebVR cameras available.
  96258. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  96259. * @hidden
  96260. */
  96261. _getWebVRProjectionMatrix(): Matrix;
  96262. /**
  96263. * This function MUST be overwritten by the different WebVR cameras available.
  96264. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  96265. * @hidden
  96266. */
  96267. _getWebVRViewMatrix(): Matrix;
  96268. /** @hidden */
  96269. setCameraRigParameter(name: string, value: any): void;
  96270. /**
  96271. * needs to be overridden by children so sub has required properties to be copied
  96272. * @hidden
  96273. */
  96274. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  96275. /**
  96276. * May need to be overridden by children
  96277. * @hidden
  96278. */
  96279. _updateRigCameras(): void;
  96280. /** @hidden */
  96281. _setupInputs(): void;
  96282. /**
  96283. * Serialiaze the camera setup to a json represention
  96284. * @returns the JSON representation
  96285. */
  96286. serialize(): any;
  96287. /**
  96288. * Clones the current camera.
  96289. * @param name The cloned camera name
  96290. * @returns the cloned camera
  96291. */
  96292. clone(name: string): Camera;
  96293. /**
  96294. * Gets the direction of the camera relative to a given local axis.
  96295. * @param localAxis Defines the reference axis to provide a relative direction.
  96296. * @return the direction
  96297. */
  96298. getDirection(localAxis: Vector3): Vector3;
  96299. /**
  96300. * Returns the current camera absolute rotation
  96301. */
  96302. get absoluteRotation(): Quaternion;
  96303. /**
  96304. * Gets the direction of the camera relative to a given local axis into a passed vector.
  96305. * @param localAxis Defines the reference axis to provide a relative direction.
  96306. * @param result Defines the vector to store the result in
  96307. */
  96308. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  96309. /**
  96310. * Gets a camera constructor for a given camera type
  96311. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  96312. * @param name The name of the camera the result will be able to instantiate
  96313. * @param scene The scene the result will construct the camera in
  96314. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  96315. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  96316. * @returns a factory method to construc the camera
  96317. */
  96318. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  96319. /**
  96320. * Compute the world matrix of the camera.
  96321. * @returns the camera world matrix
  96322. */
  96323. computeWorldMatrix(): Matrix;
  96324. /**
  96325. * Parse a JSON and creates the camera from the parsed information
  96326. * @param parsedCamera The JSON to parse
  96327. * @param scene The scene to instantiate the camera in
  96328. * @returns the newly constructed camera
  96329. */
  96330. static Parse(parsedCamera: any, scene: Scene): Camera;
  96331. }
  96332. }
  96333. declare module BABYLON {
  96334. /**
  96335. * Class containing static functions to help procedurally build meshes
  96336. */
  96337. export class DiscBuilder {
  96338. /**
  96339. * Creates a plane polygonal mesh. By default, this is a disc
  96340. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  96341. * * 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
  96342. * * 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
  96343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96344. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96346. * @param name defines the name of the mesh
  96347. * @param options defines the options used to create the mesh
  96348. * @param scene defines the hosting scene
  96349. * @returns the plane polygonal mesh
  96350. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  96351. */
  96352. static CreateDisc(name: string, options: {
  96353. radius?: number;
  96354. tessellation?: number;
  96355. arc?: number;
  96356. updatable?: boolean;
  96357. sideOrientation?: number;
  96358. frontUVs?: Vector4;
  96359. backUVs?: Vector4;
  96360. }, scene?: Nullable<Scene>): Mesh;
  96361. }
  96362. }
  96363. declare module BABYLON {
  96364. /**
  96365. * This represents all the required information to add a fresnel effect on a material:
  96366. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96367. */
  96368. export class FresnelParameters {
  96369. private _isEnabled;
  96370. /**
  96371. * Define if the fresnel effect is enable or not.
  96372. */
  96373. get isEnabled(): boolean;
  96374. set isEnabled(value: boolean);
  96375. /**
  96376. * Define the color used on edges (grazing angle)
  96377. */
  96378. leftColor: Color3;
  96379. /**
  96380. * Define the color used on center
  96381. */
  96382. rightColor: Color3;
  96383. /**
  96384. * Define bias applied to computed fresnel term
  96385. */
  96386. bias: number;
  96387. /**
  96388. * Defined the power exponent applied to fresnel term
  96389. */
  96390. power: number;
  96391. /**
  96392. * Clones the current fresnel and its valuues
  96393. * @returns a clone fresnel configuration
  96394. */
  96395. clone(): FresnelParameters;
  96396. /**
  96397. * Serializes the current fresnel parameters to a JSON representation.
  96398. * @return the JSON serialization
  96399. */
  96400. serialize(): any;
  96401. /**
  96402. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  96403. * @param parsedFresnelParameters Define the JSON representation
  96404. * @returns the parsed parameters
  96405. */
  96406. static Parse(parsedFresnelParameters: any): FresnelParameters;
  96407. }
  96408. }
  96409. declare module BABYLON {
  96410. /**
  96411. * Base class of materials working in push mode in babylon JS
  96412. * @hidden
  96413. */
  96414. export class PushMaterial extends Material {
  96415. protected _activeEffect: Effect;
  96416. protected _normalMatrix: Matrix;
  96417. /**
  96418. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  96419. * This means that the material can keep using a previous shader while a new one is being compiled.
  96420. * This is mostly used when shader parallel compilation is supported (true by default)
  96421. */
  96422. allowShaderHotSwapping: boolean;
  96423. constructor(name: string, scene: Scene);
  96424. getEffect(): Effect;
  96425. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  96426. /**
  96427. * Binds the given world matrix to the active effect
  96428. *
  96429. * @param world the matrix to bind
  96430. */
  96431. bindOnlyWorldMatrix(world: Matrix): void;
  96432. /**
  96433. * Binds the given normal matrix to the active effect
  96434. *
  96435. * @param normalMatrix the matrix to bind
  96436. */
  96437. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  96438. bind(world: Matrix, mesh?: Mesh): void;
  96439. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  96440. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  96441. }
  96442. }
  96443. declare module BABYLON {
  96444. /**
  96445. * This groups all the flags used to control the materials channel.
  96446. */
  96447. export class MaterialFlags {
  96448. private static _DiffuseTextureEnabled;
  96449. /**
  96450. * Are diffuse textures enabled in the application.
  96451. */
  96452. static get DiffuseTextureEnabled(): boolean;
  96453. static set DiffuseTextureEnabled(value: boolean);
  96454. private static _AmbientTextureEnabled;
  96455. /**
  96456. * Are ambient textures enabled in the application.
  96457. */
  96458. static get AmbientTextureEnabled(): boolean;
  96459. static set AmbientTextureEnabled(value: boolean);
  96460. private static _OpacityTextureEnabled;
  96461. /**
  96462. * Are opacity textures enabled in the application.
  96463. */
  96464. static get OpacityTextureEnabled(): boolean;
  96465. static set OpacityTextureEnabled(value: boolean);
  96466. private static _ReflectionTextureEnabled;
  96467. /**
  96468. * Are reflection textures enabled in the application.
  96469. */
  96470. static get ReflectionTextureEnabled(): boolean;
  96471. static set ReflectionTextureEnabled(value: boolean);
  96472. private static _EmissiveTextureEnabled;
  96473. /**
  96474. * Are emissive textures enabled in the application.
  96475. */
  96476. static get EmissiveTextureEnabled(): boolean;
  96477. static set EmissiveTextureEnabled(value: boolean);
  96478. private static _SpecularTextureEnabled;
  96479. /**
  96480. * Are specular textures enabled in the application.
  96481. */
  96482. static get SpecularTextureEnabled(): boolean;
  96483. static set SpecularTextureEnabled(value: boolean);
  96484. private static _BumpTextureEnabled;
  96485. /**
  96486. * Are bump textures enabled in the application.
  96487. */
  96488. static get BumpTextureEnabled(): boolean;
  96489. static set BumpTextureEnabled(value: boolean);
  96490. private static _LightmapTextureEnabled;
  96491. /**
  96492. * Are lightmap textures enabled in the application.
  96493. */
  96494. static get LightmapTextureEnabled(): boolean;
  96495. static set LightmapTextureEnabled(value: boolean);
  96496. private static _RefractionTextureEnabled;
  96497. /**
  96498. * Are refraction textures enabled in the application.
  96499. */
  96500. static get RefractionTextureEnabled(): boolean;
  96501. static set RefractionTextureEnabled(value: boolean);
  96502. private static _ColorGradingTextureEnabled;
  96503. /**
  96504. * Are color grading textures enabled in the application.
  96505. */
  96506. static get ColorGradingTextureEnabled(): boolean;
  96507. static set ColorGradingTextureEnabled(value: boolean);
  96508. private static _FresnelEnabled;
  96509. /**
  96510. * Are fresnels enabled in the application.
  96511. */
  96512. static get FresnelEnabled(): boolean;
  96513. static set FresnelEnabled(value: boolean);
  96514. private static _ClearCoatTextureEnabled;
  96515. /**
  96516. * Are clear coat textures enabled in the application.
  96517. */
  96518. static get ClearCoatTextureEnabled(): boolean;
  96519. static set ClearCoatTextureEnabled(value: boolean);
  96520. private static _ClearCoatBumpTextureEnabled;
  96521. /**
  96522. * Are clear coat bump textures enabled in the application.
  96523. */
  96524. static get ClearCoatBumpTextureEnabled(): boolean;
  96525. static set ClearCoatBumpTextureEnabled(value: boolean);
  96526. private static _ClearCoatTintTextureEnabled;
  96527. /**
  96528. * Are clear coat tint textures enabled in the application.
  96529. */
  96530. static get ClearCoatTintTextureEnabled(): boolean;
  96531. static set ClearCoatTintTextureEnabled(value: boolean);
  96532. private static _SheenTextureEnabled;
  96533. /**
  96534. * Are sheen textures enabled in the application.
  96535. */
  96536. static get SheenTextureEnabled(): boolean;
  96537. static set SheenTextureEnabled(value: boolean);
  96538. private static _AnisotropicTextureEnabled;
  96539. /**
  96540. * Are anisotropic textures enabled in the application.
  96541. */
  96542. static get AnisotropicTextureEnabled(): boolean;
  96543. static set AnisotropicTextureEnabled(value: boolean);
  96544. private static _ThicknessTextureEnabled;
  96545. /**
  96546. * Are thickness textures enabled in the application.
  96547. */
  96548. static get ThicknessTextureEnabled(): boolean;
  96549. static set ThicknessTextureEnabled(value: boolean);
  96550. }
  96551. }
  96552. declare module BABYLON {
  96553. /** @hidden */
  96554. export var defaultFragmentDeclaration: {
  96555. name: string;
  96556. shader: string;
  96557. };
  96558. }
  96559. declare module BABYLON {
  96560. /** @hidden */
  96561. export var defaultUboDeclaration: {
  96562. name: string;
  96563. shader: string;
  96564. };
  96565. }
  96566. declare module BABYLON {
  96567. /** @hidden */
  96568. export var lightFragmentDeclaration: {
  96569. name: string;
  96570. shader: string;
  96571. };
  96572. }
  96573. declare module BABYLON {
  96574. /** @hidden */
  96575. export var lightUboDeclaration: {
  96576. name: string;
  96577. shader: string;
  96578. };
  96579. }
  96580. declare module BABYLON {
  96581. /** @hidden */
  96582. export var lightsFragmentFunctions: {
  96583. name: string;
  96584. shader: string;
  96585. };
  96586. }
  96587. declare module BABYLON {
  96588. /** @hidden */
  96589. export var shadowsFragmentFunctions: {
  96590. name: string;
  96591. shader: string;
  96592. };
  96593. }
  96594. declare module BABYLON {
  96595. /** @hidden */
  96596. export var fresnelFunction: {
  96597. name: string;
  96598. shader: string;
  96599. };
  96600. }
  96601. declare module BABYLON {
  96602. /** @hidden */
  96603. export var reflectionFunction: {
  96604. name: string;
  96605. shader: string;
  96606. };
  96607. }
  96608. declare module BABYLON {
  96609. /** @hidden */
  96610. export var bumpFragmentFunctions: {
  96611. name: string;
  96612. shader: string;
  96613. };
  96614. }
  96615. declare module BABYLON {
  96616. /** @hidden */
  96617. export var logDepthDeclaration: {
  96618. name: string;
  96619. shader: string;
  96620. };
  96621. }
  96622. declare module BABYLON {
  96623. /** @hidden */
  96624. export var bumpFragment: {
  96625. name: string;
  96626. shader: string;
  96627. };
  96628. }
  96629. declare module BABYLON {
  96630. /** @hidden */
  96631. export var depthPrePass: {
  96632. name: string;
  96633. shader: string;
  96634. };
  96635. }
  96636. declare module BABYLON {
  96637. /** @hidden */
  96638. export var lightFragment: {
  96639. name: string;
  96640. shader: string;
  96641. };
  96642. }
  96643. declare module BABYLON {
  96644. /** @hidden */
  96645. export var logDepthFragment: {
  96646. name: string;
  96647. shader: string;
  96648. };
  96649. }
  96650. declare module BABYLON {
  96651. /** @hidden */
  96652. export var defaultPixelShader: {
  96653. name: string;
  96654. shader: string;
  96655. };
  96656. }
  96657. declare module BABYLON {
  96658. /** @hidden */
  96659. export var defaultVertexDeclaration: {
  96660. name: string;
  96661. shader: string;
  96662. };
  96663. }
  96664. declare module BABYLON {
  96665. /** @hidden */
  96666. export var bumpVertexDeclaration: {
  96667. name: string;
  96668. shader: string;
  96669. };
  96670. }
  96671. declare module BABYLON {
  96672. /** @hidden */
  96673. export var bumpVertex: {
  96674. name: string;
  96675. shader: string;
  96676. };
  96677. }
  96678. declare module BABYLON {
  96679. /** @hidden */
  96680. export var fogVertex: {
  96681. name: string;
  96682. shader: string;
  96683. };
  96684. }
  96685. declare module BABYLON {
  96686. /** @hidden */
  96687. export var shadowsVertex: {
  96688. name: string;
  96689. shader: string;
  96690. };
  96691. }
  96692. declare module BABYLON {
  96693. /** @hidden */
  96694. export var pointCloudVertex: {
  96695. name: string;
  96696. shader: string;
  96697. };
  96698. }
  96699. declare module BABYLON {
  96700. /** @hidden */
  96701. export var logDepthVertex: {
  96702. name: string;
  96703. shader: string;
  96704. };
  96705. }
  96706. declare module BABYLON {
  96707. /** @hidden */
  96708. export var defaultVertexShader: {
  96709. name: string;
  96710. shader: string;
  96711. };
  96712. }
  96713. declare module BABYLON {
  96714. /** @hidden */
  96715. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  96716. MAINUV1: boolean;
  96717. MAINUV2: boolean;
  96718. DIFFUSE: boolean;
  96719. DIFFUSEDIRECTUV: number;
  96720. AMBIENT: boolean;
  96721. AMBIENTDIRECTUV: number;
  96722. OPACITY: boolean;
  96723. OPACITYDIRECTUV: number;
  96724. OPACITYRGB: boolean;
  96725. REFLECTION: boolean;
  96726. EMISSIVE: boolean;
  96727. EMISSIVEDIRECTUV: number;
  96728. SPECULAR: boolean;
  96729. SPECULARDIRECTUV: number;
  96730. BUMP: boolean;
  96731. BUMPDIRECTUV: number;
  96732. PARALLAX: boolean;
  96733. PARALLAXOCCLUSION: boolean;
  96734. SPECULAROVERALPHA: boolean;
  96735. CLIPPLANE: boolean;
  96736. CLIPPLANE2: boolean;
  96737. CLIPPLANE3: boolean;
  96738. CLIPPLANE4: boolean;
  96739. CLIPPLANE5: boolean;
  96740. CLIPPLANE6: boolean;
  96741. ALPHATEST: boolean;
  96742. DEPTHPREPASS: boolean;
  96743. ALPHAFROMDIFFUSE: boolean;
  96744. POINTSIZE: boolean;
  96745. FOG: boolean;
  96746. SPECULARTERM: boolean;
  96747. DIFFUSEFRESNEL: boolean;
  96748. OPACITYFRESNEL: boolean;
  96749. REFLECTIONFRESNEL: boolean;
  96750. REFRACTIONFRESNEL: boolean;
  96751. EMISSIVEFRESNEL: boolean;
  96752. FRESNEL: boolean;
  96753. NORMAL: boolean;
  96754. UV1: boolean;
  96755. UV2: boolean;
  96756. VERTEXCOLOR: boolean;
  96757. VERTEXALPHA: boolean;
  96758. NUM_BONE_INFLUENCERS: number;
  96759. BonesPerMesh: number;
  96760. BONETEXTURE: boolean;
  96761. INSTANCES: boolean;
  96762. GLOSSINESS: boolean;
  96763. ROUGHNESS: boolean;
  96764. EMISSIVEASILLUMINATION: boolean;
  96765. LINKEMISSIVEWITHDIFFUSE: boolean;
  96766. REFLECTIONFRESNELFROMSPECULAR: boolean;
  96767. LIGHTMAP: boolean;
  96768. LIGHTMAPDIRECTUV: number;
  96769. OBJECTSPACE_NORMALMAP: boolean;
  96770. USELIGHTMAPASSHADOWMAP: boolean;
  96771. REFLECTIONMAP_3D: boolean;
  96772. REFLECTIONMAP_SPHERICAL: boolean;
  96773. REFLECTIONMAP_PLANAR: boolean;
  96774. REFLECTIONMAP_CUBIC: boolean;
  96775. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  96776. REFLECTIONMAP_PROJECTION: boolean;
  96777. REFLECTIONMAP_SKYBOX: boolean;
  96778. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  96779. REFLECTIONMAP_EXPLICIT: boolean;
  96780. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  96781. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  96782. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  96783. INVERTCUBICMAP: boolean;
  96784. LOGARITHMICDEPTH: boolean;
  96785. REFRACTION: boolean;
  96786. REFRACTIONMAP_3D: boolean;
  96787. REFLECTIONOVERALPHA: boolean;
  96788. TWOSIDEDLIGHTING: boolean;
  96789. SHADOWFLOAT: boolean;
  96790. MORPHTARGETS: boolean;
  96791. MORPHTARGETS_NORMAL: boolean;
  96792. MORPHTARGETS_TANGENT: boolean;
  96793. MORPHTARGETS_UV: boolean;
  96794. NUM_MORPH_INFLUENCERS: number;
  96795. NONUNIFORMSCALING: boolean;
  96796. PREMULTIPLYALPHA: boolean;
  96797. IMAGEPROCESSING: boolean;
  96798. VIGNETTE: boolean;
  96799. VIGNETTEBLENDMODEMULTIPLY: boolean;
  96800. VIGNETTEBLENDMODEOPAQUE: boolean;
  96801. TONEMAPPING: boolean;
  96802. TONEMAPPING_ACES: boolean;
  96803. CONTRAST: boolean;
  96804. COLORCURVES: boolean;
  96805. COLORGRADING: boolean;
  96806. COLORGRADING3D: boolean;
  96807. SAMPLER3DGREENDEPTH: boolean;
  96808. SAMPLER3DBGRMAP: boolean;
  96809. IMAGEPROCESSINGPOSTPROCESS: boolean;
  96810. MULTIVIEW: boolean;
  96811. /**
  96812. * If the reflection texture on this material is in linear color space
  96813. * @hidden
  96814. */
  96815. IS_REFLECTION_LINEAR: boolean;
  96816. /**
  96817. * If the refraction texture on this material is in linear color space
  96818. * @hidden
  96819. */
  96820. IS_REFRACTION_LINEAR: boolean;
  96821. EXPOSURE: boolean;
  96822. constructor();
  96823. setReflectionMode(modeToEnable: string): void;
  96824. }
  96825. /**
  96826. * This is the default material used in Babylon. It is the best trade off between quality
  96827. * and performances.
  96828. * @see http://doc.babylonjs.com/babylon101/materials
  96829. */
  96830. export class StandardMaterial extends PushMaterial {
  96831. private _diffuseTexture;
  96832. /**
  96833. * The basic texture of the material as viewed under a light.
  96834. */
  96835. diffuseTexture: Nullable<BaseTexture>;
  96836. private _ambientTexture;
  96837. /**
  96838. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  96839. */
  96840. ambientTexture: Nullable<BaseTexture>;
  96841. private _opacityTexture;
  96842. /**
  96843. * Define the transparency of the material from a texture.
  96844. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  96845. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  96846. */
  96847. opacityTexture: Nullable<BaseTexture>;
  96848. private _reflectionTexture;
  96849. /**
  96850. * Define the texture used to display the reflection.
  96851. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96852. */
  96853. reflectionTexture: Nullable<BaseTexture>;
  96854. private _emissiveTexture;
  96855. /**
  96856. * Define texture of the material as if self lit.
  96857. * This will be mixed in the final result even in the absence of light.
  96858. */
  96859. emissiveTexture: Nullable<BaseTexture>;
  96860. private _specularTexture;
  96861. /**
  96862. * Define how the color and intensity of the highlight given by the light in the material.
  96863. */
  96864. specularTexture: Nullable<BaseTexture>;
  96865. private _bumpTexture;
  96866. /**
  96867. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  96868. * 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.
  96869. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  96870. */
  96871. bumpTexture: Nullable<BaseTexture>;
  96872. private _lightmapTexture;
  96873. /**
  96874. * Complex lighting can be computationally expensive to compute at runtime.
  96875. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  96876. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  96877. */
  96878. lightmapTexture: Nullable<BaseTexture>;
  96879. private _refractionTexture;
  96880. /**
  96881. * Define the texture used to display the refraction.
  96882. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96883. */
  96884. refractionTexture: Nullable<BaseTexture>;
  96885. /**
  96886. * The color of the material lit by the environmental background lighting.
  96887. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  96888. */
  96889. ambientColor: Color3;
  96890. /**
  96891. * The basic color of the material as viewed under a light.
  96892. */
  96893. diffuseColor: Color3;
  96894. /**
  96895. * Define how the color and intensity of the highlight given by the light in the material.
  96896. */
  96897. specularColor: Color3;
  96898. /**
  96899. * Define the color of the material as if self lit.
  96900. * This will be mixed in the final result even in the absence of light.
  96901. */
  96902. emissiveColor: Color3;
  96903. /**
  96904. * Defines how sharp are the highlights in the material.
  96905. * The bigger the value the sharper giving a more glossy feeling to the result.
  96906. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  96907. */
  96908. specularPower: number;
  96909. private _useAlphaFromDiffuseTexture;
  96910. /**
  96911. * Does the transparency come from the diffuse texture alpha channel.
  96912. */
  96913. useAlphaFromDiffuseTexture: boolean;
  96914. private _useEmissiveAsIllumination;
  96915. /**
  96916. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  96917. */
  96918. useEmissiveAsIllumination: boolean;
  96919. private _linkEmissiveWithDiffuse;
  96920. /**
  96921. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  96922. * the emissive level when the final color is close to one.
  96923. */
  96924. linkEmissiveWithDiffuse: boolean;
  96925. private _useSpecularOverAlpha;
  96926. /**
  96927. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  96928. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  96929. */
  96930. useSpecularOverAlpha: boolean;
  96931. private _useReflectionOverAlpha;
  96932. /**
  96933. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  96934. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  96935. */
  96936. useReflectionOverAlpha: boolean;
  96937. private _disableLighting;
  96938. /**
  96939. * Does lights from the scene impacts this material.
  96940. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  96941. */
  96942. disableLighting: boolean;
  96943. private _useObjectSpaceNormalMap;
  96944. /**
  96945. * Allows using an object space normal map (instead of tangent space).
  96946. */
  96947. useObjectSpaceNormalMap: boolean;
  96948. private _useParallax;
  96949. /**
  96950. * Is parallax enabled or not.
  96951. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  96952. */
  96953. useParallax: boolean;
  96954. private _useParallaxOcclusion;
  96955. /**
  96956. * Is parallax occlusion enabled or not.
  96957. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  96958. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  96959. */
  96960. useParallaxOcclusion: boolean;
  96961. /**
  96962. * 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.
  96963. */
  96964. parallaxScaleBias: number;
  96965. private _roughness;
  96966. /**
  96967. * Helps to define how blurry the reflections should appears in the material.
  96968. */
  96969. roughness: number;
  96970. /**
  96971. * In case of refraction, define the value of the index of refraction.
  96972. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96973. */
  96974. indexOfRefraction: number;
  96975. /**
  96976. * Invert the refraction texture alongside the y axis.
  96977. * It can be useful with procedural textures or probe for instance.
  96978. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96979. */
  96980. invertRefractionY: boolean;
  96981. /**
  96982. * Defines the alpha limits in alpha test mode.
  96983. */
  96984. alphaCutOff: number;
  96985. private _useLightmapAsShadowmap;
  96986. /**
  96987. * In case of light mapping, define whether the map contains light or shadow informations.
  96988. */
  96989. useLightmapAsShadowmap: boolean;
  96990. private _diffuseFresnelParameters;
  96991. /**
  96992. * Define the diffuse fresnel parameters of the material.
  96993. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96994. */
  96995. diffuseFresnelParameters: FresnelParameters;
  96996. private _opacityFresnelParameters;
  96997. /**
  96998. * Define the opacity fresnel parameters of the material.
  96999. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97000. */
  97001. opacityFresnelParameters: FresnelParameters;
  97002. private _reflectionFresnelParameters;
  97003. /**
  97004. * Define the reflection fresnel parameters of the material.
  97005. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97006. */
  97007. reflectionFresnelParameters: FresnelParameters;
  97008. private _refractionFresnelParameters;
  97009. /**
  97010. * Define the refraction fresnel parameters of the material.
  97011. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97012. */
  97013. refractionFresnelParameters: FresnelParameters;
  97014. private _emissiveFresnelParameters;
  97015. /**
  97016. * Define the emissive fresnel parameters of the material.
  97017. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97018. */
  97019. emissiveFresnelParameters: FresnelParameters;
  97020. private _useReflectionFresnelFromSpecular;
  97021. /**
  97022. * If true automatically deducts the fresnels values from the material specularity.
  97023. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97024. */
  97025. useReflectionFresnelFromSpecular: boolean;
  97026. private _useGlossinessFromSpecularMapAlpha;
  97027. /**
  97028. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  97029. */
  97030. useGlossinessFromSpecularMapAlpha: boolean;
  97031. private _maxSimultaneousLights;
  97032. /**
  97033. * Defines the maximum number of lights that can be used in the material
  97034. */
  97035. maxSimultaneousLights: number;
  97036. private _invertNormalMapX;
  97037. /**
  97038. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  97039. */
  97040. invertNormalMapX: boolean;
  97041. private _invertNormalMapY;
  97042. /**
  97043. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  97044. */
  97045. invertNormalMapY: boolean;
  97046. private _twoSidedLighting;
  97047. /**
  97048. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  97049. */
  97050. twoSidedLighting: boolean;
  97051. /**
  97052. * Default configuration related to image processing available in the standard Material.
  97053. */
  97054. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  97055. /**
  97056. * Gets the image processing configuration used either in this material.
  97057. */
  97058. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  97059. /**
  97060. * Sets the Default image processing configuration used either in the this material.
  97061. *
  97062. * If sets to null, the scene one is in use.
  97063. */
  97064. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  97065. /**
  97066. * Keep track of the image processing observer to allow dispose and replace.
  97067. */
  97068. private _imageProcessingObserver;
  97069. /**
  97070. * Attaches a new image processing configuration to the Standard Material.
  97071. * @param configuration
  97072. */
  97073. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  97074. /**
  97075. * Gets wether the color curves effect is enabled.
  97076. */
  97077. get cameraColorCurvesEnabled(): boolean;
  97078. /**
  97079. * Sets wether the color curves effect is enabled.
  97080. */
  97081. set cameraColorCurvesEnabled(value: boolean);
  97082. /**
  97083. * Gets wether the color grading effect is enabled.
  97084. */
  97085. get cameraColorGradingEnabled(): boolean;
  97086. /**
  97087. * Gets wether the color grading effect is enabled.
  97088. */
  97089. set cameraColorGradingEnabled(value: boolean);
  97090. /**
  97091. * Gets wether tonemapping is enabled or not.
  97092. */
  97093. get cameraToneMappingEnabled(): boolean;
  97094. /**
  97095. * Sets wether tonemapping is enabled or not
  97096. */
  97097. set cameraToneMappingEnabled(value: boolean);
  97098. /**
  97099. * The camera exposure used on this material.
  97100. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  97101. * This corresponds to a photographic exposure.
  97102. */
  97103. get cameraExposure(): number;
  97104. /**
  97105. * The camera exposure used on this material.
  97106. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  97107. * This corresponds to a photographic exposure.
  97108. */
  97109. set cameraExposure(value: number);
  97110. /**
  97111. * Gets The camera contrast used on this material.
  97112. */
  97113. get cameraContrast(): number;
  97114. /**
  97115. * Sets The camera contrast used on this material.
  97116. */
  97117. set cameraContrast(value: number);
  97118. /**
  97119. * Gets the Color Grading 2D Lookup Texture.
  97120. */
  97121. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  97122. /**
  97123. * Sets the Color Grading 2D Lookup Texture.
  97124. */
  97125. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  97126. /**
  97127. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  97128. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  97129. * 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;
  97130. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  97131. */
  97132. get cameraColorCurves(): Nullable<ColorCurves>;
  97133. /**
  97134. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  97135. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  97136. * 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;
  97137. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  97138. */
  97139. set cameraColorCurves(value: Nullable<ColorCurves>);
  97140. /**
  97141. * Custom callback helping to override the default shader used in the material.
  97142. */
  97143. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  97144. protected _renderTargets: SmartArray<RenderTargetTexture>;
  97145. protected _worldViewProjectionMatrix: Matrix;
  97146. protected _globalAmbientColor: Color3;
  97147. protected _useLogarithmicDepth: boolean;
  97148. protected _rebuildInParallel: boolean;
  97149. /**
  97150. * Instantiates a new standard material.
  97151. * This is the default material used in Babylon. It is the best trade off between quality
  97152. * and performances.
  97153. * @see http://doc.babylonjs.com/babylon101/materials
  97154. * @param name Define the name of the material in the scene
  97155. * @param scene Define the scene the material belong to
  97156. */
  97157. constructor(name: string, scene: Scene);
  97158. /**
  97159. * Gets a boolean indicating that current material needs to register RTT
  97160. */
  97161. get hasRenderTargetTextures(): boolean;
  97162. /**
  97163. * Gets the current class name of the material e.g. "StandardMaterial"
  97164. * Mainly use in serialization.
  97165. * @returns the class name
  97166. */
  97167. getClassName(): string;
  97168. /**
  97169. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  97170. * You can try switching to logarithmic depth.
  97171. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  97172. */
  97173. get useLogarithmicDepth(): boolean;
  97174. set useLogarithmicDepth(value: boolean);
  97175. /**
  97176. * Specifies if the material will require alpha blending
  97177. * @returns a boolean specifying if alpha blending is needed
  97178. */
  97179. needAlphaBlending(): boolean;
  97180. /**
  97181. * Specifies if this material should be rendered in alpha test mode
  97182. * @returns a boolean specifying if an alpha test is needed.
  97183. */
  97184. needAlphaTesting(): boolean;
  97185. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  97186. /**
  97187. * Get the texture used for alpha test purpose.
  97188. * @returns the diffuse texture in case of the standard material.
  97189. */
  97190. getAlphaTestTexture(): Nullable<BaseTexture>;
  97191. /**
  97192. * Get if the submesh is ready to be used and all its information available.
  97193. * Child classes can use it to update shaders
  97194. * @param mesh defines the mesh to check
  97195. * @param subMesh defines which submesh to check
  97196. * @param useInstances specifies that instances should be used
  97197. * @returns a boolean indicating that the submesh is ready or not
  97198. */
  97199. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97200. /**
  97201. * Builds the material UBO layouts.
  97202. * Used internally during the effect preparation.
  97203. */
  97204. buildUniformLayout(): void;
  97205. /**
  97206. * Unbinds the material from the mesh
  97207. */
  97208. unbind(): void;
  97209. /**
  97210. * Binds the submesh to this material by preparing the effect and shader to draw
  97211. * @param world defines the world transformation matrix
  97212. * @param mesh defines the mesh containing the submesh
  97213. * @param subMesh defines the submesh to bind the material to
  97214. */
  97215. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97216. /**
  97217. * Get the list of animatables in the material.
  97218. * @returns the list of animatables object used in the material
  97219. */
  97220. getAnimatables(): IAnimatable[];
  97221. /**
  97222. * Gets the active textures from the material
  97223. * @returns an array of textures
  97224. */
  97225. getActiveTextures(): BaseTexture[];
  97226. /**
  97227. * Specifies if the material uses a texture
  97228. * @param texture defines the texture to check against the material
  97229. * @returns a boolean specifying if the material uses the texture
  97230. */
  97231. hasTexture(texture: BaseTexture): boolean;
  97232. /**
  97233. * Disposes the material
  97234. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97235. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97236. */
  97237. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  97238. /**
  97239. * Makes a duplicate of the material, and gives it a new name
  97240. * @param name defines the new name for the duplicated material
  97241. * @returns the cloned material
  97242. */
  97243. clone(name: string): StandardMaterial;
  97244. /**
  97245. * Serializes this material in a JSON representation
  97246. * @returns the serialized material object
  97247. */
  97248. serialize(): any;
  97249. /**
  97250. * Creates a standard material from parsed material data
  97251. * @param source defines the JSON representation of the material
  97252. * @param scene defines the hosting scene
  97253. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97254. * @returns a new standard material
  97255. */
  97256. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  97257. /**
  97258. * Are diffuse textures enabled in the application.
  97259. */
  97260. static get DiffuseTextureEnabled(): boolean;
  97261. static set DiffuseTextureEnabled(value: boolean);
  97262. /**
  97263. * Are ambient textures enabled in the application.
  97264. */
  97265. static get AmbientTextureEnabled(): boolean;
  97266. static set AmbientTextureEnabled(value: boolean);
  97267. /**
  97268. * Are opacity textures enabled in the application.
  97269. */
  97270. static get OpacityTextureEnabled(): boolean;
  97271. static set OpacityTextureEnabled(value: boolean);
  97272. /**
  97273. * Are reflection textures enabled in the application.
  97274. */
  97275. static get ReflectionTextureEnabled(): boolean;
  97276. static set ReflectionTextureEnabled(value: boolean);
  97277. /**
  97278. * Are emissive textures enabled in the application.
  97279. */
  97280. static get EmissiveTextureEnabled(): boolean;
  97281. static set EmissiveTextureEnabled(value: boolean);
  97282. /**
  97283. * Are specular textures enabled in the application.
  97284. */
  97285. static get SpecularTextureEnabled(): boolean;
  97286. static set SpecularTextureEnabled(value: boolean);
  97287. /**
  97288. * Are bump textures enabled in the application.
  97289. */
  97290. static get BumpTextureEnabled(): boolean;
  97291. static set BumpTextureEnabled(value: boolean);
  97292. /**
  97293. * Are lightmap textures enabled in the application.
  97294. */
  97295. static get LightmapTextureEnabled(): boolean;
  97296. static set LightmapTextureEnabled(value: boolean);
  97297. /**
  97298. * Are refraction textures enabled in the application.
  97299. */
  97300. static get RefractionTextureEnabled(): boolean;
  97301. static set RefractionTextureEnabled(value: boolean);
  97302. /**
  97303. * Are color grading textures enabled in the application.
  97304. */
  97305. static get ColorGradingTextureEnabled(): boolean;
  97306. static set ColorGradingTextureEnabled(value: boolean);
  97307. /**
  97308. * Are fresnels enabled in the application.
  97309. */
  97310. static get FresnelEnabled(): boolean;
  97311. static set FresnelEnabled(value: boolean);
  97312. }
  97313. }
  97314. declare module BABYLON {
  97315. /**
  97316. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  97317. *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.
  97318. * The SPS is also a particle system. It provides some methods to manage the particles.
  97319. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  97320. *
  97321. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  97322. */
  97323. export class SolidParticleSystem implements IDisposable {
  97324. /**
  97325. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  97326. * Example : var p = SPS.particles[i];
  97327. */
  97328. particles: SolidParticle[];
  97329. /**
  97330. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  97331. */
  97332. nbParticles: number;
  97333. /**
  97334. * If the particles must ever face the camera (default false). Useful for planar particles.
  97335. */
  97336. billboard: boolean;
  97337. /**
  97338. * Recompute normals when adding a shape
  97339. */
  97340. recomputeNormals: boolean;
  97341. /**
  97342. * This a counter ofr your own usage. It's not set by any SPS functions.
  97343. */
  97344. counter: number;
  97345. /**
  97346. * The SPS name. This name is also given to the underlying mesh.
  97347. */
  97348. name: string;
  97349. /**
  97350. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  97351. */
  97352. mesh: Mesh;
  97353. /**
  97354. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  97355. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  97356. */
  97357. vars: any;
  97358. /**
  97359. * This array is populated when the SPS is set as 'pickable'.
  97360. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  97361. * Each element of this array is an object `{idx: int, faceId: int}`.
  97362. * `idx` is the picked particle index in the `SPS.particles` array
  97363. * `faceId` is the picked face index counted within this particle.
  97364. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  97365. */
  97366. pickedParticles: {
  97367. idx: number;
  97368. faceId: number;
  97369. }[];
  97370. /**
  97371. * This array is populated when `enableDepthSort` is set to true.
  97372. * Each element of this array is an instance of the class DepthSortedParticle.
  97373. */
  97374. depthSortedParticles: DepthSortedParticle[];
  97375. /**
  97376. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  97377. * @hidden
  97378. */
  97379. _bSphereOnly: boolean;
  97380. /**
  97381. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  97382. * @hidden
  97383. */
  97384. _bSphereRadiusFactor: number;
  97385. private _scene;
  97386. private _positions;
  97387. private _indices;
  97388. private _normals;
  97389. private _colors;
  97390. private _uvs;
  97391. private _indices32;
  97392. private _positions32;
  97393. private _normals32;
  97394. private _fixedNormal32;
  97395. private _colors32;
  97396. private _uvs32;
  97397. private _index;
  97398. private _updatable;
  97399. private _pickable;
  97400. private _isVisibilityBoxLocked;
  97401. private _alwaysVisible;
  97402. private _depthSort;
  97403. private _expandable;
  97404. private _shapeCounter;
  97405. private _copy;
  97406. private _color;
  97407. private _computeParticleColor;
  97408. private _computeParticleTexture;
  97409. private _computeParticleRotation;
  97410. private _computeParticleVertex;
  97411. private _computeBoundingBox;
  97412. private _depthSortParticles;
  97413. private _camera;
  97414. private _mustUnrotateFixedNormals;
  97415. private _particlesIntersect;
  97416. private _needs32Bits;
  97417. private _isNotBuilt;
  97418. private _lastParticleId;
  97419. private _idxOfId;
  97420. private _multimaterialEnabled;
  97421. private _useModelMaterial;
  97422. private _indicesByMaterial;
  97423. private _materialIndexes;
  97424. private _depthSortFunction;
  97425. private _materialSortFunction;
  97426. private _materials;
  97427. private _multimaterial;
  97428. private _materialIndexesById;
  97429. private _defaultMaterial;
  97430. private _autoUpdateSubMeshes;
  97431. /**
  97432. * Creates a SPS (Solid Particle System) object.
  97433. * @param name (String) is the SPS name, this will be the underlying mesh name.
  97434. * @param scene (Scene) is the scene in which the SPS is added.
  97435. * @param options defines the options of the sps e.g.
  97436. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  97437. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  97438. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  97439. * * 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.
  97440. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  97441. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  97442. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  97443. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  97444. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  97445. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  97446. */
  97447. constructor(name: string, scene: Scene, options?: {
  97448. updatable?: boolean;
  97449. isPickable?: boolean;
  97450. enableDepthSort?: boolean;
  97451. particleIntersection?: boolean;
  97452. boundingSphereOnly?: boolean;
  97453. bSphereRadiusFactor?: number;
  97454. expandable?: boolean;
  97455. useModelMaterial?: boolean;
  97456. enableMultiMaterial?: boolean;
  97457. });
  97458. /**
  97459. * Builds the SPS underlying mesh. Returns a standard Mesh.
  97460. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  97461. * @returns the created mesh
  97462. */
  97463. buildMesh(): Mesh;
  97464. /**
  97465. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  97466. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  97467. * Thus the particles generated from `digest()` have their property `position` set yet.
  97468. * @param mesh ( Mesh ) is the mesh to be digested
  97469. * @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
  97470. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  97471. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  97472. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  97473. * @returns the current SPS
  97474. */
  97475. digest(mesh: Mesh, options?: {
  97476. facetNb?: number;
  97477. number?: number;
  97478. delta?: number;
  97479. storage?: [];
  97480. }): SolidParticleSystem;
  97481. /**
  97482. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  97483. * @hidden
  97484. */
  97485. private _unrotateFixedNormals;
  97486. /**
  97487. * Resets the temporary working copy particle
  97488. * @hidden
  97489. */
  97490. private _resetCopy;
  97491. /**
  97492. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  97493. * @param p the current index in the positions array to be updated
  97494. * @param ind the current index in the indices array
  97495. * @param shape a Vector3 array, the shape geometry
  97496. * @param positions the positions array to be updated
  97497. * @param meshInd the shape indices array
  97498. * @param indices the indices array to be updated
  97499. * @param meshUV the shape uv array
  97500. * @param uvs the uv array to be updated
  97501. * @param meshCol the shape color array
  97502. * @param colors the color array to be updated
  97503. * @param meshNor the shape normals array
  97504. * @param normals the normals array to be updated
  97505. * @param idx the particle index
  97506. * @param idxInShape the particle index in its shape
  97507. * @param options the addShape() method passed options
  97508. * @model the particle model
  97509. * @hidden
  97510. */
  97511. private _meshBuilder;
  97512. /**
  97513. * Returns a shape Vector3 array from positions float array
  97514. * @param positions float array
  97515. * @returns a vector3 array
  97516. * @hidden
  97517. */
  97518. private _posToShape;
  97519. /**
  97520. * Returns a shapeUV array from a float uvs (array deep copy)
  97521. * @param uvs as a float array
  97522. * @returns a shapeUV array
  97523. * @hidden
  97524. */
  97525. private _uvsToShapeUV;
  97526. /**
  97527. * Adds a new particle object in the particles array
  97528. * @param idx particle index in particles array
  97529. * @param id particle id
  97530. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  97531. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  97532. * @param model particle ModelShape object
  97533. * @param shapeId model shape identifier
  97534. * @param idxInShape index of the particle in the current model
  97535. * @param bInfo model bounding info object
  97536. * @param storage target storage array, if any
  97537. * @hidden
  97538. */
  97539. private _addParticle;
  97540. /**
  97541. * Adds some particles to the SPS from the model shape. Returns the shape id.
  97542. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  97543. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  97544. * @param nb (positive integer) the number of particles to be created from this model
  97545. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  97546. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  97547. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  97548. * @returns the number of shapes in the system
  97549. */
  97550. addShape(mesh: Mesh, nb: number, options?: {
  97551. positionFunction?: any;
  97552. vertexFunction?: any;
  97553. storage?: [];
  97554. }): number;
  97555. /**
  97556. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  97557. * @hidden
  97558. */
  97559. private _rebuildParticle;
  97560. /**
  97561. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  97562. * @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.
  97563. * @returns the SPS.
  97564. */
  97565. rebuildMesh(reset?: boolean): SolidParticleSystem;
  97566. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  97567. * Returns an array with the removed particles.
  97568. * 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.
  97569. * The SPS can't be empty so at least one particle needs to remain in place.
  97570. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  97571. * @param start index of the first particle to remove
  97572. * @param end index of the last particle to remove (included)
  97573. * @returns an array populated with the removed particles
  97574. */
  97575. removeParticles(start: number, end: number): SolidParticle[];
  97576. /**
  97577. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  97578. * @param solidParticleArray an array populated with Solid Particles objects
  97579. * @returns the SPS
  97580. */
  97581. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  97582. /**
  97583. * Creates a new particle and modifies the SPS mesh geometry :
  97584. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  97585. * - calls _addParticle() to populate the particle array
  97586. * factorized code from addShape() and insertParticlesFromArray()
  97587. * @param idx particle index in the particles array
  97588. * @param i particle index in its shape
  97589. * @param modelShape particle ModelShape object
  97590. * @param shape shape vertex array
  97591. * @param meshInd shape indices array
  97592. * @param meshUV shape uv array
  97593. * @param meshCol shape color array
  97594. * @param meshNor shape normals array
  97595. * @param bbInfo shape bounding info
  97596. * @param storage target particle storage
  97597. * @options addShape() passed options
  97598. * @hidden
  97599. */
  97600. private _insertNewParticle;
  97601. /**
  97602. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  97603. * This method calls `updateParticle()` for each particle of the SPS.
  97604. * For an animated SPS, it is usually called within the render loop.
  97605. * 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.
  97606. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  97607. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  97608. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  97609. * @returns the SPS.
  97610. */
  97611. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  97612. /**
  97613. * Disposes the SPS.
  97614. */
  97615. dispose(): void;
  97616. /**
  97617. * Returns a SolidParticle object from its identifier : particle.id
  97618. * @param id (integer) the particle Id
  97619. * @returns the searched particle or null if not found in the SPS.
  97620. */
  97621. getParticleById(id: number): Nullable<SolidParticle>;
  97622. /**
  97623. * Returns a new array populated with the particles having the passed shapeId.
  97624. * @param shapeId (integer) the shape identifier
  97625. * @returns a new solid particle array
  97626. */
  97627. getParticlesByShapeId(shapeId: number): SolidParticle[];
  97628. /**
  97629. * Populates the passed array "ref" with the particles having the passed shapeId.
  97630. * @param shapeId the shape identifier
  97631. * @returns the SPS
  97632. * @param ref
  97633. */
  97634. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  97635. /**
  97636. * Computes the required SubMeshes according the materials assigned to the particles.
  97637. * @returns the solid particle system.
  97638. * Does nothing if called before the SPS mesh is built.
  97639. */
  97640. computeSubMeshes(): SolidParticleSystem;
  97641. /**
  97642. * Sorts the solid particles by material when MultiMaterial is enabled.
  97643. * Updates the indices32 array.
  97644. * Updates the indicesByMaterial array.
  97645. * Updates the mesh indices array.
  97646. * @returns the SPS
  97647. * @hidden
  97648. */
  97649. private _sortParticlesByMaterial;
  97650. /**
  97651. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  97652. * @hidden
  97653. */
  97654. private _setMaterialIndexesById;
  97655. /**
  97656. * Returns an array with unique values of Materials from the passed array
  97657. * @param array the material array to be checked and filtered
  97658. * @hidden
  97659. */
  97660. private _filterUniqueMaterialId;
  97661. /**
  97662. * Sets a new Standard Material as _defaultMaterial if not already set.
  97663. * @hidden
  97664. */
  97665. private _setDefaultMaterial;
  97666. /**
  97667. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  97668. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97669. * @returns the SPS.
  97670. */
  97671. refreshVisibleSize(): SolidParticleSystem;
  97672. /**
  97673. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  97674. * @param size the size (float) of the visibility box
  97675. * note : this doesn't lock the SPS mesh bounding box.
  97676. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97677. */
  97678. setVisibilityBox(size: number): void;
  97679. /**
  97680. * Gets whether the SPS as always visible or not
  97681. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97682. */
  97683. get isAlwaysVisible(): boolean;
  97684. /**
  97685. * Sets the SPS as always visible or not
  97686. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97687. */
  97688. set isAlwaysVisible(val: boolean);
  97689. /**
  97690. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  97691. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97692. */
  97693. set isVisibilityBoxLocked(val: boolean);
  97694. /**
  97695. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  97696. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97697. */
  97698. get isVisibilityBoxLocked(): boolean;
  97699. /**
  97700. * Tells to `setParticles()` to compute the particle rotations or not.
  97701. * Default value : true. The SPS is faster when it's set to false.
  97702. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  97703. */
  97704. set computeParticleRotation(val: boolean);
  97705. /**
  97706. * Tells to `setParticles()` to compute the particle colors or not.
  97707. * Default value : true. The SPS is faster when it's set to false.
  97708. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  97709. */
  97710. set computeParticleColor(val: boolean);
  97711. set computeParticleTexture(val: boolean);
  97712. /**
  97713. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  97714. * Default value : false. The SPS is faster when it's set to false.
  97715. * Note : the particle custom vertex positions aren't stored values.
  97716. */
  97717. set computeParticleVertex(val: boolean);
  97718. /**
  97719. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  97720. */
  97721. set computeBoundingBox(val: boolean);
  97722. /**
  97723. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  97724. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  97725. * Default : `true`
  97726. */
  97727. set depthSortParticles(val: boolean);
  97728. /**
  97729. * Gets if `setParticles()` computes the particle rotations or not.
  97730. * Default value : true. The SPS is faster when it's set to false.
  97731. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  97732. */
  97733. get computeParticleRotation(): boolean;
  97734. /**
  97735. * Gets if `setParticles()` computes the particle colors or not.
  97736. * Default value : true. The SPS is faster when it's set to false.
  97737. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  97738. */
  97739. get computeParticleColor(): boolean;
  97740. /**
  97741. * Gets if `setParticles()` computes the particle textures or not.
  97742. * Default value : true. The SPS is faster when it's set to false.
  97743. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  97744. */
  97745. get computeParticleTexture(): boolean;
  97746. /**
  97747. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  97748. * Default value : false. The SPS is faster when it's set to false.
  97749. * Note : the particle custom vertex positions aren't stored values.
  97750. */
  97751. get computeParticleVertex(): boolean;
  97752. /**
  97753. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  97754. */
  97755. get computeBoundingBox(): boolean;
  97756. /**
  97757. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  97758. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  97759. * Default : `true`
  97760. */
  97761. get depthSortParticles(): boolean;
  97762. /**
  97763. * Gets if the SPS is created as expandable at construction time.
  97764. * Default : `false`
  97765. */
  97766. get expandable(): boolean;
  97767. /**
  97768. * Gets if the SPS supports the Multi Materials
  97769. */
  97770. get multimaterialEnabled(): boolean;
  97771. /**
  97772. * Gets if the SPS uses the model materials for its own multimaterial.
  97773. */
  97774. get useModelMaterial(): boolean;
  97775. /**
  97776. * The SPS used material array.
  97777. */
  97778. get materials(): Material[];
  97779. /**
  97780. * Sets the SPS MultiMaterial from the passed materials.
  97781. * Note : the passed array is internally copied and not used then by reference.
  97782. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  97783. */
  97784. setMultiMaterial(materials: Material[]): void;
  97785. /**
  97786. * The SPS computed multimaterial object
  97787. */
  97788. get multimaterial(): MultiMaterial;
  97789. set multimaterial(mm: MultiMaterial);
  97790. /**
  97791. * If the subMeshes must be updated on the next call to setParticles()
  97792. */
  97793. get autoUpdateSubMeshes(): boolean;
  97794. set autoUpdateSubMeshes(val: boolean);
  97795. /**
  97796. * This function does nothing. It may be overwritten to set all the particle first values.
  97797. * The SPS doesn't call this function, you may have to call it by your own.
  97798. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  97799. */
  97800. initParticles(): void;
  97801. /**
  97802. * This function does nothing. It may be overwritten to recycle a particle.
  97803. * The SPS doesn't call this function, you may have to call it by your own.
  97804. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  97805. * @param particle The particle to recycle
  97806. * @returns the recycled particle
  97807. */
  97808. recycleParticle(particle: SolidParticle): SolidParticle;
  97809. /**
  97810. * Updates a particle : this function should be overwritten by the user.
  97811. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  97812. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  97813. * @example : just set a particle position or velocity and recycle conditions
  97814. * @param particle The particle to update
  97815. * @returns the updated particle
  97816. */
  97817. updateParticle(particle: SolidParticle): SolidParticle;
  97818. /**
  97819. * Updates a vertex of a particle : it can be overwritten by the user.
  97820. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  97821. * @param particle the current particle
  97822. * @param vertex the current index of the current particle
  97823. * @param pt the index of the current vertex in the particle shape
  97824. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  97825. * @example : just set a vertex particle position
  97826. * @returns the updated vertex
  97827. */
  97828. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  97829. /**
  97830. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  97831. * This does nothing and may be overwritten by the user.
  97832. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  97833. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  97834. * @param update the boolean update value actually passed to setParticles()
  97835. */
  97836. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  97837. /**
  97838. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  97839. * This will be passed three parameters.
  97840. * This does nothing and may be overwritten by the user.
  97841. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  97842. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  97843. * @param update the boolean update value actually passed to setParticles()
  97844. */
  97845. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  97846. }
  97847. }
  97848. declare module BABYLON {
  97849. /**
  97850. * Represents one particle of a solid particle system.
  97851. */
  97852. export class SolidParticle {
  97853. /**
  97854. * particle global index
  97855. */
  97856. idx: number;
  97857. /**
  97858. * particle identifier
  97859. */
  97860. id: number;
  97861. /**
  97862. * The color of the particle
  97863. */
  97864. color: Nullable<Color4>;
  97865. /**
  97866. * The world space position of the particle.
  97867. */
  97868. position: Vector3;
  97869. /**
  97870. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  97871. */
  97872. rotation: Vector3;
  97873. /**
  97874. * The world space rotation quaternion of the particle.
  97875. */
  97876. rotationQuaternion: Nullable<Quaternion>;
  97877. /**
  97878. * The scaling of the particle.
  97879. */
  97880. scaling: Vector3;
  97881. /**
  97882. * The uvs of the particle.
  97883. */
  97884. uvs: Vector4;
  97885. /**
  97886. * The current speed of the particle.
  97887. */
  97888. velocity: Vector3;
  97889. /**
  97890. * The pivot point in the particle local space.
  97891. */
  97892. pivot: Vector3;
  97893. /**
  97894. * Must the particle be translated from its pivot point in its local space ?
  97895. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  97896. * Default : false
  97897. */
  97898. translateFromPivot: boolean;
  97899. /**
  97900. * Is the particle active or not ?
  97901. */
  97902. alive: boolean;
  97903. /**
  97904. * Is the particle visible or not ?
  97905. */
  97906. isVisible: boolean;
  97907. /**
  97908. * Index of this particle in the global "positions" array (Internal use)
  97909. * @hidden
  97910. */
  97911. _pos: number;
  97912. /**
  97913. * @hidden Index of this particle in the global "indices" array (Internal use)
  97914. */
  97915. _ind: number;
  97916. /**
  97917. * @hidden ModelShape of this particle (Internal use)
  97918. */
  97919. _model: ModelShape;
  97920. /**
  97921. * ModelShape id of this particle
  97922. */
  97923. shapeId: number;
  97924. /**
  97925. * Index of the particle in its shape id
  97926. */
  97927. idxInShape: number;
  97928. /**
  97929. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  97930. */
  97931. _modelBoundingInfo: BoundingInfo;
  97932. /**
  97933. * @hidden Particle BoundingInfo object (Internal use)
  97934. */
  97935. _boundingInfo: BoundingInfo;
  97936. /**
  97937. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  97938. */
  97939. _sps: SolidParticleSystem;
  97940. /**
  97941. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  97942. */
  97943. _stillInvisible: boolean;
  97944. /**
  97945. * @hidden Last computed particle rotation matrix
  97946. */
  97947. _rotationMatrix: number[];
  97948. /**
  97949. * Parent particle Id, if any.
  97950. * Default null.
  97951. */
  97952. parentId: Nullable<number>;
  97953. /**
  97954. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  97955. */
  97956. materialIndex: Nullable<number>;
  97957. /**
  97958. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  97959. * The possible values are :
  97960. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  97961. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  97962. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  97963. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  97964. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  97965. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  97966. * */
  97967. cullingStrategy: number;
  97968. /**
  97969. * @hidden Internal global position in the SPS.
  97970. */
  97971. _globalPosition: Vector3;
  97972. /**
  97973. * Creates a Solid Particle object.
  97974. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  97975. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  97976. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  97977. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  97978. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  97979. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  97980. * @param shapeId (integer) is the model shape identifier in the SPS.
  97981. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  97982. * @param sps defines the sps it is associated to
  97983. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  97984. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  97985. */
  97986. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  97987. /**
  97988. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  97989. * @param target the particle target
  97990. * @returns the current particle
  97991. */
  97992. copyToRef(target: SolidParticle): SolidParticle;
  97993. /**
  97994. * Legacy support, changed scale to scaling
  97995. */
  97996. get scale(): Vector3;
  97997. /**
  97998. * Legacy support, changed scale to scaling
  97999. */
  98000. set scale(scale: Vector3);
  98001. /**
  98002. * Legacy support, changed quaternion to rotationQuaternion
  98003. */
  98004. get quaternion(): Nullable<Quaternion>;
  98005. /**
  98006. * Legacy support, changed quaternion to rotationQuaternion
  98007. */
  98008. set quaternion(q: Nullable<Quaternion>);
  98009. /**
  98010. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  98011. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  98012. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  98013. * @returns true if it intersects
  98014. */
  98015. intersectsMesh(target: Mesh | SolidParticle): boolean;
  98016. /**
  98017. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  98018. * A particle is in the frustum if its bounding box intersects the frustum
  98019. * @param frustumPlanes defines the frustum to test
  98020. * @returns true if the particle is in the frustum planes
  98021. */
  98022. isInFrustum(frustumPlanes: Plane[]): boolean;
  98023. /**
  98024. * get the rotation matrix of the particle
  98025. * @hidden
  98026. */
  98027. getRotationMatrix(m: Matrix): void;
  98028. }
  98029. /**
  98030. * Represents the shape of the model used by one particle of a solid particle system.
  98031. * SPS internal tool, don't use it manually.
  98032. */
  98033. export class ModelShape {
  98034. /**
  98035. * The shape id
  98036. * @hidden
  98037. */
  98038. shapeID: number;
  98039. /**
  98040. * flat array of model positions (internal use)
  98041. * @hidden
  98042. */
  98043. _shape: Vector3[];
  98044. /**
  98045. * flat array of model UVs (internal use)
  98046. * @hidden
  98047. */
  98048. _shapeUV: number[];
  98049. /**
  98050. * color array of the model
  98051. * @hidden
  98052. */
  98053. _shapeColors: number[];
  98054. /**
  98055. * indices array of the model
  98056. * @hidden
  98057. */
  98058. _indices: number[];
  98059. /**
  98060. * normals array of the model
  98061. * @hidden
  98062. */
  98063. _normals: number[];
  98064. /**
  98065. * length of the shape in the model indices array (internal use)
  98066. * @hidden
  98067. */
  98068. _indicesLength: number;
  98069. /**
  98070. * Custom position function (internal use)
  98071. * @hidden
  98072. */
  98073. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  98074. /**
  98075. * Custom vertex function (internal use)
  98076. * @hidden
  98077. */
  98078. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  98079. /**
  98080. * Model material (internal use)
  98081. * @hidden
  98082. */
  98083. _material: Nullable<Material>;
  98084. /**
  98085. * 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.
  98086. * SPS internal tool, don't use it manually.
  98087. * @hidden
  98088. */
  98089. 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>);
  98090. }
  98091. /**
  98092. * Represents a Depth Sorted Particle in the solid particle system.
  98093. * @hidden
  98094. */
  98095. export class DepthSortedParticle {
  98096. /**
  98097. * Index of the particle in the "indices" array
  98098. */
  98099. ind: number;
  98100. /**
  98101. * Length of the particle shape in the "indices" array
  98102. */
  98103. indicesLength: number;
  98104. /**
  98105. * Squared distance from the particle to the camera
  98106. */
  98107. sqDistance: number;
  98108. /**
  98109. * Material index when used with MultiMaterials
  98110. */
  98111. materialIndex: number;
  98112. /**
  98113. * Creates a new sorted particle
  98114. * @param materialIndex
  98115. */
  98116. constructor(ind: number, indLength: number, materialIndex: number);
  98117. }
  98118. }
  98119. declare module BABYLON {
  98120. /**
  98121. * @hidden
  98122. */
  98123. export class _MeshCollisionData {
  98124. _checkCollisions: boolean;
  98125. _collisionMask: number;
  98126. _collisionGroup: number;
  98127. _collider: Nullable<Collider>;
  98128. _oldPositionForCollisions: Vector3;
  98129. _diffPositionForCollisions: Vector3;
  98130. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  98131. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  98132. }
  98133. }
  98134. declare module BABYLON {
  98135. /** @hidden */
  98136. class _FacetDataStorage {
  98137. facetPositions: Vector3[];
  98138. facetNormals: Vector3[];
  98139. facetPartitioning: number[][];
  98140. facetNb: number;
  98141. partitioningSubdivisions: number;
  98142. partitioningBBoxRatio: number;
  98143. facetDataEnabled: boolean;
  98144. facetParameters: any;
  98145. bbSize: Vector3;
  98146. subDiv: {
  98147. max: number;
  98148. X: number;
  98149. Y: number;
  98150. Z: number;
  98151. };
  98152. facetDepthSort: boolean;
  98153. facetDepthSortEnabled: boolean;
  98154. depthSortedIndices: IndicesArray;
  98155. depthSortedFacets: {
  98156. ind: number;
  98157. sqDistance: number;
  98158. }[];
  98159. facetDepthSortFunction: (f1: {
  98160. ind: number;
  98161. sqDistance: number;
  98162. }, f2: {
  98163. ind: number;
  98164. sqDistance: number;
  98165. }) => number;
  98166. facetDepthSortFrom: Vector3;
  98167. facetDepthSortOrigin: Vector3;
  98168. invertedMatrix: Matrix;
  98169. }
  98170. /**
  98171. * @hidden
  98172. **/
  98173. class _InternalAbstractMeshDataInfo {
  98174. _hasVertexAlpha: boolean;
  98175. _useVertexColors: boolean;
  98176. _numBoneInfluencers: number;
  98177. _applyFog: boolean;
  98178. _receiveShadows: boolean;
  98179. _facetData: _FacetDataStorage;
  98180. _visibility: number;
  98181. _skeleton: Nullable<Skeleton>;
  98182. _layerMask: number;
  98183. _computeBonesUsingShaders: boolean;
  98184. _isActive: boolean;
  98185. _onlyForInstances: boolean;
  98186. _isActiveIntermediate: boolean;
  98187. _onlyForInstancesIntermediate: boolean;
  98188. _actAsRegularMesh: boolean;
  98189. }
  98190. /**
  98191. * Class used to store all common mesh properties
  98192. */
  98193. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  98194. /** No occlusion */
  98195. static OCCLUSION_TYPE_NONE: number;
  98196. /** Occlusion set to optimisitic */
  98197. static OCCLUSION_TYPE_OPTIMISTIC: number;
  98198. /** Occlusion set to strict */
  98199. static OCCLUSION_TYPE_STRICT: number;
  98200. /** Use an accurante occlusion algorithm */
  98201. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  98202. /** Use a conservative occlusion algorithm */
  98203. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  98204. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  98205. * Test order :
  98206. * Is the bounding sphere outside the frustum ?
  98207. * If not, are the bounding box vertices outside the frustum ?
  98208. * It not, then the cullable object is in the frustum.
  98209. */
  98210. static readonly CULLINGSTRATEGY_STANDARD: number;
  98211. /** Culling strategy : Bounding Sphere Only.
  98212. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  98213. * It's also less accurate than the standard because some not visible objects can still be selected.
  98214. * Test : is the bounding sphere outside the frustum ?
  98215. * If not, then the cullable object is in the frustum.
  98216. */
  98217. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  98218. /** Culling strategy : Optimistic Inclusion.
  98219. * This in an inclusion test first, then the standard exclusion test.
  98220. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  98221. * 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.
  98222. * Anyway, it's as accurate as the standard strategy.
  98223. * Test :
  98224. * Is the cullable object bounding sphere center in the frustum ?
  98225. * If not, apply the default culling strategy.
  98226. */
  98227. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  98228. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  98229. * This in an inclusion test first, then the bounding sphere only exclusion test.
  98230. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  98231. * 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.
  98232. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  98233. * Test :
  98234. * Is the cullable object bounding sphere center in the frustum ?
  98235. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  98236. */
  98237. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  98238. /**
  98239. * No billboard
  98240. */
  98241. static get BILLBOARDMODE_NONE(): number;
  98242. /** Billboard on X axis */
  98243. static get BILLBOARDMODE_X(): number;
  98244. /** Billboard on Y axis */
  98245. static get BILLBOARDMODE_Y(): number;
  98246. /** Billboard on Z axis */
  98247. static get BILLBOARDMODE_Z(): number;
  98248. /** Billboard on all axes */
  98249. static get BILLBOARDMODE_ALL(): number;
  98250. /** Billboard on using position instead of orientation */
  98251. static get BILLBOARDMODE_USE_POSITION(): number;
  98252. /** @hidden */
  98253. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  98254. /**
  98255. * The culling strategy to use to check whether the mesh must be rendered or not.
  98256. * This value can be changed at any time and will be used on the next render mesh selection.
  98257. * The possible values are :
  98258. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  98259. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  98260. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  98261. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  98262. * Please read each static variable documentation to get details about the culling process.
  98263. * */
  98264. cullingStrategy: number;
  98265. /**
  98266. * Gets the number of facets in the mesh
  98267. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  98268. */
  98269. get facetNb(): number;
  98270. /**
  98271. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  98272. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  98273. */
  98274. get partitioningSubdivisions(): number;
  98275. set partitioningSubdivisions(nb: number);
  98276. /**
  98277. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  98278. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  98279. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  98280. */
  98281. get partitioningBBoxRatio(): number;
  98282. set partitioningBBoxRatio(ratio: number);
  98283. /**
  98284. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  98285. * Works only for updatable meshes.
  98286. * Doesn't work with multi-materials
  98287. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  98288. */
  98289. get mustDepthSortFacets(): boolean;
  98290. set mustDepthSortFacets(sort: boolean);
  98291. /**
  98292. * The location (Vector3) where the facet depth sort must be computed from.
  98293. * By default, the active camera position.
  98294. * Used only when facet depth sort is enabled
  98295. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  98296. */
  98297. get facetDepthSortFrom(): Vector3;
  98298. set facetDepthSortFrom(location: Vector3);
  98299. /**
  98300. * gets a boolean indicating if facetData is enabled
  98301. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  98302. */
  98303. get isFacetDataEnabled(): boolean;
  98304. /** @hidden */
  98305. _updateNonUniformScalingState(value: boolean): boolean;
  98306. /**
  98307. * An event triggered when this mesh collides with another one
  98308. */
  98309. onCollideObservable: Observable<AbstractMesh>;
  98310. /** Set a function to call when this mesh collides with another one */
  98311. set onCollide(callback: () => void);
  98312. /**
  98313. * An event triggered when the collision's position changes
  98314. */
  98315. onCollisionPositionChangeObservable: Observable<Vector3>;
  98316. /** Set a function to call when the collision's position changes */
  98317. set onCollisionPositionChange(callback: () => void);
  98318. /**
  98319. * An event triggered when material is changed
  98320. */
  98321. onMaterialChangedObservable: Observable<AbstractMesh>;
  98322. /**
  98323. * Gets or sets the orientation for POV movement & rotation
  98324. */
  98325. definedFacingForward: boolean;
  98326. /** @hidden */
  98327. _occlusionQuery: Nullable<WebGLQuery>;
  98328. /** @hidden */
  98329. _renderingGroup: Nullable<RenderingGroup>;
  98330. /**
  98331. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  98332. */
  98333. get visibility(): number;
  98334. /**
  98335. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  98336. */
  98337. set visibility(value: number);
  98338. /** Gets or sets the alpha index used to sort transparent meshes
  98339. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  98340. */
  98341. alphaIndex: number;
  98342. /**
  98343. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  98344. */
  98345. isVisible: boolean;
  98346. /**
  98347. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  98348. */
  98349. isPickable: boolean;
  98350. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  98351. showSubMeshesBoundingBox: boolean;
  98352. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  98353. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  98354. */
  98355. isBlocker: boolean;
  98356. /**
  98357. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  98358. */
  98359. enablePointerMoveEvents: boolean;
  98360. /**
  98361. * Specifies the rendering group id for this mesh (0 by default)
  98362. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  98363. */
  98364. renderingGroupId: number;
  98365. private _material;
  98366. /** Gets or sets current material */
  98367. get material(): Nullable<Material>;
  98368. set material(value: Nullable<Material>);
  98369. /**
  98370. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  98371. * @see http://doc.babylonjs.com/babylon101/shadows
  98372. */
  98373. get receiveShadows(): boolean;
  98374. set receiveShadows(value: boolean);
  98375. /** Defines color to use when rendering outline */
  98376. outlineColor: Color3;
  98377. /** Define width to use when rendering outline */
  98378. outlineWidth: number;
  98379. /** Defines color to use when rendering overlay */
  98380. overlayColor: Color3;
  98381. /** Defines alpha to use when rendering overlay */
  98382. overlayAlpha: number;
  98383. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  98384. get hasVertexAlpha(): boolean;
  98385. set hasVertexAlpha(value: boolean);
  98386. /** 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) */
  98387. get useVertexColors(): boolean;
  98388. set useVertexColors(value: boolean);
  98389. /**
  98390. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  98391. */
  98392. get computeBonesUsingShaders(): boolean;
  98393. set computeBonesUsingShaders(value: boolean);
  98394. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  98395. get numBoneInfluencers(): number;
  98396. set numBoneInfluencers(value: number);
  98397. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  98398. get applyFog(): boolean;
  98399. set applyFog(value: boolean);
  98400. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  98401. useOctreeForRenderingSelection: boolean;
  98402. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  98403. useOctreeForPicking: boolean;
  98404. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  98405. useOctreeForCollisions: boolean;
  98406. /**
  98407. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  98408. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  98409. */
  98410. get layerMask(): number;
  98411. set layerMask(value: number);
  98412. /**
  98413. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  98414. */
  98415. alwaysSelectAsActiveMesh: boolean;
  98416. /**
  98417. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  98418. */
  98419. doNotSyncBoundingInfo: boolean;
  98420. /**
  98421. * Gets or sets the current action manager
  98422. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  98423. */
  98424. actionManager: Nullable<AbstractActionManager>;
  98425. private _meshCollisionData;
  98426. /**
  98427. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  98428. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98429. */
  98430. ellipsoid: Vector3;
  98431. /**
  98432. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  98433. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98434. */
  98435. ellipsoidOffset: Vector3;
  98436. /**
  98437. * Gets or sets a collision mask used to mask collisions (default is -1).
  98438. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  98439. */
  98440. get collisionMask(): number;
  98441. set collisionMask(mask: number);
  98442. /**
  98443. * Gets or sets the current collision group mask (-1 by default).
  98444. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  98445. */
  98446. get collisionGroup(): number;
  98447. set collisionGroup(mask: number);
  98448. /**
  98449. * Defines edge width used when edgesRenderer is enabled
  98450. * @see https://www.babylonjs-playground.com/#10OJSG#13
  98451. */
  98452. edgesWidth: number;
  98453. /**
  98454. * Defines edge color used when edgesRenderer is enabled
  98455. * @see https://www.babylonjs-playground.com/#10OJSG#13
  98456. */
  98457. edgesColor: Color4;
  98458. /** @hidden */
  98459. _edgesRenderer: Nullable<IEdgesRenderer>;
  98460. /** @hidden */
  98461. _masterMesh: Nullable<AbstractMesh>;
  98462. /** @hidden */
  98463. _boundingInfo: Nullable<BoundingInfo>;
  98464. /** @hidden */
  98465. _renderId: number;
  98466. /**
  98467. * Gets or sets the list of subMeshes
  98468. * @see http://doc.babylonjs.com/how_to/multi_materials
  98469. */
  98470. subMeshes: SubMesh[];
  98471. /** @hidden */
  98472. _intersectionsInProgress: AbstractMesh[];
  98473. /** @hidden */
  98474. _unIndexed: boolean;
  98475. /** @hidden */
  98476. _lightSources: Light[];
  98477. /** Gets the list of lights affecting that mesh */
  98478. get lightSources(): Light[];
  98479. /** @hidden */
  98480. get _positions(): Nullable<Vector3[]>;
  98481. /** @hidden */
  98482. _waitingData: {
  98483. lods: Nullable<any>;
  98484. actions: Nullable<any>;
  98485. freezeWorldMatrix: Nullable<boolean>;
  98486. };
  98487. /** @hidden */
  98488. _bonesTransformMatrices: Nullable<Float32Array>;
  98489. /** @hidden */
  98490. _transformMatrixTexture: Nullable<RawTexture>;
  98491. /**
  98492. * Gets or sets a skeleton to apply skining transformations
  98493. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  98494. */
  98495. set skeleton(value: Nullable<Skeleton>);
  98496. get skeleton(): Nullable<Skeleton>;
  98497. /**
  98498. * An event triggered when the mesh is rebuilt.
  98499. */
  98500. onRebuildObservable: Observable<AbstractMesh>;
  98501. /**
  98502. * Creates a new AbstractMesh
  98503. * @param name defines the name of the mesh
  98504. * @param scene defines the hosting scene
  98505. */
  98506. constructor(name: string, scene?: Nullable<Scene>);
  98507. /**
  98508. * Returns the string "AbstractMesh"
  98509. * @returns "AbstractMesh"
  98510. */
  98511. getClassName(): string;
  98512. /**
  98513. * Gets a string representation of the current mesh
  98514. * @param fullDetails defines a boolean indicating if full details must be included
  98515. * @returns a string representation of the current mesh
  98516. */
  98517. toString(fullDetails?: boolean): string;
  98518. /**
  98519. * @hidden
  98520. */
  98521. protected _getEffectiveParent(): Nullable<Node>;
  98522. /** @hidden */
  98523. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  98524. /** @hidden */
  98525. _rebuild(): void;
  98526. /** @hidden */
  98527. _resyncLightSources(): void;
  98528. /** @hidden */
  98529. _resyncLightSource(light: Light): void;
  98530. /** @hidden */
  98531. _unBindEffect(): void;
  98532. /** @hidden */
  98533. _removeLightSource(light: Light, dispose: boolean): void;
  98534. private _markSubMeshesAsDirty;
  98535. /** @hidden */
  98536. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  98537. /** @hidden */
  98538. _markSubMeshesAsAttributesDirty(): void;
  98539. /** @hidden */
  98540. _markSubMeshesAsMiscDirty(): void;
  98541. /**
  98542. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  98543. */
  98544. get scaling(): Vector3;
  98545. set scaling(newScaling: Vector3);
  98546. /**
  98547. * Returns true if the mesh is blocked. Implemented by child classes
  98548. */
  98549. get isBlocked(): boolean;
  98550. /**
  98551. * Returns the mesh itself by default. Implemented by child classes
  98552. * @param camera defines the camera to use to pick the right LOD level
  98553. * @returns the currentAbstractMesh
  98554. */
  98555. getLOD(camera: Camera): Nullable<AbstractMesh>;
  98556. /**
  98557. * Returns 0 by default. Implemented by child classes
  98558. * @returns an integer
  98559. */
  98560. getTotalVertices(): number;
  98561. /**
  98562. * Returns a positive integer : the total number of indices in this mesh geometry.
  98563. * @returns the numner of indices or zero if the mesh has no geometry.
  98564. */
  98565. getTotalIndices(): number;
  98566. /**
  98567. * Returns null by default. Implemented by child classes
  98568. * @returns null
  98569. */
  98570. getIndices(): Nullable<IndicesArray>;
  98571. /**
  98572. * Returns the array of the requested vertex data kind. Implemented by child classes
  98573. * @param kind defines the vertex data kind to use
  98574. * @returns null
  98575. */
  98576. getVerticesData(kind: string): Nullable<FloatArray>;
  98577. /**
  98578. * Sets the vertex data of the mesh geometry for the requested `kind`.
  98579. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  98580. * Note that a new underlying VertexBuffer object is created each call.
  98581. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  98582. * @param kind defines vertex data kind:
  98583. * * VertexBuffer.PositionKind
  98584. * * VertexBuffer.UVKind
  98585. * * VertexBuffer.UV2Kind
  98586. * * VertexBuffer.UV3Kind
  98587. * * VertexBuffer.UV4Kind
  98588. * * VertexBuffer.UV5Kind
  98589. * * VertexBuffer.UV6Kind
  98590. * * VertexBuffer.ColorKind
  98591. * * VertexBuffer.MatricesIndicesKind
  98592. * * VertexBuffer.MatricesIndicesExtraKind
  98593. * * VertexBuffer.MatricesWeightsKind
  98594. * * VertexBuffer.MatricesWeightsExtraKind
  98595. * @param data defines the data source
  98596. * @param updatable defines if the data must be flagged as updatable (or static)
  98597. * @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
  98598. * @returns the current mesh
  98599. */
  98600. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  98601. /**
  98602. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  98603. * If the mesh has no geometry, it is simply returned as it is.
  98604. * @param kind defines vertex data kind:
  98605. * * VertexBuffer.PositionKind
  98606. * * VertexBuffer.UVKind
  98607. * * VertexBuffer.UV2Kind
  98608. * * VertexBuffer.UV3Kind
  98609. * * VertexBuffer.UV4Kind
  98610. * * VertexBuffer.UV5Kind
  98611. * * VertexBuffer.UV6Kind
  98612. * * VertexBuffer.ColorKind
  98613. * * VertexBuffer.MatricesIndicesKind
  98614. * * VertexBuffer.MatricesIndicesExtraKind
  98615. * * VertexBuffer.MatricesWeightsKind
  98616. * * VertexBuffer.MatricesWeightsExtraKind
  98617. * @param data defines the data source
  98618. * @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
  98619. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  98620. * @returns the current mesh
  98621. */
  98622. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  98623. /**
  98624. * Sets the mesh indices,
  98625. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  98626. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  98627. * @param totalVertices Defines the total number of vertices
  98628. * @returns the current mesh
  98629. */
  98630. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  98631. /**
  98632. * Gets a boolean indicating if specific vertex data is present
  98633. * @param kind defines the vertex data kind to use
  98634. * @returns true is data kind is present
  98635. */
  98636. isVerticesDataPresent(kind: string): boolean;
  98637. /**
  98638. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  98639. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  98640. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  98641. * @returns a BoundingInfo
  98642. */
  98643. getBoundingInfo(): BoundingInfo;
  98644. /**
  98645. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  98646. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  98647. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  98648. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  98649. * @returns the current mesh
  98650. */
  98651. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  98652. /**
  98653. * Overwrite the current bounding info
  98654. * @param boundingInfo defines the new bounding info
  98655. * @returns the current mesh
  98656. */
  98657. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  98658. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  98659. get useBones(): boolean;
  98660. /** @hidden */
  98661. _preActivate(): void;
  98662. /** @hidden */
  98663. _preActivateForIntermediateRendering(renderId: number): void;
  98664. /** @hidden */
  98665. _activate(renderId: number, intermediateRendering: boolean): boolean;
  98666. /** @hidden */
  98667. _postActivate(): void;
  98668. /** @hidden */
  98669. _freeze(): void;
  98670. /** @hidden */
  98671. _unFreeze(): void;
  98672. /**
  98673. * Gets the current world matrix
  98674. * @returns a Matrix
  98675. */
  98676. getWorldMatrix(): Matrix;
  98677. /** @hidden */
  98678. _getWorldMatrixDeterminant(): number;
  98679. /**
  98680. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  98681. */
  98682. get isAnInstance(): boolean;
  98683. /**
  98684. * Gets a boolean indicating if this mesh has instances
  98685. */
  98686. get hasInstances(): boolean;
  98687. /**
  98688. * Perform relative position change from the point of view of behind the front of the mesh.
  98689. * This is performed taking into account the meshes current rotation, so you do not have to care.
  98690. * Supports definition of mesh facing forward or backward
  98691. * @param amountRight defines the distance on the right axis
  98692. * @param amountUp defines the distance on the up axis
  98693. * @param amountForward defines the distance on the forward axis
  98694. * @returns the current mesh
  98695. */
  98696. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  98697. /**
  98698. * Calculate relative position change from the point of view of behind the front of the mesh.
  98699. * This is performed taking into account the meshes current rotation, so you do not have to care.
  98700. * Supports definition of mesh facing forward or backward
  98701. * @param amountRight defines the distance on the right axis
  98702. * @param amountUp defines the distance on the up axis
  98703. * @param amountForward defines the distance on the forward axis
  98704. * @returns the new displacement vector
  98705. */
  98706. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  98707. /**
  98708. * Perform relative rotation change from the point of view of behind the front of the mesh.
  98709. * Supports definition of mesh facing forward or backward
  98710. * @param flipBack defines the flip
  98711. * @param twirlClockwise defines the twirl
  98712. * @param tiltRight defines the tilt
  98713. * @returns the current mesh
  98714. */
  98715. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  98716. /**
  98717. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  98718. * Supports definition of mesh facing forward or backward.
  98719. * @param flipBack defines the flip
  98720. * @param twirlClockwise defines the twirl
  98721. * @param tiltRight defines the tilt
  98722. * @returns the new rotation vector
  98723. */
  98724. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  98725. /**
  98726. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  98727. * This means the mesh underlying bounding box and sphere are recomputed.
  98728. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  98729. * @returns the current mesh
  98730. */
  98731. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  98732. /** @hidden */
  98733. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  98734. /** @hidden */
  98735. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  98736. /** @hidden */
  98737. _updateBoundingInfo(): AbstractMesh;
  98738. /** @hidden */
  98739. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  98740. /** @hidden */
  98741. protected _afterComputeWorldMatrix(): void;
  98742. /** @hidden */
  98743. get _effectiveMesh(): AbstractMesh;
  98744. /**
  98745. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  98746. * A mesh is in the frustum if its bounding box intersects the frustum
  98747. * @param frustumPlanes defines the frustum to test
  98748. * @returns true if the mesh is in the frustum planes
  98749. */
  98750. isInFrustum(frustumPlanes: Plane[]): boolean;
  98751. /**
  98752. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  98753. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  98754. * @param frustumPlanes defines the frustum to test
  98755. * @returns true if the mesh is completely in the frustum planes
  98756. */
  98757. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  98758. /**
  98759. * True if the mesh intersects another mesh or a SolidParticle object
  98760. * @param mesh defines a target mesh or SolidParticle to test
  98761. * @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)
  98762. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  98763. * @returns true if there is an intersection
  98764. */
  98765. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  98766. /**
  98767. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  98768. * @param point defines the point to test
  98769. * @returns true if there is an intersection
  98770. */
  98771. intersectsPoint(point: Vector3): boolean;
  98772. /**
  98773. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  98774. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98775. */
  98776. get checkCollisions(): boolean;
  98777. set checkCollisions(collisionEnabled: boolean);
  98778. /**
  98779. * Gets Collider object used to compute collisions (not physics)
  98780. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98781. */
  98782. get collider(): Nullable<Collider>;
  98783. /**
  98784. * Move the mesh using collision engine
  98785. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98786. * @param displacement defines the requested displacement vector
  98787. * @returns the current mesh
  98788. */
  98789. moveWithCollisions(displacement: Vector3): AbstractMesh;
  98790. private _onCollisionPositionChange;
  98791. /** @hidden */
  98792. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  98793. /** @hidden */
  98794. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  98795. /** @hidden */
  98796. _checkCollision(collider: Collider): AbstractMesh;
  98797. /** @hidden */
  98798. _generatePointsArray(): boolean;
  98799. /**
  98800. * Checks if the passed Ray intersects with the mesh
  98801. * @param ray defines the ray to use
  98802. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  98803. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98804. * @returns the picking info
  98805. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  98806. */
  98807. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  98808. /**
  98809. * Clones the current mesh
  98810. * @param name defines the mesh name
  98811. * @param newParent defines the new mesh parent
  98812. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  98813. * @returns the new mesh
  98814. */
  98815. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  98816. /**
  98817. * Disposes all the submeshes of the current meshnp
  98818. * @returns the current mesh
  98819. */
  98820. releaseSubMeshes(): AbstractMesh;
  98821. /**
  98822. * Releases resources associated with this abstract mesh.
  98823. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98824. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98825. */
  98826. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98827. /**
  98828. * Adds the passed mesh as a child to the current mesh
  98829. * @param mesh defines the child mesh
  98830. * @returns the current mesh
  98831. */
  98832. addChild(mesh: AbstractMesh): AbstractMesh;
  98833. /**
  98834. * Removes the passed mesh from the current mesh children list
  98835. * @param mesh defines the child mesh
  98836. * @returns the current mesh
  98837. */
  98838. removeChild(mesh: AbstractMesh): AbstractMesh;
  98839. /** @hidden */
  98840. private _initFacetData;
  98841. /**
  98842. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  98843. * This method can be called within the render loop.
  98844. * 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
  98845. * @returns the current mesh
  98846. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98847. */
  98848. updateFacetData(): AbstractMesh;
  98849. /**
  98850. * Returns the facetLocalNormals array.
  98851. * The normals are expressed in the mesh local spac
  98852. * @returns an array of Vector3
  98853. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98854. */
  98855. getFacetLocalNormals(): Vector3[];
  98856. /**
  98857. * Returns the facetLocalPositions array.
  98858. * The facet positions are expressed in the mesh local space
  98859. * @returns an array of Vector3
  98860. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98861. */
  98862. getFacetLocalPositions(): Vector3[];
  98863. /**
  98864. * Returns the facetLocalPartioning array
  98865. * @returns an array of array of numbers
  98866. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98867. */
  98868. getFacetLocalPartitioning(): number[][];
  98869. /**
  98870. * Returns the i-th facet position in the world system.
  98871. * This method allocates a new Vector3 per call
  98872. * @param i defines the facet index
  98873. * @returns a new Vector3
  98874. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98875. */
  98876. getFacetPosition(i: number): Vector3;
  98877. /**
  98878. * Sets the reference Vector3 with the i-th facet position in the world system
  98879. * @param i defines the facet index
  98880. * @param ref defines the target vector
  98881. * @returns the current mesh
  98882. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98883. */
  98884. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  98885. /**
  98886. * Returns the i-th facet normal in the world system.
  98887. * This method allocates a new Vector3 per call
  98888. * @param i defines the facet index
  98889. * @returns a new Vector3
  98890. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98891. */
  98892. getFacetNormal(i: number): Vector3;
  98893. /**
  98894. * Sets the reference Vector3 with the i-th facet normal in the world system
  98895. * @param i defines the facet index
  98896. * @param ref defines the target vector
  98897. * @returns the current mesh
  98898. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98899. */
  98900. getFacetNormalToRef(i: number, ref: Vector3): this;
  98901. /**
  98902. * 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)
  98903. * @param x defines x coordinate
  98904. * @param y defines y coordinate
  98905. * @param z defines z coordinate
  98906. * @returns the array of facet indexes
  98907. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98908. */
  98909. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  98910. /**
  98911. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  98912. * @param projected sets as the (x,y,z) world projection on the facet
  98913. * @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
  98914. * @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
  98915. * @param x defines x coordinate
  98916. * @param y defines y coordinate
  98917. * @param z defines z coordinate
  98918. * @returns the face index if found (or null instead)
  98919. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98920. */
  98921. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  98922. /**
  98923. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  98924. * @param projected sets as the (x,y,z) local projection on the facet
  98925. * @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
  98926. * @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
  98927. * @param x defines x coordinate
  98928. * @param y defines y coordinate
  98929. * @param z defines z coordinate
  98930. * @returns the face index if found (or null instead)
  98931. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98932. */
  98933. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  98934. /**
  98935. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  98936. * @returns the parameters
  98937. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98938. */
  98939. getFacetDataParameters(): any;
  98940. /**
  98941. * Disables the feature FacetData and frees the related memory
  98942. * @returns the current mesh
  98943. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98944. */
  98945. disableFacetData(): AbstractMesh;
  98946. /**
  98947. * Updates the AbstractMesh indices array
  98948. * @param indices defines the data source
  98949. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  98950. * @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)
  98951. * @returns the current mesh
  98952. */
  98953. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  98954. /**
  98955. * Creates new normals data for the mesh
  98956. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  98957. * @returns the current mesh
  98958. */
  98959. createNormals(updatable: boolean): AbstractMesh;
  98960. /**
  98961. * Align the mesh with a normal
  98962. * @param normal defines the normal to use
  98963. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  98964. * @returns the current mesh
  98965. */
  98966. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  98967. /** @hidden */
  98968. _checkOcclusionQuery(): boolean;
  98969. /**
  98970. * Disables the mesh edge rendering mode
  98971. * @returns the currentAbstractMesh
  98972. */
  98973. disableEdgesRendering(): AbstractMesh;
  98974. /**
  98975. * Enables the edge rendering mode on the mesh.
  98976. * This mode makes the mesh edges visible
  98977. * @param epsilon defines the maximal distance between two angles to detect a face
  98978. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  98979. * @returns the currentAbstractMesh
  98980. * @see https://www.babylonjs-playground.com/#19O9TU#0
  98981. */
  98982. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  98983. }
  98984. }
  98985. declare module BABYLON {
  98986. /**
  98987. * Interface used to define ActionEvent
  98988. */
  98989. export interface IActionEvent {
  98990. /** The mesh or sprite that triggered the action */
  98991. source: any;
  98992. /** The X mouse cursor position at the time of the event */
  98993. pointerX: number;
  98994. /** The Y mouse cursor position at the time of the event */
  98995. pointerY: number;
  98996. /** The mesh that is currently pointed at (can be null) */
  98997. meshUnderPointer: Nullable<AbstractMesh>;
  98998. /** the original (browser) event that triggered the ActionEvent */
  98999. sourceEvent?: any;
  99000. /** additional data for the event */
  99001. additionalData?: any;
  99002. }
  99003. /**
  99004. * ActionEvent is the event being sent when an action is triggered.
  99005. */
  99006. export class ActionEvent implements IActionEvent {
  99007. /** The mesh or sprite that triggered the action */
  99008. source: any;
  99009. /** The X mouse cursor position at the time of the event */
  99010. pointerX: number;
  99011. /** The Y mouse cursor position at the time of the event */
  99012. pointerY: number;
  99013. /** The mesh that is currently pointed at (can be null) */
  99014. meshUnderPointer: Nullable<AbstractMesh>;
  99015. /** the original (browser) event that triggered the ActionEvent */
  99016. sourceEvent?: any;
  99017. /** additional data for the event */
  99018. additionalData?: any;
  99019. /**
  99020. * Creates a new ActionEvent
  99021. * @param source The mesh or sprite that triggered the action
  99022. * @param pointerX The X mouse cursor position at the time of the event
  99023. * @param pointerY The Y mouse cursor position at the time of the event
  99024. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  99025. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  99026. * @param additionalData additional data for the event
  99027. */
  99028. constructor(
  99029. /** The mesh or sprite that triggered the action */
  99030. source: any,
  99031. /** The X mouse cursor position at the time of the event */
  99032. pointerX: number,
  99033. /** The Y mouse cursor position at the time of the event */
  99034. pointerY: number,
  99035. /** The mesh that is currently pointed at (can be null) */
  99036. meshUnderPointer: Nullable<AbstractMesh>,
  99037. /** the original (browser) event that triggered the ActionEvent */
  99038. sourceEvent?: any,
  99039. /** additional data for the event */
  99040. additionalData?: any);
  99041. /**
  99042. * Helper function to auto-create an ActionEvent from a source mesh.
  99043. * @param source The source mesh that triggered the event
  99044. * @param evt The original (browser) event
  99045. * @param additionalData additional data for the event
  99046. * @returns the new ActionEvent
  99047. */
  99048. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  99049. /**
  99050. * Helper function to auto-create an ActionEvent from a source sprite
  99051. * @param source The source sprite that triggered the event
  99052. * @param scene Scene associated with the sprite
  99053. * @param evt The original (browser) event
  99054. * @param additionalData additional data for the event
  99055. * @returns the new ActionEvent
  99056. */
  99057. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  99058. /**
  99059. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  99060. * @param scene the scene where the event occurred
  99061. * @param evt The original (browser) event
  99062. * @returns the new ActionEvent
  99063. */
  99064. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  99065. /**
  99066. * Helper function to auto-create an ActionEvent from a primitive
  99067. * @param prim defines the target primitive
  99068. * @param pointerPos defines the pointer position
  99069. * @param evt The original (browser) event
  99070. * @param additionalData additional data for the event
  99071. * @returns the new ActionEvent
  99072. */
  99073. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  99074. }
  99075. }
  99076. declare module BABYLON {
  99077. /**
  99078. * Abstract class used to decouple action Manager from scene and meshes.
  99079. * Do not instantiate.
  99080. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  99081. */
  99082. export abstract class AbstractActionManager implements IDisposable {
  99083. /** Gets the list of active triggers */
  99084. static Triggers: {
  99085. [key: string]: number;
  99086. };
  99087. /** Gets the cursor to use when hovering items */
  99088. hoverCursor: string;
  99089. /** Gets the list of actions */
  99090. actions: IAction[];
  99091. /**
  99092. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  99093. */
  99094. isRecursive: boolean;
  99095. /**
  99096. * Releases all associated resources
  99097. */
  99098. abstract dispose(): void;
  99099. /**
  99100. * Does this action manager has pointer triggers
  99101. */
  99102. abstract get hasPointerTriggers(): boolean;
  99103. /**
  99104. * Does this action manager has pick triggers
  99105. */
  99106. abstract get hasPickTriggers(): boolean;
  99107. /**
  99108. * Process a specific trigger
  99109. * @param trigger defines the trigger to process
  99110. * @param evt defines the event details to be processed
  99111. */
  99112. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  99113. /**
  99114. * Does this action manager handles actions of any of the given triggers
  99115. * @param triggers defines the triggers to be tested
  99116. * @return a boolean indicating whether one (or more) of the triggers is handled
  99117. */
  99118. abstract hasSpecificTriggers(triggers: number[]): boolean;
  99119. /**
  99120. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  99121. * speed.
  99122. * @param triggerA defines the trigger to be tested
  99123. * @param triggerB defines the trigger to be tested
  99124. * @return a boolean indicating whether one (or more) of the triggers is handled
  99125. */
  99126. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  99127. /**
  99128. * Does this action manager handles actions of a given trigger
  99129. * @param trigger defines the trigger to be tested
  99130. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  99131. * @return whether the trigger is handled
  99132. */
  99133. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  99134. /**
  99135. * Serialize this manager to a JSON object
  99136. * @param name defines the property name to store this manager
  99137. * @returns a JSON representation of this manager
  99138. */
  99139. abstract serialize(name: string): any;
  99140. /**
  99141. * Registers an action to this action manager
  99142. * @param action defines the action to be registered
  99143. * @return the action amended (prepared) after registration
  99144. */
  99145. abstract registerAction(action: IAction): Nullable<IAction>;
  99146. /**
  99147. * Unregisters an action to this action manager
  99148. * @param action defines the action to be unregistered
  99149. * @return a boolean indicating whether the action has been unregistered
  99150. */
  99151. abstract unregisterAction(action: IAction): Boolean;
  99152. /**
  99153. * Does exist one action manager with at least one trigger
  99154. **/
  99155. static get HasTriggers(): boolean;
  99156. /**
  99157. * Does exist one action manager with at least one pick trigger
  99158. **/
  99159. static get HasPickTriggers(): boolean;
  99160. /**
  99161. * Does exist one action manager that handles actions of a given trigger
  99162. * @param trigger defines the trigger to be tested
  99163. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  99164. **/
  99165. static HasSpecificTrigger(trigger: number): boolean;
  99166. }
  99167. }
  99168. declare module BABYLON {
  99169. /**
  99170. * Defines how a node can be built from a string name.
  99171. */
  99172. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  99173. /**
  99174. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  99175. */
  99176. export class Node implements IBehaviorAware<Node> {
  99177. /** @hidden */
  99178. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  99179. private static _NodeConstructors;
  99180. /**
  99181. * Add a new node constructor
  99182. * @param type defines the type name of the node to construct
  99183. * @param constructorFunc defines the constructor function
  99184. */
  99185. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  99186. /**
  99187. * Returns a node constructor based on type name
  99188. * @param type defines the type name
  99189. * @param name defines the new node name
  99190. * @param scene defines the hosting scene
  99191. * @param options defines optional options to transmit to constructors
  99192. * @returns the new constructor or null
  99193. */
  99194. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  99195. /**
  99196. * Gets or sets the name of the node
  99197. */
  99198. name: string;
  99199. /**
  99200. * Gets or sets the id of the node
  99201. */
  99202. id: string;
  99203. /**
  99204. * Gets or sets the unique id of the node
  99205. */
  99206. uniqueId: number;
  99207. /**
  99208. * Gets or sets a string used to store user defined state for the node
  99209. */
  99210. state: string;
  99211. /**
  99212. * Gets or sets an object used to store user defined information for the node
  99213. */
  99214. metadata: any;
  99215. /**
  99216. * For internal use only. Please do not use.
  99217. */
  99218. reservedDataStore: any;
  99219. /**
  99220. * List of inspectable custom properties (used by the Inspector)
  99221. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  99222. */
  99223. inspectableCustomProperties: IInspectable[];
  99224. private _doNotSerialize;
  99225. /**
  99226. * Gets or sets a boolean used to define if the node must be serialized
  99227. */
  99228. get doNotSerialize(): boolean;
  99229. set doNotSerialize(value: boolean);
  99230. /** @hidden */
  99231. _isDisposed: boolean;
  99232. /**
  99233. * Gets a list of Animations associated with the node
  99234. */
  99235. animations: Animation[];
  99236. protected _ranges: {
  99237. [name: string]: Nullable<AnimationRange>;
  99238. };
  99239. /**
  99240. * Callback raised when the node is ready to be used
  99241. */
  99242. onReady: Nullable<(node: Node) => void>;
  99243. private _isEnabled;
  99244. private _isParentEnabled;
  99245. private _isReady;
  99246. /** @hidden */
  99247. _currentRenderId: number;
  99248. private _parentUpdateId;
  99249. /** @hidden */
  99250. _childUpdateId: number;
  99251. /** @hidden */
  99252. _waitingParentId: Nullable<string>;
  99253. /** @hidden */
  99254. _scene: Scene;
  99255. /** @hidden */
  99256. _cache: any;
  99257. private _parentNode;
  99258. private _children;
  99259. /** @hidden */
  99260. _worldMatrix: Matrix;
  99261. /** @hidden */
  99262. _worldMatrixDeterminant: number;
  99263. /** @hidden */
  99264. _worldMatrixDeterminantIsDirty: boolean;
  99265. /** @hidden */
  99266. private _sceneRootNodesIndex;
  99267. /**
  99268. * Gets a boolean indicating if the node has been disposed
  99269. * @returns true if the node was disposed
  99270. */
  99271. isDisposed(): boolean;
  99272. /**
  99273. * Gets or sets the parent of the node (without keeping the current position in the scene)
  99274. * @see https://doc.babylonjs.com/how_to/parenting
  99275. */
  99276. set parent(parent: Nullable<Node>);
  99277. get parent(): Nullable<Node>;
  99278. /** @hidden */
  99279. _addToSceneRootNodes(): void;
  99280. /** @hidden */
  99281. _removeFromSceneRootNodes(): void;
  99282. private _animationPropertiesOverride;
  99283. /**
  99284. * Gets or sets the animation properties override
  99285. */
  99286. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  99287. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  99288. /**
  99289. * Gets a string idenfifying the name of the class
  99290. * @returns "Node" string
  99291. */
  99292. getClassName(): string;
  99293. /** @hidden */
  99294. readonly _isNode: boolean;
  99295. /**
  99296. * An event triggered when the mesh is disposed
  99297. */
  99298. onDisposeObservable: Observable<Node>;
  99299. private _onDisposeObserver;
  99300. /**
  99301. * Sets a callback that will be raised when the node will be disposed
  99302. */
  99303. set onDispose(callback: () => void);
  99304. /**
  99305. * Creates a new Node
  99306. * @param name the name and id to be given to this node
  99307. * @param scene the scene this node will be added to
  99308. */
  99309. constructor(name: string, scene?: Nullable<Scene>);
  99310. /**
  99311. * Gets the scene of the node
  99312. * @returns a scene
  99313. */
  99314. getScene(): Scene;
  99315. /**
  99316. * Gets the engine of the node
  99317. * @returns a Engine
  99318. */
  99319. getEngine(): Engine;
  99320. private _behaviors;
  99321. /**
  99322. * Attach a behavior to the node
  99323. * @see http://doc.babylonjs.com/features/behaviour
  99324. * @param behavior defines the behavior to attach
  99325. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  99326. * @returns the current Node
  99327. */
  99328. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  99329. /**
  99330. * Remove an attached behavior
  99331. * @see http://doc.babylonjs.com/features/behaviour
  99332. * @param behavior defines the behavior to attach
  99333. * @returns the current Node
  99334. */
  99335. removeBehavior(behavior: Behavior<Node>): Node;
  99336. /**
  99337. * Gets the list of attached behaviors
  99338. * @see http://doc.babylonjs.com/features/behaviour
  99339. */
  99340. get behaviors(): Behavior<Node>[];
  99341. /**
  99342. * Gets an attached behavior by name
  99343. * @param name defines the name of the behavior to look for
  99344. * @see http://doc.babylonjs.com/features/behaviour
  99345. * @returns null if behavior was not found else the requested behavior
  99346. */
  99347. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  99348. /**
  99349. * Returns the latest update of the World matrix
  99350. * @returns a Matrix
  99351. */
  99352. getWorldMatrix(): Matrix;
  99353. /** @hidden */
  99354. _getWorldMatrixDeterminant(): number;
  99355. /**
  99356. * Returns directly the latest state of the mesh World matrix.
  99357. * A Matrix is returned.
  99358. */
  99359. get worldMatrixFromCache(): Matrix;
  99360. /** @hidden */
  99361. _initCache(): void;
  99362. /** @hidden */
  99363. updateCache(force?: boolean): void;
  99364. /** @hidden */
  99365. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  99366. /** @hidden */
  99367. _updateCache(ignoreParentClass?: boolean): void;
  99368. /** @hidden */
  99369. _isSynchronized(): boolean;
  99370. /** @hidden */
  99371. _markSyncedWithParent(): void;
  99372. /** @hidden */
  99373. isSynchronizedWithParent(): boolean;
  99374. /** @hidden */
  99375. isSynchronized(): boolean;
  99376. /**
  99377. * Is this node ready to be used/rendered
  99378. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  99379. * @return true if the node is ready
  99380. */
  99381. isReady(completeCheck?: boolean): boolean;
  99382. /**
  99383. * Is this node enabled?
  99384. * 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
  99385. * @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
  99386. * @return whether this node (and its parent) is enabled
  99387. */
  99388. isEnabled(checkAncestors?: boolean): boolean;
  99389. /** @hidden */
  99390. protected _syncParentEnabledState(): void;
  99391. /**
  99392. * Set the enabled state of this node
  99393. * @param value defines the new enabled state
  99394. */
  99395. setEnabled(value: boolean): void;
  99396. /**
  99397. * Is this node a descendant of the given node?
  99398. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  99399. * @param ancestor defines the parent node to inspect
  99400. * @returns a boolean indicating if this node is a descendant of the given node
  99401. */
  99402. isDescendantOf(ancestor: Node): boolean;
  99403. /** @hidden */
  99404. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  99405. /**
  99406. * Will return all nodes that have this node as ascendant
  99407. * @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
  99408. * @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
  99409. * @return all children nodes of all types
  99410. */
  99411. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  99412. /**
  99413. * Get all child-meshes of this node
  99414. * @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)
  99415. * @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
  99416. * @returns an array of AbstractMesh
  99417. */
  99418. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  99419. /**
  99420. * Get all direct children of this node
  99421. * @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
  99422. * @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)
  99423. * @returns an array of Node
  99424. */
  99425. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  99426. /** @hidden */
  99427. _setReady(state: boolean): void;
  99428. /**
  99429. * Get an animation by name
  99430. * @param name defines the name of the animation to look for
  99431. * @returns null if not found else the requested animation
  99432. */
  99433. getAnimationByName(name: string): Nullable<Animation>;
  99434. /**
  99435. * Creates an animation range for this node
  99436. * @param name defines the name of the range
  99437. * @param from defines the starting key
  99438. * @param to defines the end key
  99439. */
  99440. createAnimationRange(name: string, from: number, to: number): void;
  99441. /**
  99442. * Delete a specific animation range
  99443. * @param name defines the name of the range to delete
  99444. * @param deleteFrames defines if animation frames from the range must be deleted as well
  99445. */
  99446. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  99447. /**
  99448. * Get an animation range by name
  99449. * @param name defines the name of the animation range to look for
  99450. * @returns null if not found else the requested animation range
  99451. */
  99452. getAnimationRange(name: string): Nullable<AnimationRange>;
  99453. /**
  99454. * Gets the list of all animation ranges defined on this node
  99455. * @returns an array
  99456. */
  99457. getAnimationRanges(): Nullable<AnimationRange>[];
  99458. /**
  99459. * Will start the animation sequence
  99460. * @param name defines the range frames for animation sequence
  99461. * @param loop defines if the animation should loop (false by default)
  99462. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  99463. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  99464. * @returns the object created for this animation. If range does not exist, it will return null
  99465. */
  99466. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  99467. /**
  99468. * Serialize animation ranges into a JSON compatible object
  99469. * @returns serialization object
  99470. */
  99471. serializeAnimationRanges(): any;
  99472. /**
  99473. * Computes the world matrix of the node
  99474. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  99475. * @returns the world matrix
  99476. */
  99477. computeWorldMatrix(force?: boolean): Matrix;
  99478. /**
  99479. * Releases resources associated with this node.
  99480. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99481. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99482. */
  99483. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99484. /**
  99485. * Parse animation range data from a serialization object and store them into a given node
  99486. * @param node defines where to store the animation ranges
  99487. * @param parsedNode defines the serialization object to read data from
  99488. * @param scene defines the hosting scene
  99489. */
  99490. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  99491. /**
  99492. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  99493. * @param includeDescendants Include bounding info from descendants as well (true by default)
  99494. * @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
  99495. * @returns the new bounding vectors
  99496. */
  99497. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  99498. min: Vector3;
  99499. max: Vector3;
  99500. };
  99501. }
  99502. }
  99503. declare module BABYLON {
  99504. /**
  99505. * @hidden
  99506. */
  99507. export class _IAnimationState {
  99508. key: number;
  99509. repeatCount: number;
  99510. workValue?: any;
  99511. loopMode?: number;
  99512. offsetValue?: any;
  99513. highLimitValue?: any;
  99514. }
  99515. /**
  99516. * Class used to store any kind of animation
  99517. */
  99518. export class Animation {
  99519. /**Name of the animation */
  99520. name: string;
  99521. /**Property to animate */
  99522. targetProperty: string;
  99523. /**The frames per second of the animation */
  99524. framePerSecond: number;
  99525. /**The data type of the animation */
  99526. dataType: number;
  99527. /**The loop mode of the animation */
  99528. loopMode?: number | undefined;
  99529. /**Specifies if blending should be enabled */
  99530. enableBlending?: boolean | undefined;
  99531. /**
  99532. * Use matrix interpolation instead of using direct key value when animating matrices
  99533. */
  99534. static AllowMatricesInterpolation: boolean;
  99535. /**
  99536. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  99537. */
  99538. static AllowMatrixDecomposeForInterpolation: boolean;
  99539. /**
  99540. * Stores the key frames of the animation
  99541. */
  99542. private _keys;
  99543. /**
  99544. * Stores the easing function of the animation
  99545. */
  99546. private _easingFunction;
  99547. /**
  99548. * @hidden Internal use only
  99549. */
  99550. _runtimeAnimations: RuntimeAnimation[];
  99551. /**
  99552. * The set of event that will be linked to this animation
  99553. */
  99554. private _events;
  99555. /**
  99556. * Stores an array of target property paths
  99557. */
  99558. targetPropertyPath: string[];
  99559. /**
  99560. * Stores the blending speed of the animation
  99561. */
  99562. blendingSpeed: number;
  99563. /**
  99564. * Stores the animation ranges for the animation
  99565. */
  99566. private _ranges;
  99567. /**
  99568. * @hidden Internal use
  99569. */
  99570. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  99571. /**
  99572. * Sets up an animation
  99573. * @param property The property to animate
  99574. * @param animationType The animation type to apply
  99575. * @param framePerSecond The frames per second of the animation
  99576. * @param easingFunction The easing function used in the animation
  99577. * @returns The created animation
  99578. */
  99579. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  99580. /**
  99581. * Create and start an animation on a node
  99582. * @param name defines the name of the global animation that will be run on all nodes
  99583. * @param node defines the root node where the animation will take place
  99584. * @param targetProperty defines property to animate
  99585. * @param framePerSecond defines the number of frame per second yo use
  99586. * @param totalFrame defines the number of frames in total
  99587. * @param from defines the initial value
  99588. * @param to defines the final value
  99589. * @param loopMode defines which loop mode you want to use (off by default)
  99590. * @param easingFunction defines the easing function to use (linear by default)
  99591. * @param onAnimationEnd defines the callback to call when animation end
  99592. * @returns the animatable created for this animation
  99593. */
  99594. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  99595. /**
  99596. * Create and start an animation on a node and its descendants
  99597. * @param name defines the name of the global animation that will be run on all nodes
  99598. * @param node defines the root node where the animation will take place
  99599. * @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
  99600. * @param targetProperty defines property to animate
  99601. * @param framePerSecond defines the number of frame per second to use
  99602. * @param totalFrame defines the number of frames in total
  99603. * @param from defines the initial value
  99604. * @param to defines the final value
  99605. * @param loopMode defines which loop mode you want to use (off by default)
  99606. * @param easingFunction defines the easing function to use (linear by default)
  99607. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  99608. * @returns the list of animatables created for all nodes
  99609. * @example https://www.babylonjs-playground.com/#MH0VLI
  99610. */
  99611. 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[]>;
  99612. /**
  99613. * Creates a new animation, merges it with the existing animations and starts it
  99614. * @param name Name of the animation
  99615. * @param node Node which contains the scene that begins the animations
  99616. * @param targetProperty Specifies which property to animate
  99617. * @param framePerSecond The frames per second of the animation
  99618. * @param totalFrame The total number of frames
  99619. * @param from The frame at the beginning of the animation
  99620. * @param to The frame at the end of the animation
  99621. * @param loopMode Specifies the loop mode of the animation
  99622. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  99623. * @param onAnimationEnd Callback to run once the animation is complete
  99624. * @returns Nullable animation
  99625. */
  99626. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  99627. /**
  99628. * Transition property of an host to the target Value
  99629. * @param property The property to transition
  99630. * @param targetValue The target Value of the property
  99631. * @param host The object where the property to animate belongs
  99632. * @param scene Scene used to run the animation
  99633. * @param frameRate Framerate (in frame/s) to use
  99634. * @param transition The transition type we want to use
  99635. * @param duration The duration of the animation, in milliseconds
  99636. * @param onAnimationEnd Callback trigger at the end of the animation
  99637. * @returns Nullable animation
  99638. */
  99639. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  99640. /**
  99641. * Return the array of runtime animations currently using this animation
  99642. */
  99643. get runtimeAnimations(): RuntimeAnimation[];
  99644. /**
  99645. * Specifies if any of the runtime animations are currently running
  99646. */
  99647. get hasRunningRuntimeAnimations(): boolean;
  99648. /**
  99649. * Initializes the animation
  99650. * @param name Name of the animation
  99651. * @param targetProperty Property to animate
  99652. * @param framePerSecond The frames per second of the animation
  99653. * @param dataType The data type of the animation
  99654. * @param loopMode The loop mode of the animation
  99655. * @param enableBlending Specifies if blending should be enabled
  99656. */
  99657. constructor(
  99658. /**Name of the animation */
  99659. name: string,
  99660. /**Property to animate */
  99661. targetProperty: string,
  99662. /**The frames per second of the animation */
  99663. framePerSecond: number,
  99664. /**The data type of the animation */
  99665. dataType: number,
  99666. /**The loop mode of the animation */
  99667. loopMode?: number | undefined,
  99668. /**Specifies if blending should be enabled */
  99669. enableBlending?: boolean | undefined);
  99670. /**
  99671. * Converts the animation to a string
  99672. * @param fullDetails support for multiple levels of logging within scene loading
  99673. * @returns String form of the animation
  99674. */
  99675. toString(fullDetails?: boolean): string;
  99676. /**
  99677. * Add an event to this animation
  99678. * @param event Event to add
  99679. */
  99680. addEvent(event: AnimationEvent): void;
  99681. /**
  99682. * Remove all events found at the given frame
  99683. * @param frame The frame to remove events from
  99684. */
  99685. removeEvents(frame: number): void;
  99686. /**
  99687. * Retrieves all the events from the animation
  99688. * @returns Events from the animation
  99689. */
  99690. getEvents(): AnimationEvent[];
  99691. /**
  99692. * Creates an animation range
  99693. * @param name Name of the animation range
  99694. * @param from Starting frame of the animation range
  99695. * @param to Ending frame of the animation
  99696. */
  99697. createRange(name: string, from: number, to: number): void;
  99698. /**
  99699. * Deletes an animation range by name
  99700. * @param name Name of the animation range to delete
  99701. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  99702. */
  99703. deleteRange(name: string, deleteFrames?: boolean): void;
  99704. /**
  99705. * Gets the animation range by name, or null if not defined
  99706. * @param name Name of the animation range
  99707. * @returns Nullable animation range
  99708. */
  99709. getRange(name: string): Nullable<AnimationRange>;
  99710. /**
  99711. * Gets the key frames from the animation
  99712. * @returns The key frames of the animation
  99713. */
  99714. getKeys(): Array<IAnimationKey>;
  99715. /**
  99716. * Gets the highest frame rate of the animation
  99717. * @returns Highest frame rate of the animation
  99718. */
  99719. getHighestFrame(): number;
  99720. /**
  99721. * Gets the easing function of the animation
  99722. * @returns Easing function of the animation
  99723. */
  99724. getEasingFunction(): IEasingFunction;
  99725. /**
  99726. * Sets the easing function of the animation
  99727. * @param easingFunction A custom mathematical formula for animation
  99728. */
  99729. setEasingFunction(easingFunction: EasingFunction): void;
  99730. /**
  99731. * Interpolates a scalar linearly
  99732. * @param startValue Start value of the animation curve
  99733. * @param endValue End value of the animation curve
  99734. * @param gradient Scalar amount to interpolate
  99735. * @returns Interpolated scalar value
  99736. */
  99737. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  99738. /**
  99739. * Interpolates a scalar cubically
  99740. * @param startValue Start value of the animation curve
  99741. * @param outTangent End tangent of the animation
  99742. * @param endValue End value of the animation curve
  99743. * @param inTangent Start tangent of the animation curve
  99744. * @param gradient Scalar amount to interpolate
  99745. * @returns Interpolated scalar value
  99746. */
  99747. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  99748. /**
  99749. * Interpolates a quaternion using a spherical linear interpolation
  99750. * @param startValue Start value of the animation curve
  99751. * @param endValue End value of the animation curve
  99752. * @param gradient Scalar amount to interpolate
  99753. * @returns Interpolated quaternion value
  99754. */
  99755. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  99756. /**
  99757. * Interpolates a quaternion cubically
  99758. * @param startValue Start value of the animation curve
  99759. * @param outTangent End tangent of the animation curve
  99760. * @param endValue End value of the animation curve
  99761. * @param inTangent Start tangent of the animation curve
  99762. * @param gradient Scalar amount to interpolate
  99763. * @returns Interpolated quaternion value
  99764. */
  99765. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  99766. /**
  99767. * Interpolates a Vector3 linearl
  99768. * @param startValue Start value of the animation curve
  99769. * @param endValue End value of the animation curve
  99770. * @param gradient Scalar amount to interpolate
  99771. * @returns Interpolated scalar value
  99772. */
  99773. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  99774. /**
  99775. * Interpolates a Vector3 cubically
  99776. * @param startValue Start value of the animation curve
  99777. * @param outTangent End tangent of the animation
  99778. * @param endValue End value of the animation curve
  99779. * @param inTangent Start tangent of the animation curve
  99780. * @param gradient Scalar amount to interpolate
  99781. * @returns InterpolatedVector3 value
  99782. */
  99783. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  99784. /**
  99785. * Interpolates a Vector2 linearly
  99786. * @param startValue Start value of the animation curve
  99787. * @param endValue End value of the animation curve
  99788. * @param gradient Scalar amount to interpolate
  99789. * @returns Interpolated Vector2 value
  99790. */
  99791. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  99792. /**
  99793. * Interpolates a Vector2 cubically
  99794. * @param startValue Start value of the animation curve
  99795. * @param outTangent End tangent of the animation
  99796. * @param endValue End value of the animation curve
  99797. * @param inTangent Start tangent of the animation curve
  99798. * @param gradient Scalar amount to interpolate
  99799. * @returns Interpolated Vector2 value
  99800. */
  99801. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  99802. /**
  99803. * Interpolates a size linearly
  99804. * @param startValue Start value of the animation curve
  99805. * @param endValue End value of the animation curve
  99806. * @param gradient Scalar amount to interpolate
  99807. * @returns Interpolated Size value
  99808. */
  99809. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  99810. /**
  99811. * Interpolates a Color3 linearly
  99812. * @param startValue Start value of the animation curve
  99813. * @param endValue End value of the animation curve
  99814. * @param gradient Scalar amount to interpolate
  99815. * @returns Interpolated Color3 value
  99816. */
  99817. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  99818. /**
  99819. * Interpolates a Color4 linearly
  99820. * @param startValue Start value of the animation curve
  99821. * @param endValue End value of the animation curve
  99822. * @param gradient Scalar amount to interpolate
  99823. * @returns Interpolated Color3 value
  99824. */
  99825. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  99826. /**
  99827. * @hidden Internal use only
  99828. */
  99829. _getKeyValue(value: any): any;
  99830. /**
  99831. * @hidden Internal use only
  99832. */
  99833. _interpolate(currentFrame: number, state: _IAnimationState): any;
  99834. /**
  99835. * Defines the function to use to interpolate matrices
  99836. * @param startValue defines the start matrix
  99837. * @param endValue defines the end matrix
  99838. * @param gradient defines the gradient between both matrices
  99839. * @param result defines an optional target matrix where to store the interpolation
  99840. * @returns the interpolated matrix
  99841. */
  99842. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  99843. /**
  99844. * Makes a copy of the animation
  99845. * @returns Cloned animation
  99846. */
  99847. clone(): Animation;
  99848. /**
  99849. * Sets the key frames of the animation
  99850. * @param values The animation key frames to set
  99851. */
  99852. setKeys(values: Array<IAnimationKey>): void;
  99853. /**
  99854. * Serializes the animation to an object
  99855. * @returns Serialized object
  99856. */
  99857. serialize(): any;
  99858. /**
  99859. * Float animation type
  99860. */
  99861. static readonly ANIMATIONTYPE_FLOAT: number;
  99862. /**
  99863. * Vector3 animation type
  99864. */
  99865. static readonly ANIMATIONTYPE_VECTOR3: number;
  99866. /**
  99867. * Quaternion animation type
  99868. */
  99869. static readonly ANIMATIONTYPE_QUATERNION: number;
  99870. /**
  99871. * Matrix animation type
  99872. */
  99873. static readonly ANIMATIONTYPE_MATRIX: number;
  99874. /**
  99875. * Color3 animation type
  99876. */
  99877. static readonly ANIMATIONTYPE_COLOR3: number;
  99878. /**
  99879. * Color3 animation type
  99880. */
  99881. static readonly ANIMATIONTYPE_COLOR4: number;
  99882. /**
  99883. * Vector2 animation type
  99884. */
  99885. static readonly ANIMATIONTYPE_VECTOR2: number;
  99886. /**
  99887. * Size animation type
  99888. */
  99889. static readonly ANIMATIONTYPE_SIZE: number;
  99890. /**
  99891. * Relative Loop Mode
  99892. */
  99893. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  99894. /**
  99895. * Cycle Loop Mode
  99896. */
  99897. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  99898. /**
  99899. * Constant Loop Mode
  99900. */
  99901. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  99902. /** @hidden */
  99903. static _UniversalLerp(left: any, right: any, amount: number): any;
  99904. /**
  99905. * Parses an animation object and creates an animation
  99906. * @param parsedAnimation Parsed animation object
  99907. * @returns Animation object
  99908. */
  99909. static Parse(parsedAnimation: any): Animation;
  99910. /**
  99911. * Appends the serialized animations from the source animations
  99912. * @param source Source containing the animations
  99913. * @param destination Target to store the animations
  99914. */
  99915. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  99916. }
  99917. }
  99918. declare module BABYLON {
  99919. /**
  99920. * Interface containing an array of animations
  99921. */
  99922. export interface IAnimatable {
  99923. /**
  99924. * Array of animations
  99925. */
  99926. animations: Nullable<Array<Animation>>;
  99927. }
  99928. }
  99929. declare module BABYLON {
  99930. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  99931. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99932. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99933. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99934. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99935. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99936. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99937. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99938. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99939. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99940. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99941. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99942. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99943. /**
  99944. * Decorator used to define property that can be serialized as reference to a camera
  99945. * @param sourceName defines the name of the property to decorate
  99946. */
  99947. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99948. /**
  99949. * Class used to help serialization objects
  99950. */
  99951. export class SerializationHelper {
  99952. /** @hidden */
  99953. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  99954. /** @hidden */
  99955. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  99956. /** @hidden */
  99957. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  99958. /** @hidden */
  99959. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  99960. /**
  99961. * Appends the serialized animations from the source animations
  99962. * @param source Source containing the animations
  99963. * @param destination Target to store the animations
  99964. */
  99965. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  99966. /**
  99967. * Static function used to serialized a specific entity
  99968. * @param entity defines the entity to serialize
  99969. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  99970. * @returns a JSON compatible object representing the serialization of the entity
  99971. */
  99972. static Serialize<T>(entity: T, serializationObject?: any): any;
  99973. /**
  99974. * Creates a new entity from a serialization data object
  99975. * @param creationFunction defines a function used to instanciated the new entity
  99976. * @param source defines the source serialization data
  99977. * @param scene defines the hosting scene
  99978. * @param rootUrl defines the root url for resources
  99979. * @returns a new entity
  99980. */
  99981. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  99982. /**
  99983. * Clones an object
  99984. * @param creationFunction defines the function used to instanciate the new object
  99985. * @param source defines the source object
  99986. * @returns the cloned object
  99987. */
  99988. static Clone<T>(creationFunction: () => T, source: T): T;
  99989. /**
  99990. * Instanciates a new object based on a source one (some data will be shared between both object)
  99991. * @param creationFunction defines the function used to instanciate the new object
  99992. * @param source defines the source object
  99993. * @returns the new object
  99994. */
  99995. static Instanciate<T>(creationFunction: () => T, source: T): T;
  99996. }
  99997. }
  99998. declare module BABYLON {
  99999. /**
  100000. * Class used to manipulate GUIDs
  100001. */
  100002. export class GUID {
  100003. /**
  100004. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  100005. * Be aware Math.random() could cause collisions, but:
  100006. * "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"
  100007. * @returns a pseudo random id
  100008. */
  100009. static RandomId(): string;
  100010. }
  100011. }
  100012. declare module BABYLON {
  100013. /**
  100014. * Base class of all the textures in babylon.
  100015. * It groups all the common properties the materials, post process, lights... might need
  100016. * in order to make a correct use of the texture.
  100017. */
  100018. export class BaseTexture implements IAnimatable {
  100019. /**
  100020. * Default anisotropic filtering level for the application.
  100021. * It is set to 4 as a good tradeoff between perf and quality.
  100022. */
  100023. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  100024. /**
  100025. * Gets or sets the unique id of the texture
  100026. */
  100027. uniqueId: number;
  100028. /**
  100029. * Define the name of the texture.
  100030. */
  100031. name: string;
  100032. /**
  100033. * Gets or sets an object used to store user defined information.
  100034. */
  100035. metadata: any;
  100036. /**
  100037. * For internal use only. Please do not use.
  100038. */
  100039. reservedDataStore: any;
  100040. private _hasAlpha;
  100041. /**
  100042. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  100043. */
  100044. set hasAlpha(value: boolean);
  100045. get hasAlpha(): boolean;
  100046. /**
  100047. * Defines if the alpha value should be determined via the rgb values.
  100048. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  100049. */
  100050. getAlphaFromRGB: boolean;
  100051. /**
  100052. * Intensity or strength of the texture.
  100053. * It is commonly used by materials to fine tune the intensity of the texture
  100054. */
  100055. level: number;
  100056. /**
  100057. * Define the UV chanel to use starting from 0 and defaulting to 0.
  100058. * This is part of the texture as textures usually maps to one uv set.
  100059. */
  100060. coordinatesIndex: number;
  100061. private _coordinatesMode;
  100062. /**
  100063. * How a texture is mapped.
  100064. *
  100065. * | Value | Type | Description |
  100066. * | ----- | ----------------------------------- | ----------- |
  100067. * | 0 | EXPLICIT_MODE | |
  100068. * | 1 | SPHERICAL_MODE | |
  100069. * | 2 | PLANAR_MODE | |
  100070. * | 3 | CUBIC_MODE | |
  100071. * | 4 | PROJECTION_MODE | |
  100072. * | 5 | SKYBOX_MODE | |
  100073. * | 6 | INVCUBIC_MODE | |
  100074. * | 7 | EQUIRECTANGULAR_MODE | |
  100075. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  100076. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  100077. */
  100078. set coordinatesMode(value: number);
  100079. get coordinatesMode(): number;
  100080. /**
  100081. * | Value | Type | Description |
  100082. * | ----- | ------------------ | ----------- |
  100083. * | 0 | CLAMP_ADDRESSMODE | |
  100084. * | 1 | WRAP_ADDRESSMODE | |
  100085. * | 2 | MIRROR_ADDRESSMODE | |
  100086. */
  100087. wrapU: number;
  100088. /**
  100089. * | Value | Type | Description |
  100090. * | ----- | ------------------ | ----------- |
  100091. * | 0 | CLAMP_ADDRESSMODE | |
  100092. * | 1 | WRAP_ADDRESSMODE | |
  100093. * | 2 | MIRROR_ADDRESSMODE | |
  100094. */
  100095. wrapV: number;
  100096. /**
  100097. * | Value | Type | Description |
  100098. * | ----- | ------------------ | ----------- |
  100099. * | 0 | CLAMP_ADDRESSMODE | |
  100100. * | 1 | WRAP_ADDRESSMODE | |
  100101. * | 2 | MIRROR_ADDRESSMODE | |
  100102. */
  100103. wrapR: number;
  100104. /**
  100105. * With compliant hardware and browser (supporting anisotropic filtering)
  100106. * this defines the level of anisotropic filtering in the texture.
  100107. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  100108. */
  100109. anisotropicFilteringLevel: number;
  100110. /**
  100111. * Define if the texture is a cube texture or if false a 2d texture.
  100112. */
  100113. get isCube(): boolean;
  100114. set isCube(value: boolean);
  100115. /**
  100116. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  100117. */
  100118. get is3D(): boolean;
  100119. set is3D(value: boolean);
  100120. /**
  100121. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  100122. */
  100123. get is2DArray(): boolean;
  100124. set is2DArray(value: boolean);
  100125. /**
  100126. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  100127. * HDR texture are usually stored in linear space.
  100128. * This only impacts the PBR and Background materials
  100129. */
  100130. gammaSpace: boolean;
  100131. /**
  100132. * Gets or sets whether or not the texture contains RGBD data.
  100133. */
  100134. get isRGBD(): boolean;
  100135. set isRGBD(value: boolean);
  100136. /**
  100137. * Is Z inverted in the texture (useful in a cube texture).
  100138. */
  100139. invertZ: boolean;
  100140. /**
  100141. * Are mip maps generated for this texture or not.
  100142. */
  100143. get noMipmap(): boolean;
  100144. /**
  100145. * @hidden
  100146. */
  100147. lodLevelInAlpha: boolean;
  100148. /**
  100149. * With prefiltered texture, defined the offset used during the prefiltering steps.
  100150. */
  100151. get lodGenerationOffset(): number;
  100152. set lodGenerationOffset(value: number);
  100153. /**
  100154. * With prefiltered texture, defined the scale used during the prefiltering steps.
  100155. */
  100156. get lodGenerationScale(): number;
  100157. set lodGenerationScale(value: number);
  100158. /**
  100159. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  100160. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  100161. * average roughness values.
  100162. */
  100163. get linearSpecularLOD(): boolean;
  100164. set linearSpecularLOD(value: boolean);
  100165. /**
  100166. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  100167. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  100168. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  100169. */
  100170. get irradianceTexture(): Nullable<BaseTexture>;
  100171. set irradianceTexture(value: Nullable<BaseTexture>);
  100172. /**
  100173. * Define if the texture is a render target.
  100174. */
  100175. isRenderTarget: boolean;
  100176. /**
  100177. * Define the unique id of the texture in the scene.
  100178. */
  100179. get uid(): string;
  100180. /**
  100181. * Return a string representation of the texture.
  100182. * @returns the texture as a string
  100183. */
  100184. toString(): string;
  100185. /**
  100186. * Get the class name of the texture.
  100187. * @returns "BaseTexture"
  100188. */
  100189. getClassName(): string;
  100190. /**
  100191. * Define the list of animation attached to the texture.
  100192. */
  100193. animations: Animation[];
  100194. /**
  100195. * An event triggered when the texture is disposed.
  100196. */
  100197. onDisposeObservable: Observable<BaseTexture>;
  100198. private _onDisposeObserver;
  100199. /**
  100200. * Callback triggered when the texture has been disposed.
  100201. * Kept for back compatibility, you can use the onDisposeObservable instead.
  100202. */
  100203. set onDispose(callback: () => void);
  100204. /**
  100205. * Define the current state of the loading sequence when in delayed load mode.
  100206. */
  100207. delayLoadState: number;
  100208. private _scene;
  100209. /** @hidden */
  100210. _texture: Nullable<InternalTexture>;
  100211. private _uid;
  100212. /**
  100213. * Define if the texture is preventinga material to render or not.
  100214. * If not and the texture is not ready, the engine will use a default black texture instead.
  100215. */
  100216. get isBlocking(): boolean;
  100217. /**
  100218. * Instantiates a new BaseTexture.
  100219. * Base class of all the textures in babylon.
  100220. * It groups all the common properties the materials, post process, lights... might need
  100221. * in order to make a correct use of the texture.
  100222. * @param scene Define the scene the texture blongs to
  100223. */
  100224. constructor(scene: Nullable<Scene>);
  100225. /**
  100226. * Get the scene the texture belongs to.
  100227. * @returns the scene or null if undefined
  100228. */
  100229. getScene(): Nullable<Scene>;
  100230. /**
  100231. * Get the texture transform matrix used to offset tile the texture for istance.
  100232. * @returns the transformation matrix
  100233. */
  100234. getTextureMatrix(): Matrix;
  100235. /**
  100236. * Get the texture reflection matrix used to rotate/transform the reflection.
  100237. * @returns the reflection matrix
  100238. */
  100239. getReflectionTextureMatrix(): Matrix;
  100240. /**
  100241. * Get the underlying lower level texture from Babylon.
  100242. * @returns the insternal texture
  100243. */
  100244. getInternalTexture(): Nullable<InternalTexture>;
  100245. /**
  100246. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  100247. * @returns true if ready or not blocking
  100248. */
  100249. isReadyOrNotBlocking(): boolean;
  100250. /**
  100251. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  100252. * @returns true if fully ready
  100253. */
  100254. isReady(): boolean;
  100255. private _cachedSize;
  100256. /**
  100257. * Get the size of the texture.
  100258. * @returns the texture size.
  100259. */
  100260. getSize(): ISize;
  100261. /**
  100262. * Get the base size of the texture.
  100263. * It can be different from the size if the texture has been resized for POT for instance
  100264. * @returns the base size
  100265. */
  100266. getBaseSize(): ISize;
  100267. /**
  100268. * Update the sampling mode of the texture.
  100269. * Default is Trilinear mode.
  100270. *
  100271. * | Value | Type | Description |
  100272. * | ----- | ------------------ | ----------- |
  100273. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  100274. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  100275. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  100276. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  100277. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  100278. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  100279. * | 7 | NEAREST_LINEAR | |
  100280. * | 8 | NEAREST_NEAREST | |
  100281. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  100282. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  100283. * | 11 | LINEAR_LINEAR | |
  100284. * | 12 | LINEAR_NEAREST | |
  100285. *
  100286. * > _mag_: magnification filter (close to the viewer)
  100287. * > _min_: minification filter (far from the viewer)
  100288. * > _mip_: filter used between mip map levels
  100289. *@param samplingMode Define the new sampling mode of the texture
  100290. */
  100291. updateSamplingMode(samplingMode: number): void;
  100292. /**
  100293. * Scales the texture if is `canRescale()`
  100294. * @param ratio the resize factor we want to use to rescale
  100295. */
  100296. scale(ratio: number): void;
  100297. /**
  100298. * Get if the texture can rescale.
  100299. */
  100300. get canRescale(): boolean;
  100301. /** @hidden */
  100302. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  100303. /** @hidden */
  100304. _rebuild(): void;
  100305. /**
  100306. * Triggers the load sequence in delayed load mode.
  100307. */
  100308. delayLoad(): void;
  100309. /**
  100310. * Clones the texture.
  100311. * @returns the cloned texture
  100312. */
  100313. clone(): Nullable<BaseTexture>;
  100314. /**
  100315. * Get the texture underlying type (INT, FLOAT...)
  100316. */
  100317. get textureType(): number;
  100318. /**
  100319. * Get the texture underlying format (RGB, RGBA...)
  100320. */
  100321. get textureFormat(): number;
  100322. /**
  100323. * Indicates that textures need to be re-calculated for all materials
  100324. */
  100325. protected _markAllSubMeshesAsTexturesDirty(): void;
  100326. /**
  100327. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  100328. * This will returns an RGBA array buffer containing either in values (0-255) or
  100329. * float values (0-1) depending of the underlying buffer type.
  100330. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  100331. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  100332. * @param buffer defines a user defined buffer to fill with data (can be null)
  100333. * @returns The Array buffer containing the pixels data.
  100334. */
  100335. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  100336. /**
  100337. * Release and destroy the underlying lower level texture aka internalTexture.
  100338. */
  100339. releaseInternalTexture(): void;
  100340. /** @hidden */
  100341. get _lodTextureHigh(): Nullable<BaseTexture>;
  100342. /** @hidden */
  100343. get _lodTextureMid(): Nullable<BaseTexture>;
  100344. /** @hidden */
  100345. get _lodTextureLow(): Nullable<BaseTexture>;
  100346. /**
  100347. * Dispose the texture and release its associated resources.
  100348. */
  100349. dispose(): void;
  100350. /**
  100351. * Serialize the texture into a JSON representation that can be parsed later on.
  100352. * @returns the JSON representation of the texture
  100353. */
  100354. serialize(): any;
  100355. /**
  100356. * Helper function to be called back once a list of texture contains only ready textures.
  100357. * @param textures Define the list of textures to wait for
  100358. * @param callback Define the callback triggered once the entire list will be ready
  100359. */
  100360. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  100361. }
  100362. }
  100363. declare module BABYLON {
  100364. /**
  100365. * Options to be used when creating an effect.
  100366. */
  100367. export interface IEffectCreationOptions {
  100368. /**
  100369. * Atrributes that will be used in the shader.
  100370. */
  100371. attributes: string[];
  100372. /**
  100373. * Uniform varible names that will be set in the shader.
  100374. */
  100375. uniformsNames: string[];
  100376. /**
  100377. * Uniform buffer variable names that will be set in the shader.
  100378. */
  100379. uniformBuffersNames: string[];
  100380. /**
  100381. * Sampler texture variable names that will be set in the shader.
  100382. */
  100383. samplers: string[];
  100384. /**
  100385. * Define statements that will be set in the shader.
  100386. */
  100387. defines: any;
  100388. /**
  100389. * Possible fallbacks for this effect to improve performance when needed.
  100390. */
  100391. fallbacks: Nullable<IEffectFallbacks>;
  100392. /**
  100393. * Callback that will be called when the shader is compiled.
  100394. */
  100395. onCompiled: Nullable<(effect: Effect) => void>;
  100396. /**
  100397. * Callback that will be called if an error occurs during shader compilation.
  100398. */
  100399. onError: Nullable<(effect: Effect, errors: string) => void>;
  100400. /**
  100401. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  100402. */
  100403. indexParameters?: any;
  100404. /**
  100405. * Max number of lights that can be used in the shader.
  100406. */
  100407. maxSimultaneousLights?: number;
  100408. /**
  100409. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  100410. */
  100411. transformFeedbackVaryings?: Nullable<string[]>;
  100412. }
  100413. /**
  100414. * Effect containing vertex and fragment shader that can be executed on an object.
  100415. */
  100416. export class Effect implements IDisposable {
  100417. /**
  100418. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  100419. */
  100420. static ShadersRepository: string;
  100421. /**
  100422. * Name of the effect.
  100423. */
  100424. name: any;
  100425. /**
  100426. * String container all the define statements that should be set on the shader.
  100427. */
  100428. defines: string;
  100429. /**
  100430. * Callback that will be called when the shader is compiled.
  100431. */
  100432. onCompiled: Nullable<(effect: Effect) => void>;
  100433. /**
  100434. * Callback that will be called if an error occurs during shader compilation.
  100435. */
  100436. onError: Nullable<(effect: Effect, errors: string) => void>;
  100437. /**
  100438. * Callback that will be called when effect is bound.
  100439. */
  100440. onBind: Nullable<(effect: Effect) => void>;
  100441. /**
  100442. * Unique ID of the effect.
  100443. */
  100444. uniqueId: number;
  100445. /**
  100446. * Observable that will be called when the shader is compiled.
  100447. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  100448. */
  100449. onCompileObservable: Observable<Effect>;
  100450. /**
  100451. * Observable that will be called if an error occurs during shader compilation.
  100452. */
  100453. onErrorObservable: Observable<Effect>;
  100454. /** @hidden */
  100455. _onBindObservable: Nullable<Observable<Effect>>;
  100456. /**
  100457. * Observable that will be called when effect is bound.
  100458. */
  100459. get onBindObservable(): Observable<Effect>;
  100460. /** @hidden */
  100461. _bonesComputationForcedToCPU: boolean;
  100462. private static _uniqueIdSeed;
  100463. private _engine;
  100464. private _uniformBuffersNames;
  100465. private _uniformsNames;
  100466. private _samplerList;
  100467. private _samplers;
  100468. private _isReady;
  100469. private _compilationError;
  100470. private _allFallbacksProcessed;
  100471. private _attributesNames;
  100472. private _attributes;
  100473. private _attributeLocationByName;
  100474. private _uniforms;
  100475. /**
  100476. * Key for the effect.
  100477. * @hidden
  100478. */
  100479. _key: string;
  100480. private _indexParameters;
  100481. private _fallbacks;
  100482. private _vertexSourceCode;
  100483. private _fragmentSourceCode;
  100484. private _vertexSourceCodeOverride;
  100485. private _fragmentSourceCodeOverride;
  100486. private _transformFeedbackVaryings;
  100487. /**
  100488. * Compiled shader to webGL program.
  100489. * @hidden
  100490. */
  100491. _pipelineContext: Nullable<IPipelineContext>;
  100492. private _valueCache;
  100493. private static _baseCache;
  100494. /**
  100495. * Instantiates an effect.
  100496. * An effect can be used to create/manage/execute vertex and fragment shaders.
  100497. * @param baseName Name of the effect.
  100498. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  100499. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  100500. * @param samplers List of sampler variables that will be passed to the shader.
  100501. * @param engine Engine to be used to render the effect
  100502. * @param defines Define statements to be added to the shader.
  100503. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  100504. * @param onCompiled Callback that will be called when the shader is compiled.
  100505. * @param onError Callback that will be called if an error occurs during shader compilation.
  100506. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  100507. */
  100508. 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);
  100509. private _useFinalCode;
  100510. /**
  100511. * Unique key for this effect
  100512. */
  100513. get key(): string;
  100514. /**
  100515. * If the effect has been compiled and prepared.
  100516. * @returns if the effect is compiled and prepared.
  100517. */
  100518. isReady(): boolean;
  100519. private _isReadyInternal;
  100520. /**
  100521. * The engine the effect was initialized with.
  100522. * @returns the engine.
  100523. */
  100524. getEngine(): Engine;
  100525. /**
  100526. * The pipeline context for this effect
  100527. * @returns the associated pipeline context
  100528. */
  100529. getPipelineContext(): Nullable<IPipelineContext>;
  100530. /**
  100531. * The set of names of attribute variables for the shader.
  100532. * @returns An array of attribute names.
  100533. */
  100534. getAttributesNames(): string[];
  100535. /**
  100536. * Returns the attribute at the given index.
  100537. * @param index The index of the attribute.
  100538. * @returns The location of the attribute.
  100539. */
  100540. getAttributeLocation(index: number): number;
  100541. /**
  100542. * Returns the attribute based on the name of the variable.
  100543. * @param name of the attribute to look up.
  100544. * @returns the attribute location.
  100545. */
  100546. getAttributeLocationByName(name: string): number;
  100547. /**
  100548. * The number of attributes.
  100549. * @returns the numnber of attributes.
  100550. */
  100551. getAttributesCount(): number;
  100552. /**
  100553. * Gets the index of a uniform variable.
  100554. * @param uniformName of the uniform to look up.
  100555. * @returns the index.
  100556. */
  100557. getUniformIndex(uniformName: string): number;
  100558. /**
  100559. * Returns the attribute based on the name of the variable.
  100560. * @param uniformName of the uniform to look up.
  100561. * @returns the location of the uniform.
  100562. */
  100563. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  100564. /**
  100565. * Returns an array of sampler variable names
  100566. * @returns The array of sampler variable neames.
  100567. */
  100568. getSamplers(): string[];
  100569. /**
  100570. * The error from the last compilation.
  100571. * @returns the error string.
  100572. */
  100573. getCompilationError(): string;
  100574. /**
  100575. * Gets a boolean indicating that all fallbacks were used during compilation
  100576. * @returns true if all fallbacks were used
  100577. */
  100578. allFallbacksProcessed(): boolean;
  100579. /**
  100580. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  100581. * @param func The callback to be used.
  100582. */
  100583. executeWhenCompiled(func: (effect: Effect) => void): void;
  100584. private _checkIsReady;
  100585. private _loadShader;
  100586. /**
  100587. * Recompiles the webGL program
  100588. * @param vertexSourceCode The source code for the vertex shader.
  100589. * @param fragmentSourceCode The source code for the fragment shader.
  100590. * @param onCompiled Callback called when completed.
  100591. * @param onError Callback called on error.
  100592. * @hidden
  100593. */
  100594. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  100595. /**
  100596. * Prepares the effect
  100597. * @hidden
  100598. */
  100599. _prepareEffect(): void;
  100600. private _processCompilationErrors;
  100601. /**
  100602. * Checks if the effect is supported. (Must be called after compilation)
  100603. */
  100604. get isSupported(): boolean;
  100605. /**
  100606. * Binds a texture to the engine to be used as output of the shader.
  100607. * @param channel Name of the output variable.
  100608. * @param texture Texture to bind.
  100609. * @hidden
  100610. */
  100611. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  100612. /**
  100613. * Sets a texture on the engine to be used in the shader.
  100614. * @param channel Name of the sampler variable.
  100615. * @param texture Texture to set.
  100616. */
  100617. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  100618. /**
  100619. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  100620. * @param channel Name of the sampler variable.
  100621. * @param texture Texture to set.
  100622. */
  100623. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  100624. /**
  100625. * Sets an array of textures on the engine to be used in the shader.
  100626. * @param channel Name of the variable.
  100627. * @param textures Textures to set.
  100628. */
  100629. setTextureArray(channel: string, textures: BaseTexture[]): void;
  100630. /**
  100631. * 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)
  100632. * @param channel Name of the sampler variable.
  100633. * @param postProcess Post process to get the input texture from.
  100634. */
  100635. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  100636. /**
  100637. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  100638. * 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)
  100639. * @param channel Name of the sampler variable.
  100640. * @param postProcess Post process to get the output texture from.
  100641. */
  100642. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  100643. /** @hidden */
  100644. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  100645. /** @hidden */
  100646. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  100647. /** @hidden */
  100648. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  100649. /** @hidden */
  100650. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  100651. /**
  100652. * Binds a buffer to a uniform.
  100653. * @param buffer Buffer to bind.
  100654. * @param name Name of the uniform variable to bind to.
  100655. */
  100656. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  100657. /**
  100658. * Binds block to a uniform.
  100659. * @param blockName Name of the block to bind.
  100660. * @param index Index to bind.
  100661. */
  100662. bindUniformBlock(blockName: string, index: number): void;
  100663. /**
  100664. * Sets an interger value on a uniform variable.
  100665. * @param uniformName Name of the variable.
  100666. * @param value Value to be set.
  100667. * @returns this effect.
  100668. */
  100669. setInt(uniformName: string, value: number): Effect;
  100670. /**
  100671. * Sets an int array on a uniform variable.
  100672. * @param uniformName Name of the variable.
  100673. * @param array array to be set.
  100674. * @returns this effect.
  100675. */
  100676. setIntArray(uniformName: string, array: Int32Array): Effect;
  100677. /**
  100678. * 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)
  100679. * @param uniformName Name of the variable.
  100680. * @param array array to be set.
  100681. * @returns this effect.
  100682. */
  100683. setIntArray2(uniformName: string, array: Int32Array): Effect;
  100684. /**
  100685. * 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)
  100686. * @param uniformName Name of the variable.
  100687. * @param array array to be set.
  100688. * @returns this effect.
  100689. */
  100690. setIntArray3(uniformName: string, array: Int32Array): Effect;
  100691. /**
  100692. * 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)
  100693. * @param uniformName Name of the variable.
  100694. * @param array array to be set.
  100695. * @returns this effect.
  100696. */
  100697. setIntArray4(uniformName: string, array: Int32Array): Effect;
  100698. /**
  100699. * Sets an float array on a uniform variable.
  100700. * @param uniformName Name of the variable.
  100701. * @param array array to be set.
  100702. * @returns this effect.
  100703. */
  100704. setFloatArray(uniformName: string, array: Float32Array): Effect;
  100705. /**
  100706. * 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)
  100707. * @param uniformName Name of the variable.
  100708. * @param array array to be set.
  100709. * @returns this effect.
  100710. */
  100711. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  100712. /**
  100713. * 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)
  100714. * @param uniformName Name of the variable.
  100715. * @param array array to be set.
  100716. * @returns this effect.
  100717. */
  100718. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  100719. /**
  100720. * 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)
  100721. * @param uniformName Name of the variable.
  100722. * @param array array to be set.
  100723. * @returns this effect.
  100724. */
  100725. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  100726. /**
  100727. * Sets an array on a uniform variable.
  100728. * @param uniformName Name of the variable.
  100729. * @param array array to be set.
  100730. * @returns this effect.
  100731. */
  100732. setArray(uniformName: string, array: number[]): Effect;
  100733. /**
  100734. * 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)
  100735. * @param uniformName Name of the variable.
  100736. * @param array array to be set.
  100737. * @returns this effect.
  100738. */
  100739. setArray2(uniformName: string, array: number[]): Effect;
  100740. /**
  100741. * 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)
  100742. * @param uniformName Name of the variable.
  100743. * @param array array to be set.
  100744. * @returns this effect.
  100745. */
  100746. setArray3(uniformName: string, array: number[]): Effect;
  100747. /**
  100748. * 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)
  100749. * @param uniformName Name of the variable.
  100750. * @param array array to be set.
  100751. * @returns this effect.
  100752. */
  100753. setArray4(uniformName: string, array: number[]): Effect;
  100754. /**
  100755. * Sets matrices on a uniform variable.
  100756. * @param uniformName Name of the variable.
  100757. * @param matrices matrices to be set.
  100758. * @returns this effect.
  100759. */
  100760. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  100761. /**
  100762. * Sets matrix on a uniform variable.
  100763. * @param uniformName Name of the variable.
  100764. * @param matrix matrix to be set.
  100765. * @returns this effect.
  100766. */
  100767. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  100768. /**
  100769. * 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)
  100770. * @param uniformName Name of the variable.
  100771. * @param matrix matrix to be set.
  100772. * @returns this effect.
  100773. */
  100774. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  100775. /**
  100776. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  100777. * @param uniformName Name of the variable.
  100778. * @param matrix matrix to be set.
  100779. * @returns this effect.
  100780. */
  100781. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  100782. /**
  100783. * Sets a float on a uniform variable.
  100784. * @param uniformName Name of the variable.
  100785. * @param value value to be set.
  100786. * @returns this effect.
  100787. */
  100788. setFloat(uniformName: string, value: number): Effect;
  100789. /**
  100790. * Sets a boolean on a uniform variable.
  100791. * @param uniformName Name of the variable.
  100792. * @param bool value to be set.
  100793. * @returns this effect.
  100794. */
  100795. setBool(uniformName: string, bool: boolean): Effect;
  100796. /**
  100797. * Sets a Vector2 on a uniform variable.
  100798. * @param uniformName Name of the variable.
  100799. * @param vector2 vector2 to be set.
  100800. * @returns this effect.
  100801. */
  100802. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  100803. /**
  100804. * Sets a float2 on a uniform variable.
  100805. * @param uniformName Name of the variable.
  100806. * @param x First float in float2.
  100807. * @param y Second float in float2.
  100808. * @returns this effect.
  100809. */
  100810. setFloat2(uniformName: string, x: number, y: number): Effect;
  100811. /**
  100812. * Sets a Vector3 on a uniform variable.
  100813. * @param uniformName Name of the variable.
  100814. * @param vector3 Value to be set.
  100815. * @returns this effect.
  100816. */
  100817. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  100818. /**
  100819. * Sets a float3 on a uniform variable.
  100820. * @param uniformName Name of the variable.
  100821. * @param x First float in float3.
  100822. * @param y Second float in float3.
  100823. * @param z Third float in float3.
  100824. * @returns this effect.
  100825. */
  100826. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  100827. /**
  100828. * Sets a Vector4 on a uniform variable.
  100829. * @param uniformName Name of the variable.
  100830. * @param vector4 Value to be set.
  100831. * @returns this effect.
  100832. */
  100833. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  100834. /**
  100835. * Sets a float4 on a uniform variable.
  100836. * @param uniformName Name of the variable.
  100837. * @param x First float in float4.
  100838. * @param y Second float in float4.
  100839. * @param z Third float in float4.
  100840. * @param w Fourth float in float4.
  100841. * @returns this effect.
  100842. */
  100843. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  100844. /**
  100845. * Sets a Color3 on a uniform variable.
  100846. * @param uniformName Name of the variable.
  100847. * @param color3 Value to be set.
  100848. * @returns this effect.
  100849. */
  100850. setColor3(uniformName: string, color3: IColor3Like): Effect;
  100851. /**
  100852. * Sets a Color4 on a uniform variable.
  100853. * @param uniformName Name of the variable.
  100854. * @param color3 Value to be set.
  100855. * @param alpha Alpha value to be set.
  100856. * @returns this effect.
  100857. */
  100858. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  100859. /**
  100860. * Sets a Color4 on a uniform variable
  100861. * @param uniformName defines the name of the variable
  100862. * @param color4 defines the value to be set
  100863. * @returns this effect.
  100864. */
  100865. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  100866. /** Release all associated resources */
  100867. dispose(): void;
  100868. /**
  100869. * This function will add a new shader to the shader store
  100870. * @param name the name of the shader
  100871. * @param pixelShader optional pixel shader content
  100872. * @param vertexShader optional vertex shader content
  100873. */
  100874. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  100875. /**
  100876. * Store of each shader (The can be looked up using effect.key)
  100877. */
  100878. static ShadersStore: {
  100879. [key: string]: string;
  100880. };
  100881. /**
  100882. * Store of each included file for a shader (The can be looked up using effect.key)
  100883. */
  100884. static IncludesShadersStore: {
  100885. [key: string]: string;
  100886. };
  100887. /**
  100888. * Resets the cache of effects.
  100889. */
  100890. static ResetCache(): void;
  100891. }
  100892. }
  100893. declare module BABYLON {
  100894. /**
  100895. * Interface used to describe the capabilities of the engine relatively to the current browser
  100896. */
  100897. export interface EngineCapabilities {
  100898. /** Maximum textures units per fragment shader */
  100899. maxTexturesImageUnits: number;
  100900. /** Maximum texture units per vertex shader */
  100901. maxVertexTextureImageUnits: number;
  100902. /** Maximum textures units in the entire pipeline */
  100903. maxCombinedTexturesImageUnits: number;
  100904. /** Maximum texture size */
  100905. maxTextureSize: number;
  100906. /** Maximum texture samples */
  100907. maxSamples?: number;
  100908. /** Maximum cube texture size */
  100909. maxCubemapTextureSize: number;
  100910. /** Maximum render texture size */
  100911. maxRenderTextureSize: number;
  100912. /** Maximum number of vertex attributes */
  100913. maxVertexAttribs: number;
  100914. /** Maximum number of varyings */
  100915. maxVaryingVectors: number;
  100916. /** Maximum number of uniforms per vertex shader */
  100917. maxVertexUniformVectors: number;
  100918. /** Maximum number of uniforms per fragment shader */
  100919. maxFragmentUniformVectors: number;
  100920. /** Defines if standard derivates (dx/dy) are supported */
  100921. standardDerivatives: boolean;
  100922. /** Defines if s3tc texture compression is supported */
  100923. s3tc?: WEBGL_compressed_texture_s3tc;
  100924. /** Defines if pvrtc texture compression is supported */
  100925. pvrtc: any;
  100926. /** Defines if etc1 texture compression is supported */
  100927. etc1: any;
  100928. /** Defines if etc2 texture compression is supported */
  100929. etc2: any;
  100930. /** Defines if astc texture compression is supported */
  100931. astc: any;
  100932. /** Defines if float textures are supported */
  100933. textureFloat: boolean;
  100934. /** Defines if vertex array objects are supported */
  100935. vertexArrayObject: boolean;
  100936. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  100937. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  100938. /** Gets the maximum level of anisotropy supported */
  100939. maxAnisotropy: number;
  100940. /** Defines if instancing is supported */
  100941. instancedArrays: boolean;
  100942. /** Defines if 32 bits indices are supported */
  100943. uintIndices: boolean;
  100944. /** Defines if high precision shaders are supported */
  100945. highPrecisionShaderSupported: boolean;
  100946. /** Defines if depth reading in the fragment shader is supported */
  100947. fragmentDepthSupported: boolean;
  100948. /** Defines if float texture linear filtering is supported*/
  100949. textureFloatLinearFiltering: boolean;
  100950. /** Defines if rendering to float textures is supported */
  100951. textureFloatRender: boolean;
  100952. /** Defines if half float textures are supported*/
  100953. textureHalfFloat: boolean;
  100954. /** Defines if half float texture linear filtering is supported*/
  100955. textureHalfFloatLinearFiltering: boolean;
  100956. /** Defines if rendering to half float textures is supported */
  100957. textureHalfFloatRender: boolean;
  100958. /** Defines if textureLOD shader command is supported */
  100959. textureLOD: boolean;
  100960. /** Defines if draw buffers extension is supported */
  100961. drawBuffersExtension: boolean;
  100962. /** Defines if depth textures are supported */
  100963. depthTextureExtension: boolean;
  100964. /** Defines if float color buffer are supported */
  100965. colorBufferFloat: boolean;
  100966. /** Gets disjoint timer query extension (null if not supported) */
  100967. timerQuery?: EXT_disjoint_timer_query;
  100968. /** Defines if timestamp can be used with timer query */
  100969. canUseTimestampForTimerQuery: boolean;
  100970. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  100971. multiview?: any;
  100972. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  100973. oculusMultiview?: any;
  100974. /** Function used to let the system compiles shaders in background */
  100975. parallelShaderCompile?: {
  100976. COMPLETION_STATUS_KHR: number;
  100977. };
  100978. /** Max number of texture samples for MSAA */
  100979. maxMSAASamples: number;
  100980. /** Defines if the blend min max extension is supported */
  100981. blendMinMax: boolean;
  100982. }
  100983. }
  100984. declare module BABYLON {
  100985. /**
  100986. * @hidden
  100987. **/
  100988. export class DepthCullingState {
  100989. private _isDepthTestDirty;
  100990. private _isDepthMaskDirty;
  100991. private _isDepthFuncDirty;
  100992. private _isCullFaceDirty;
  100993. private _isCullDirty;
  100994. private _isZOffsetDirty;
  100995. private _isFrontFaceDirty;
  100996. private _depthTest;
  100997. private _depthMask;
  100998. private _depthFunc;
  100999. private _cull;
  101000. private _cullFace;
  101001. private _zOffset;
  101002. private _frontFace;
  101003. /**
  101004. * Initializes the state.
  101005. */
  101006. constructor();
  101007. get isDirty(): boolean;
  101008. get zOffset(): number;
  101009. set zOffset(value: number);
  101010. get cullFace(): Nullable<number>;
  101011. set cullFace(value: Nullable<number>);
  101012. get cull(): Nullable<boolean>;
  101013. set cull(value: Nullable<boolean>);
  101014. get depthFunc(): Nullable<number>;
  101015. set depthFunc(value: Nullable<number>);
  101016. get depthMask(): boolean;
  101017. set depthMask(value: boolean);
  101018. get depthTest(): boolean;
  101019. set depthTest(value: boolean);
  101020. get frontFace(): Nullable<number>;
  101021. set frontFace(value: Nullable<number>);
  101022. reset(): void;
  101023. apply(gl: WebGLRenderingContext): void;
  101024. }
  101025. }
  101026. declare module BABYLON {
  101027. /**
  101028. * @hidden
  101029. **/
  101030. export class StencilState {
  101031. /** 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 */
  101032. static readonly ALWAYS: number;
  101033. /** Passed to stencilOperation to specify that stencil value must be kept */
  101034. static readonly KEEP: number;
  101035. /** Passed to stencilOperation to specify that stencil value must be replaced */
  101036. static readonly REPLACE: number;
  101037. private _isStencilTestDirty;
  101038. private _isStencilMaskDirty;
  101039. private _isStencilFuncDirty;
  101040. private _isStencilOpDirty;
  101041. private _stencilTest;
  101042. private _stencilMask;
  101043. private _stencilFunc;
  101044. private _stencilFuncRef;
  101045. private _stencilFuncMask;
  101046. private _stencilOpStencilFail;
  101047. private _stencilOpDepthFail;
  101048. private _stencilOpStencilDepthPass;
  101049. get isDirty(): boolean;
  101050. get stencilFunc(): number;
  101051. set stencilFunc(value: number);
  101052. get stencilFuncRef(): number;
  101053. set stencilFuncRef(value: number);
  101054. get stencilFuncMask(): number;
  101055. set stencilFuncMask(value: number);
  101056. get stencilOpStencilFail(): number;
  101057. set stencilOpStencilFail(value: number);
  101058. get stencilOpDepthFail(): number;
  101059. set stencilOpDepthFail(value: number);
  101060. get stencilOpStencilDepthPass(): number;
  101061. set stencilOpStencilDepthPass(value: number);
  101062. get stencilMask(): number;
  101063. set stencilMask(value: number);
  101064. get stencilTest(): boolean;
  101065. set stencilTest(value: boolean);
  101066. constructor();
  101067. reset(): void;
  101068. apply(gl: WebGLRenderingContext): void;
  101069. }
  101070. }
  101071. declare module BABYLON {
  101072. /**
  101073. * @hidden
  101074. **/
  101075. export class AlphaState {
  101076. private _isAlphaBlendDirty;
  101077. private _isBlendFunctionParametersDirty;
  101078. private _isBlendEquationParametersDirty;
  101079. private _isBlendConstantsDirty;
  101080. private _alphaBlend;
  101081. private _blendFunctionParameters;
  101082. private _blendEquationParameters;
  101083. private _blendConstants;
  101084. /**
  101085. * Initializes the state.
  101086. */
  101087. constructor();
  101088. get isDirty(): boolean;
  101089. get alphaBlend(): boolean;
  101090. set alphaBlend(value: boolean);
  101091. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  101092. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  101093. setAlphaEquationParameters(rgb: number, alpha: number): void;
  101094. reset(): void;
  101095. apply(gl: WebGLRenderingContext): void;
  101096. }
  101097. }
  101098. declare module BABYLON {
  101099. /** @hidden */
  101100. export class WebGL2ShaderProcessor implements IShaderProcessor {
  101101. attributeProcessor(attribute: string): string;
  101102. varyingProcessor(varying: string, isFragment: boolean): string;
  101103. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  101104. }
  101105. }
  101106. declare module BABYLON {
  101107. /**
  101108. * Interface for attribute information associated with buffer instanciation
  101109. */
  101110. export interface InstancingAttributeInfo {
  101111. /**
  101112. * Name of the GLSL attribute
  101113. * if attribute index is not specified, this is used to retrieve the index from the effect
  101114. */
  101115. attributeName: string;
  101116. /**
  101117. * Index/offset of the attribute in the vertex shader
  101118. * if not specified, this will be computes from the name.
  101119. */
  101120. index?: number;
  101121. /**
  101122. * size of the attribute, 1, 2, 3 or 4
  101123. */
  101124. attributeSize: number;
  101125. /**
  101126. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  101127. */
  101128. offset: number;
  101129. /**
  101130. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  101131. * default to 1
  101132. */
  101133. divisor?: number;
  101134. /**
  101135. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  101136. * default is FLOAT
  101137. */
  101138. attributeType?: number;
  101139. /**
  101140. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  101141. */
  101142. normalized?: boolean;
  101143. }
  101144. }
  101145. declare module BABYLON {
  101146. interface ThinEngine {
  101147. /**
  101148. * Update a video texture
  101149. * @param texture defines the texture to update
  101150. * @param video defines the video element to use
  101151. * @param invertY defines if data must be stored with Y axis inverted
  101152. */
  101153. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  101154. }
  101155. }
  101156. declare module BABYLON {
  101157. /**
  101158. * Settings for finer control over video usage
  101159. */
  101160. export interface VideoTextureSettings {
  101161. /**
  101162. * Applies `autoplay` to video, if specified
  101163. */
  101164. autoPlay?: boolean;
  101165. /**
  101166. * Applies `loop` to video, if specified
  101167. */
  101168. loop?: boolean;
  101169. /**
  101170. * Automatically updates internal texture from video at every frame in the render loop
  101171. */
  101172. autoUpdateTexture: boolean;
  101173. /**
  101174. * Image src displayed during the video loading or until the user interacts with the video.
  101175. */
  101176. poster?: string;
  101177. }
  101178. /**
  101179. * If you want to display a video in your scene, this is the special texture for that.
  101180. * This special texture works similar to other textures, with the exception of a few parameters.
  101181. * @see https://doc.babylonjs.com/how_to/video_texture
  101182. */
  101183. export class VideoTexture extends Texture {
  101184. /**
  101185. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  101186. */
  101187. readonly autoUpdateTexture: boolean;
  101188. /**
  101189. * The video instance used by the texture internally
  101190. */
  101191. readonly video: HTMLVideoElement;
  101192. private _onUserActionRequestedObservable;
  101193. /**
  101194. * Event triggerd when a dom action is required by the user to play the video.
  101195. * This happens due to recent changes in browser policies preventing video to auto start.
  101196. */
  101197. get onUserActionRequestedObservable(): Observable<Texture>;
  101198. private _generateMipMaps;
  101199. private _engine;
  101200. private _stillImageCaptured;
  101201. private _displayingPosterTexture;
  101202. private _settings;
  101203. private _createInternalTextureOnEvent;
  101204. private _frameId;
  101205. /**
  101206. * Creates a video texture.
  101207. * If you want to display a video in your scene, this is the special texture for that.
  101208. * This special texture works similar to other textures, with the exception of a few parameters.
  101209. * @see https://doc.babylonjs.com/how_to/video_texture
  101210. * @param name optional name, will detect from video source, if not defined
  101211. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  101212. * @param scene is obviously the current scene.
  101213. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  101214. * @param invertY is false by default but can be used to invert video on Y axis
  101215. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  101216. * @param settings allows finer control over video usage
  101217. */
  101218. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  101219. private _getName;
  101220. private _getVideo;
  101221. private _createInternalTexture;
  101222. private reset;
  101223. /**
  101224. * @hidden Internal method to initiate `update`.
  101225. */
  101226. _rebuild(): void;
  101227. /**
  101228. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  101229. */
  101230. update(): void;
  101231. /**
  101232. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  101233. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  101234. */
  101235. updateTexture(isVisible: boolean): void;
  101236. protected _updateInternalTexture: () => void;
  101237. /**
  101238. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  101239. * @param url New url.
  101240. */
  101241. updateURL(url: string): void;
  101242. /**
  101243. * Dispose the texture and release its associated resources.
  101244. */
  101245. dispose(): void;
  101246. /**
  101247. * Creates a video texture straight from a stream.
  101248. * @param scene Define the scene the texture should be created in
  101249. * @param stream Define the stream the texture should be created from
  101250. * @returns The created video texture as a promise
  101251. */
  101252. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  101253. /**
  101254. * Creates a video texture straight from your WebCam video feed.
  101255. * @param scene Define the scene the texture should be created in
  101256. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  101257. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  101258. * @returns The created video texture as a promise
  101259. */
  101260. static CreateFromWebCamAsync(scene: Scene, constraints: {
  101261. minWidth: number;
  101262. maxWidth: number;
  101263. minHeight: number;
  101264. maxHeight: number;
  101265. deviceId: string;
  101266. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  101267. /**
  101268. * Creates a video texture straight from your WebCam video feed.
  101269. * @param scene Define the scene the texture should be created in
  101270. * @param onReady Define a callback to triggered once the texture will be ready
  101271. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  101272. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  101273. */
  101274. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  101275. minWidth: number;
  101276. maxWidth: number;
  101277. minHeight: number;
  101278. maxHeight: number;
  101279. deviceId: string;
  101280. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  101281. }
  101282. }
  101283. declare module BABYLON {
  101284. /**
  101285. * Defines the interface used by objects working like Scene
  101286. * @hidden
  101287. */
  101288. interface ISceneLike {
  101289. _addPendingData(data: any): void;
  101290. _removePendingData(data: any): void;
  101291. offlineProvider: IOfflineProvider;
  101292. }
  101293. /** Interface defining initialization parameters for Engine class */
  101294. export interface EngineOptions extends WebGLContextAttributes {
  101295. /**
  101296. * Defines if the engine should no exceed a specified device ratio
  101297. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  101298. */
  101299. limitDeviceRatio?: number;
  101300. /**
  101301. * Defines if webvr should be enabled automatically
  101302. * @see http://doc.babylonjs.com/how_to/webvr_camera
  101303. */
  101304. autoEnableWebVR?: boolean;
  101305. /**
  101306. * Defines if webgl2 should be turned off even if supported
  101307. * @see http://doc.babylonjs.com/features/webgl2
  101308. */
  101309. disableWebGL2Support?: boolean;
  101310. /**
  101311. * Defines if webaudio should be initialized as well
  101312. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101313. */
  101314. audioEngine?: boolean;
  101315. /**
  101316. * Defines if animations should run using a deterministic lock step
  101317. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101318. */
  101319. deterministicLockstep?: boolean;
  101320. /** Defines the maximum steps to use with deterministic lock step mode */
  101321. lockstepMaxSteps?: number;
  101322. /** Defines the seconds between each deterministic lock step */
  101323. timeStep?: number;
  101324. /**
  101325. * Defines that engine should ignore context lost events
  101326. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  101327. */
  101328. doNotHandleContextLost?: boolean;
  101329. /**
  101330. * Defines that engine should ignore modifying touch action attribute and style
  101331. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  101332. */
  101333. doNotHandleTouchAction?: boolean;
  101334. /**
  101335. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  101336. */
  101337. useHighPrecisionFloats?: boolean;
  101338. }
  101339. /**
  101340. * The base engine class (root of all engines)
  101341. */
  101342. export class ThinEngine {
  101343. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  101344. static ExceptionList: ({
  101345. key: string;
  101346. capture: string;
  101347. captureConstraint: number;
  101348. targets: string[];
  101349. } | {
  101350. key: string;
  101351. capture: null;
  101352. captureConstraint: null;
  101353. targets: string[];
  101354. })[];
  101355. /** @hidden */
  101356. static _TextureLoaders: IInternalTextureLoader[];
  101357. /**
  101358. * Returns the current npm package of the sdk
  101359. */
  101360. static get NpmPackage(): string;
  101361. /**
  101362. * Returns the current version of the framework
  101363. */
  101364. static get Version(): string;
  101365. /**
  101366. * Returns a string describing the current engine
  101367. */
  101368. get description(): string;
  101369. /**
  101370. * Gets or sets the epsilon value used by collision engine
  101371. */
  101372. static CollisionsEpsilon: number;
  101373. /**
  101374. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  101375. */
  101376. static get ShadersRepository(): string;
  101377. static set ShadersRepository(value: string);
  101378. /**
  101379. * Gets or sets the textures that the engine should not attempt to load as compressed
  101380. */
  101381. protected _excludedCompressedTextures: string[];
  101382. /**
  101383. * Filters the compressed texture formats to only include
  101384. * files that are not included in the skippable list
  101385. *
  101386. * @param url the current extension
  101387. * @param textureFormatInUse the current compressed texture format
  101388. * @returns "format" string
  101389. */
  101390. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  101391. /** @hidden */
  101392. _shaderProcessor: IShaderProcessor;
  101393. /**
  101394. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  101395. */
  101396. forcePOTTextures: boolean;
  101397. /**
  101398. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  101399. */
  101400. isFullscreen: boolean;
  101401. /**
  101402. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  101403. */
  101404. cullBackFaces: boolean;
  101405. /**
  101406. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  101407. */
  101408. renderEvenInBackground: boolean;
  101409. /**
  101410. * Gets or sets a boolean indicating that cache can be kept between frames
  101411. */
  101412. preventCacheWipeBetweenFrames: boolean;
  101413. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  101414. validateShaderPrograms: boolean;
  101415. /**
  101416. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  101417. * This can provide greater z depth for distant objects.
  101418. */
  101419. useReverseDepthBuffer: boolean;
  101420. /**
  101421. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  101422. */
  101423. disableUniformBuffers: boolean;
  101424. /** @hidden */
  101425. _uniformBuffers: UniformBuffer[];
  101426. /**
  101427. * Gets a boolean indicating that the engine supports uniform buffers
  101428. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  101429. */
  101430. get supportsUniformBuffers(): boolean;
  101431. /** @hidden */
  101432. _gl: WebGLRenderingContext;
  101433. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  101434. protected _windowIsBackground: boolean;
  101435. protected _webGLVersion: number;
  101436. protected _creationOptions: EngineOptions;
  101437. protected _highPrecisionShadersAllowed: boolean;
  101438. /** @hidden */
  101439. get _shouldUseHighPrecisionShader(): boolean;
  101440. /**
  101441. * Gets a boolean indicating that only power of 2 textures are supported
  101442. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  101443. */
  101444. get needPOTTextures(): boolean;
  101445. /** @hidden */
  101446. _badOS: boolean;
  101447. /** @hidden */
  101448. _badDesktopOS: boolean;
  101449. private _hardwareScalingLevel;
  101450. /** @hidden */
  101451. _caps: EngineCapabilities;
  101452. private _isStencilEnable;
  101453. private _glVersion;
  101454. private _glRenderer;
  101455. private _glVendor;
  101456. /** @hidden */
  101457. _videoTextureSupported: boolean;
  101458. protected _renderingQueueLaunched: boolean;
  101459. protected _activeRenderLoops: (() => void)[];
  101460. /**
  101461. * Observable signaled when a context lost event is raised
  101462. */
  101463. onContextLostObservable: Observable<ThinEngine>;
  101464. /**
  101465. * Observable signaled when a context restored event is raised
  101466. */
  101467. onContextRestoredObservable: Observable<ThinEngine>;
  101468. private _onContextLost;
  101469. private _onContextRestored;
  101470. protected _contextWasLost: boolean;
  101471. /** @hidden */
  101472. _doNotHandleContextLost: boolean;
  101473. /**
  101474. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  101475. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  101476. */
  101477. get doNotHandleContextLost(): boolean;
  101478. set doNotHandleContextLost(value: boolean);
  101479. /**
  101480. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  101481. */
  101482. disableVertexArrayObjects: boolean;
  101483. /** @hidden */
  101484. protected _colorWrite: boolean;
  101485. /** @hidden */
  101486. protected _colorWriteChanged: boolean;
  101487. /** @hidden */
  101488. protected _depthCullingState: DepthCullingState;
  101489. /** @hidden */
  101490. protected _stencilState: StencilState;
  101491. /** @hidden */
  101492. _alphaState: AlphaState;
  101493. /** @hidden */
  101494. _alphaMode: number;
  101495. /** @hidden */
  101496. _alphaEquation: number;
  101497. /** @hidden */
  101498. _internalTexturesCache: InternalTexture[];
  101499. /** @hidden */
  101500. protected _activeChannel: number;
  101501. private _currentTextureChannel;
  101502. /** @hidden */
  101503. protected _boundTexturesCache: {
  101504. [key: string]: Nullable<InternalTexture>;
  101505. };
  101506. /** @hidden */
  101507. protected _currentEffect: Nullable<Effect>;
  101508. /** @hidden */
  101509. protected _currentProgram: Nullable<WebGLProgram>;
  101510. private _compiledEffects;
  101511. private _vertexAttribArraysEnabled;
  101512. /** @hidden */
  101513. protected _cachedViewport: Nullable<IViewportLike>;
  101514. private _cachedVertexArrayObject;
  101515. /** @hidden */
  101516. protected _cachedVertexBuffers: any;
  101517. /** @hidden */
  101518. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  101519. /** @hidden */
  101520. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  101521. /** @hidden */
  101522. _currentRenderTarget: Nullable<InternalTexture>;
  101523. private _uintIndicesCurrentlySet;
  101524. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  101525. /** @hidden */
  101526. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  101527. private _currentBufferPointers;
  101528. private _currentInstanceLocations;
  101529. private _currentInstanceBuffers;
  101530. private _textureUnits;
  101531. /** @hidden */
  101532. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  101533. /** @hidden */
  101534. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  101535. /** @hidden */
  101536. _boundRenderFunction: any;
  101537. private _vaoRecordInProgress;
  101538. private _mustWipeVertexAttributes;
  101539. private _emptyTexture;
  101540. private _emptyCubeTexture;
  101541. private _emptyTexture3D;
  101542. private _emptyTexture2DArray;
  101543. /** @hidden */
  101544. _frameHandler: number;
  101545. private _nextFreeTextureSlots;
  101546. private _maxSimultaneousTextures;
  101547. private _activeRequests;
  101548. protected _texturesSupported: string[];
  101549. /** @hidden */
  101550. _textureFormatInUse: Nullable<string>;
  101551. protected get _supportsHardwareTextureRescaling(): boolean;
  101552. /**
  101553. * Gets the list of texture formats supported
  101554. */
  101555. get texturesSupported(): Array<string>;
  101556. /**
  101557. * Gets the list of texture formats in use
  101558. */
  101559. get textureFormatInUse(): Nullable<string>;
  101560. /**
  101561. * Gets the current viewport
  101562. */
  101563. get currentViewport(): Nullable<IViewportLike>;
  101564. /**
  101565. * Gets the default empty texture
  101566. */
  101567. get emptyTexture(): InternalTexture;
  101568. /**
  101569. * Gets the default empty 3D texture
  101570. */
  101571. get emptyTexture3D(): InternalTexture;
  101572. /**
  101573. * Gets the default empty 2D array texture
  101574. */
  101575. get emptyTexture2DArray(): InternalTexture;
  101576. /**
  101577. * Gets the default empty cube texture
  101578. */
  101579. get emptyCubeTexture(): InternalTexture;
  101580. /**
  101581. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  101582. */
  101583. readonly premultipliedAlpha: boolean;
  101584. /**
  101585. * Observable event triggered before each texture is initialized
  101586. */
  101587. onBeforeTextureInitObservable: Observable<Texture>;
  101588. /**
  101589. * Creates a new engine
  101590. * @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
  101591. * @param antialias defines enable antialiasing (default: false)
  101592. * @param options defines further options to be sent to the getContext() function
  101593. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  101594. */
  101595. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  101596. private _rebuildInternalTextures;
  101597. private _rebuildEffects;
  101598. /**
  101599. * Gets a boolean indicating if all created effects are ready
  101600. * @returns true if all effects are ready
  101601. */
  101602. areAllEffectsReady(): boolean;
  101603. protected _rebuildBuffers(): void;
  101604. private _initGLContext;
  101605. /**
  101606. * Gets version of the current webGL context
  101607. */
  101608. get webGLVersion(): number;
  101609. /**
  101610. * Gets a string idenfifying the name of the class
  101611. * @returns "Engine" string
  101612. */
  101613. getClassName(): string;
  101614. /**
  101615. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  101616. */
  101617. get isStencilEnable(): boolean;
  101618. /** @hidden */
  101619. _prepareWorkingCanvas(): void;
  101620. /**
  101621. * Reset the texture cache to empty state
  101622. */
  101623. resetTextureCache(): void;
  101624. /**
  101625. * Gets an object containing information about the current webGL context
  101626. * @returns an object containing the vender, the renderer and the version of the current webGL context
  101627. */
  101628. getGlInfo(): {
  101629. vendor: string;
  101630. renderer: string;
  101631. version: string;
  101632. };
  101633. /**
  101634. * Defines the hardware scaling level.
  101635. * By default the hardware scaling level is computed from the window device ratio.
  101636. * 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.
  101637. * @param level defines the level to use
  101638. */
  101639. setHardwareScalingLevel(level: number): void;
  101640. /**
  101641. * Gets the current hardware scaling level.
  101642. * By default the hardware scaling level is computed from the window device ratio.
  101643. * 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.
  101644. * @returns a number indicating the current hardware scaling level
  101645. */
  101646. getHardwareScalingLevel(): number;
  101647. /**
  101648. * Gets the list of loaded textures
  101649. * @returns an array containing all loaded textures
  101650. */
  101651. getLoadedTexturesCache(): InternalTexture[];
  101652. /**
  101653. * Gets the object containing all engine capabilities
  101654. * @returns the EngineCapabilities object
  101655. */
  101656. getCaps(): EngineCapabilities;
  101657. /**
  101658. * stop executing a render loop function and remove it from the execution array
  101659. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  101660. */
  101661. stopRenderLoop(renderFunction?: () => void): void;
  101662. /** @hidden */
  101663. _renderLoop(): void;
  101664. /**
  101665. * Gets the HTML canvas attached with the current webGL context
  101666. * @returns a HTML canvas
  101667. */
  101668. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  101669. /**
  101670. * Gets host window
  101671. * @returns the host window object
  101672. */
  101673. getHostWindow(): Nullable<Window>;
  101674. /**
  101675. * Gets the current render width
  101676. * @param useScreen defines if screen size must be used (or the current render target if any)
  101677. * @returns a number defining the current render width
  101678. */
  101679. getRenderWidth(useScreen?: boolean): number;
  101680. /**
  101681. * Gets the current render height
  101682. * @param useScreen defines if screen size must be used (or the current render target if any)
  101683. * @returns a number defining the current render height
  101684. */
  101685. getRenderHeight(useScreen?: boolean): number;
  101686. /**
  101687. * Can be used to override the current requestAnimationFrame requester.
  101688. * @hidden
  101689. */
  101690. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  101691. /**
  101692. * Register and execute a render loop. The engine can have more than one render function
  101693. * @param renderFunction defines the function to continuously execute
  101694. */
  101695. runRenderLoop(renderFunction: () => void): void;
  101696. /**
  101697. * Clear the current render buffer or the current render target (if any is set up)
  101698. * @param color defines the color to use
  101699. * @param backBuffer defines if the back buffer must be cleared
  101700. * @param depth defines if the depth buffer must be cleared
  101701. * @param stencil defines if the stencil buffer must be cleared
  101702. */
  101703. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  101704. private _viewportCached;
  101705. /** @hidden */
  101706. _viewport(x: number, y: number, width: number, height: number): void;
  101707. /**
  101708. * Set the WebGL's viewport
  101709. * @param viewport defines the viewport element to be used
  101710. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  101711. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  101712. */
  101713. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  101714. /**
  101715. * Begin a new frame
  101716. */
  101717. beginFrame(): void;
  101718. /**
  101719. * Enf the current frame
  101720. */
  101721. endFrame(): void;
  101722. /**
  101723. * Resize the view according to the canvas' size
  101724. */
  101725. resize(): void;
  101726. /**
  101727. * Force a specific size of the canvas
  101728. * @param width defines the new canvas' width
  101729. * @param height defines the new canvas' height
  101730. */
  101731. setSize(width: number, height: number): void;
  101732. /**
  101733. * Binds the frame buffer to the specified texture.
  101734. * @param texture The texture to render to or null for the default canvas
  101735. * @param faceIndex The face of the texture to render to in case of cube texture
  101736. * @param requiredWidth The width of the target to render to
  101737. * @param requiredHeight The height of the target to render to
  101738. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  101739. * @param depthStencilTexture The depth stencil texture to use to render
  101740. * @param lodLevel defines le lod level to bind to the frame buffer
  101741. */
  101742. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  101743. /** @hidden */
  101744. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  101745. /**
  101746. * Unbind the current render target texture from the webGL context
  101747. * @param texture defines the render target texture to unbind
  101748. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  101749. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  101750. */
  101751. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  101752. /**
  101753. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  101754. */
  101755. flushFramebuffer(): void;
  101756. /**
  101757. * Unbind the current render target and bind the default framebuffer
  101758. */
  101759. restoreDefaultFramebuffer(): void;
  101760. /** @hidden */
  101761. protected _resetVertexBufferBinding(): void;
  101762. /**
  101763. * Creates a vertex buffer
  101764. * @param data the data for the vertex buffer
  101765. * @returns the new WebGL static buffer
  101766. */
  101767. createVertexBuffer(data: DataArray): DataBuffer;
  101768. private _createVertexBuffer;
  101769. /**
  101770. * Creates a dynamic vertex buffer
  101771. * @param data the data for the dynamic vertex buffer
  101772. * @returns the new WebGL dynamic buffer
  101773. */
  101774. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  101775. protected _resetIndexBufferBinding(): void;
  101776. /**
  101777. * Creates a new index buffer
  101778. * @param indices defines the content of the index buffer
  101779. * @param updatable defines if the index buffer must be updatable
  101780. * @returns a new webGL buffer
  101781. */
  101782. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  101783. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  101784. /**
  101785. * Bind a webGL buffer to the webGL context
  101786. * @param buffer defines the buffer to bind
  101787. */
  101788. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  101789. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  101790. private bindBuffer;
  101791. /**
  101792. * update the bound buffer with the given data
  101793. * @param data defines the data to update
  101794. */
  101795. updateArrayBuffer(data: Float32Array): void;
  101796. private _vertexAttribPointer;
  101797. private _bindIndexBufferWithCache;
  101798. private _bindVertexBuffersAttributes;
  101799. /**
  101800. * Records a vertex array object
  101801. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  101802. * @param vertexBuffers defines the list of vertex buffers to store
  101803. * @param indexBuffer defines the index buffer to store
  101804. * @param effect defines the effect to store
  101805. * @returns the new vertex array object
  101806. */
  101807. recordVertexArrayObject(vertexBuffers: {
  101808. [key: string]: VertexBuffer;
  101809. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  101810. /**
  101811. * Bind a specific vertex array object
  101812. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  101813. * @param vertexArrayObject defines the vertex array object to bind
  101814. * @param indexBuffer defines the index buffer to bind
  101815. */
  101816. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  101817. /**
  101818. * Bind webGl buffers directly to the webGL context
  101819. * @param vertexBuffer defines the vertex buffer to bind
  101820. * @param indexBuffer defines the index buffer to bind
  101821. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  101822. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  101823. * @param effect defines the effect associated with the vertex buffer
  101824. */
  101825. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  101826. private _unbindVertexArrayObject;
  101827. /**
  101828. * Bind a list of vertex buffers to the webGL context
  101829. * @param vertexBuffers defines the list of vertex buffers to bind
  101830. * @param indexBuffer defines the index buffer to bind
  101831. * @param effect defines the effect associated with the vertex buffers
  101832. */
  101833. bindBuffers(vertexBuffers: {
  101834. [key: string]: Nullable<VertexBuffer>;
  101835. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  101836. /**
  101837. * Unbind all instance attributes
  101838. */
  101839. unbindInstanceAttributes(): void;
  101840. /**
  101841. * Release and free the memory of a vertex array object
  101842. * @param vao defines the vertex array object to delete
  101843. */
  101844. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  101845. /** @hidden */
  101846. _releaseBuffer(buffer: DataBuffer): boolean;
  101847. protected _deleteBuffer(buffer: DataBuffer): void;
  101848. /**
  101849. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  101850. * @param instancesBuffer defines the webGL buffer to update and bind
  101851. * @param data defines the data to store in the buffer
  101852. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  101853. */
  101854. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  101855. /**
  101856. * Bind the content of a webGL buffer used with instanciation
  101857. * @param instancesBuffer defines the webGL buffer to bind
  101858. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  101859. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  101860. */
  101861. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  101862. /**
  101863. * Disable the instance attribute corresponding to the name in parameter
  101864. * @param name defines the name of the attribute to disable
  101865. */
  101866. disableInstanceAttributeByName(name: string): void;
  101867. /**
  101868. * Disable the instance attribute corresponding to the location in parameter
  101869. * @param attributeLocation defines the attribute location of the attribute to disable
  101870. */
  101871. disableInstanceAttribute(attributeLocation: number): void;
  101872. /**
  101873. * Disable the attribute corresponding to the location in parameter
  101874. * @param attributeLocation defines the attribute location of the attribute to disable
  101875. */
  101876. disableAttributeByIndex(attributeLocation: number): void;
  101877. /**
  101878. * Send a draw order
  101879. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  101880. * @param indexStart defines the starting index
  101881. * @param indexCount defines the number of index to draw
  101882. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101883. */
  101884. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  101885. /**
  101886. * Draw a list of points
  101887. * @param verticesStart defines the index of first vertex to draw
  101888. * @param verticesCount defines the count of vertices to draw
  101889. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101890. */
  101891. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101892. /**
  101893. * Draw a list of unindexed primitives
  101894. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  101895. * @param verticesStart defines the index of first vertex to draw
  101896. * @param verticesCount defines the count of vertices to draw
  101897. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101898. */
  101899. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101900. /**
  101901. * Draw a list of indexed primitives
  101902. * @param fillMode defines the primitive to use
  101903. * @param indexStart defines the starting index
  101904. * @param indexCount defines the number of index to draw
  101905. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101906. */
  101907. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  101908. /**
  101909. * Draw a list of unindexed primitives
  101910. * @param fillMode defines the primitive to use
  101911. * @param verticesStart defines the index of first vertex to draw
  101912. * @param verticesCount defines the count of vertices to draw
  101913. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101914. */
  101915. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101916. private _drawMode;
  101917. /** @hidden */
  101918. protected _reportDrawCall(): void;
  101919. /** @hidden */
  101920. _releaseEffect(effect: Effect): void;
  101921. /** @hidden */
  101922. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  101923. /**
  101924. * Create a new effect (used to store vertex/fragment shaders)
  101925. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  101926. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  101927. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  101928. * @param samplers defines an array of string used to represent textures
  101929. * @param defines defines the string containing the defines to use to compile the shaders
  101930. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  101931. * @param onCompiled defines a function to call when the effect creation is successful
  101932. * @param onError defines a function to call when the effect creation has failed
  101933. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  101934. * @returns the new Effect
  101935. */
  101936. 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;
  101937. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  101938. private _compileShader;
  101939. private _compileRawShader;
  101940. /**
  101941. * Directly creates a webGL program
  101942. * @param pipelineContext defines the pipeline context to attach to
  101943. * @param vertexCode defines the vertex shader code to use
  101944. * @param fragmentCode defines the fragment shader code to use
  101945. * @param context defines the webGL context to use (if not set, the current one will be used)
  101946. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  101947. * @returns the new webGL program
  101948. */
  101949. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  101950. /**
  101951. * Creates a webGL program
  101952. * @param pipelineContext defines the pipeline context to attach to
  101953. * @param vertexCode defines the vertex shader code to use
  101954. * @param fragmentCode defines the fragment shader code to use
  101955. * @param defines defines the string containing the defines to use to compile the shaders
  101956. * @param context defines the webGL context to use (if not set, the current one will be used)
  101957. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  101958. * @returns the new webGL program
  101959. */
  101960. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  101961. /**
  101962. * Creates a new pipeline context
  101963. * @returns the new pipeline
  101964. */
  101965. createPipelineContext(): IPipelineContext;
  101966. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  101967. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  101968. /** @hidden */
  101969. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  101970. /** @hidden */
  101971. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  101972. /** @hidden */
  101973. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  101974. /**
  101975. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  101976. * @param pipelineContext defines the pipeline context to use
  101977. * @param uniformsNames defines the list of uniform names
  101978. * @returns an array of webGL uniform locations
  101979. */
  101980. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  101981. /**
  101982. * Gets the lsit of active attributes for a given webGL program
  101983. * @param pipelineContext defines the pipeline context to use
  101984. * @param attributesNames defines the list of attribute names to get
  101985. * @returns an array of indices indicating the offset of each attribute
  101986. */
  101987. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  101988. /**
  101989. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  101990. * @param effect defines the effect to activate
  101991. */
  101992. enableEffect(effect: Nullable<Effect>): void;
  101993. /**
  101994. * Set the value of an uniform to a number (int)
  101995. * @param uniform defines the webGL uniform location where to store the value
  101996. * @param value defines the int number to store
  101997. */
  101998. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  101999. /**
  102000. * Set the value of an uniform to an array of int32
  102001. * @param uniform defines the webGL uniform location where to store the value
  102002. * @param array defines the array of int32 to store
  102003. */
  102004. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  102005. /**
  102006. * Set the value of an uniform to an array of int32 (stored as vec2)
  102007. * @param uniform defines the webGL uniform location where to store the value
  102008. * @param array defines the array of int32 to store
  102009. */
  102010. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  102011. /**
  102012. * Set the value of an uniform to an array of int32 (stored as vec3)
  102013. * @param uniform defines the webGL uniform location where to store the value
  102014. * @param array defines the array of int32 to store
  102015. */
  102016. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  102017. /**
  102018. * Set the value of an uniform to an array of int32 (stored as vec4)
  102019. * @param uniform defines the webGL uniform location where to store the value
  102020. * @param array defines the array of int32 to store
  102021. */
  102022. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  102023. /**
  102024. * Set the value of an uniform to an array of number
  102025. * @param uniform defines the webGL uniform location where to store the value
  102026. * @param array defines the array of number to store
  102027. */
  102028. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  102029. /**
  102030. * Set the value of an uniform to an array of number (stored as vec2)
  102031. * @param uniform defines the webGL uniform location where to store the value
  102032. * @param array defines the array of number to store
  102033. */
  102034. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  102035. /**
  102036. * Set the value of an uniform to an array of number (stored as vec3)
  102037. * @param uniform defines the webGL uniform location where to store the value
  102038. * @param array defines the array of number to store
  102039. */
  102040. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  102041. /**
  102042. * Set the value of an uniform to an array of number (stored as vec4)
  102043. * @param uniform defines the webGL uniform location where to store the value
  102044. * @param array defines the array of number to store
  102045. */
  102046. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  102047. /**
  102048. * Set the value of an uniform to an array of float32 (stored as matrices)
  102049. * @param uniform defines the webGL uniform location where to store the value
  102050. * @param matrices defines the array of float32 to store
  102051. */
  102052. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  102053. /**
  102054. * Set the value of an uniform to a matrix (3x3)
  102055. * @param uniform defines the webGL uniform location where to store the value
  102056. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  102057. */
  102058. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  102059. /**
  102060. * Set the value of an uniform to a matrix (2x2)
  102061. * @param uniform defines the webGL uniform location where to store the value
  102062. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  102063. */
  102064. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  102065. /**
  102066. * Set the value of an uniform to a number (float)
  102067. * @param uniform defines the webGL uniform location where to store the value
  102068. * @param value defines the float number to store
  102069. */
  102070. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  102071. /**
  102072. * Set the value of an uniform to a vec2
  102073. * @param uniform defines the webGL uniform location where to store the value
  102074. * @param x defines the 1st component of the value
  102075. * @param y defines the 2nd component of the value
  102076. */
  102077. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  102078. /**
  102079. * Set the value of an uniform to a vec3
  102080. * @param uniform defines the webGL uniform location where to store the value
  102081. * @param x defines the 1st component of the value
  102082. * @param y defines the 2nd component of the value
  102083. * @param z defines the 3rd component of the value
  102084. */
  102085. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  102086. /**
  102087. * Set the value of an uniform to a vec4
  102088. * @param uniform defines the webGL uniform location where to store the value
  102089. * @param x defines the 1st component of the value
  102090. * @param y defines the 2nd component of the value
  102091. * @param z defines the 3rd component of the value
  102092. * @param w defines the 4th component of the value
  102093. */
  102094. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  102095. /**
  102096. * Apply all cached states (depth, culling, stencil and alpha)
  102097. */
  102098. applyStates(): void;
  102099. /**
  102100. * Enable or disable color writing
  102101. * @param enable defines the state to set
  102102. */
  102103. setColorWrite(enable: boolean): void;
  102104. /**
  102105. * Gets a boolean indicating if color writing is enabled
  102106. * @returns the current color writing state
  102107. */
  102108. getColorWrite(): boolean;
  102109. /**
  102110. * Gets the depth culling state manager
  102111. */
  102112. get depthCullingState(): DepthCullingState;
  102113. /**
  102114. * Gets the alpha state manager
  102115. */
  102116. get alphaState(): AlphaState;
  102117. /**
  102118. * Gets the stencil state manager
  102119. */
  102120. get stencilState(): StencilState;
  102121. /**
  102122. * Clears the list of texture accessible through engine.
  102123. * This can help preventing texture load conflict due to name collision.
  102124. */
  102125. clearInternalTexturesCache(): void;
  102126. /**
  102127. * Force the entire cache to be cleared
  102128. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  102129. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  102130. */
  102131. wipeCaches(bruteForce?: boolean): void;
  102132. /** @hidden */
  102133. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  102134. min: number;
  102135. mag: number;
  102136. };
  102137. /** @hidden */
  102138. _createTexture(): WebGLTexture;
  102139. /**
  102140. * Usually called from Texture.ts.
  102141. * Passed information to create a WebGLTexture
  102142. * @param urlArg defines a value which contains one of the following:
  102143. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  102144. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  102145. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  102146. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  102147. * @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)
  102148. * @param scene needed for loading to the correct scene
  102149. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  102150. * @param onLoad optional callback to be called upon successful completion
  102151. * @param onError optional callback to be called upon failure
  102152. * @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
  102153. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  102154. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  102155. * @param forcedExtension defines the extension to use to pick the right loader
  102156. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  102157. * @param mimeType defines an optional mime type
  102158. * @returns a InternalTexture for assignment back into BABYLON.Texture
  102159. */
  102160. 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;
  102161. /**
  102162. * Loads an image as an HTMLImageElement.
  102163. * @param input url string, ArrayBuffer, or Blob to load
  102164. * @param onLoad callback called when the image successfully loads
  102165. * @param onError callback called when the image fails to load
  102166. * @param offlineProvider offline provider for caching
  102167. * @param mimeType optional mime type
  102168. * @returns the HTMLImageElement of the loaded image
  102169. * @hidden
  102170. */
  102171. 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>;
  102172. /**
  102173. * @hidden
  102174. */
  102175. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  102176. /**
  102177. * Creates a raw texture
  102178. * @param data defines the data to store in the texture
  102179. * @param width defines the width of the texture
  102180. * @param height defines the height of the texture
  102181. * @param format defines the format of the data
  102182. * @param generateMipMaps defines if the engine should generate the mip levels
  102183. * @param invertY defines if data must be stored with Y axis inverted
  102184. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  102185. * @param compression defines the compression used (null by default)
  102186. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  102187. * @returns the raw texture inside an InternalTexture
  102188. */
  102189. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  102190. /**
  102191. * Creates a new raw cube texture
  102192. * @param data defines the array of data to use to create each face
  102193. * @param size defines the size of the textures
  102194. * @param format defines the format of the data
  102195. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  102196. * @param generateMipMaps defines if the engine should generate the mip levels
  102197. * @param invertY defines if data must be stored with Y axis inverted
  102198. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102199. * @param compression defines the compression used (null by default)
  102200. * @returns the cube texture as an InternalTexture
  102201. */
  102202. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  102203. /**
  102204. * Creates a new raw 3D texture
  102205. * @param data defines the data used to create the texture
  102206. * @param width defines the width of the texture
  102207. * @param height defines the height of the texture
  102208. * @param depth defines the depth of the texture
  102209. * @param format defines the format of the texture
  102210. * @param generateMipMaps defines if the engine must generate mip levels
  102211. * @param invertY defines if data must be stored with Y axis inverted
  102212. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102213. * @param compression defines the compressed used (can be null)
  102214. * @param textureType defines the compressed used (can be null)
  102215. * @returns a new raw 3D texture (stored in an InternalTexture)
  102216. */
  102217. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  102218. /**
  102219. * Creates a new raw 2D array texture
  102220. * @param data defines the data used to create the texture
  102221. * @param width defines the width of the texture
  102222. * @param height defines the height of the texture
  102223. * @param depth defines the number of layers of the texture
  102224. * @param format defines the format of the texture
  102225. * @param generateMipMaps defines if the engine must generate mip levels
  102226. * @param invertY defines if data must be stored with Y axis inverted
  102227. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102228. * @param compression defines the compressed used (can be null)
  102229. * @param textureType defines the compressed used (can be null)
  102230. * @returns a new raw 2D array texture (stored in an InternalTexture)
  102231. */
  102232. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  102233. private _unpackFlipYCached;
  102234. /**
  102235. * In case you are sharing the context with other applications, it might
  102236. * be interested to not cache the unpack flip y state to ensure a consistent
  102237. * value would be set.
  102238. */
  102239. enableUnpackFlipYCached: boolean;
  102240. /** @hidden */
  102241. _unpackFlipY(value: boolean): void;
  102242. /** @hidden */
  102243. _getUnpackAlignement(): number;
  102244. private _getTextureTarget;
  102245. /**
  102246. * Update the sampling mode of a given texture
  102247. * @param samplingMode defines the required sampling mode
  102248. * @param texture defines the texture to update
  102249. * @param generateMipMaps defines whether to generate mipmaps for the texture
  102250. */
  102251. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  102252. /**
  102253. * Update the sampling mode of a given texture
  102254. * @param texture defines the texture to update
  102255. * @param wrapU defines the texture wrap mode of the u coordinates
  102256. * @param wrapV defines the texture wrap mode of the v coordinates
  102257. * @param wrapR defines the texture wrap mode of the r coordinates
  102258. */
  102259. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  102260. /** @hidden */
  102261. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  102262. width: number;
  102263. height: number;
  102264. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  102265. /** @hidden */
  102266. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  102267. /** @hidden */
  102268. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  102269. /** @hidden */
  102270. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  102271. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  102272. private _prepareWebGLTexture;
  102273. /** @hidden */
  102274. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  102275. private _getDepthStencilBuffer;
  102276. /** @hidden */
  102277. _releaseFramebufferObjects(texture: InternalTexture): void;
  102278. /** @hidden */
  102279. _releaseTexture(texture: InternalTexture): void;
  102280. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  102281. protected _setProgram(program: WebGLProgram): void;
  102282. protected _boundUniforms: {
  102283. [key: number]: WebGLUniformLocation;
  102284. };
  102285. /**
  102286. * Binds an effect to the webGL context
  102287. * @param effect defines the effect to bind
  102288. */
  102289. bindSamplers(effect: Effect): void;
  102290. private _activateCurrentTexture;
  102291. /** @hidden */
  102292. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  102293. /** @hidden */
  102294. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  102295. /**
  102296. * Unbind all textures from the webGL context
  102297. */
  102298. unbindAllTextures(): void;
  102299. /**
  102300. * Sets a texture to the according uniform.
  102301. * @param channel The texture channel
  102302. * @param uniform The uniform to set
  102303. * @param texture The texture to apply
  102304. */
  102305. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  102306. private _bindSamplerUniformToChannel;
  102307. private _getTextureWrapMode;
  102308. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  102309. /**
  102310. * Sets an array of texture to the webGL context
  102311. * @param channel defines the channel where the texture array must be set
  102312. * @param uniform defines the associated uniform location
  102313. * @param textures defines the array of textures to bind
  102314. */
  102315. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  102316. /** @hidden */
  102317. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  102318. private _setTextureParameterFloat;
  102319. private _setTextureParameterInteger;
  102320. /**
  102321. * Unbind all vertex attributes from the webGL context
  102322. */
  102323. unbindAllAttributes(): void;
  102324. /**
  102325. * 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
  102326. */
  102327. releaseEffects(): void;
  102328. /**
  102329. * Dispose and release all associated resources
  102330. */
  102331. dispose(): void;
  102332. /**
  102333. * Attach a new callback raised when context lost event is fired
  102334. * @param callback defines the callback to call
  102335. */
  102336. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  102337. /**
  102338. * Attach a new callback raised when context restored event is fired
  102339. * @param callback defines the callback to call
  102340. */
  102341. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  102342. /**
  102343. * Get the current error code of the webGL context
  102344. * @returns the error code
  102345. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  102346. */
  102347. getError(): number;
  102348. private _canRenderToFloatFramebuffer;
  102349. private _canRenderToHalfFloatFramebuffer;
  102350. private _canRenderToFramebuffer;
  102351. /** @hidden */
  102352. _getWebGLTextureType(type: number): number;
  102353. /** @hidden */
  102354. _getInternalFormat(format: number): number;
  102355. /** @hidden */
  102356. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  102357. /** @hidden */
  102358. _getRGBAMultiSampleBufferFormat(type: number): number;
  102359. /** @hidden */
  102360. _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;
  102361. /**
  102362. * Loads a file from a url
  102363. * @param url url to load
  102364. * @param onSuccess callback called when the file successfully loads
  102365. * @param onProgress callback called while file is loading (if the server supports this mode)
  102366. * @param offlineProvider defines the offline provider for caching
  102367. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  102368. * @param onError callback called when the file fails to load
  102369. * @returns a file request object
  102370. * @hidden
  102371. */
  102372. 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;
  102373. /**
  102374. * Reads pixels from the current frame buffer. Please note that this function can be slow
  102375. * @param x defines the x coordinate of the rectangle where pixels must be read
  102376. * @param y defines the y coordinate of the rectangle where pixels must be read
  102377. * @param width defines the width of the rectangle where pixels must be read
  102378. * @param height defines the height of the rectangle where pixels must be read
  102379. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  102380. * @returns a Uint8Array containing RGBA colors
  102381. */
  102382. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  102383. private static _isSupported;
  102384. /**
  102385. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  102386. * @returns true if the engine can be created
  102387. * @ignorenaming
  102388. */
  102389. static isSupported(): boolean;
  102390. /**
  102391. * Find the next highest power of two.
  102392. * @param x Number to start search from.
  102393. * @return Next highest power of two.
  102394. */
  102395. static CeilingPOT(x: number): number;
  102396. /**
  102397. * Find the next lowest power of two.
  102398. * @param x Number to start search from.
  102399. * @return Next lowest power of two.
  102400. */
  102401. static FloorPOT(x: number): number;
  102402. /**
  102403. * Find the nearest power of two.
  102404. * @param x Number to start search from.
  102405. * @return Next nearest power of two.
  102406. */
  102407. static NearestPOT(x: number): number;
  102408. /**
  102409. * Get the closest exponent of two
  102410. * @param value defines the value to approximate
  102411. * @param max defines the maximum value to return
  102412. * @param mode defines how to define the closest value
  102413. * @returns closest exponent of two of the given value
  102414. */
  102415. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  102416. /**
  102417. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  102418. * @param func - the function to be called
  102419. * @param requester - the object that will request the next frame. Falls back to window.
  102420. * @returns frame number
  102421. */
  102422. static QueueNewFrame(func: () => void, requester?: any): number;
  102423. /**
  102424. * Gets host document
  102425. * @returns the host document object
  102426. */
  102427. getHostDocument(): Nullable<Document>;
  102428. }
  102429. }
  102430. declare module BABYLON {
  102431. /**
  102432. * Class representing spherical harmonics coefficients to the 3rd degree
  102433. */
  102434. export class SphericalHarmonics {
  102435. /**
  102436. * Defines whether or not the harmonics have been prescaled for rendering.
  102437. */
  102438. preScaled: boolean;
  102439. /**
  102440. * The l0,0 coefficients of the spherical harmonics
  102441. */
  102442. l00: Vector3;
  102443. /**
  102444. * The l1,-1 coefficients of the spherical harmonics
  102445. */
  102446. l1_1: Vector3;
  102447. /**
  102448. * The l1,0 coefficients of the spherical harmonics
  102449. */
  102450. l10: Vector3;
  102451. /**
  102452. * The l1,1 coefficients of the spherical harmonics
  102453. */
  102454. l11: Vector3;
  102455. /**
  102456. * The l2,-2 coefficients of the spherical harmonics
  102457. */
  102458. l2_2: Vector3;
  102459. /**
  102460. * The l2,-1 coefficients of the spherical harmonics
  102461. */
  102462. l2_1: Vector3;
  102463. /**
  102464. * The l2,0 coefficients of the spherical harmonics
  102465. */
  102466. l20: Vector3;
  102467. /**
  102468. * The l2,1 coefficients of the spherical harmonics
  102469. */
  102470. l21: Vector3;
  102471. /**
  102472. * The l2,2 coefficients of the spherical harmonics
  102473. */
  102474. l22: Vector3;
  102475. /**
  102476. * Adds a light to the spherical harmonics
  102477. * @param direction the direction of the light
  102478. * @param color the color of the light
  102479. * @param deltaSolidAngle the delta solid angle of the light
  102480. */
  102481. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  102482. /**
  102483. * Scales the spherical harmonics by the given amount
  102484. * @param scale the amount to scale
  102485. */
  102486. scaleInPlace(scale: number): void;
  102487. /**
  102488. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  102489. *
  102490. * ```
  102491. * E_lm = A_l * L_lm
  102492. * ```
  102493. *
  102494. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  102495. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  102496. * the scaling factors are given in equation 9.
  102497. */
  102498. convertIncidentRadianceToIrradiance(): void;
  102499. /**
  102500. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  102501. *
  102502. * ```
  102503. * L = (1/pi) * E * rho
  102504. * ```
  102505. *
  102506. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  102507. */
  102508. convertIrradianceToLambertianRadiance(): void;
  102509. /**
  102510. * Integrates the reconstruction coefficients directly in to the SH preventing further
  102511. * required operations at run time.
  102512. *
  102513. * This is simply done by scaling back the SH with Ylm constants parameter.
  102514. * The trigonometric part being applied by the shader at run time.
  102515. */
  102516. preScaleForRendering(): void;
  102517. /**
  102518. * Constructs a spherical harmonics from an array.
  102519. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  102520. * @returns the spherical harmonics
  102521. */
  102522. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  102523. /**
  102524. * Gets the spherical harmonics from polynomial
  102525. * @param polynomial the spherical polynomial
  102526. * @returns the spherical harmonics
  102527. */
  102528. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  102529. }
  102530. /**
  102531. * Class representing spherical polynomial coefficients to the 3rd degree
  102532. */
  102533. export class SphericalPolynomial {
  102534. private _harmonics;
  102535. /**
  102536. * The spherical harmonics used to create the polynomials.
  102537. */
  102538. get preScaledHarmonics(): SphericalHarmonics;
  102539. /**
  102540. * The x coefficients of the spherical polynomial
  102541. */
  102542. x: Vector3;
  102543. /**
  102544. * The y coefficients of the spherical polynomial
  102545. */
  102546. y: Vector3;
  102547. /**
  102548. * The z coefficients of the spherical polynomial
  102549. */
  102550. z: Vector3;
  102551. /**
  102552. * The xx coefficients of the spherical polynomial
  102553. */
  102554. xx: Vector3;
  102555. /**
  102556. * The yy coefficients of the spherical polynomial
  102557. */
  102558. yy: Vector3;
  102559. /**
  102560. * The zz coefficients of the spherical polynomial
  102561. */
  102562. zz: Vector3;
  102563. /**
  102564. * The xy coefficients of the spherical polynomial
  102565. */
  102566. xy: Vector3;
  102567. /**
  102568. * The yz coefficients of the spherical polynomial
  102569. */
  102570. yz: Vector3;
  102571. /**
  102572. * The zx coefficients of the spherical polynomial
  102573. */
  102574. zx: Vector3;
  102575. /**
  102576. * Adds an ambient color to the spherical polynomial
  102577. * @param color the color to add
  102578. */
  102579. addAmbient(color: Color3): void;
  102580. /**
  102581. * Scales the spherical polynomial by the given amount
  102582. * @param scale the amount to scale
  102583. */
  102584. scaleInPlace(scale: number): void;
  102585. /**
  102586. * Gets the spherical polynomial from harmonics
  102587. * @param harmonics the spherical harmonics
  102588. * @returns the spherical polynomial
  102589. */
  102590. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  102591. /**
  102592. * Constructs a spherical polynomial from an array.
  102593. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  102594. * @returns the spherical polynomial
  102595. */
  102596. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  102597. }
  102598. }
  102599. declare module BABYLON {
  102600. /**
  102601. * Defines the source of the internal texture
  102602. */
  102603. export enum InternalTextureSource {
  102604. /**
  102605. * The source of the texture data is unknown
  102606. */
  102607. Unknown = 0,
  102608. /**
  102609. * Texture data comes from an URL
  102610. */
  102611. Url = 1,
  102612. /**
  102613. * Texture data is only used for temporary storage
  102614. */
  102615. Temp = 2,
  102616. /**
  102617. * Texture data comes from raw data (ArrayBuffer)
  102618. */
  102619. Raw = 3,
  102620. /**
  102621. * Texture content is dynamic (video or dynamic texture)
  102622. */
  102623. Dynamic = 4,
  102624. /**
  102625. * Texture content is generated by rendering to it
  102626. */
  102627. RenderTarget = 5,
  102628. /**
  102629. * Texture content is part of a multi render target process
  102630. */
  102631. MultiRenderTarget = 6,
  102632. /**
  102633. * Texture data comes from a cube data file
  102634. */
  102635. Cube = 7,
  102636. /**
  102637. * Texture data comes from a raw cube data
  102638. */
  102639. CubeRaw = 8,
  102640. /**
  102641. * Texture data come from a prefiltered cube data file
  102642. */
  102643. CubePrefiltered = 9,
  102644. /**
  102645. * Texture content is raw 3D data
  102646. */
  102647. Raw3D = 10,
  102648. /**
  102649. * Texture content is raw 2D array data
  102650. */
  102651. Raw2DArray = 11,
  102652. /**
  102653. * Texture content is a depth texture
  102654. */
  102655. Depth = 12,
  102656. /**
  102657. * Texture data comes from a raw cube data encoded with RGBD
  102658. */
  102659. CubeRawRGBD = 13
  102660. }
  102661. /**
  102662. * Class used to store data associated with WebGL texture data for the engine
  102663. * This class should not be used directly
  102664. */
  102665. export class InternalTexture {
  102666. /** @hidden */
  102667. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  102668. /**
  102669. * Defines if the texture is ready
  102670. */
  102671. isReady: boolean;
  102672. /**
  102673. * Defines if the texture is a cube texture
  102674. */
  102675. isCube: boolean;
  102676. /**
  102677. * Defines if the texture contains 3D data
  102678. */
  102679. is3D: boolean;
  102680. /**
  102681. * Defines if the texture contains 2D array data
  102682. */
  102683. is2DArray: boolean;
  102684. /**
  102685. * Defines if the texture contains multiview data
  102686. */
  102687. isMultiview: boolean;
  102688. /**
  102689. * Gets the URL used to load this texture
  102690. */
  102691. url: string;
  102692. /**
  102693. * Gets the sampling mode of the texture
  102694. */
  102695. samplingMode: number;
  102696. /**
  102697. * Gets a boolean indicating if the texture needs mipmaps generation
  102698. */
  102699. generateMipMaps: boolean;
  102700. /**
  102701. * Gets the number of samples used by the texture (WebGL2+ only)
  102702. */
  102703. samples: number;
  102704. /**
  102705. * Gets the type of the texture (int, float...)
  102706. */
  102707. type: number;
  102708. /**
  102709. * Gets the format of the texture (RGB, RGBA...)
  102710. */
  102711. format: number;
  102712. /**
  102713. * Observable called when the texture is loaded
  102714. */
  102715. onLoadedObservable: Observable<InternalTexture>;
  102716. /**
  102717. * Gets the width of the texture
  102718. */
  102719. width: number;
  102720. /**
  102721. * Gets the height of the texture
  102722. */
  102723. height: number;
  102724. /**
  102725. * Gets the depth of the texture
  102726. */
  102727. depth: number;
  102728. /**
  102729. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  102730. */
  102731. baseWidth: number;
  102732. /**
  102733. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  102734. */
  102735. baseHeight: number;
  102736. /**
  102737. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  102738. */
  102739. baseDepth: number;
  102740. /**
  102741. * Gets a boolean indicating if the texture is inverted on Y axis
  102742. */
  102743. invertY: boolean;
  102744. /** @hidden */
  102745. _invertVScale: boolean;
  102746. /** @hidden */
  102747. _associatedChannel: number;
  102748. /** @hidden */
  102749. _source: InternalTextureSource;
  102750. /** @hidden */
  102751. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  102752. /** @hidden */
  102753. _bufferView: Nullable<ArrayBufferView>;
  102754. /** @hidden */
  102755. _bufferViewArray: Nullable<ArrayBufferView[]>;
  102756. /** @hidden */
  102757. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  102758. /** @hidden */
  102759. _size: number;
  102760. /** @hidden */
  102761. _extension: string;
  102762. /** @hidden */
  102763. _files: Nullable<string[]>;
  102764. /** @hidden */
  102765. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  102766. /** @hidden */
  102767. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  102768. /** @hidden */
  102769. _framebuffer: Nullable<WebGLFramebuffer>;
  102770. /** @hidden */
  102771. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  102772. /** @hidden */
  102773. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  102774. /** @hidden */
  102775. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  102776. /** @hidden */
  102777. _attachments: Nullable<number[]>;
  102778. /** @hidden */
  102779. _cachedCoordinatesMode: Nullable<number>;
  102780. /** @hidden */
  102781. _cachedWrapU: Nullable<number>;
  102782. /** @hidden */
  102783. _cachedWrapV: Nullable<number>;
  102784. /** @hidden */
  102785. _cachedWrapR: Nullable<number>;
  102786. /** @hidden */
  102787. _cachedAnisotropicFilteringLevel: Nullable<number>;
  102788. /** @hidden */
  102789. _isDisabled: boolean;
  102790. /** @hidden */
  102791. _compression: Nullable<string>;
  102792. /** @hidden */
  102793. _generateStencilBuffer: boolean;
  102794. /** @hidden */
  102795. _generateDepthBuffer: boolean;
  102796. /** @hidden */
  102797. _comparisonFunction: number;
  102798. /** @hidden */
  102799. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  102800. /** @hidden */
  102801. _lodGenerationScale: number;
  102802. /** @hidden */
  102803. _lodGenerationOffset: number;
  102804. /** @hidden */
  102805. _colorTextureArray: Nullable<WebGLTexture>;
  102806. /** @hidden */
  102807. _depthStencilTextureArray: Nullable<WebGLTexture>;
  102808. /** @hidden */
  102809. _lodTextureHigh: Nullable<BaseTexture>;
  102810. /** @hidden */
  102811. _lodTextureMid: Nullable<BaseTexture>;
  102812. /** @hidden */
  102813. _lodTextureLow: Nullable<BaseTexture>;
  102814. /** @hidden */
  102815. _isRGBD: boolean;
  102816. /** @hidden */
  102817. _linearSpecularLOD: boolean;
  102818. /** @hidden */
  102819. _irradianceTexture: Nullable<BaseTexture>;
  102820. /** @hidden */
  102821. _webGLTexture: Nullable<WebGLTexture>;
  102822. /** @hidden */
  102823. _references: number;
  102824. private _engine;
  102825. /**
  102826. * Gets the Engine the texture belongs to.
  102827. * @returns The babylon engine
  102828. */
  102829. getEngine(): ThinEngine;
  102830. /**
  102831. * Gets the data source type of the texture
  102832. */
  102833. get source(): InternalTextureSource;
  102834. /**
  102835. * Creates a new InternalTexture
  102836. * @param engine defines the engine to use
  102837. * @param source defines the type of data that will be used
  102838. * @param delayAllocation if the texture allocation should be delayed (default: false)
  102839. */
  102840. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  102841. /**
  102842. * Increments the number of references (ie. the number of Texture that point to it)
  102843. */
  102844. incrementReferences(): void;
  102845. /**
  102846. * Change the size of the texture (not the size of the content)
  102847. * @param width defines the new width
  102848. * @param height defines the new height
  102849. * @param depth defines the new depth (1 by default)
  102850. */
  102851. updateSize(width: int, height: int, depth?: int): void;
  102852. /** @hidden */
  102853. _rebuild(): void;
  102854. /** @hidden */
  102855. _swapAndDie(target: InternalTexture): void;
  102856. /**
  102857. * Dispose the current allocated resources
  102858. */
  102859. dispose(): void;
  102860. }
  102861. }
  102862. declare module BABYLON {
  102863. /**
  102864. * Class used to work with sound analyzer using fast fourier transform (FFT)
  102865. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102866. */
  102867. export class Analyser {
  102868. /**
  102869. * Gets or sets the smoothing
  102870. * @ignorenaming
  102871. */
  102872. SMOOTHING: number;
  102873. /**
  102874. * Gets or sets the FFT table size
  102875. * @ignorenaming
  102876. */
  102877. FFT_SIZE: number;
  102878. /**
  102879. * Gets or sets the bar graph amplitude
  102880. * @ignorenaming
  102881. */
  102882. BARGRAPHAMPLITUDE: number;
  102883. /**
  102884. * Gets or sets the position of the debug canvas
  102885. * @ignorenaming
  102886. */
  102887. DEBUGCANVASPOS: {
  102888. x: number;
  102889. y: number;
  102890. };
  102891. /**
  102892. * Gets or sets the debug canvas size
  102893. * @ignorenaming
  102894. */
  102895. DEBUGCANVASSIZE: {
  102896. width: number;
  102897. height: number;
  102898. };
  102899. private _byteFreqs;
  102900. private _byteTime;
  102901. private _floatFreqs;
  102902. private _webAudioAnalyser;
  102903. private _debugCanvas;
  102904. private _debugCanvasContext;
  102905. private _scene;
  102906. private _registerFunc;
  102907. private _audioEngine;
  102908. /**
  102909. * Creates a new analyser
  102910. * @param scene defines hosting scene
  102911. */
  102912. constructor(scene: Scene);
  102913. /**
  102914. * Get the number of data values you will have to play with for the visualization
  102915. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  102916. * @returns a number
  102917. */
  102918. getFrequencyBinCount(): number;
  102919. /**
  102920. * Gets the current frequency data as a byte array
  102921. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  102922. * @returns a Uint8Array
  102923. */
  102924. getByteFrequencyData(): Uint8Array;
  102925. /**
  102926. * Gets the current waveform as a byte array
  102927. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  102928. * @returns a Uint8Array
  102929. */
  102930. getByteTimeDomainData(): Uint8Array;
  102931. /**
  102932. * Gets the current frequency data as a float array
  102933. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  102934. * @returns a Float32Array
  102935. */
  102936. getFloatFrequencyData(): Float32Array;
  102937. /**
  102938. * Renders the debug canvas
  102939. */
  102940. drawDebugCanvas(): void;
  102941. /**
  102942. * Stops rendering the debug canvas and removes it
  102943. */
  102944. stopDebugCanvas(): void;
  102945. /**
  102946. * Connects two audio nodes
  102947. * @param inputAudioNode defines first node to connect
  102948. * @param outputAudioNode defines second node to connect
  102949. */
  102950. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  102951. /**
  102952. * Releases all associated resources
  102953. */
  102954. dispose(): void;
  102955. }
  102956. }
  102957. declare module BABYLON {
  102958. /**
  102959. * This represents an audio engine and it is responsible
  102960. * to play, synchronize and analyse sounds throughout the application.
  102961. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102962. */
  102963. export interface IAudioEngine extends IDisposable {
  102964. /**
  102965. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  102966. */
  102967. readonly canUseWebAudio: boolean;
  102968. /**
  102969. * Gets the current AudioContext if available.
  102970. */
  102971. readonly audioContext: Nullable<AudioContext>;
  102972. /**
  102973. * The master gain node defines the global audio volume of your audio engine.
  102974. */
  102975. readonly masterGain: GainNode;
  102976. /**
  102977. * Gets whether or not mp3 are supported by your browser.
  102978. */
  102979. readonly isMP3supported: boolean;
  102980. /**
  102981. * Gets whether or not ogg are supported by your browser.
  102982. */
  102983. readonly isOGGsupported: boolean;
  102984. /**
  102985. * Defines if Babylon should emit a warning if WebAudio is not supported.
  102986. * @ignoreNaming
  102987. */
  102988. WarnedWebAudioUnsupported: boolean;
  102989. /**
  102990. * Defines if the audio engine relies on a custom unlocked button.
  102991. * In this case, the embedded button will not be displayed.
  102992. */
  102993. useCustomUnlockedButton: boolean;
  102994. /**
  102995. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  102996. */
  102997. readonly unlocked: boolean;
  102998. /**
  102999. * Event raised when audio has been unlocked on the browser.
  103000. */
  103001. onAudioUnlockedObservable: Observable<AudioEngine>;
  103002. /**
  103003. * Event raised when audio has been locked on the browser.
  103004. */
  103005. onAudioLockedObservable: Observable<AudioEngine>;
  103006. /**
  103007. * Flags the audio engine in Locked state.
  103008. * This happens due to new browser policies preventing audio to autoplay.
  103009. */
  103010. lock(): void;
  103011. /**
  103012. * Unlocks the audio engine once a user action has been done on the dom.
  103013. * This is helpful to resume play once browser policies have been satisfied.
  103014. */
  103015. unlock(): void;
  103016. }
  103017. /**
  103018. * This represents the default audio engine used in babylon.
  103019. * It is responsible to play, synchronize and analyse sounds throughout the application.
  103020. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103021. */
  103022. export class AudioEngine implements IAudioEngine {
  103023. private _audioContext;
  103024. private _audioContextInitialized;
  103025. private _muteButton;
  103026. private _hostElement;
  103027. /**
  103028. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  103029. */
  103030. canUseWebAudio: boolean;
  103031. /**
  103032. * The master gain node defines the global audio volume of your audio engine.
  103033. */
  103034. masterGain: GainNode;
  103035. /**
  103036. * Defines if Babylon should emit a warning if WebAudio is not supported.
  103037. * @ignoreNaming
  103038. */
  103039. WarnedWebAudioUnsupported: boolean;
  103040. /**
  103041. * Gets whether or not mp3 are supported by your browser.
  103042. */
  103043. isMP3supported: boolean;
  103044. /**
  103045. * Gets whether or not ogg are supported by your browser.
  103046. */
  103047. isOGGsupported: boolean;
  103048. /**
  103049. * Gets whether audio has been unlocked on the device.
  103050. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  103051. * a user interaction has happened.
  103052. */
  103053. unlocked: boolean;
  103054. /**
  103055. * Defines if the audio engine relies on a custom unlocked button.
  103056. * In this case, the embedded button will not be displayed.
  103057. */
  103058. useCustomUnlockedButton: boolean;
  103059. /**
  103060. * Event raised when audio has been unlocked on the browser.
  103061. */
  103062. onAudioUnlockedObservable: Observable<AudioEngine>;
  103063. /**
  103064. * Event raised when audio has been locked on the browser.
  103065. */
  103066. onAudioLockedObservable: Observable<AudioEngine>;
  103067. /**
  103068. * Gets the current AudioContext if available.
  103069. */
  103070. get audioContext(): Nullable<AudioContext>;
  103071. private _connectedAnalyser;
  103072. /**
  103073. * Instantiates a new audio engine.
  103074. *
  103075. * There should be only one per page as some browsers restrict the number
  103076. * of audio contexts you can create.
  103077. * @param hostElement defines the host element where to display the mute icon if necessary
  103078. */
  103079. constructor(hostElement?: Nullable<HTMLElement>);
  103080. /**
  103081. * Flags the audio engine in Locked state.
  103082. * This happens due to new browser policies preventing audio to autoplay.
  103083. */
  103084. lock(): void;
  103085. /**
  103086. * Unlocks the audio engine once a user action has been done on the dom.
  103087. * This is helpful to resume play once browser policies have been satisfied.
  103088. */
  103089. unlock(): void;
  103090. private _resumeAudioContext;
  103091. private _initializeAudioContext;
  103092. private _tryToRun;
  103093. private _triggerRunningState;
  103094. private _triggerSuspendedState;
  103095. private _displayMuteButton;
  103096. private _moveButtonToTopLeft;
  103097. private _onResize;
  103098. private _hideMuteButton;
  103099. /**
  103100. * Destroy and release the resources associated with the audio ccontext.
  103101. */
  103102. dispose(): void;
  103103. /**
  103104. * Gets the global volume sets on the master gain.
  103105. * @returns the global volume if set or -1 otherwise
  103106. */
  103107. getGlobalVolume(): number;
  103108. /**
  103109. * Sets the global volume of your experience (sets on the master gain).
  103110. * @param newVolume Defines the new global volume of the application
  103111. */
  103112. setGlobalVolume(newVolume: number): void;
  103113. /**
  103114. * Connect the audio engine to an audio analyser allowing some amazing
  103115. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  103116. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  103117. * @param analyser The analyser to connect to the engine
  103118. */
  103119. connectToAnalyser(analyser: Analyser): void;
  103120. }
  103121. }
  103122. declare module BABYLON {
  103123. /**
  103124. * Interface used to present a loading screen while loading a scene
  103125. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  103126. */
  103127. export interface ILoadingScreen {
  103128. /**
  103129. * Function called to display the loading screen
  103130. */
  103131. displayLoadingUI: () => void;
  103132. /**
  103133. * Function called to hide the loading screen
  103134. */
  103135. hideLoadingUI: () => void;
  103136. /**
  103137. * Gets or sets the color to use for the background
  103138. */
  103139. loadingUIBackgroundColor: string;
  103140. /**
  103141. * Gets or sets the text to display while loading
  103142. */
  103143. loadingUIText: string;
  103144. }
  103145. /**
  103146. * Class used for the default loading screen
  103147. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  103148. */
  103149. export class DefaultLoadingScreen implements ILoadingScreen {
  103150. private _renderingCanvas;
  103151. private _loadingText;
  103152. private _loadingDivBackgroundColor;
  103153. private _loadingDiv;
  103154. private _loadingTextDiv;
  103155. /** Gets or sets the logo url to use for the default loading screen */
  103156. static DefaultLogoUrl: string;
  103157. /** Gets or sets the spinner url to use for the default loading screen */
  103158. static DefaultSpinnerUrl: string;
  103159. /**
  103160. * Creates a new default loading screen
  103161. * @param _renderingCanvas defines the canvas used to render the scene
  103162. * @param _loadingText defines the default text to display
  103163. * @param _loadingDivBackgroundColor defines the default background color
  103164. */
  103165. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  103166. /**
  103167. * Function called to display the loading screen
  103168. */
  103169. displayLoadingUI(): void;
  103170. /**
  103171. * Function called to hide the loading screen
  103172. */
  103173. hideLoadingUI(): void;
  103174. /**
  103175. * Gets or sets the text to display while loading
  103176. */
  103177. set loadingUIText(text: string);
  103178. get loadingUIText(): string;
  103179. /**
  103180. * Gets or sets the color to use for the background
  103181. */
  103182. get loadingUIBackgroundColor(): string;
  103183. set loadingUIBackgroundColor(color: string);
  103184. private _resizeLoadingUI;
  103185. }
  103186. }
  103187. declare module BABYLON {
  103188. /**
  103189. * Interface for any object that can request an animation frame
  103190. */
  103191. export interface ICustomAnimationFrameRequester {
  103192. /**
  103193. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  103194. */
  103195. renderFunction?: Function;
  103196. /**
  103197. * Called to request the next frame to render to
  103198. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  103199. */
  103200. requestAnimationFrame: Function;
  103201. /**
  103202. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  103203. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  103204. */
  103205. requestID?: number;
  103206. }
  103207. }
  103208. declare module BABYLON {
  103209. /**
  103210. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  103211. */
  103212. export class PerformanceMonitor {
  103213. private _enabled;
  103214. private _rollingFrameTime;
  103215. private _lastFrameTimeMs;
  103216. /**
  103217. * constructor
  103218. * @param frameSampleSize The number of samples required to saturate the sliding window
  103219. */
  103220. constructor(frameSampleSize?: number);
  103221. /**
  103222. * Samples current frame
  103223. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  103224. */
  103225. sampleFrame(timeMs?: number): void;
  103226. /**
  103227. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  103228. */
  103229. get averageFrameTime(): number;
  103230. /**
  103231. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  103232. */
  103233. get averageFrameTimeVariance(): number;
  103234. /**
  103235. * Returns the frame time of the most recent frame
  103236. */
  103237. get instantaneousFrameTime(): number;
  103238. /**
  103239. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  103240. */
  103241. get averageFPS(): number;
  103242. /**
  103243. * Returns the average framerate in frames per second using the most recent frame time
  103244. */
  103245. get instantaneousFPS(): number;
  103246. /**
  103247. * Returns true if enough samples have been taken to completely fill the sliding window
  103248. */
  103249. get isSaturated(): boolean;
  103250. /**
  103251. * Enables contributions to the sliding window sample set
  103252. */
  103253. enable(): void;
  103254. /**
  103255. * Disables contributions to the sliding window sample set
  103256. * Samples will not be interpolated over the disabled period
  103257. */
  103258. disable(): void;
  103259. /**
  103260. * Returns true if sampling is enabled
  103261. */
  103262. get isEnabled(): boolean;
  103263. /**
  103264. * Resets performance monitor
  103265. */
  103266. reset(): void;
  103267. }
  103268. /**
  103269. * RollingAverage
  103270. *
  103271. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  103272. */
  103273. export class RollingAverage {
  103274. /**
  103275. * Current average
  103276. */
  103277. average: number;
  103278. /**
  103279. * Current variance
  103280. */
  103281. variance: number;
  103282. protected _samples: Array<number>;
  103283. protected _sampleCount: number;
  103284. protected _pos: number;
  103285. protected _m2: number;
  103286. /**
  103287. * constructor
  103288. * @param length The number of samples required to saturate the sliding window
  103289. */
  103290. constructor(length: number);
  103291. /**
  103292. * Adds a sample to the sample set
  103293. * @param v The sample value
  103294. */
  103295. add(v: number): void;
  103296. /**
  103297. * Returns previously added values or null if outside of history or outside the sliding window domain
  103298. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  103299. * @return Value previously recorded with add() or null if outside of range
  103300. */
  103301. history(i: number): number;
  103302. /**
  103303. * Returns true if enough samples have been taken to completely fill the sliding window
  103304. * @return true if sample-set saturated
  103305. */
  103306. isSaturated(): boolean;
  103307. /**
  103308. * Resets the rolling average (equivalent to 0 samples taken so far)
  103309. */
  103310. reset(): void;
  103311. /**
  103312. * Wraps a value around the sample range boundaries
  103313. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  103314. * @return Wrapped position in sample range
  103315. */
  103316. protected _wrapPosition(i: number): number;
  103317. }
  103318. }
  103319. declare module BABYLON {
  103320. /**
  103321. * This class is used to track a performance counter which is number based.
  103322. * The user has access to many properties which give statistics of different nature.
  103323. *
  103324. * The implementer can track two kinds of Performance Counter: time and count.
  103325. * 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.
  103326. * 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.
  103327. */
  103328. export class PerfCounter {
  103329. /**
  103330. * Gets or sets a global boolean to turn on and off all the counters
  103331. */
  103332. static Enabled: boolean;
  103333. /**
  103334. * Returns the smallest value ever
  103335. */
  103336. get min(): number;
  103337. /**
  103338. * Returns the biggest value ever
  103339. */
  103340. get max(): number;
  103341. /**
  103342. * Returns the average value since the performance counter is running
  103343. */
  103344. get average(): number;
  103345. /**
  103346. * Returns the average value of the last second the counter was monitored
  103347. */
  103348. get lastSecAverage(): number;
  103349. /**
  103350. * Returns the current value
  103351. */
  103352. get current(): number;
  103353. /**
  103354. * Gets the accumulated total
  103355. */
  103356. get total(): number;
  103357. /**
  103358. * Gets the total value count
  103359. */
  103360. get count(): number;
  103361. /**
  103362. * Creates a new counter
  103363. */
  103364. constructor();
  103365. /**
  103366. * Call this method to start monitoring a new frame.
  103367. * 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.
  103368. */
  103369. fetchNewFrame(): void;
  103370. /**
  103371. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  103372. * @param newCount the count value to add to the monitored count
  103373. * @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.
  103374. */
  103375. addCount(newCount: number, fetchResult: boolean): void;
  103376. /**
  103377. * Start monitoring this performance counter
  103378. */
  103379. beginMonitoring(): void;
  103380. /**
  103381. * Compute the time lapsed since the previous beginMonitoring() call.
  103382. * @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
  103383. */
  103384. endMonitoring(newFrame?: boolean): void;
  103385. private _fetchResult;
  103386. private _startMonitoringTime;
  103387. private _min;
  103388. private _max;
  103389. private _average;
  103390. private _current;
  103391. private _totalValueCount;
  103392. private _totalAccumulated;
  103393. private _lastSecAverage;
  103394. private _lastSecAccumulated;
  103395. private _lastSecTime;
  103396. private _lastSecValueCount;
  103397. }
  103398. }
  103399. declare module BABYLON {
  103400. interface ThinEngine {
  103401. /**
  103402. * Sets alpha constants used by some alpha blending modes
  103403. * @param r defines the red component
  103404. * @param g defines the green component
  103405. * @param b defines the blue component
  103406. * @param a defines the alpha component
  103407. */
  103408. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  103409. /**
  103410. * Sets the current alpha mode
  103411. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  103412. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  103413. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  103414. */
  103415. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  103416. /**
  103417. * Gets the current alpha mode
  103418. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  103419. * @returns the current alpha mode
  103420. */
  103421. getAlphaMode(): number;
  103422. /**
  103423. * Sets the current alpha equation
  103424. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  103425. */
  103426. setAlphaEquation(equation: number): void;
  103427. /**
  103428. * Gets the current alpha equation.
  103429. * @returns the current alpha equation
  103430. */
  103431. getAlphaEquation(): number;
  103432. }
  103433. }
  103434. declare module BABYLON {
  103435. /**
  103436. * Defines the interface used by display changed events
  103437. */
  103438. export interface IDisplayChangedEventArgs {
  103439. /** Gets the vrDisplay object (if any) */
  103440. vrDisplay: Nullable<any>;
  103441. /** Gets a boolean indicating if webVR is supported */
  103442. vrSupported: boolean;
  103443. }
  103444. /**
  103445. * Defines the interface used by objects containing a viewport (like a camera)
  103446. */
  103447. interface IViewportOwnerLike {
  103448. /**
  103449. * Gets or sets the viewport
  103450. */
  103451. viewport: IViewportLike;
  103452. }
  103453. /**
  103454. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  103455. */
  103456. export class Engine extends ThinEngine {
  103457. /** Defines that alpha blending is disabled */
  103458. static readonly ALPHA_DISABLE: number;
  103459. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  103460. static readonly ALPHA_ADD: number;
  103461. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  103462. static readonly ALPHA_COMBINE: number;
  103463. /** Defines that alpha blending to DEST - SRC * DEST */
  103464. static readonly ALPHA_SUBTRACT: number;
  103465. /** Defines that alpha blending to SRC * DEST */
  103466. static readonly ALPHA_MULTIPLY: number;
  103467. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  103468. static readonly ALPHA_MAXIMIZED: number;
  103469. /** Defines that alpha blending to SRC + DEST */
  103470. static readonly ALPHA_ONEONE: number;
  103471. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  103472. static readonly ALPHA_PREMULTIPLIED: number;
  103473. /**
  103474. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  103475. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  103476. */
  103477. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  103478. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  103479. static readonly ALPHA_INTERPOLATE: number;
  103480. /**
  103481. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  103482. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  103483. */
  103484. static readonly ALPHA_SCREENMODE: number;
  103485. /** Defines that the ressource is not delayed*/
  103486. static readonly DELAYLOADSTATE_NONE: number;
  103487. /** Defines that the ressource was successfully delay loaded */
  103488. static readonly DELAYLOADSTATE_LOADED: number;
  103489. /** Defines that the ressource is currently delay loading */
  103490. static readonly DELAYLOADSTATE_LOADING: number;
  103491. /** Defines that the ressource is delayed and has not started loading */
  103492. static readonly DELAYLOADSTATE_NOTLOADED: number;
  103493. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  103494. static readonly NEVER: number;
  103495. /** 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 */
  103496. static readonly ALWAYS: number;
  103497. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  103498. static readonly LESS: number;
  103499. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  103500. static readonly EQUAL: number;
  103501. /** 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 */
  103502. static readonly LEQUAL: number;
  103503. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  103504. static readonly GREATER: number;
  103505. /** 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 */
  103506. static readonly GEQUAL: number;
  103507. /** 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 */
  103508. static readonly NOTEQUAL: number;
  103509. /** Passed to stencilOperation to specify that stencil value must be kept */
  103510. static readonly KEEP: number;
  103511. /** Passed to stencilOperation to specify that stencil value must be replaced */
  103512. static readonly REPLACE: number;
  103513. /** Passed to stencilOperation to specify that stencil value must be incremented */
  103514. static readonly INCR: number;
  103515. /** Passed to stencilOperation to specify that stencil value must be decremented */
  103516. static readonly DECR: number;
  103517. /** Passed to stencilOperation to specify that stencil value must be inverted */
  103518. static readonly INVERT: number;
  103519. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  103520. static readonly INCR_WRAP: number;
  103521. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  103522. static readonly DECR_WRAP: number;
  103523. /** Texture is not repeating outside of 0..1 UVs */
  103524. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  103525. /** Texture is repeating outside of 0..1 UVs */
  103526. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  103527. /** Texture is repeating and mirrored */
  103528. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  103529. /** ALPHA */
  103530. static readonly TEXTUREFORMAT_ALPHA: number;
  103531. /** LUMINANCE */
  103532. static readonly TEXTUREFORMAT_LUMINANCE: number;
  103533. /** LUMINANCE_ALPHA */
  103534. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  103535. /** RGB */
  103536. static readonly TEXTUREFORMAT_RGB: number;
  103537. /** RGBA */
  103538. static readonly TEXTUREFORMAT_RGBA: number;
  103539. /** RED */
  103540. static readonly TEXTUREFORMAT_RED: number;
  103541. /** RED (2nd reference) */
  103542. static readonly TEXTUREFORMAT_R: number;
  103543. /** RG */
  103544. static readonly TEXTUREFORMAT_RG: number;
  103545. /** RED_INTEGER */
  103546. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  103547. /** RED_INTEGER (2nd reference) */
  103548. static readonly TEXTUREFORMAT_R_INTEGER: number;
  103549. /** RG_INTEGER */
  103550. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  103551. /** RGB_INTEGER */
  103552. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  103553. /** RGBA_INTEGER */
  103554. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  103555. /** UNSIGNED_BYTE */
  103556. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  103557. /** UNSIGNED_BYTE (2nd reference) */
  103558. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  103559. /** FLOAT */
  103560. static readonly TEXTURETYPE_FLOAT: number;
  103561. /** HALF_FLOAT */
  103562. static readonly TEXTURETYPE_HALF_FLOAT: number;
  103563. /** BYTE */
  103564. static readonly TEXTURETYPE_BYTE: number;
  103565. /** SHORT */
  103566. static readonly TEXTURETYPE_SHORT: number;
  103567. /** UNSIGNED_SHORT */
  103568. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  103569. /** INT */
  103570. static readonly TEXTURETYPE_INT: number;
  103571. /** UNSIGNED_INT */
  103572. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  103573. /** UNSIGNED_SHORT_4_4_4_4 */
  103574. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  103575. /** UNSIGNED_SHORT_5_5_5_1 */
  103576. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  103577. /** UNSIGNED_SHORT_5_6_5 */
  103578. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  103579. /** UNSIGNED_INT_2_10_10_10_REV */
  103580. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  103581. /** UNSIGNED_INT_24_8 */
  103582. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  103583. /** UNSIGNED_INT_10F_11F_11F_REV */
  103584. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  103585. /** UNSIGNED_INT_5_9_9_9_REV */
  103586. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  103587. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  103588. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  103589. /** nearest is mag = nearest and min = nearest and mip = linear */
  103590. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  103591. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103592. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  103593. /** Trilinear is mag = linear and min = linear and mip = linear */
  103594. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  103595. /** nearest is mag = nearest and min = nearest and mip = linear */
  103596. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  103597. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103598. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  103599. /** Trilinear is mag = linear and min = linear and mip = linear */
  103600. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  103601. /** mag = nearest and min = nearest and mip = nearest */
  103602. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  103603. /** mag = nearest and min = linear and mip = nearest */
  103604. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  103605. /** mag = nearest and min = linear and mip = linear */
  103606. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  103607. /** mag = nearest and min = linear and mip = none */
  103608. static readonly TEXTURE_NEAREST_LINEAR: number;
  103609. /** mag = nearest and min = nearest and mip = none */
  103610. static readonly TEXTURE_NEAREST_NEAREST: number;
  103611. /** mag = linear and min = nearest and mip = nearest */
  103612. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  103613. /** mag = linear and min = nearest and mip = linear */
  103614. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  103615. /** mag = linear and min = linear and mip = none */
  103616. static readonly TEXTURE_LINEAR_LINEAR: number;
  103617. /** mag = linear and min = nearest and mip = none */
  103618. static readonly TEXTURE_LINEAR_NEAREST: number;
  103619. /** Explicit coordinates mode */
  103620. static readonly TEXTURE_EXPLICIT_MODE: number;
  103621. /** Spherical coordinates mode */
  103622. static readonly TEXTURE_SPHERICAL_MODE: number;
  103623. /** Planar coordinates mode */
  103624. static readonly TEXTURE_PLANAR_MODE: number;
  103625. /** Cubic coordinates mode */
  103626. static readonly TEXTURE_CUBIC_MODE: number;
  103627. /** Projection coordinates mode */
  103628. static readonly TEXTURE_PROJECTION_MODE: number;
  103629. /** Skybox coordinates mode */
  103630. static readonly TEXTURE_SKYBOX_MODE: number;
  103631. /** Inverse Cubic coordinates mode */
  103632. static readonly TEXTURE_INVCUBIC_MODE: number;
  103633. /** Equirectangular coordinates mode */
  103634. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  103635. /** Equirectangular Fixed coordinates mode */
  103636. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  103637. /** Equirectangular Fixed Mirrored coordinates mode */
  103638. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  103639. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  103640. static readonly SCALEMODE_FLOOR: number;
  103641. /** Defines that texture rescaling will look for the nearest power of 2 size */
  103642. static readonly SCALEMODE_NEAREST: number;
  103643. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  103644. static readonly SCALEMODE_CEILING: number;
  103645. /**
  103646. * Returns the current npm package of the sdk
  103647. */
  103648. static get NpmPackage(): string;
  103649. /**
  103650. * Returns the current version of the framework
  103651. */
  103652. static get Version(): string;
  103653. /** Gets the list of created engines */
  103654. static get Instances(): Engine[];
  103655. /**
  103656. * Gets the latest created engine
  103657. */
  103658. static get LastCreatedEngine(): Nullable<Engine>;
  103659. /**
  103660. * Gets the latest created scene
  103661. */
  103662. static get LastCreatedScene(): Nullable<Scene>;
  103663. /**
  103664. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  103665. * @param flag defines which part of the materials must be marked as dirty
  103666. * @param predicate defines a predicate used to filter which materials should be affected
  103667. */
  103668. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  103669. /**
  103670. * Method called to create the default loading screen.
  103671. * This can be overriden in your own app.
  103672. * @param canvas The rendering canvas element
  103673. * @returns The loading screen
  103674. */
  103675. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  103676. /**
  103677. * Method called to create the default rescale post process on each engine.
  103678. */
  103679. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  103680. /**
  103681. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  103682. **/
  103683. enableOfflineSupport: boolean;
  103684. /**
  103685. * 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)
  103686. **/
  103687. disableManifestCheck: boolean;
  103688. /**
  103689. * Gets the list of created scenes
  103690. */
  103691. scenes: Scene[];
  103692. /**
  103693. * Event raised when a new scene is created
  103694. */
  103695. onNewSceneAddedObservable: Observable<Scene>;
  103696. /**
  103697. * Gets the list of created postprocesses
  103698. */
  103699. postProcesses: PostProcess[];
  103700. /**
  103701. * Gets a boolean indicating if the pointer is currently locked
  103702. */
  103703. isPointerLock: boolean;
  103704. /**
  103705. * Observable event triggered each time the rendering canvas is resized
  103706. */
  103707. onResizeObservable: Observable<Engine>;
  103708. /**
  103709. * Observable event triggered each time the canvas loses focus
  103710. */
  103711. onCanvasBlurObservable: Observable<Engine>;
  103712. /**
  103713. * Observable event triggered each time the canvas gains focus
  103714. */
  103715. onCanvasFocusObservable: Observable<Engine>;
  103716. /**
  103717. * Observable event triggered each time the canvas receives pointerout event
  103718. */
  103719. onCanvasPointerOutObservable: Observable<PointerEvent>;
  103720. /**
  103721. * Observable raised when the engine begins a new frame
  103722. */
  103723. onBeginFrameObservable: Observable<Engine>;
  103724. /**
  103725. * If set, will be used to request the next animation frame for the render loop
  103726. */
  103727. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  103728. /**
  103729. * Observable raised when the engine ends the current frame
  103730. */
  103731. onEndFrameObservable: Observable<Engine>;
  103732. /**
  103733. * Observable raised when the engine is about to compile a shader
  103734. */
  103735. onBeforeShaderCompilationObservable: Observable<Engine>;
  103736. /**
  103737. * Observable raised when the engine has jsut compiled a shader
  103738. */
  103739. onAfterShaderCompilationObservable: Observable<Engine>;
  103740. /**
  103741. * Gets the audio engine
  103742. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103743. * @ignorenaming
  103744. */
  103745. static audioEngine: IAudioEngine;
  103746. /**
  103747. * Default AudioEngine factory responsible of creating the Audio Engine.
  103748. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  103749. */
  103750. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  103751. /**
  103752. * Default offline support factory responsible of creating a tool used to store data locally.
  103753. * By default, this will create a Database object if the workload has been embedded.
  103754. */
  103755. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  103756. private _loadingScreen;
  103757. private _pointerLockRequested;
  103758. private _dummyFramebuffer;
  103759. private _rescalePostProcess;
  103760. private _deterministicLockstep;
  103761. private _lockstepMaxSteps;
  103762. private _timeStep;
  103763. protected get _supportsHardwareTextureRescaling(): boolean;
  103764. private _fps;
  103765. private _deltaTime;
  103766. /** @hidden */
  103767. _drawCalls: PerfCounter;
  103768. /**
  103769. * Turn this value on if you want to pause FPS computation when in background
  103770. */
  103771. disablePerformanceMonitorInBackground: boolean;
  103772. private _performanceMonitor;
  103773. /**
  103774. * Gets the performance monitor attached to this engine
  103775. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  103776. */
  103777. get performanceMonitor(): PerformanceMonitor;
  103778. private _onFocus;
  103779. private _onBlur;
  103780. private _onCanvasPointerOut;
  103781. private _onCanvasBlur;
  103782. private _onCanvasFocus;
  103783. private _onFullscreenChange;
  103784. private _onPointerLockChange;
  103785. /**
  103786. * Gets the HTML element used to attach event listeners
  103787. * @returns a HTML element
  103788. */
  103789. getInputElement(): Nullable<HTMLElement>;
  103790. /**
  103791. * Creates a new engine
  103792. * @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
  103793. * @param antialias defines enable antialiasing (default: false)
  103794. * @param options defines further options to be sent to the getContext() function
  103795. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  103796. */
  103797. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  103798. /**
  103799. * Gets current aspect ratio
  103800. * @param viewportOwner defines the camera to use to get the aspect ratio
  103801. * @param useScreen defines if screen size must be used (or the current render target if any)
  103802. * @returns a number defining the aspect ratio
  103803. */
  103804. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  103805. /**
  103806. * Gets current screen aspect ratio
  103807. * @returns a number defining the aspect ratio
  103808. */
  103809. getScreenAspectRatio(): number;
  103810. /**
  103811. * Gets the client rect of the HTML canvas attached with the current webGL context
  103812. * @returns a client rectanglee
  103813. */
  103814. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  103815. /**
  103816. * Gets the client rect of the HTML element used for events
  103817. * @returns a client rectanglee
  103818. */
  103819. getInputElementClientRect(): Nullable<ClientRect>;
  103820. /**
  103821. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  103822. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103823. * @returns true if engine is in deterministic lock step mode
  103824. */
  103825. isDeterministicLockStep(): boolean;
  103826. /**
  103827. * Gets the max steps when engine is running in deterministic lock step
  103828. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103829. * @returns the max steps
  103830. */
  103831. getLockstepMaxSteps(): number;
  103832. /**
  103833. * Returns the time in ms between steps when using deterministic lock step.
  103834. * @returns time step in (ms)
  103835. */
  103836. getTimeStep(): number;
  103837. /**
  103838. * Force the mipmap generation for the given render target texture
  103839. * @param texture defines the render target texture to use
  103840. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  103841. */
  103842. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  103843. /** States */
  103844. /**
  103845. * Set various states to the webGL context
  103846. * @param culling defines backface culling state
  103847. * @param zOffset defines the value to apply to zOffset (0 by default)
  103848. * @param force defines if states must be applied even if cache is up to date
  103849. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  103850. */
  103851. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  103852. /**
  103853. * Set the z offset to apply to current rendering
  103854. * @param value defines the offset to apply
  103855. */
  103856. setZOffset(value: number): void;
  103857. /**
  103858. * Gets the current value of the zOffset
  103859. * @returns the current zOffset state
  103860. */
  103861. getZOffset(): number;
  103862. /**
  103863. * Enable or disable depth buffering
  103864. * @param enable defines the state to set
  103865. */
  103866. setDepthBuffer(enable: boolean): void;
  103867. /**
  103868. * Gets a boolean indicating if depth writing is enabled
  103869. * @returns the current depth writing state
  103870. */
  103871. getDepthWrite(): boolean;
  103872. /**
  103873. * Enable or disable depth writing
  103874. * @param enable defines the state to set
  103875. */
  103876. setDepthWrite(enable: boolean): void;
  103877. /**
  103878. * Gets a boolean indicating if stencil buffer is enabled
  103879. * @returns the current stencil buffer state
  103880. */
  103881. getStencilBuffer(): boolean;
  103882. /**
  103883. * Enable or disable the stencil buffer
  103884. * @param enable defines if the stencil buffer must be enabled or disabled
  103885. */
  103886. setStencilBuffer(enable: boolean): void;
  103887. /**
  103888. * Gets the current stencil mask
  103889. * @returns a number defining the new stencil mask to use
  103890. */
  103891. getStencilMask(): number;
  103892. /**
  103893. * Sets the current stencil mask
  103894. * @param mask defines the new stencil mask to use
  103895. */
  103896. setStencilMask(mask: number): void;
  103897. /**
  103898. * Gets the current stencil function
  103899. * @returns a number defining the stencil function to use
  103900. */
  103901. getStencilFunction(): number;
  103902. /**
  103903. * Gets the current stencil reference value
  103904. * @returns a number defining the stencil reference value to use
  103905. */
  103906. getStencilFunctionReference(): number;
  103907. /**
  103908. * Gets the current stencil mask
  103909. * @returns a number defining the stencil mask to use
  103910. */
  103911. getStencilFunctionMask(): number;
  103912. /**
  103913. * Sets the current stencil function
  103914. * @param stencilFunc defines the new stencil function to use
  103915. */
  103916. setStencilFunction(stencilFunc: number): void;
  103917. /**
  103918. * Sets the current stencil reference
  103919. * @param reference defines the new stencil reference to use
  103920. */
  103921. setStencilFunctionReference(reference: number): void;
  103922. /**
  103923. * Sets the current stencil mask
  103924. * @param mask defines the new stencil mask to use
  103925. */
  103926. setStencilFunctionMask(mask: number): void;
  103927. /**
  103928. * Gets the current stencil operation when stencil fails
  103929. * @returns a number defining stencil operation to use when stencil fails
  103930. */
  103931. getStencilOperationFail(): number;
  103932. /**
  103933. * Gets the current stencil operation when depth fails
  103934. * @returns a number defining stencil operation to use when depth fails
  103935. */
  103936. getStencilOperationDepthFail(): number;
  103937. /**
  103938. * Gets the current stencil operation when stencil passes
  103939. * @returns a number defining stencil operation to use when stencil passes
  103940. */
  103941. getStencilOperationPass(): number;
  103942. /**
  103943. * Sets the stencil operation to use when stencil fails
  103944. * @param operation defines the stencil operation to use when stencil fails
  103945. */
  103946. setStencilOperationFail(operation: number): void;
  103947. /**
  103948. * Sets the stencil operation to use when depth fails
  103949. * @param operation defines the stencil operation to use when depth fails
  103950. */
  103951. setStencilOperationDepthFail(operation: number): void;
  103952. /**
  103953. * Sets the stencil operation to use when stencil passes
  103954. * @param operation defines the stencil operation to use when stencil passes
  103955. */
  103956. setStencilOperationPass(operation: number): void;
  103957. /**
  103958. * Sets a boolean indicating if the dithering state is enabled or disabled
  103959. * @param value defines the dithering state
  103960. */
  103961. setDitheringState(value: boolean): void;
  103962. /**
  103963. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  103964. * @param value defines the rasterizer state
  103965. */
  103966. setRasterizerState(value: boolean): void;
  103967. /**
  103968. * Gets the current depth function
  103969. * @returns a number defining the depth function
  103970. */
  103971. getDepthFunction(): Nullable<number>;
  103972. /**
  103973. * Sets the current depth function
  103974. * @param depthFunc defines the function to use
  103975. */
  103976. setDepthFunction(depthFunc: number): void;
  103977. /**
  103978. * Sets the current depth function to GREATER
  103979. */
  103980. setDepthFunctionToGreater(): void;
  103981. /**
  103982. * Sets the current depth function to GEQUAL
  103983. */
  103984. setDepthFunctionToGreaterOrEqual(): void;
  103985. /**
  103986. * Sets the current depth function to LESS
  103987. */
  103988. setDepthFunctionToLess(): void;
  103989. /**
  103990. * Sets the current depth function to LEQUAL
  103991. */
  103992. setDepthFunctionToLessOrEqual(): void;
  103993. private _cachedStencilBuffer;
  103994. private _cachedStencilFunction;
  103995. private _cachedStencilMask;
  103996. private _cachedStencilOperationPass;
  103997. private _cachedStencilOperationFail;
  103998. private _cachedStencilOperationDepthFail;
  103999. private _cachedStencilReference;
  104000. /**
  104001. * Caches the the state of the stencil buffer
  104002. */
  104003. cacheStencilState(): void;
  104004. /**
  104005. * Restores the state of the stencil buffer
  104006. */
  104007. restoreStencilState(): void;
  104008. /**
  104009. * Directly set the WebGL Viewport
  104010. * @param x defines the x coordinate of the viewport (in screen space)
  104011. * @param y defines the y coordinate of the viewport (in screen space)
  104012. * @param width defines the width of the viewport (in screen space)
  104013. * @param height defines the height of the viewport (in screen space)
  104014. * @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
  104015. */
  104016. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  104017. /**
  104018. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  104019. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  104020. * @param y defines the y-coordinate of the corner of the clear rectangle
  104021. * @param width defines the width of the clear rectangle
  104022. * @param height defines the height of the clear rectangle
  104023. * @param clearColor defines the clear color
  104024. */
  104025. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  104026. /**
  104027. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  104028. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  104029. * @param y defines the y-coordinate of the corner of the clear rectangle
  104030. * @param width defines the width of the clear rectangle
  104031. * @param height defines the height of the clear rectangle
  104032. */
  104033. enableScissor(x: number, y: number, width: number, height: number): void;
  104034. /**
  104035. * Disable previously set scissor test rectangle
  104036. */
  104037. disableScissor(): void;
  104038. protected _reportDrawCall(): void;
  104039. /**
  104040. * Initializes a webVR display and starts listening to display change events
  104041. * The onVRDisplayChangedObservable will be notified upon these changes
  104042. * @returns The onVRDisplayChangedObservable
  104043. */
  104044. initWebVR(): Observable<IDisplayChangedEventArgs>;
  104045. /** @hidden */
  104046. _prepareVRComponent(): void;
  104047. /** @hidden */
  104048. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  104049. /** @hidden */
  104050. _submitVRFrame(): void;
  104051. /**
  104052. * Call this function to leave webVR mode
  104053. * Will do nothing if webVR is not supported or if there is no webVR device
  104054. * @see http://doc.babylonjs.com/how_to/webvr_camera
  104055. */
  104056. disableVR(): void;
  104057. /**
  104058. * Gets a boolean indicating that the system is in VR mode and is presenting
  104059. * @returns true if VR mode is engaged
  104060. */
  104061. isVRPresenting(): boolean;
  104062. /** @hidden */
  104063. _requestVRFrame(): void;
  104064. /** @hidden */
  104065. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  104066. /**
  104067. * Gets the source code of the vertex shader associated with a specific webGL program
  104068. * @param program defines the program to use
  104069. * @returns a string containing the source code of the vertex shader associated with the program
  104070. */
  104071. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  104072. /**
  104073. * Gets the source code of the fragment shader associated with a specific webGL program
  104074. * @param program defines the program to use
  104075. * @returns a string containing the source code of the fragment shader associated with the program
  104076. */
  104077. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  104078. /**
  104079. * Sets a depth stencil texture from a render target to the according uniform.
  104080. * @param channel The texture channel
  104081. * @param uniform The uniform to set
  104082. * @param texture The render target texture containing the depth stencil texture to apply
  104083. */
  104084. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  104085. /**
  104086. * Sets a texture to the webGL context from a postprocess
  104087. * @param channel defines the channel to use
  104088. * @param postProcess defines the source postprocess
  104089. */
  104090. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  104091. /**
  104092. * Binds the output of the passed in post process to the texture channel specified
  104093. * @param channel The channel the texture should be bound to
  104094. * @param postProcess The post process which's output should be bound
  104095. */
  104096. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  104097. /** @hidden */
  104098. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  104099. protected _rebuildBuffers(): void;
  104100. /** @hidden */
  104101. _renderFrame(): void;
  104102. _renderLoop(): void;
  104103. /** @hidden */
  104104. _renderViews(): boolean;
  104105. /**
  104106. * Toggle full screen mode
  104107. * @param requestPointerLock defines if a pointer lock should be requested from the user
  104108. */
  104109. switchFullscreen(requestPointerLock: boolean): void;
  104110. /**
  104111. * Enters full screen mode
  104112. * @param requestPointerLock defines if a pointer lock should be requested from the user
  104113. */
  104114. enterFullscreen(requestPointerLock: boolean): void;
  104115. /**
  104116. * Exits full screen mode
  104117. */
  104118. exitFullscreen(): void;
  104119. /**
  104120. * Enters Pointerlock mode
  104121. */
  104122. enterPointerlock(): void;
  104123. /**
  104124. * Exits Pointerlock mode
  104125. */
  104126. exitPointerlock(): void;
  104127. /**
  104128. * Begin a new frame
  104129. */
  104130. beginFrame(): void;
  104131. /**
  104132. * Enf the current frame
  104133. */
  104134. endFrame(): void;
  104135. resize(): void;
  104136. /**
  104137. * Set the compressed texture format to use, based on the formats you have, and the formats
  104138. * supported by the hardware / browser.
  104139. *
  104140. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  104141. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  104142. * to API arguments needed to compressed textures. This puts the burden on the container
  104143. * generator to house the arcane code for determining these for current & future formats.
  104144. *
  104145. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  104146. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  104147. *
  104148. * Note: The result of this call is not taken into account when a texture is base64.
  104149. *
  104150. * @param formatsAvailable defines the list of those format families you have created
  104151. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  104152. *
  104153. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  104154. * @returns The extension selected.
  104155. */
  104156. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  104157. /**
  104158. * Set the compressed texture extensions or file names to skip.
  104159. *
  104160. * @param skippedFiles defines the list of those texture files you want to skip
  104161. * Example: [".dds", ".env", "myfile.png"]
  104162. */
  104163. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  104164. /**
  104165. * Force a specific size of the canvas
  104166. * @param width defines the new canvas' width
  104167. * @param height defines the new canvas' height
  104168. */
  104169. setSize(width: number, height: number): void;
  104170. /**
  104171. * Updates a dynamic vertex buffer.
  104172. * @param vertexBuffer the vertex buffer to update
  104173. * @param data the data used to update the vertex buffer
  104174. * @param byteOffset the byte offset of the data
  104175. * @param byteLength the byte length of the data
  104176. */
  104177. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  104178. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  104179. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104180. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104181. _releaseTexture(texture: InternalTexture): void;
  104182. /**
  104183. * @hidden
  104184. * Rescales a texture
  104185. * @param source input texutre
  104186. * @param destination destination texture
  104187. * @param scene scene to use to render the resize
  104188. * @param internalFormat format to use when resizing
  104189. * @param onComplete callback to be called when resize has completed
  104190. */
  104191. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  104192. /**
  104193. * Gets the current framerate
  104194. * @returns a number representing the framerate
  104195. */
  104196. getFps(): number;
  104197. /**
  104198. * Gets the time spent between current and previous frame
  104199. * @returns a number representing the delta time in ms
  104200. */
  104201. getDeltaTime(): number;
  104202. private _measureFps;
  104203. /** @hidden */
  104204. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  104205. /**
  104206. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  104207. * @param renderTarget The render target to set the frame buffer for
  104208. */
  104209. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  104210. /**
  104211. * Update a dynamic index buffer
  104212. * @param indexBuffer defines the target index buffer
  104213. * @param indices defines the data to update
  104214. * @param offset defines the offset in the target index buffer where update should start
  104215. */
  104216. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  104217. /**
  104218. * Updates the sample count of a render target texture
  104219. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  104220. * @param texture defines the texture to update
  104221. * @param samples defines the sample count to set
  104222. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  104223. */
  104224. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  104225. /**
  104226. * Updates a depth texture Comparison Mode and Function.
  104227. * If the comparison Function is equal to 0, the mode will be set to none.
  104228. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  104229. * @param texture The texture to set the comparison function for
  104230. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  104231. */
  104232. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  104233. /**
  104234. * Creates a webGL buffer to use with instanciation
  104235. * @param capacity defines the size of the buffer
  104236. * @returns the webGL buffer
  104237. */
  104238. createInstancesBuffer(capacity: number): DataBuffer;
  104239. /**
  104240. * Delete a webGL buffer used with instanciation
  104241. * @param buffer defines the webGL buffer to delete
  104242. */
  104243. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  104244. /** @hidden */
  104245. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  104246. dispose(): void;
  104247. private _disableTouchAction;
  104248. /**
  104249. * Display the loading screen
  104250. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104251. */
  104252. displayLoadingUI(): void;
  104253. /**
  104254. * Hide the loading screen
  104255. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104256. */
  104257. hideLoadingUI(): void;
  104258. /**
  104259. * Gets the current loading screen object
  104260. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104261. */
  104262. get loadingScreen(): ILoadingScreen;
  104263. /**
  104264. * Sets the current loading screen object
  104265. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104266. */
  104267. set loadingScreen(loadingScreen: ILoadingScreen);
  104268. /**
  104269. * Sets the current loading screen text
  104270. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104271. */
  104272. set loadingUIText(text: string);
  104273. /**
  104274. * Sets the current loading screen background color
  104275. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104276. */
  104277. set loadingUIBackgroundColor(color: string);
  104278. /** Pointerlock and fullscreen */
  104279. /**
  104280. * Ask the browser to promote the current element to pointerlock mode
  104281. * @param element defines the DOM element to promote
  104282. */
  104283. static _RequestPointerlock(element: HTMLElement): void;
  104284. /**
  104285. * Asks the browser to exit pointerlock mode
  104286. */
  104287. static _ExitPointerlock(): void;
  104288. /**
  104289. * Ask the browser to promote the current element to fullscreen rendering mode
  104290. * @param element defines the DOM element to promote
  104291. */
  104292. static _RequestFullscreen(element: HTMLElement): void;
  104293. /**
  104294. * Asks the browser to exit fullscreen mode
  104295. */
  104296. static _ExitFullscreen(): void;
  104297. }
  104298. }
  104299. declare module BABYLON {
  104300. /**
  104301. * The engine store class is responsible to hold all the instances of Engine and Scene created
  104302. * during the life time of the application.
  104303. */
  104304. export class EngineStore {
  104305. /** Gets the list of created engines */
  104306. static Instances: Engine[];
  104307. /** @hidden */
  104308. static _LastCreatedScene: Nullable<Scene>;
  104309. /**
  104310. * Gets the latest created engine
  104311. */
  104312. static get LastCreatedEngine(): Nullable<Engine>;
  104313. /**
  104314. * Gets the latest created scene
  104315. */
  104316. static get LastCreatedScene(): Nullable<Scene>;
  104317. /**
  104318. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  104319. * @ignorenaming
  104320. */
  104321. static UseFallbackTexture: boolean;
  104322. /**
  104323. * Texture content used if a texture cannot loaded
  104324. * @ignorenaming
  104325. */
  104326. static FallbackTexture: string;
  104327. }
  104328. }
  104329. declare module BABYLON {
  104330. /**
  104331. * Helper class that provides a small promise polyfill
  104332. */
  104333. export class PromisePolyfill {
  104334. /**
  104335. * Static function used to check if the polyfill is required
  104336. * If this is the case then the function will inject the polyfill to window.Promise
  104337. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  104338. */
  104339. static Apply(force?: boolean): void;
  104340. }
  104341. }
  104342. declare module BABYLON {
  104343. /**
  104344. * Interface for screenshot methods with describe argument called `size` as object with options
  104345. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  104346. */
  104347. export interface IScreenshotSize {
  104348. /**
  104349. * number in pixels for canvas height
  104350. */
  104351. height?: number;
  104352. /**
  104353. * multiplier allowing render at a higher or lower resolution
  104354. * If value is defined then height and width will be ignored and taken from camera
  104355. */
  104356. precision?: number;
  104357. /**
  104358. * number in pixels for canvas width
  104359. */
  104360. width?: number;
  104361. }
  104362. }
  104363. declare module BABYLON {
  104364. interface IColor4Like {
  104365. r: float;
  104366. g: float;
  104367. b: float;
  104368. a: float;
  104369. }
  104370. /**
  104371. * Class containing a set of static utilities functions
  104372. */
  104373. export class Tools {
  104374. /**
  104375. * Gets or sets the base URL to use to load assets
  104376. */
  104377. static get BaseUrl(): string;
  104378. static set BaseUrl(value: string);
  104379. /**
  104380. * Enable/Disable Custom HTTP Request Headers globally.
  104381. * default = false
  104382. * @see CustomRequestHeaders
  104383. */
  104384. static UseCustomRequestHeaders: boolean;
  104385. /**
  104386. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  104387. * i.e. when loading files, where the server/service expects an Authorization header
  104388. */
  104389. static CustomRequestHeaders: {
  104390. [key: string]: string;
  104391. };
  104392. /**
  104393. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  104394. */
  104395. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  104396. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  104397. /**
  104398. * Default behaviour for cors in the application.
  104399. * It can be a string if the expected behavior is identical in the entire app.
  104400. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  104401. */
  104402. static CorsBehavior: string | ((url: string | string[]) => string);
  104403. /**
  104404. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  104405. * @ignorenaming
  104406. */
  104407. static get UseFallbackTexture(): boolean;
  104408. static set UseFallbackTexture(value: boolean);
  104409. /**
  104410. * Use this object to register external classes like custom textures or material
  104411. * to allow the laoders to instantiate them
  104412. */
  104413. static get RegisteredExternalClasses(): {
  104414. [key: string]: Object;
  104415. };
  104416. static set RegisteredExternalClasses(classes: {
  104417. [key: string]: Object;
  104418. });
  104419. /**
  104420. * Texture content used if a texture cannot loaded
  104421. * @ignorenaming
  104422. */
  104423. static get fallbackTexture(): string;
  104424. static set fallbackTexture(value: string);
  104425. /**
  104426. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  104427. * @param u defines the coordinate on X axis
  104428. * @param v defines the coordinate on Y axis
  104429. * @param width defines the width of the source data
  104430. * @param height defines the height of the source data
  104431. * @param pixels defines the source byte array
  104432. * @param color defines the output color
  104433. */
  104434. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  104435. /**
  104436. * Interpolates between a and b via alpha
  104437. * @param a The lower value (returned when alpha = 0)
  104438. * @param b The upper value (returned when alpha = 1)
  104439. * @param alpha The interpolation-factor
  104440. * @return The mixed value
  104441. */
  104442. static Mix(a: number, b: number, alpha: number): number;
  104443. /**
  104444. * Tries to instantiate a new object from a given class name
  104445. * @param className defines the class name to instantiate
  104446. * @returns the new object or null if the system was not able to do the instantiation
  104447. */
  104448. static Instantiate(className: string): any;
  104449. /**
  104450. * Provides a slice function that will work even on IE
  104451. * @param data defines the array to slice
  104452. * @param start defines the start of the data (optional)
  104453. * @param end defines the end of the data (optional)
  104454. * @returns the new sliced array
  104455. */
  104456. static Slice<T>(data: T, start?: number, end?: number): T;
  104457. /**
  104458. * Polyfill for setImmediate
  104459. * @param action defines the action to execute after the current execution block
  104460. */
  104461. static SetImmediate(action: () => void): void;
  104462. /**
  104463. * Function indicating if a number is an exponent of 2
  104464. * @param value defines the value to test
  104465. * @returns true if the value is an exponent of 2
  104466. */
  104467. static IsExponentOfTwo(value: number): boolean;
  104468. private static _tmpFloatArray;
  104469. /**
  104470. * Returns the nearest 32-bit single precision float representation of a Number
  104471. * @param value A Number. If the parameter is of a different type, it will get converted
  104472. * to a number or to NaN if it cannot be converted
  104473. * @returns number
  104474. */
  104475. static FloatRound(value: number): number;
  104476. /**
  104477. * Extracts the filename from a path
  104478. * @param path defines the path to use
  104479. * @returns the filename
  104480. */
  104481. static GetFilename(path: string): string;
  104482. /**
  104483. * Extracts the "folder" part of a path (everything before the filename).
  104484. * @param uri The URI to extract the info from
  104485. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  104486. * @returns The "folder" part of the path
  104487. */
  104488. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  104489. /**
  104490. * Extracts text content from a DOM element hierarchy
  104491. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  104492. */
  104493. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  104494. /**
  104495. * Convert an angle in radians to degrees
  104496. * @param angle defines the angle to convert
  104497. * @returns the angle in degrees
  104498. */
  104499. static ToDegrees(angle: number): number;
  104500. /**
  104501. * Convert an angle in degrees to radians
  104502. * @param angle defines the angle to convert
  104503. * @returns the angle in radians
  104504. */
  104505. static ToRadians(angle: number): number;
  104506. /**
  104507. * Returns an array if obj is not an array
  104508. * @param obj defines the object to evaluate as an array
  104509. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  104510. * @returns either obj directly if obj is an array or a new array containing obj
  104511. */
  104512. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  104513. /**
  104514. * Gets the pointer prefix to use
  104515. * @returns "pointer" if touch is enabled. Else returns "mouse"
  104516. */
  104517. static GetPointerPrefix(): string;
  104518. /**
  104519. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  104520. * @param url define the url we are trying
  104521. * @param element define the dom element where to configure the cors policy
  104522. */
  104523. static SetCorsBehavior(url: string | string[], element: {
  104524. crossOrigin: string | null;
  104525. }): void;
  104526. /**
  104527. * Removes unwanted characters from an url
  104528. * @param url defines the url to clean
  104529. * @returns the cleaned url
  104530. */
  104531. static CleanUrl(url: string): string;
  104532. /**
  104533. * Gets or sets a function used to pre-process url before using them to load assets
  104534. */
  104535. static get PreprocessUrl(): (url: string) => string;
  104536. static set PreprocessUrl(processor: (url: string) => string);
  104537. /**
  104538. * Loads an image as an HTMLImageElement.
  104539. * @param input url string, ArrayBuffer, or Blob to load
  104540. * @param onLoad callback called when the image successfully loads
  104541. * @param onError callback called when the image fails to load
  104542. * @param offlineProvider offline provider for caching
  104543. * @param mimeType optional mime type
  104544. * @returns the HTMLImageElement of the loaded image
  104545. */
  104546. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  104547. /**
  104548. * Loads a file from a url
  104549. * @param url url string, ArrayBuffer, or Blob to load
  104550. * @param onSuccess callback called when the file successfully loads
  104551. * @param onProgress callback called while file is loading (if the server supports this mode)
  104552. * @param offlineProvider defines the offline provider for caching
  104553. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  104554. * @param onError callback called when the file fails to load
  104555. * @returns a file request object
  104556. */
  104557. 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;
  104558. /**
  104559. * Loads a file from a url
  104560. * @param url the file url to load
  104561. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  104562. */
  104563. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  104564. /**
  104565. * Load a script (identified by an url). When the url returns, the
  104566. * content of this file is added into a new script element, attached to the DOM (body element)
  104567. * @param scriptUrl defines the url of the script to laod
  104568. * @param onSuccess defines the callback called when the script is loaded
  104569. * @param onError defines the callback to call if an error occurs
  104570. * @param scriptId defines the id of the script element
  104571. */
  104572. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  104573. /**
  104574. * Load an asynchronous script (identified by an url). When the url returns, the
  104575. * content of this file is added into a new script element, attached to the DOM (body element)
  104576. * @param scriptUrl defines the url of the script to laod
  104577. * @param scriptId defines the id of the script element
  104578. * @returns a promise request object
  104579. */
  104580. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  104581. /**
  104582. * Loads a file from a blob
  104583. * @param fileToLoad defines the blob to use
  104584. * @param callback defines the callback to call when data is loaded
  104585. * @param progressCallback defines the callback to call during loading process
  104586. * @returns a file request object
  104587. */
  104588. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  104589. /**
  104590. * Reads a file from a File object
  104591. * @param file defines the file to load
  104592. * @param onSuccess defines the callback to call when data is loaded
  104593. * @param onProgress defines the callback to call during loading process
  104594. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  104595. * @param onError defines the callback to call when an error occurs
  104596. * @returns a file request object
  104597. */
  104598. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  104599. /**
  104600. * Creates a data url from a given string content
  104601. * @param content defines the content to convert
  104602. * @returns the new data url link
  104603. */
  104604. static FileAsURL(content: string): string;
  104605. /**
  104606. * Format the given number to a specific decimal format
  104607. * @param value defines the number to format
  104608. * @param decimals defines the number of decimals to use
  104609. * @returns the formatted string
  104610. */
  104611. static Format(value: number, decimals?: number): string;
  104612. /**
  104613. * Tries to copy an object by duplicating every property
  104614. * @param source defines the source object
  104615. * @param destination defines the target object
  104616. * @param doNotCopyList defines a list of properties to avoid
  104617. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  104618. */
  104619. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  104620. /**
  104621. * Gets a boolean indicating if the given object has no own property
  104622. * @param obj defines the object to test
  104623. * @returns true if object has no own property
  104624. */
  104625. static IsEmpty(obj: any): boolean;
  104626. /**
  104627. * Function used to register events at window level
  104628. * @param windowElement defines the Window object to use
  104629. * @param events defines the events to register
  104630. */
  104631. static RegisterTopRootEvents(windowElement: Window, events: {
  104632. name: string;
  104633. handler: Nullable<(e: FocusEvent) => any>;
  104634. }[]): void;
  104635. /**
  104636. * Function used to unregister events from window level
  104637. * @param windowElement defines the Window object to use
  104638. * @param events defines the events to unregister
  104639. */
  104640. static UnregisterTopRootEvents(windowElement: Window, events: {
  104641. name: string;
  104642. handler: Nullable<(e: FocusEvent) => any>;
  104643. }[]): void;
  104644. /**
  104645. * @ignore
  104646. */
  104647. static _ScreenshotCanvas: HTMLCanvasElement;
  104648. /**
  104649. * Dumps the current bound framebuffer
  104650. * @param width defines the rendering width
  104651. * @param height defines the rendering height
  104652. * @param engine defines the hosting engine
  104653. * @param successCallback defines the callback triggered once the data are available
  104654. * @param mimeType defines the mime type of the result
  104655. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  104656. */
  104657. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  104658. /**
  104659. * Converts the canvas data to blob.
  104660. * This acts as a polyfill for browsers not supporting the to blob function.
  104661. * @param canvas Defines the canvas to extract the data from
  104662. * @param successCallback Defines the callback triggered once the data are available
  104663. * @param mimeType Defines the mime type of the result
  104664. */
  104665. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  104666. /**
  104667. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  104668. * @param successCallback defines the callback triggered once the data are available
  104669. * @param mimeType defines the mime type of the result
  104670. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  104671. */
  104672. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  104673. /**
  104674. * Downloads a blob in the browser
  104675. * @param blob defines the blob to download
  104676. * @param fileName defines the name of the downloaded file
  104677. */
  104678. static Download(blob: Blob, fileName: string): void;
  104679. /**
  104680. * Captures a screenshot of the current rendering
  104681. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104682. * @param engine defines the rendering engine
  104683. * @param camera defines the source camera
  104684. * @param size This parameter can be set to a single number or to an object with the
  104685. * following (optional) properties: precision, width, height. If a single number is passed,
  104686. * it will be used for both width and height. If an object is passed, the screenshot size
  104687. * will be derived from the parameters. The precision property is a multiplier allowing
  104688. * rendering at a higher or lower resolution
  104689. * @param successCallback defines the callback receives a single parameter which contains the
  104690. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  104691. * src parameter of an <img> to display it
  104692. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  104693. * Check your browser for supported MIME types
  104694. */
  104695. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  104696. /**
  104697. * Captures a screenshot of the current rendering
  104698. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104699. * @param engine defines the rendering engine
  104700. * @param camera defines the source camera
  104701. * @param size This parameter can be set to a single number or to an object with the
  104702. * following (optional) properties: precision, width, height. If a single number is passed,
  104703. * it will be used for both width and height. If an object is passed, the screenshot size
  104704. * will be derived from the parameters. The precision property is a multiplier allowing
  104705. * rendering at a higher or lower resolution
  104706. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  104707. * Check your browser for supported MIME types
  104708. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  104709. * to the src parameter of an <img> to display it
  104710. */
  104711. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  104712. /**
  104713. * Generates an image screenshot from the specified camera.
  104714. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104715. * @param engine The engine to use for rendering
  104716. * @param camera The camera to use for rendering
  104717. * @param size This parameter can be set to a single number or to an object with the
  104718. * following (optional) properties: precision, width, height. If a single number is passed,
  104719. * it will be used for both width and height. If an object is passed, the screenshot size
  104720. * will be derived from the parameters. The precision property is a multiplier allowing
  104721. * rendering at a higher or lower resolution
  104722. * @param successCallback The callback receives a single parameter which contains the
  104723. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  104724. * src parameter of an <img> to display it
  104725. * @param mimeType The MIME type of the screenshot image (default: image/png).
  104726. * Check your browser for supported MIME types
  104727. * @param samples Texture samples (default: 1)
  104728. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  104729. * @param fileName A name for for the downloaded file.
  104730. */
  104731. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  104732. /**
  104733. * Generates an image screenshot from the specified camera.
  104734. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104735. * @param engine The engine to use for rendering
  104736. * @param camera The camera to use for rendering
  104737. * @param size This parameter can be set to a single number or to an object with the
  104738. * following (optional) properties: precision, width, height. If a single number is passed,
  104739. * it will be used for both width and height. If an object is passed, the screenshot size
  104740. * will be derived from the parameters. The precision property is a multiplier allowing
  104741. * rendering at a higher or lower resolution
  104742. * @param mimeType The MIME type of the screenshot image (default: image/png).
  104743. * Check your browser for supported MIME types
  104744. * @param samples Texture samples (default: 1)
  104745. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  104746. * @param fileName A name for for the downloaded file.
  104747. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  104748. * to the src parameter of an <img> to display it
  104749. */
  104750. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  104751. /**
  104752. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  104753. * Be aware Math.random() could cause collisions, but:
  104754. * "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"
  104755. * @returns a pseudo random id
  104756. */
  104757. static RandomId(): string;
  104758. /**
  104759. * Test if the given uri is a base64 string
  104760. * @param uri The uri to test
  104761. * @return True if the uri is a base64 string or false otherwise
  104762. */
  104763. static IsBase64(uri: string): boolean;
  104764. /**
  104765. * Decode the given base64 uri.
  104766. * @param uri The uri to decode
  104767. * @return The decoded base64 data.
  104768. */
  104769. static DecodeBase64(uri: string): ArrayBuffer;
  104770. /**
  104771. * Gets the absolute url.
  104772. * @param url the input url
  104773. * @return the absolute url
  104774. */
  104775. static GetAbsoluteUrl(url: string): string;
  104776. /**
  104777. * No log
  104778. */
  104779. static readonly NoneLogLevel: number;
  104780. /**
  104781. * Only message logs
  104782. */
  104783. static readonly MessageLogLevel: number;
  104784. /**
  104785. * Only warning logs
  104786. */
  104787. static readonly WarningLogLevel: number;
  104788. /**
  104789. * Only error logs
  104790. */
  104791. static readonly ErrorLogLevel: number;
  104792. /**
  104793. * All logs
  104794. */
  104795. static readonly AllLogLevel: number;
  104796. /**
  104797. * Gets a value indicating the number of loading errors
  104798. * @ignorenaming
  104799. */
  104800. static get errorsCount(): number;
  104801. /**
  104802. * Callback called when a new log is added
  104803. */
  104804. static OnNewCacheEntry: (entry: string) => void;
  104805. /**
  104806. * Log a message to the console
  104807. * @param message defines the message to log
  104808. */
  104809. static Log(message: string): void;
  104810. /**
  104811. * Write a warning message to the console
  104812. * @param message defines the message to log
  104813. */
  104814. static Warn(message: string): void;
  104815. /**
  104816. * Write an error message to the console
  104817. * @param message defines the message to log
  104818. */
  104819. static Error(message: string): void;
  104820. /**
  104821. * Gets current log cache (list of logs)
  104822. */
  104823. static get LogCache(): string;
  104824. /**
  104825. * Clears the log cache
  104826. */
  104827. static ClearLogCache(): void;
  104828. /**
  104829. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  104830. */
  104831. static set LogLevels(level: number);
  104832. /**
  104833. * Checks if the window object exists
  104834. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  104835. */
  104836. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  104837. /**
  104838. * No performance log
  104839. */
  104840. static readonly PerformanceNoneLogLevel: number;
  104841. /**
  104842. * Use user marks to log performance
  104843. */
  104844. static readonly PerformanceUserMarkLogLevel: number;
  104845. /**
  104846. * Log performance to the console
  104847. */
  104848. static readonly PerformanceConsoleLogLevel: number;
  104849. private static _performance;
  104850. /**
  104851. * Sets the current performance log level
  104852. */
  104853. static set PerformanceLogLevel(level: number);
  104854. private static _StartPerformanceCounterDisabled;
  104855. private static _EndPerformanceCounterDisabled;
  104856. private static _StartUserMark;
  104857. private static _EndUserMark;
  104858. private static _StartPerformanceConsole;
  104859. private static _EndPerformanceConsole;
  104860. /**
  104861. * Starts a performance counter
  104862. */
  104863. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  104864. /**
  104865. * Ends a specific performance coutner
  104866. */
  104867. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  104868. /**
  104869. * Gets either window.performance.now() if supported or Date.now() else
  104870. */
  104871. static get Now(): number;
  104872. /**
  104873. * This method will return the name of the class used to create the instance of the given object.
  104874. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  104875. * @param object the object to get the class name from
  104876. * @param isType defines if the object is actually a type
  104877. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  104878. */
  104879. static GetClassName(object: any, isType?: boolean): string;
  104880. /**
  104881. * Gets the first element of an array satisfying a given predicate
  104882. * @param array defines the array to browse
  104883. * @param predicate defines the predicate to use
  104884. * @returns null if not found or the element
  104885. */
  104886. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  104887. /**
  104888. * This method will return the name of the full name of the class, including its owning module (if any).
  104889. * 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).
  104890. * @param object the object to get the class name from
  104891. * @param isType defines if the object is actually a type
  104892. * @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.
  104893. * @ignorenaming
  104894. */
  104895. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  104896. /**
  104897. * Returns a promise that resolves after the given amount of time.
  104898. * @param delay Number of milliseconds to delay
  104899. * @returns Promise that resolves after the given amount of time
  104900. */
  104901. static DelayAsync(delay: number): Promise<void>;
  104902. }
  104903. /**
  104904. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  104905. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  104906. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  104907. * @param name The name of the class, case should be preserved
  104908. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  104909. */
  104910. export function className(name: string, module?: string): (target: Object) => void;
  104911. /**
  104912. * An implementation of a loop for asynchronous functions.
  104913. */
  104914. export class AsyncLoop {
  104915. /**
  104916. * Defines the number of iterations for the loop
  104917. */
  104918. iterations: number;
  104919. /**
  104920. * Defines the current index of the loop.
  104921. */
  104922. index: number;
  104923. private _done;
  104924. private _fn;
  104925. private _successCallback;
  104926. /**
  104927. * Constructor.
  104928. * @param iterations the number of iterations.
  104929. * @param func the function to run each iteration
  104930. * @param successCallback the callback that will be called upon succesful execution
  104931. * @param offset starting offset.
  104932. */
  104933. constructor(
  104934. /**
  104935. * Defines the number of iterations for the loop
  104936. */
  104937. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  104938. /**
  104939. * Execute the next iteration. Must be called after the last iteration was finished.
  104940. */
  104941. executeNext(): void;
  104942. /**
  104943. * Break the loop and run the success callback.
  104944. */
  104945. breakLoop(): void;
  104946. /**
  104947. * Create and run an async loop.
  104948. * @param iterations the number of iterations.
  104949. * @param fn the function to run each iteration
  104950. * @param successCallback the callback that will be called upon succesful execution
  104951. * @param offset starting offset.
  104952. * @returns the created async loop object
  104953. */
  104954. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  104955. /**
  104956. * A for-loop that will run a given number of iterations synchronous and the rest async.
  104957. * @param iterations total number of iterations
  104958. * @param syncedIterations number of synchronous iterations in each async iteration.
  104959. * @param fn the function to call each iteration.
  104960. * @param callback a success call back that will be called when iterating stops.
  104961. * @param breakFunction a break condition (optional)
  104962. * @param timeout timeout settings for the setTimeout function. default - 0.
  104963. * @returns the created async loop object
  104964. */
  104965. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  104966. }
  104967. }
  104968. declare module BABYLON {
  104969. /**
  104970. * This class implement a typical dictionary using a string as key and the generic type T as value.
  104971. * The underlying implementation relies on an associative array to ensure the best performances.
  104972. * The value can be anything including 'null' but except 'undefined'
  104973. */
  104974. export class StringDictionary<T> {
  104975. /**
  104976. * This will clear this dictionary and copy the content from the 'source' one.
  104977. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  104978. * @param source the dictionary to take the content from and copy to this dictionary
  104979. */
  104980. copyFrom(source: StringDictionary<T>): void;
  104981. /**
  104982. * Get a value based from its key
  104983. * @param key the given key to get the matching value from
  104984. * @return the value if found, otherwise undefined is returned
  104985. */
  104986. get(key: string): T | undefined;
  104987. /**
  104988. * Get a value from its key or add it if it doesn't exist.
  104989. * This method will ensure you that a given key/data will be present in the dictionary.
  104990. * @param key the given key to get the matching value from
  104991. * @param factory the factory that will create the value if the key is not present in the dictionary.
  104992. * The factory will only be invoked if there's no data for the given key.
  104993. * @return the value corresponding to the key.
  104994. */
  104995. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  104996. /**
  104997. * Get a value from its key if present in the dictionary otherwise add it
  104998. * @param key the key to get the value from
  104999. * @param val if there's no such key/value pair in the dictionary add it with this value
  105000. * @return the value corresponding to the key
  105001. */
  105002. getOrAdd(key: string, val: T): T;
  105003. /**
  105004. * Check if there's a given key in the dictionary
  105005. * @param key the key to check for
  105006. * @return true if the key is present, false otherwise
  105007. */
  105008. contains(key: string): boolean;
  105009. /**
  105010. * Add a new key and its corresponding value
  105011. * @param key the key to add
  105012. * @param value the value corresponding to the key
  105013. * @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
  105014. */
  105015. add(key: string, value: T): boolean;
  105016. /**
  105017. * Update a specific value associated to a key
  105018. * @param key defines the key to use
  105019. * @param value defines the value to store
  105020. * @returns true if the value was updated (or false if the key was not found)
  105021. */
  105022. set(key: string, value: T): boolean;
  105023. /**
  105024. * Get the element of the given key and remove it from the dictionary
  105025. * @param key defines the key to search
  105026. * @returns the value associated with the key or null if not found
  105027. */
  105028. getAndRemove(key: string): Nullable<T>;
  105029. /**
  105030. * Remove a key/value from the dictionary.
  105031. * @param key the key to remove
  105032. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  105033. */
  105034. remove(key: string): boolean;
  105035. /**
  105036. * Clear the whole content of the dictionary
  105037. */
  105038. clear(): void;
  105039. /**
  105040. * Gets the current count
  105041. */
  105042. get count(): number;
  105043. /**
  105044. * Execute a callback on each key/val of the dictionary.
  105045. * Note that you can remove any element in this dictionary in the callback implementation
  105046. * @param callback the callback to execute on a given key/value pair
  105047. */
  105048. forEach(callback: (key: string, val: T) => void): void;
  105049. /**
  105050. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  105051. * If the callback returns null or undefined the method will iterate to the next key/value pair
  105052. * Note that you can remove any element in this dictionary in the callback implementation
  105053. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  105054. * @returns the first item
  105055. */
  105056. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  105057. private _count;
  105058. private _data;
  105059. }
  105060. }
  105061. declare module BABYLON {
  105062. /** @hidden */
  105063. export interface ICollisionCoordinator {
  105064. createCollider(): Collider;
  105065. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  105066. init(scene: Scene): void;
  105067. }
  105068. /** @hidden */
  105069. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  105070. private _scene;
  105071. private _scaledPosition;
  105072. private _scaledVelocity;
  105073. private _finalPosition;
  105074. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  105075. createCollider(): Collider;
  105076. init(scene: Scene): void;
  105077. private _collideWithWorld;
  105078. }
  105079. }
  105080. declare module BABYLON {
  105081. /**
  105082. * Class used to manage all inputs for the scene.
  105083. */
  105084. export class InputManager {
  105085. /** The distance in pixel that you have to move to prevent some events */
  105086. static DragMovementThreshold: number;
  105087. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  105088. static LongPressDelay: number;
  105089. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  105090. static DoubleClickDelay: number;
  105091. /** If you need to check double click without raising a single click at first click, enable this flag */
  105092. static ExclusiveDoubleClickMode: boolean;
  105093. private _wheelEventName;
  105094. private _onPointerMove;
  105095. private _onPointerDown;
  105096. private _onPointerUp;
  105097. private _initClickEvent;
  105098. private _initActionManager;
  105099. private _delayedSimpleClick;
  105100. private _delayedSimpleClickTimeout;
  105101. private _previousDelayedSimpleClickTimeout;
  105102. private _meshPickProceed;
  105103. private _previousButtonPressed;
  105104. private _currentPickResult;
  105105. private _previousPickResult;
  105106. private _totalPointersPressed;
  105107. private _doubleClickOccured;
  105108. private _pointerOverMesh;
  105109. private _pickedDownMesh;
  105110. private _pickedUpMesh;
  105111. private _pointerX;
  105112. private _pointerY;
  105113. private _unTranslatedPointerX;
  105114. private _unTranslatedPointerY;
  105115. private _startingPointerPosition;
  105116. private _previousStartingPointerPosition;
  105117. private _startingPointerTime;
  105118. private _previousStartingPointerTime;
  105119. private _pointerCaptures;
  105120. private _onKeyDown;
  105121. private _onKeyUp;
  105122. private _onCanvasFocusObserver;
  105123. private _onCanvasBlurObserver;
  105124. private _scene;
  105125. /**
  105126. * Creates a new InputManager
  105127. * @param scene defines the hosting scene
  105128. */
  105129. constructor(scene: Scene);
  105130. /**
  105131. * Gets the mesh that is currently under the pointer
  105132. */
  105133. get meshUnderPointer(): Nullable<AbstractMesh>;
  105134. /**
  105135. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  105136. */
  105137. get unTranslatedPointer(): Vector2;
  105138. /**
  105139. * Gets or sets the current on-screen X position of the pointer
  105140. */
  105141. get pointerX(): number;
  105142. set pointerX(value: number);
  105143. /**
  105144. * Gets or sets the current on-screen Y position of the pointer
  105145. */
  105146. get pointerY(): number;
  105147. set pointerY(value: number);
  105148. private _updatePointerPosition;
  105149. private _processPointerMove;
  105150. private _setRayOnPointerInfo;
  105151. private _checkPrePointerObservable;
  105152. /**
  105153. * Use this method to simulate a pointer move on a mesh
  105154. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105155. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105156. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105157. */
  105158. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  105159. /**
  105160. * Use this method to simulate a pointer down on a mesh
  105161. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105162. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105163. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105164. */
  105165. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  105166. private _processPointerDown;
  105167. /** @hidden */
  105168. _isPointerSwiping(): boolean;
  105169. /**
  105170. * Use this method to simulate a pointer up on a mesh
  105171. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105172. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105173. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105174. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  105175. */
  105176. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  105177. private _processPointerUp;
  105178. /**
  105179. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  105180. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  105181. * @returns true if the pointer was captured
  105182. */
  105183. isPointerCaptured(pointerId?: number): boolean;
  105184. /**
  105185. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  105186. * @param attachUp defines if you want to attach events to pointerup
  105187. * @param attachDown defines if you want to attach events to pointerdown
  105188. * @param attachMove defines if you want to attach events to pointermove
  105189. */
  105190. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  105191. /**
  105192. * Detaches all event handlers
  105193. */
  105194. detachControl(): void;
  105195. /**
  105196. * Force the value of meshUnderPointer
  105197. * @param mesh defines the mesh to use
  105198. */
  105199. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  105200. /**
  105201. * Gets the mesh under the pointer
  105202. * @returns a Mesh or null if no mesh is under the pointer
  105203. */
  105204. getPointerOverMesh(): Nullable<AbstractMesh>;
  105205. }
  105206. }
  105207. declare module BABYLON {
  105208. /**
  105209. * Helper class used to generate session unique ID
  105210. */
  105211. export class UniqueIdGenerator {
  105212. private static _UniqueIdCounter;
  105213. /**
  105214. * Gets an unique (relatively to the current scene) Id
  105215. */
  105216. static get UniqueId(): number;
  105217. }
  105218. }
  105219. declare module BABYLON {
  105220. /**
  105221. * This class defines the direct association between an animation and a target
  105222. */
  105223. export class TargetedAnimation {
  105224. /**
  105225. * Animation to perform
  105226. */
  105227. animation: Animation;
  105228. /**
  105229. * Target to animate
  105230. */
  105231. target: any;
  105232. /**
  105233. * Serialize the object
  105234. * @returns the JSON object representing the current entity
  105235. */
  105236. serialize(): any;
  105237. }
  105238. /**
  105239. * Use this class to create coordinated animations on multiple targets
  105240. */
  105241. export class AnimationGroup implements IDisposable {
  105242. /** The name of the animation group */
  105243. name: string;
  105244. private _scene;
  105245. private _targetedAnimations;
  105246. private _animatables;
  105247. private _from;
  105248. private _to;
  105249. private _isStarted;
  105250. private _isPaused;
  105251. private _speedRatio;
  105252. private _loopAnimation;
  105253. /**
  105254. * Gets or sets the unique id of the node
  105255. */
  105256. uniqueId: number;
  105257. /**
  105258. * This observable will notify when one animation have ended
  105259. */
  105260. onAnimationEndObservable: Observable<TargetedAnimation>;
  105261. /**
  105262. * Observer raised when one animation loops
  105263. */
  105264. onAnimationLoopObservable: Observable<TargetedAnimation>;
  105265. /**
  105266. * Observer raised when all animations have looped
  105267. */
  105268. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  105269. /**
  105270. * This observable will notify when all animations have ended.
  105271. */
  105272. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  105273. /**
  105274. * This observable will notify when all animations have paused.
  105275. */
  105276. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  105277. /**
  105278. * This observable will notify when all animations are playing.
  105279. */
  105280. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  105281. /**
  105282. * Gets the first frame
  105283. */
  105284. get from(): number;
  105285. /**
  105286. * Gets the last frame
  105287. */
  105288. get to(): number;
  105289. /**
  105290. * Define if the animations are started
  105291. */
  105292. get isStarted(): boolean;
  105293. /**
  105294. * Gets a value indicating that the current group is playing
  105295. */
  105296. get isPlaying(): boolean;
  105297. /**
  105298. * Gets or sets the speed ratio to use for all animations
  105299. */
  105300. get speedRatio(): number;
  105301. /**
  105302. * Gets or sets the speed ratio to use for all animations
  105303. */
  105304. set speedRatio(value: number);
  105305. /**
  105306. * Gets or sets if all animations should loop or not
  105307. */
  105308. get loopAnimation(): boolean;
  105309. set loopAnimation(value: boolean);
  105310. /**
  105311. * Gets the targeted animations for this animation group
  105312. */
  105313. get targetedAnimations(): Array<TargetedAnimation>;
  105314. /**
  105315. * returning the list of animatables controlled by this animation group.
  105316. */
  105317. get animatables(): Array<Animatable>;
  105318. /**
  105319. * Instantiates a new Animation Group.
  105320. * This helps managing several animations at once.
  105321. * @see http://doc.babylonjs.com/how_to/group
  105322. * @param name Defines the name of the group
  105323. * @param scene Defines the scene the group belongs to
  105324. */
  105325. constructor(
  105326. /** The name of the animation group */
  105327. name: string, scene?: Nullable<Scene>);
  105328. /**
  105329. * Add an animation (with its target) in the group
  105330. * @param animation defines the animation we want to add
  105331. * @param target defines the target of the animation
  105332. * @returns the TargetedAnimation object
  105333. */
  105334. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  105335. /**
  105336. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  105337. * It can add constant keys at begin or end
  105338. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  105339. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  105340. * @returns the animation group
  105341. */
  105342. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  105343. private _animationLoopCount;
  105344. private _animationLoopFlags;
  105345. private _processLoop;
  105346. /**
  105347. * Start all animations on given targets
  105348. * @param loop defines if animations must loop
  105349. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  105350. * @param from defines the from key (optional)
  105351. * @param to defines the to key (optional)
  105352. * @returns the current animation group
  105353. */
  105354. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  105355. /**
  105356. * Pause all animations
  105357. * @returns the animation group
  105358. */
  105359. pause(): AnimationGroup;
  105360. /**
  105361. * Play all animations to initial state
  105362. * This function will start() the animations if they were not started or will restart() them if they were paused
  105363. * @param loop defines if animations must loop
  105364. * @returns the animation group
  105365. */
  105366. play(loop?: boolean): AnimationGroup;
  105367. /**
  105368. * Reset all animations to initial state
  105369. * @returns the animation group
  105370. */
  105371. reset(): AnimationGroup;
  105372. /**
  105373. * Restart animations from key 0
  105374. * @returns the animation group
  105375. */
  105376. restart(): AnimationGroup;
  105377. /**
  105378. * Stop all animations
  105379. * @returns the animation group
  105380. */
  105381. stop(): AnimationGroup;
  105382. /**
  105383. * Set animation weight for all animatables
  105384. * @param weight defines the weight to use
  105385. * @return the animationGroup
  105386. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  105387. */
  105388. setWeightForAllAnimatables(weight: number): AnimationGroup;
  105389. /**
  105390. * Synchronize and normalize all animatables with a source animatable
  105391. * @param root defines the root animatable to synchronize with
  105392. * @return the animationGroup
  105393. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  105394. */
  105395. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  105396. /**
  105397. * Goes to a specific frame in this animation group
  105398. * @param frame the frame number to go to
  105399. * @return the animationGroup
  105400. */
  105401. goToFrame(frame: number): AnimationGroup;
  105402. /**
  105403. * Dispose all associated resources
  105404. */
  105405. dispose(): void;
  105406. private _checkAnimationGroupEnded;
  105407. /**
  105408. * Clone the current animation group and returns a copy
  105409. * @param newName defines the name of the new group
  105410. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  105411. * @returns the new aniamtion group
  105412. */
  105413. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  105414. /**
  105415. * Serializes the animationGroup to an object
  105416. * @returns Serialized object
  105417. */
  105418. serialize(): any;
  105419. /**
  105420. * Returns a new AnimationGroup object parsed from the source provided.
  105421. * @param parsedAnimationGroup defines the source
  105422. * @param scene defines the scene that will receive the animationGroup
  105423. * @returns a new AnimationGroup
  105424. */
  105425. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  105426. /**
  105427. * Returns the string "AnimationGroup"
  105428. * @returns "AnimationGroup"
  105429. */
  105430. getClassName(): string;
  105431. /**
  105432. * Creates a detailled string about the object
  105433. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  105434. * @returns a string representing the object
  105435. */
  105436. toString(fullDetails?: boolean): string;
  105437. }
  105438. }
  105439. declare module BABYLON {
  105440. /**
  105441. * Define an interface for all classes that will hold resources
  105442. */
  105443. export interface IDisposable {
  105444. /**
  105445. * Releases all held resources
  105446. */
  105447. dispose(): void;
  105448. }
  105449. /** Interface defining initialization parameters for Scene class */
  105450. export interface SceneOptions {
  105451. /**
  105452. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  105453. * It will improve performance when the number of geometries becomes important.
  105454. */
  105455. useGeometryUniqueIdsMap?: boolean;
  105456. /**
  105457. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  105458. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  105459. */
  105460. useMaterialMeshMap?: boolean;
  105461. /**
  105462. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  105463. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  105464. */
  105465. useClonedMeshMap?: boolean;
  105466. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  105467. virtual?: boolean;
  105468. }
  105469. /**
  105470. * Represents a scene to be rendered by the engine.
  105471. * @see http://doc.babylonjs.com/features/scene
  105472. */
  105473. export class Scene extends AbstractScene implements IAnimatable {
  105474. /** The fog is deactivated */
  105475. static readonly FOGMODE_NONE: number;
  105476. /** The fog density is following an exponential function */
  105477. static readonly FOGMODE_EXP: number;
  105478. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  105479. static readonly FOGMODE_EXP2: number;
  105480. /** The fog density is following a linear function. */
  105481. static readonly FOGMODE_LINEAR: number;
  105482. /**
  105483. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  105484. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105485. */
  105486. static MinDeltaTime: number;
  105487. /**
  105488. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  105489. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105490. */
  105491. static MaxDeltaTime: number;
  105492. /**
  105493. * Factory used to create the default material.
  105494. * @param name The name of the material to create
  105495. * @param scene The scene to create the material for
  105496. * @returns The default material
  105497. */
  105498. static DefaultMaterialFactory(scene: Scene): Material;
  105499. /**
  105500. * Factory used to create the a collision coordinator.
  105501. * @returns The collision coordinator
  105502. */
  105503. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  105504. /** @hidden */
  105505. _inputManager: InputManager;
  105506. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  105507. cameraToUseForPointers: Nullable<Camera>;
  105508. /** @hidden */
  105509. readonly _isScene: boolean;
  105510. /**
  105511. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  105512. */
  105513. autoClear: boolean;
  105514. /**
  105515. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  105516. */
  105517. autoClearDepthAndStencil: boolean;
  105518. /**
  105519. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  105520. */
  105521. clearColor: Color4;
  105522. /**
  105523. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  105524. */
  105525. ambientColor: Color3;
  105526. /**
  105527. * This is use to store the default BRDF lookup for PBR materials in your scene.
  105528. * It should only be one of the following (if not the default embedded one):
  105529. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  105530. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  105531. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  105532. * The material properties need to be setup according to the type of texture in use.
  105533. */
  105534. environmentBRDFTexture: BaseTexture;
  105535. /** @hidden */
  105536. protected _environmentTexture: Nullable<BaseTexture>;
  105537. /**
  105538. * Texture used in all pbr material as the reflection texture.
  105539. * As in the majority of the scene they are the same (exception for multi room and so on),
  105540. * this is easier to reference from here than from all the materials.
  105541. */
  105542. get environmentTexture(): Nullable<BaseTexture>;
  105543. /**
  105544. * Texture used in all pbr material as the reflection texture.
  105545. * As in the majority of the scene they are the same (exception for multi room and so on),
  105546. * this is easier to set here than in all the materials.
  105547. */
  105548. set environmentTexture(value: Nullable<BaseTexture>);
  105549. /** @hidden */
  105550. protected _environmentIntensity: number;
  105551. /**
  105552. * Intensity of the environment in all pbr material.
  105553. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  105554. * As in the majority of the scene they are the same (exception for multi room and so on),
  105555. * this is easier to reference from here than from all the materials.
  105556. */
  105557. get environmentIntensity(): number;
  105558. /**
  105559. * Intensity of the environment in all pbr material.
  105560. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  105561. * As in the majority of the scene they are the same (exception for multi room and so on),
  105562. * this is easier to set here than in all the materials.
  105563. */
  105564. set environmentIntensity(value: number);
  105565. /** @hidden */
  105566. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105567. /**
  105568. * Default image processing configuration used either in the rendering
  105569. * Forward main pass or through the imageProcessingPostProcess if present.
  105570. * As in the majority of the scene they are the same (exception for multi camera),
  105571. * this is easier to reference from here than from all the materials and post process.
  105572. *
  105573. * No setter as we it is a shared configuration, you can set the values instead.
  105574. */
  105575. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  105576. private _forceWireframe;
  105577. /**
  105578. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  105579. */
  105580. set forceWireframe(value: boolean);
  105581. get forceWireframe(): boolean;
  105582. private _skipFrustumClipping;
  105583. /**
  105584. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  105585. */
  105586. set skipFrustumClipping(value: boolean);
  105587. get skipFrustumClipping(): boolean;
  105588. private _forcePointsCloud;
  105589. /**
  105590. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  105591. */
  105592. set forcePointsCloud(value: boolean);
  105593. get forcePointsCloud(): boolean;
  105594. /**
  105595. * Gets or sets the active clipplane 1
  105596. */
  105597. clipPlane: Nullable<Plane>;
  105598. /**
  105599. * Gets or sets the active clipplane 2
  105600. */
  105601. clipPlane2: Nullable<Plane>;
  105602. /**
  105603. * Gets or sets the active clipplane 3
  105604. */
  105605. clipPlane3: Nullable<Plane>;
  105606. /**
  105607. * Gets or sets the active clipplane 4
  105608. */
  105609. clipPlane4: Nullable<Plane>;
  105610. /**
  105611. * Gets or sets the active clipplane 5
  105612. */
  105613. clipPlane5: Nullable<Plane>;
  105614. /**
  105615. * Gets or sets the active clipplane 6
  105616. */
  105617. clipPlane6: Nullable<Plane>;
  105618. /**
  105619. * Gets or sets a boolean indicating if animations are enabled
  105620. */
  105621. animationsEnabled: boolean;
  105622. private _animationPropertiesOverride;
  105623. /**
  105624. * Gets or sets the animation properties override
  105625. */
  105626. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  105627. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  105628. /**
  105629. * Gets or sets a boolean indicating if a constant deltatime has to be used
  105630. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  105631. */
  105632. useConstantAnimationDeltaTime: boolean;
  105633. /**
  105634. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  105635. * Please note that it requires to run a ray cast through the scene on every frame
  105636. */
  105637. constantlyUpdateMeshUnderPointer: boolean;
  105638. /**
  105639. * Defines the HTML cursor to use when hovering over interactive elements
  105640. */
  105641. hoverCursor: string;
  105642. /**
  105643. * Defines the HTML default cursor to use (empty by default)
  105644. */
  105645. defaultCursor: string;
  105646. /**
  105647. * Defines wether cursors are handled by the scene.
  105648. */
  105649. doNotHandleCursors: boolean;
  105650. /**
  105651. * This is used to call preventDefault() on pointer down
  105652. * in order to block unwanted artifacts like system double clicks
  105653. */
  105654. preventDefaultOnPointerDown: boolean;
  105655. /**
  105656. * This is used to call preventDefault() on pointer up
  105657. * in order to block unwanted artifacts like system double clicks
  105658. */
  105659. preventDefaultOnPointerUp: boolean;
  105660. /**
  105661. * Gets or sets user defined metadata
  105662. */
  105663. metadata: any;
  105664. /**
  105665. * For internal use only. Please do not use.
  105666. */
  105667. reservedDataStore: any;
  105668. /**
  105669. * Gets the name of the plugin used to load this scene (null by default)
  105670. */
  105671. loadingPluginName: string;
  105672. /**
  105673. * Use this array to add regular expressions used to disable offline support for specific urls
  105674. */
  105675. disableOfflineSupportExceptionRules: RegExp[];
  105676. /**
  105677. * An event triggered when the scene is disposed.
  105678. */
  105679. onDisposeObservable: Observable<Scene>;
  105680. private _onDisposeObserver;
  105681. /** Sets a function to be executed when this scene is disposed. */
  105682. set onDispose(callback: () => void);
  105683. /**
  105684. * An event triggered before rendering the scene (right after animations and physics)
  105685. */
  105686. onBeforeRenderObservable: Observable<Scene>;
  105687. private _onBeforeRenderObserver;
  105688. /** Sets a function to be executed before rendering this scene */
  105689. set beforeRender(callback: Nullable<() => void>);
  105690. /**
  105691. * An event triggered after rendering the scene
  105692. */
  105693. onAfterRenderObservable: Observable<Scene>;
  105694. /**
  105695. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  105696. */
  105697. onAfterRenderCameraObservable: Observable<Camera>;
  105698. private _onAfterRenderObserver;
  105699. /** Sets a function to be executed after rendering this scene */
  105700. set afterRender(callback: Nullable<() => void>);
  105701. /**
  105702. * An event triggered before animating the scene
  105703. */
  105704. onBeforeAnimationsObservable: Observable<Scene>;
  105705. /**
  105706. * An event triggered after animations processing
  105707. */
  105708. onAfterAnimationsObservable: Observable<Scene>;
  105709. /**
  105710. * An event triggered before draw calls are ready to be sent
  105711. */
  105712. onBeforeDrawPhaseObservable: Observable<Scene>;
  105713. /**
  105714. * An event triggered after draw calls have been sent
  105715. */
  105716. onAfterDrawPhaseObservable: Observable<Scene>;
  105717. /**
  105718. * An event triggered when the scene is ready
  105719. */
  105720. onReadyObservable: Observable<Scene>;
  105721. /**
  105722. * An event triggered before rendering a camera
  105723. */
  105724. onBeforeCameraRenderObservable: Observable<Camera>;
  105725. private _onBeforeCameraRenderObserver;
  105726. /** Sets a function to be executed before rendering a camera*/
  105727. set beforeCameraRender(callback: () => void);
  105728. /**
  105729. * An event triggered after rendering a camera
  105730. */
  105731. onAfterCameraRenderObservable: Observable<Camera>;
  105732. private _onAfterCameraRenderObserver;
  105733. /** Sets a function to be executed after rendering a camera*/
  105734. set afterCameraRender(callback: () => void);
  105735. /**
  105736. * An event triggered when active meshes evaluation is about to start
  105737. */
  105738. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  105739. /**
  105740. * An event triggered when active meshes evaluation is done
  105741. */
  105742. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  105743. /**
  105744. * An event triggered when particles rendering is about to start
  105745. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  105746. */
  105747. onBeforeParticlesRenderingObservable: Observable<Scene>;
  105748. /**
  105749. * An event triggered when particles rendering is done
  105750. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  105751. */
  105752. onAfterParticlesRenderingObservable: Observable<Scene>;
  105753. /**
  105754. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  105755. */
  105756. onDataLoadedObservable: Observable<Scene>;
  105757. /**
  105758. * An event triggered when a camera is created
  105759. */
  105760. onNewCameraAddedObservable: Observable<Camera>;
  105761. /**
  105762. * An event triggered when a camera is removed
  105763. */
  105764. onCameraRemovedObservable: Observable<Camera>;
  105765. /**
  105766. * An event triggered when a light is created
  105767. */
  105768. onNewLightAddedObservable: Observable<Light>;
  105769. /**
  105770. * An event triggered when a light is removed
  105771. */
  105772. onLightRemovedObservable: Observable<Light>;
  105773. /**
  105774. * An event triggered when a geometry is created
  105775. */
  105776. onNewGeometryAddedObservable: Observable<Geometry>;
  105777. /**
  105778. * An event triggered when a geometry is removed
  105779. */
  105780. onGeometryRemovedObservable: Observable<Geometry>;
  105781. /**
  105782. * An event triggered when a transform node is created
  105783. */
  105784. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  105785. /**
  105786. * An event triggered when a transform node is removed
  105787. */
  105788. onTransformNodeRemovedObservable: Observable<TransformNode>;
  105789. /**
  105790. * An event triggered when a mesh is created
  105791. */
  105792. onNewMeshAddedObservable: Observable<AbstractMesh>;
  105793. /**
  105794. * An event triggered when a mesh is removed
  105795. */
  105796. onMeshRemovedObservable: Observable<AbstractMesh>;
  105797. /**
  105798. * An event triggered when a skeleton is created
  105799. */
  105800. onNewSkeletonAddedObservable: Observable<Skeleton>;
  105801. /**
  105802. * An event triggered when a skeleton is removed
  105803. */
  105804. onSkeletonRemovedObservable: Observable<Skeleton>;
  105805. /**
  105806. * An event triggered when a material is created
  105807. */
  105808. onNewMaterialAddedObservable: Observable<Material>;
  105809. /**
  105810. * An event triggered when a material is removed
  105811. */
  105812. onMaterialRemovedObservable: Observable<Material>;
  105813. /**
  105814. * An event triggered when a texture is created
  105815. */
  105816. onNewTextureAddedObservable: Observable<BaseTexture>;
  105817. /**
  105818. * An event triggered when a texture is removed
  105819. */
  105820. onTextureRemovedObservable: Observable<BaseTexture>;
  105821. /**
  105822. * An event triggered when render targets are about to be rendered
  105823. * Can happen multiple times per frame.
  105824. */
  105825. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  105826. /**
  105827. * An event triggered when render targets were rendered.
  105828. * Can happen multiple times per frame.
  105829. */
  105830. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  105831. /**
  105832. * An event triggered before calculating deterministic simulation step
  105833. */
  105834. onBeforeStepObservable: Observable<Scene>;
  105835. /**
  105836. * An event triggered after calculating deterministic simulation step
  105837. */
  105838. onAfterStepObservable: Observable<Scene>;
  105839. /**
  105840. * An event triggered when the activeCamera property is updated
  105841. */
  105842. onActiveCameraChanged: Observable<Scene>;
  105843. /**
  105844. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  105845. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  105846. * 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)
  105847. */
  105848. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  105849. /**
  105850. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  105851. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  105852. * 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)
  105853. */
  105854. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  105855. /**
  105856. * This Observable will when a mesh has been imported into the scene.
  105857. */
  105858. onMeshImportedObservable: Observable<AbstractMesh>;
  105859. /**
  105860. * This Observable will when an animation file has been imported into the scene.
  105861. */
  105862. onAnimationFileImportedObservable: Observable<Scene>;
  105863. /**
  105864. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  105865. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  105866. */
  105867. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  105868. /** @hidden */
  105869. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  105870. /**
  105871. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  105872. */
  105873. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  105874. /**
  105875. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  105876. */
  105877. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  105878. /**
  105879. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  105880. */
  105881. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  105882. /** Callback called when a pointer move is detected */
  105883. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  105884. /** Callback called when a pointer down is detected */
  105885. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  105886. /** Callback called when a pointer up is detected */
  105887. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  105888. /** Callback called when a pointer pick is detected */
  105889. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  105890. /**
  105891. * 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).
  105892. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  105893. */
  105894. onPrePointerObservable: Observable<PointerInfoPre>;
  105895. /**
  105896. * Observable event triggered each time an input event is received from the rendering canvas
  105897. */
  105898. onPointerObservable: Observable<PointerInfo>;
  105899. /**
  105900. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  105901. */
  105902. get unTranslatedPointer(): Vector2;
  105903. /**
  105904. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  105905. */
  105906. static get DragMovementThreshold(): number;
  105907. static set DragMovementThreshold(value: number);
  105908. /**
  105909. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  105910. */
  105911. static get LongPressDelay(): number;
  105912. static set LongPressDelay(value: number);
  105913. /**
  105914. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  105915. */
  105916. static get DoubleClickDelay(): number;
  105917. static set DoubleClickDelay(value: number);
  105918. /** If you need to check double click without raising a single click at first click, enable this flag */
  105919. static get ExclusiveDoubleClickMode(): boolean;
  105920. static set ExclusiveDoubleClickMode(value: boolean);
  105921. /** @hidden */
  105922. _mirroredCameraPosition: Nullable<Vector3>;
  105923. /**
  105924. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  105925. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  105926. */
  105927. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  105928. /**
  105929. * Observable event triggered each time an keyboard event is received from the hosting window
  105930. */
  105931. onKeyboardObservable: Observable<KeyboardInfo>;
  105932. private _useRightHandedSystem;
  105933. /**
  105934. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  105935. */
  105936. set useRightHandedSystem(value: boolean);
  105937. get useRightHandedSystem(): boolean;
  105938. private _timeAccumulator;
  105939. private _currentStepId;
  105940. private _currentInternalStep;
  105941. /**
  105942. * Sets the step Id used by deterministic lock step
  105943. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105944. * @param newStepId defines the step Id
  105945. */
  105946. setStepId(newStepId: number): void;
  105947. /**
  105948. * Gets the step Id used by deterministic lock step
  105949. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105950. * @returns the step Id
  105951. */
  105952. getStepId(): number;
  105953. /**
  105954. * Gets the internal step used by deterministic lock step
  105955. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105956. * @returns the internal step
  105957. */
  105958. getInternalStep(): number;
  105959. private _fogEnabled;
  105960. /**
  105961. * Gets or sets a boolean indicating if fog is enabled on this scene
  105962. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105963. * (Default is true)
  105964. */
  105965. set fogEnabled(value: boolean);
  105966. get fogEnabled(): boolean;
  105967. private _fogMode;
  105968. /**
  105969. * Gets or sets the fog mode to use
  105970. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105971. * | mode | value |
  105972. * | --- | --- |
  105973. * | FOGMODE_NONE | 0 |
  105974. * | FOGMODE_EXP | 1 |
  105975. * | FOGMODE_EXP2 | 2 |
  105976. * | FOGMODE_LINEAR | 3 |
  105977. */
  105978. set fogMode(value: number);
  105979. get fogMode(): number;
  105980. /**
  105981. * Gets or sets the fog color to use
  105982. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105983. * (Default is Color3(0.2, 0.2, 0.3))
  105984. */
  105985. fogColor: Color3;
  105986. /**
  105987. * Gets or sets the fog density to use
  105988. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105989. * (Default is 0.1)
  105990. */
  105991. fogDensity: number;
  105992. /**
  105993. * Gets or sets the fog start distance to use
  105994. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105995. * (Default is 0)
  105996. */
  105997. fogStart: number;
  105998. /**
  105999. * Gets or sets the fog end distance to use
  106000. * @see http://doc.babylonjs.com/babylon101/environment#fog
  106001. * (Default is 1000)
  106002. */
  106003. fogEnd: number;
  106004. private _shadowsEnabled;
  106005. /**
  106006. * Gets or sets a boolean indicating if shadows are enabled on this scene
  106007. */
  106008. set shadowsEnabled(value: boolean);
  106009. get shadowsEnabled(): boolean;
  106010. private _lightsEnabled;
  106011. /**
  106012. * Gets or sets a boolean indicating if lights are enabled on this scene
  106013. */
  106014. set lightsEnabled(value: boolean);
  106015. get lightsEnabled(): boolean;
  106016. /** All of the active cameras added to this scene. */
  106017. activeCameras: Camera[];
  106018. /** @hidden */
  106019. _activeCamera: Nullable<Camera>;
  106020. /** Gets or sets the current active camera */
  106021. get activeCamera(): Nullable<Camera>;
  106022. set activeCamera(value: Nullable<Camera>);
  106023. private _defaultMaterial;
  106024. /** The default material used on meshes when no material is affected */
  106025. get defaultMaterial(): Material;
  106026. /** The default material used on meshes when no material is affected */
  106027. set defaultMaterial(value: Material);
  106028. private _texturesEnabled;
  106029. /**
  106030. * Gets or sets a boolean indicating if textures are enabled on this scene
  106031. */
  106032. set texturesEnabled(value: boolean);
  106033. get texturesEnabled(): boolean;
  106034. /**
  106035. * Gets or sets a boolean indicating if particles are enabled on this scene
  106036. */
  106037. particlesEnabled: boolean;
  106038. /**
  106039. * Gets or sets a boolean indicating if sprites are enabled on this scene
  106040. */
  106041. spritesEnabled: boolean;
  106042. private _skeletonsEnabled;
  106043. /**
  106044. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  106045. */
  106046. set skeletonsEnabled(value: boolean);
  106047. get skeletonsEnabled(): boolean;
  106048. /**
  106049. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  106050. */
  106051. lensFlaresEnabled: boolean;
  106052. /**
  106053. * Gets or sets a boolean indicating if collisions are enabled on this scene
  106054. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  106055. */
  106056. collisionsEnabled: boolean;
  106057. private _collisionCoordinator;
  106058. /** @hidden */
  106059. get collisionCoordinator(): ICollisionCoordinator;
  106060. /**
  106061. * Defines the gravity applied to this scene (used only for collisions)
  106062. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  106063. */
  106064. gravity: Vector3;
  106065. /**
  106066. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  106067. */
  106068. postProcessesEnabled: boolean;
  106069. /**
  106070. * The list of postprocesses added to the scene
  106071. */
  106072. postProcesses: PostProcess[];
  106073. /**
  106074. * Gets the current postprocess manager
  106075. */
  106076. postProcessManager: PostProcessManager;
  106077. /**
  106078. * Gets or sets a boolean indicating if render targets are enabled on this scene
  106079. */
  106080. renderTargetsEnabled: boolean;
  106081. /**
  106082. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  106083. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  106084. */
  106085. dumpNextRenderTargets: boolean;
  106086. /**
  106087. * The list of user defined render targets added to the scene
  106088. */
  106089. customRenderTargets: RenderTargetTexture[];
  106090. /**
  106091. * Defines if texture loading must be delayed
  106092. * If true, textures will only be loaded when they need to be rendered
  106093. */
  106094. useDelayedTextureLoading: boolean;
  106095. /**
  106096. * Gets the list of meshes imported to the scene through SceneLoader
  106097. */
  106098. importedMeshesFiles: String[];
  106099. /**
  106100. * Gets or sets a boolean indicating if probes are enabled on this scene
  106101. */
  106102. probesEnabled: boolean;
  106103. /**
  106104. * Gets or sets the current offline provider to use to store scene data
  106105. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  106106. */
  106107. offlineProvider: IOfflineProvider;
  106108. /**
  106109. * Gets or sets the action manager associated with the scene
  106110. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  106111. */
  106112. actionManager: AbstractActionManager;
  106113. private _meshesForIntersections;
  106114. /**
  106115. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  106116. */
  106117. proceduralTexturesEnabled: boolean;
  106118. private _engine;
  106119. private _totalVertices;
  106120. /** @hidden */
  106121. _activeIndices: PerfCounter;
  106122. /** @hidden */
  106123. _activeParticles: PerfCounter;
  106124. /** @hidden */
  106125. _activeBones: PerfCounter;
  106126. private _animationRatio;
  106127. /** @hidden */
  106128. _animationTimeLast: number;
  106129. /** @hidden */
  106130. _animationTime: number;
  106131. /**
  106132. * Gets or sets a general scale for animation speed
  106133. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  106134. */
  106135. animationTimeScale: number;
  106136. /** @hidden */
  106137. _cachedMaterial: Nullable<Material>;
  106138. /** @hidden */
  106139. _cachedEffect: Nullable<Effect>;
  106140. /** @hidden */
  106141. _cachedVisibility: Nullable<number>;
  106142. private _renderId;
  106143. private _frameId;
  106144. private _executeWhenReadyTimeoutId;
  106145. private _intermediateRendering;
  106146. private _viewUpdateFlag;
  106147. private _projectionUpdateFlag;
  106148. /** @hidden */
  106149. _toBeDisposed: Nullable<IDisposable>[];
  106150. private _activeRequests;
  106151. /** @hidden */
  106152. _pendingData: any[];
  106153. private _isDisposed;
  106154. /**
  106155. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  106156. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  106157. */
  106158. dispatchAllSubMeshesOfActiveMeshes: boolean;
  106159. private _activeMeshes;
  106160. private _processedMaterials;
  106161. private _renderTargets;
  106162. /** @hidden */
  106163. _activeParticleSystems: SmartArray<IParticleSystem>;
  106164. private _activeSkeletons;
  106165. private _softwareSkinnedMeshes;
  106166. private _renderingManager;
  106167. /** @hidden */
  106168. _activeAnimatables: Animatable[];
  106169. private _transformMatrix;
  106170. private _sceneUbo;
  106171. /** @hidden */
  106172. _viewMatrix: Matrix;
  106173. private _projectionMatrix;
  106174. /** @hidden */
  106175. _forcedViewPosition: Nullable<Vector3>;
  106176. /** @hidden */
  106177. _frustumPlanes: Plane[];
  106178. /**
  106179. * Gets the list of frustum planes (built from the active camera)
  106180. */
  106181. get frustumPlanes(): Plane[];
  106182. /**
  106183. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  106184. * This is useful if there are more lights that the maximum simulteanous authorized
  106185. */
  106186. requireLightSorting: boolean;
  106187. /** @hidden */
  106188. readonly useMaterialMeshMap: boolean;
  106189. /** @hidden */
  106190. readonly useClonedMeshMap: boolean;
  106191. private _externalData;
  106192. private _uid;
  106193. /**
  106194. * @hidden
  106195. * Backing store of defined scene components.
  106196. */
  106197. _components: ISceneComponent[];
  106198. /**
  106199. * @hidden
  106200. * Backing store of defined scene components.
  106201. */
  106202. _serializableComponents: ISceneSerializableComponent[];
  106203. /**
  106204. * List of components to register on the next registration step.
  106205. */
  106206. private _transientComponents;
  106207. /**
  106208. * Registers the transient components if needed.
  106209. */
  106210. private _registerTransientComponents;
  106211. /**
  106212. * @hidden
  106213. * Add a component to the scene.
  106214. * Note that the ccomponent could be registered on th next frame if this is called after
  106215. * the register component stage.
  106216. * @param component Defines the component to add to the scene
  106217. */
  106218. _addComponent(component: ISceneComponent): void;
  106219. /**
  106220. * @hidden
  106221. * Gets a component from the scene.
  106222. * @param name defines the name of the component to retrieve
  106223. * @returns the component or null if not present
  106224. */
  106225. _getComponent(name: string): Nullable<ISceneComponent>;
  106226. /**
  106227. * @hidden
  106228. * Defines the actions happening before camera updates.
  106229. */
  106230. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  106231. /**
  106232. * @hidden
  106233. * Defines the actions happening before clear the canvas.
  106234. */
  106235. _beforeClearStage: Stage<SimpleStageAction>;
  106236. /**
  106237. * @hidden
  106238. * Defines the actions when collecting render targets for the frame.
  106239. */
  106240. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  106241. /**
  106242. * @hidden
  106243. * Defines the actions happening for one camera in the frame.
  106244. */
  106245. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  106246. /**
  106247. * @hidden
  106248. * Defines the actions happening during the per mesh ready checks.
  106249. */
  106250. _isReadyForMeshStage: Stage<MeshStageAction>;
  106251. /**
  106252. * @hidden
  106253. * Defines the actions happening before evaluate active mesh checks.
  106254. */
  106255. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  106256. /**
  106257. * @hidden
  106258. * Defines the actions happening during the evaluate sub mesh checks.
  106259. */
  106260. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  106261. /**
  106262. * @hidden
  106263. * Defines the actions happening during the active mesh stage.
  106264. */
  106265. _activeMeshStage: Stage<ActiveMeshStageAction>;
  106266. /**
  106267. * @hidden
  106268. * Defines the actions happening during the per camera render target step.
  106269. */
  106270. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  106271. /**
  106272. * @hidden
  106273. * Defines the actions happening just before the active camera is drawing.
  106274. */
  106275. _beforeCameraDrawStage: Stage<CameraStageAction>;
  106276. /**
  106277. * @hidden
  106278. * Defines the actions happening just before a render target is drawing.
  106279. */
  106280. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  106281. /**
  106282. * @hidden
  106283. * Defines the actions happening just before a rendering group is drawing.
  106284. */
  106285. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  106286. /**
  106287. * @hidden
  106288. * Defines the actions happening just before a mesh is drawing.
  106289. */
  106290. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  106291. /**
  106292. * @hidden
  106293. * Defines the actions happening just after a mesh has been drawn.
  106294. */
  106295. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  106296. /**
  106297. * @hidden
  106298. * Defines the actions happening just after a rendering group has been drawn.
  106299. */
  106300. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  106301. /**
  106302. * @hidden
  106303. * Defines the actions happening just after the active camera has been drawn.
  106304. */
  106305. _afterCameraDrawStage: Stage<CameraStageAction>;
  106306. /**
  106307. * @hidden
  106308. * Defines the actions happening just after a render target has been drawn.
  106309. */
  106310. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  106311. /**
  106312. * @hidden
  106313. * Defines the actions happening just after rendering all cameras and computing intersections.
  106314. */
  106315. _afterRenderStage: Stage<SimpleStageAction>;
  106316. /**
  106317. * @hidden
  106318. * Defines the actions happening when a pointer move event happens.
  106319. */
  106320. _pointerMoveStage: Stage<PointerMoveStageAction>;
  106321. /**
  106322. * @hidden
  106323. * Defines the actions happening when a pointer down event happens.
  106324. */
  106325. _pointerDownStage: Stage<PointerUpDownStageAction>;
  106326. /**
  106327. * @hidden
  106328. * Defines the actions happening when a pointer up event happens.
  106329. */
  106330. _pointerUpStage: Stage<PointerUpDownStageAction>;
  106331. /**
  106332. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  106333. */
  106334. private geometriesByUniqueId;
  106335. /**
  106336. * Creates a new Scene
  106337. * @param engine defines the engine to use to render this scene
  106338. * @param options defines the scene options
  106339. */
  106340. constructor(engine: Engine, options?: SceneOptions);
  106341. /**
  106342. * Gets a string idenfifying the name of the class
  106343. * @returns "Scene" string
  106344. */
  106345. getClassName(): string;
  106346. private _defaultMeshCandidates;
  106347. /**
  106348. * @hidden
  106349. */
  106350. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  106351. private _defaultSubMeshCandidates;
  106352. /**
  106353. * @hidden
  106354. */
  106355. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  106356. /**
  106357. * Sets the default candidate providers for the scene.
  106358. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  106359. * and getCollidingSubMeshCandidates to their default function
  106360. */
  106361. setDefaultCandidateProviders(): void;
  106362. /**
  106363. * Gets the mesh that is currently under the pointer
  106364. */
  106365. get meshUnderPointer(): Nullable<AbstractMesh>;
  106366. /**
  106367. * Gets or sets the current on-screen X position of the pointer
  106368. */
  106369. get pointerX(): number;
  106370. set pointerX(value: number);
  106371. /**
  106372. * Gets or sets the current on-screen Y position of the pointer
  106373. */
  106374. get pointerY(): number;
  106375. set pointerY(value: number);
  106376. /**
  106377. * Gets the cached material (ie. the latest rendered one)
  106378. * @returns the cached material
  106379. */
  106380. getCachedMaterial(): Nullable<Material>;
  106381. /**
  106382. * Gets the cached effect (ie. the latest rendered one)
  106383. * @returns the cached effect
  106384. */
  106385. getCachedEffect(): Nullable<Effect>;
  106386. /**
  106387. * Gets the cached visibility state (ie. the latest rendered one)
  106388. * @returns the cached visibility state
  106389. */
  106390. getCachedVisibility(): Nullable<number>;
  106391. /**
  106392. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  106393. * @param material defines the current material
  106394. * @param effect defines the current effect
  106395. * @param visibility defines the current visibility state
  106396. * @returns true if one parameter is not cached
  106397. */
  106398. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  106399. /**
  106400. * Gets the engine associated with the scene
  106401. * @returns an Engine
  106402. */
  106403. getEngine(): Engine;
  106404. /**
  106405. * Gets the total number of vertices rendered per frame
  106406. * @returns the total number of vertices rendered per frame
  106407. */
  106408. getTotalVertices(): number;
  106409. /**
  106410. * Gets the performance counter for total vertices
  106411. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  106412. */
  106413. get totalVerticesPerfCounter(): PerfCounter;
  106414. /**
  106415. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  106416. * @returns the total number of active indices rendered per frame
  106417. */
  106418. getActiveIndices(): number;
  106419. /**
  106420. * Gets the performance counter for active indices
  106421. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  106422. */
  106423. get totalActiveIndicesPerfCounter(): PerfCounter;
  106424. /**
  106425. * Gets the total number of active particles rendered per frame
  106426. * @returns the total number of active particles rendered per frame
  106427. */
  106428. getActiveParticles(): number;
  106429. /**
  106430. * Gets the performance counter for active particles
  106431. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  106432. */
  106433. get activeParticlesPerfCounter(): PerfCounter;
  106434. /**
  106435. * Gets the total number of active bones rendered per frame
  106436. * @returns the total number of active bones rendered per frame
  106437. */
  106438. getActiveBones(): number;
  106439. /**
  106440. * Gets the performance counter for active bones
  106441. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  106442. */
  106443. get activeBonesPerfCounter(): PerfCounter;
  106444. /**
  106445. * Gets the array of active meshes
  106446. * @returns an array of AbstractMesh
  106447. */
  106448. getActiveMeshes(): SmartArray<AbstractMesh>;
  106449. /**
  106450. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  106451. * @returns a number
  106452. */
  106453. getAnimationRatio(): number;
  106454. /**
  106455. * Gets an unique Id for the current render phase
  106456. * @returns a number
  106457. */
  106458. getRenderId(): number;
  106459. /**
  106460. * Gets an unique Id for the current frame
  106461. * @returns a number
  106462. */
  106463. getFrameId(): number;
  106464. /** Call this function if you want to manually increment the render Id*/
  106465. incrementRenderId(): void;
  106466. private _createUbo;
  106467. /**
  106468. * Use this method to simulate a pointer move on a mesh
  106469. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  106470. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  106471. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  106472. * @returns the current scene
  106473. */
  106474. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  106475. /**
  106476. * Use this method to simulate a pointer down on a mesh
  106477. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  106478. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  106479. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  106480. * @returns the current scene
  106481. */
  106482. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  106483. /**
  106484. * Use this method to simulate a pointer up on a mesh
  106485. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  106486. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  106487. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  106488. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  106489. * @returns the current scene
  106490. */
  106491. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  106492. /**
  106493. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  106494. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  106495. * @returns true if the pointer was captured
  106496. */
  106497. isPointerCaptured(pointerId?: number): boolean;
  106498. /**
  106499. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  106500. * @param attachUp defines if you want to attach events to pointerup
  106501. * @param attachDown defines if you want to attach events to pointerdown
  106502. * @param attachMove defines if you want to attach events to pointermove
  106503. */
  106504. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  106505. /** Detaches all event handlers*/
  106506. detachControl(): void;
  106507. /**
  106508. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  106509. * Delay loaded resources are not taking in account
  106510. * @return true if all required resources are ready
  106511. */
  106512. isReady(): boolean;
  106513. /** Resets all cached information relative to material (including effect and visibility) */
  106514. resetCachedMaterial(): void;
  106515. /**
  106516. * Registers a function to be called before every frame render
  106517. * @param func defines the function to register
  106518. */
  106519. registerBeforeRender(func: () => void): void;
  106520. /**
  106521. * Unregisters a function called before every frame render
  106522. * @param func defines the function to unregister
  106523. */
  106524. unregisterBeforeRender(func: () => void): void;
  106525. /**
  106526. * Registers a function to be called after every frame render
  106527. * @param func defines the function to register
  106528. */
  106529. registerAfterRender(func: () => void): void;
  106530. /**
  106531. * Unregisters a function called after every frame render
  106532. * @param func defines the function to unregister
  106533. */
  106534. unregisterAfterRender(func: () => void): void;
  106535. private _executeOnceBeforeRender;
  106536. /**
  106537. * The provided function will run before render once and will be disposed afterwards.
  106538. * A timeout delay can be provided so that the function will be executed in N ms.
  106539. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  106540. * @param func The function to be executed.
  106541. * @param timeout optional delay in ms
  106542. */
  106543. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  106544. /** @hidden */
  106545. _addPendingData(data: any): void;
  106546. /** @hidden */
  106547. _removePendingData(data: any): void;
  106548. /**
  106549. * Returns the number of items waiting to be loaded
  106550. * @returns the number of items waiting to be loaded
  106551. */
  106552. getWaitingItemsCount(): number;
  106553. /**
  106554. * Returns a boolean indicating if the scene is still loading data
  106555. */
  106556. get isLoading(): boolean;
  106557. /**
  106558. * Registers a function to be executed when the scene is ready
  106559. * @param {Function} func - the function to be executed
  106560. */
  106561. executeWhenReady(func: () => void): void;
  106562. /**
  106563. * Returns a promise that resolves when the scene is ready
  106564. * @returns A promise that resolves when the scene is ready
  106565. */
  106566. whenReadyAsync(): Promise<void>;
  106567. /** @hidden */
  106568. _checkIsReady(): void;
  106569. /**
  106570. * Gets all animatable attached to the scene
  106571. */
  106572. get animatables(): Animatable[];
  106573. /**
  106574. * Resets the last animation time frame.
  106575. * Useful to override when animations start running when loading a scene for the first time.
  106576. */
  106577. resetLastAnimationTimeFrame(): void;
  106578. /**
  106579. * Gets the current view matrix
  106580. * @returns a Matrix
  106581. */
  106582. getViewMatrix(): Matrix;
  106583. /**
  106584. * Gets the current projection matrix
  106585. * @returns a Matrix
  106586. */
  106587. getProjectionMatrix(): Matrix;
  106588. /**
  106589. * Gets the current transform matrix
  106590. * @returns a Matrix made of View * Projection
  106591. */
  106592. getTransformMatrix(): Matrix;
  106593. /**
  106594. * Sets the current transform matrix
  106595. * @param viewL defines the View matrix to use
  106596. * @param projectionL defines the Projection matrix to use
  106597. * @param viewR defines the right View matrix to use (if provided)
  106598. * @param projectionR defines the right Projection matrix to use (if provided)
  106599. */
  106600. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  106601. /**
  106602. * Gets the uniform buffer used to store scene data
  106603. * @returns a UniformBuffer
  106604. */
  106605. getSceneUniformBuffer(): UniformBuffer;
  106606. /**
  106607. * Gets an unique (relatively to the current scene) Id
  106608. * @returns an unique number for the scene
  106609. */
  106610. getUniqueId(): number;
  106611. /**
  106612. * Add a mesh to the list of scene's meshes
  106613. * @param newMesh defines the mesh to add
  106614. * @param recursive if all child meshes should also be added to the scene
  106615. */
  106616. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  106617. /**
  106618. * Remove a mesh for the list of scene's meshes
  106619. * @param toRemove defines the mesh to remove
  106620. * @param recursive if all child meshes should also be removed from the scene
  106621. * @returns the index where the mesh was in the mesh list
  106622. */
  106623. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  106624. /**
  106625. * Add a transform node to the list of scene's transform nodes
  106626. * @param newTransformNode defines the transform node to add
  106627. */
  106628. addTransformNode(newTransformNode: TransformNode): void;
  106629. /**
  106630. * Remove a transform node for the list of scene's transform nodes
  106631. * @param toRemove defines the transform node to remove
  106632. * @returns the index where the transform node was in the transform node list
  106633. */
  106634. removeTransformNode(toRemove: TransformNode): number;
  106635. /**
  106636. * Remove a skeleton for the list of scene's skeletons
  106637. * @param toRemove defines the skeleton to remove
  106638. * @returns the index where the skeleton was in the skeleton list
  106639. */
  106640. removeSkeleton(toRemove: Skeleton): number;
  106641. /**
  106642. * Remove a morph target for the list of scene's morph targets
  106643. * @param toRemove defines the morph target to remove
  106644. * @returns the index where the morph target was in the morph target list
  106645. */
  106646. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  106647. /**
  106648. * Remove a light for the list of scene's lights
  106649. * @param toRemove defines the light to remove
  106650. * @returns the index where the light was in the light list
  106651. */
  106652. removeLight(toRemove: Light): number;
  106653. /**
  106654. * Remove a camera for the list of scene's cameras
  106655. * @param toRemove defines the camera to remove
  106656. * @returns the index where the camera was in the camera list
  106657. */
  106658. removeCamera(toRemove: Camera): number;
  106659. /**
  106660. * Remove a particle system for the list of scene's particle systems
  106661. * @param toRemove defines the particle system to remove
  106662. * @returns the index where the particle system was in the particle system list
  106663. */
  106664. removeParticleSystem(toRemove: IParticleSystem): number;
  106665. /**
  106666. * Remove a animation for the list of scene's animations
  106667. * @param toRemove defines the animation to remove
  106668. * @returns the index where the animation was in the animation list
  106669. */
  106670. removeAnimation(toRemove: Animation): number;
  106671. /**
  106672. * Will stop the animation of the given target
  106673. * @param target - the target
  106674. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  106675. * @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)
  106676. */
  106677. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  106678. /**
  106679. * Removes the given animation group from this scene.
  106680. * @param toRemove The animation group to remove
  106681. * @returns The index of the removed animation group
  106682. */
  106683. removeAnimationGroup(toRemove: AnimationGroup): number;
  106684. /**
  106685. * Removes the given multi-material from this scene.
  106686. * @param toRemove The multi-material to remove
  106687. * @returns The index of the removed multi-material
  106688. */
  106689. removeMultiMaterial(toRemove: MultiMaterial): number;
  106690. /**
  106691. * Removes the given material from this scene.
  106692. * @param toRemove The material to remove
  106693. * @returns The index of the removed material
  106694. */
  106695. removeMaterial(toRemove: Material): number;
  106696. /**
  106697. * Removes the given action manager from this scene.
  106698. * @param toRemove The action manager to remove
  106699. * @returns The index of the removed action manager
  106700. */
  106701. removeActionManager(toRemove: AbstractActionManager): number;
  106702. /**
  106703. * Removes the given texture from this scene.
  106704. * @param toRemove The texture to remove
  106705. * @returns The index of the removed texture
  106706. */
  106707. removeTexture(toRemove: BaseTexture): number;
  106708. /**
  106709. * Adds the given light to this scene
  106710. * @param newLight The light to add
  106711. */
  106712. addLight(newLight: Light): void;
  106713. /**
  106714. * Sorts the list list based on light priorities
  106715. */
  106716. sortLightsByPriority(): void;
  106717. /**
  106718. * Adds the given camera to this scene
  106719. * @param newCamera The camera to add
  106720. */
  106721. addCamera(newCamera: Camera): void;
  106722. /**
  106723. * Adds the given skeleton to this scene
  106724. * @param newSkeleton The skeleton to add
  106725. */
  106726. addSkeleton(newSkeleton: Skeleton): void;
  106727. /**
  106728. * Adds the given particle system to this scene
  106729. * @param newParticleSystem The particle system to add
  106730. */
  106731. addParticleSystem(newParticleSystem: IParticleSystem): void;
  106732. /**
  106733. * Adds the given animation to this scene
  106734. * @param newAnimation The animation to add
  106735. */
  106736. addAnimation(newAnimation: Animation): void;
  106737. /**
  106738. * Adds the given animation group to this scene.
  106739. * @param newAnimationGroup The animation group to add
  106740. */
  106741. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  106742. /**
  106743. * Adds the given multi-material to this scene
  106744. * @param newMultiMaterial The multi-material to add
  106745. */
  106746. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  106747. /**
  106748. * Adds the given material to this scene
  106749. * @param newMaterial The material to add
  106750. */
  106751. addMaterial(newMaterial: Material): void;
  106752. /**
  106753. * Adds the given morph target to this scene
  106754. * @param newMorphTargetManager The morph target to add
  106755. */
  106756. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  106757. /**
  106758. * Adds the given geometry to this scene
  106759. * @param newGeometry The geometry to add
  106760. */
  106761. addGeometry(newGeometry: Geometry): void;
  106762. /**
  106763. * Adds the given action manager to this scene
  106764. * @param newActionManager The action manager to add
  106765. */
  106766. addActionManager(newActionManager: AbstractActionManager): void;
  106767. /**
  106768. * Adds the given texture to this scene.
  106769. * @param newTexture The texture to add
  106770. */
  106771. addTexture(newTexture: BaseTexture): void;
  106772. /**
  106773. * Switch active camera
  106774. * @param newCamera defines the new active camera
  106775. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  106776. */
  106777. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  106778. /**
  106779. * sets the active camera of the scene using its ID
  106780. * @param id defines the camera's ID
  106781. * @return the new active camera or null if none found.
  106782. */
  106783. setActiveCameraByID(id: string): Nullable<Camera>;
  106784. /**
  106785. * sets the active camera of the scene using its name
  106786. * @param name defines the camera's name
  106787. * @returns the new active camera or null if none found.
  106788. */
  106789. setActiveCameraByName(name: string): Nullable<Camera>;
  106790. /**
  106791. * get an animation group using its name
  106792. * @param name defines the material's name
  106793. * @return the animation group or null if none found.
  106794. */
  106795. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  106796. /**
  106797. * Get a material using its unique id
  106798. * @param uniqueId defines the material's unique id
  106799. * @return the material or null if none found.
  106800. */
  106801. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  106802. /**
  106803. * get a material using its id
  106804. * @param id defines the material's ID
  106805. * @return the material or null if none found.
  106806. */
  106807. getMaterialByID(id: string): Nullable<Material>;
  106808. /**
  106809. * Gets a the last added material using a given id
  106810. * @param id defines the material's ID
  106811. * @return the last material with the given id or null if none found.
  106812. */
  106813. getLastMaterialByID(id: string): Nullable<Material>;
  106814. /**
  106815. * Gets a material using its name
  106816. * @param name defines the material's name
  106817. * @return the material or null if none found.
  106818. */
  106819. getMaterialByName(name: string): Nullable<Material>;
  106820. /**
  106821. * Get a texture using its unique id
  106822. * @param uniqueId defines the texture's unique id
  106823. * @return the texture or null if none found.
  106824. */
  106825. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  106826. /**
  106827. * Gets a camera using its id
  106828. * @param id defines the id to look for
  106829. * @returns the camera or null if not found
  106830. */
  106831. getCameraByID(id: string): Nullable<Camera>;
  106832. /**
  106833. * Gets a camera using its unique id
  106834. * @param uniqueId defines the unique id to look for
  106835. * @returns the camera or null if not found
  106836. */
  106837. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  106838. /**
  106839. * Gets a camera using its name
  106840. * @param name defines the camera's name
  106841. * @return the camera or null if none found.
  106842. */
  106843. getCameraByName(name: string): Nullable<Camera>;
  106844. /**
  106845. * Gets a bone using its id
  106846. * @param id defines the bone's id
  106847. * @return the bone or null if not found
  106848. */
  106849. getBoneByID(id: string): Nullable<Bone>;
  106850. /**
  106851. * Gets a bone using its id
  106852. * @param name defines the bone's name
  106853. * @return the bone or null if not found
  106854. */
  106855. getBoneByName(name: string): Nullable<Bone>;
  106856. /**
  106857. * Gets a light node using its name
  106858. * @param name defines the the light's name
  106859. * @return the light or null if none found.
  106860. */
  106861. getLightByName(name: string): Nullable<Light>;
  106862. /**
  106863. * Gets a light node using its id
  106864. * @param id defines the light's id
  106865. * @return the light or null if none found.
  106866. */
  106867. getLightByID(id: string): Nullable<Light>;
  106868. /**
  106869. * Gets a light node using its scene-generated unique ID
  106870. * @param uniqueId defines the light's unique id
  106871. * @return the light or null if none found.
  106872. */
  106873. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  106874. /**
  106875. * Gets a particle system by id
  106876. * @param id defines the particle system id
  106877. * @return the corresponding system or null if none found
  106878. */
  106879. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  106880. /**
  106881. * Gets a geometry using its ID
  106882. * @param id defines the geometry's id
  106883. * @return the geometry or null if none found.
  106884. */
  106885. getGeometryByID(id: string): Nullable<Geometry>;
  106886. private _getGeometryByUniqueID;
  106887. /**
  106888. * Add a new geometry to this scene
  106889. * @param geometry defines the geometry to be added to the scene.
  106890. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  106891. * @return a boolean defining if the geometry was added or not
  106892. */
  106893. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  106894. /**
  106895. * Removes an existing geometry
  106896. * @param geometry defines the geometry to be removed from the scene
  106897. * @return a boolean defining if the geometry was removed or not
  106898. */
  106899. removeGeometry(geometry: Geometry): boolean;
  106900. /**
  106901. * Gets the list of geometries attached to the scene
  106902. * @returns an array of Geometry
  106903. */
  106904. getGeometries(): Geometry[];
  106905. /**
  106906. * Gets the first added mesh found of a given ID
  106907. * @param id defines the id to search for
  106908. * @return the mesh found or null if not found at all
  106909. */
  106910. getMeshByID(id: string): Nullable<AbstractMesh>;
  106911. /**
  106912. * Gets a list of meshes using their id
  106913. * @param id defines the id to search for
  106914. * @returns a list of meshes
  106915. */
  106916. getMeshesByID(id: string): Array<AbstractMesh>;
  106917. /**
  106918. * Gets the first added transform node found of a given ID
  106919. * @param id defines the id to search for
  106920. * @return the found transform node or null if not found at all.
  106921. */
  106922. getTransformNodeByID(id: string): Nullable<TransformNode>;
  106923. /**
  106924. * Gets a transform node with its auto-generated unique id
  106925. * @param uniqueId efines the unique id to search for
  106926. * @return the found transform node or null if not found at all.
  106927. */
  106928. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  106929. /**
  106930. * Gets a list of transform nodes using their id
  106931. * @param id defines the id to search for
  106932. * @returns a list of transform nodes
  106933. */
  106934. getTransformNodesByID(id: string): Array<TransformNode>;
  106935. /**
  106936. * Gets a mesh with its auto-generated unique id
  106937. * @param uniqueId defines the unique id to search for
  106938. * @return the found mesh or null if not found at all.
  106939. */
  106940. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  106941. /**
  106942. * Gets a the last added mesh using a given id
  106943. * @param id defines the id to search for
  106944. * @return the found mesh or null if not found at all.
  106945. */
  106946. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  106947. /**
  106948. * Gets a the last added node (Mesh, Camera, Light) using a given id
  106949. * @param id defines the id to search for
  106950. * @return the found node or null if not found at all
  106951. */
  106952. getLastEntryByID(id: string): Nullable<Node>;
  106953. /**
  106954. * Gets a node (Mesh, Camera, Light) using a given id
  106955. * @param id defines the id to search for
  106956. * @return the found node or null if not found at all
  106957. */
  106958. getNodeByID(id: string): Nullable<Node>;
  106959. /**
  106960. * Gets a node (Mesh, Camera, Light) using a given name
  106961. * @param name defines the name to search for
  106962. * @return the found node or null if not found at all.
  106963. */
  106964. getNodeByName(name: string): Nullable<Node>;
  106965. /**
  106966. * Gets a mesh using a given name
  106967. * @param name defines the name to search for
  106968. * @return the found mesh or null if not found at all.
  106969. */
  106970. getMeshByName(name: string): Nullable<AbstractMesh>;
  106971. /**
  106972. * Gets a transform node using a given name
  106973. * @param name defines the name to search for
  106974. * @return the found transform node or null if not found at all.
  106975. */
  106976. getTransformNodeByName(name: string): Nullable<TransformNode>;
  106977. /**
  106978. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  106979. * @param id defines the id to search for
  106980. * @return the found skeleton or null if not found at all.
  106981. */
  106982. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  106983. /**
  106984. * Gets a skeleton using a given auto generated unique id
  106985. * @param uniqueId defines the unique id to search for
  106986. * @return the found skeleton or null if not found at all.
  106987. */
  106988. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  106989. /**
  106990. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  106991. * @param id defines the id to search for
  106992. * @return the found skeleton or null if not found at all.
  106993. */
  106994. getSkeletonById(id: string): Nullable<Skeleton>;
  106995. /**
  106996. * Gets a skeleton using a given name
  106997. * @param name defines the name to search for
  106998. * @return the found skeleton or null if not found at all.
  106999. */
  107000. getSkeletonByName(name: string): Nullable<Skeleton>;
  107001. /**
  107002. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  107003. * @param id defines the id to search for
  107004. * @return the found morph target manager or null if not found at all.
  107005. */
  107006. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  107007. /**
  107008. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  107009. * @param id defines the id to search for
  107010. * @return the found morph target or null if not found at all.
  107011. */
  107012. getMorphTargetById(id: string): Nullable<MorphTarget>;
  107013. /**
  107014. * Gets a boolean indicating if the given mesh is active
  107015. * @param mesh defines the mesh to look for
  107016. * @returns true if the mesh is in the active list
  107017. */
  107018. isActiveMesh(mesh: AbstractMesh): boolean;
  107019. /**
  107020. * Return a unique id as a string which can serve as an identifier for the scene
  107021. */
  107022. get uid(): string;
  107023. /**
  107024. * Add an externaly attached data from its key.
  107025. * This method call will fail and return false, if such key already exists.
  107026. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  107027. * @param key the unique key that identifies the data
  107028. * @param data the data object to associate to the key for this Engine instance
  107029. * @return true if no such key were already present and the data was added successfully, false otherwise
  107030. */
  107031. addExternalData<T>(key: string, data: T): boolean;
  107032. /**
  107033. * Get an externaly attached data from its key
  107034. * @param key the unique key that identifies the data
  107035. * @return the associated data, if present (can be null), or undefined if not present
  107036. */
  107037. getExternalData<T>(key: string): Nullable<T>;
  107038. /**
  107039. * Get an externaly attached data from its key, create it using a factory if it's not already present
  107040. * @param key the unique key that identifies the data
  107041. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  107042. * @return the associated data, can be null if the factory returned null.
  107043. */
  107044. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  107045. /**
  107046. * Remove an externaly attached data from the Engine instance
  107047. * @param key the unique key that identifies the data
  107048. * @return true if the data was successfully removed, false if it doesn't exist
  107049. */
  107050. removeExternalData(key: string): boolean;
  107051. private _evaluateSubMesh;
  107052. /**
  107053. * Clear the processed materials smart array preventing retention point in material dispose.
  107054. */
  107055. freeProcessedMaterials(): void;
  107056. private _preventFreeActiveMeshesAndRenderingGroups;
  107057. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  107058. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  107059. * when disposing several meshes in a row or a hierarchy of meshes.
  107060. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  107061. */
  107062. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  107063. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  107064. /**
  107065. * Clear the active meshes smart array preventing retention point in mesh dispose.
  107066. */
  107067. freeActiveMeshes(): void;
  107068. /**
  107069. * Clear the info related to rendering groups preventing retention points during dispose.
  107070. */
  107071. freeRenderingGroups(): void;
  107072. /** @hidden */
  107073. _isInIntermediateRendering(): boolean;
  107074. /**
  107075. * Lambda returning the list of potentially active meshes.
  107076. */
  107077. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  107078. /**
  107079. * Lambda returning the list of potentially active sub meshes.
  107080. */
  107081. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  107082. /**
  107083. * Lambda returning the list of potentially intersecting sub meshes.
  107084. */
  107085. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  107086. /**
  107087. * Lambda returning the list of potentially colliding sub meshes.
  107088. */
  107089. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  107090. private _activeMeshesFrozen;
  107091. private _skipEvaluateActiveMeshesCompletely;
  107092. /**
  107093. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  107094. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  107095. * @returns the current scene
  107096. */
  107097. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  107098. /**
  107099. * Use this function to restart evaluating active meshes on every frame
  107100. * @returns the current scene
  107101. */
  107102. unfreezeActiveMeshes(): Scene;
  107103. private _evaluateActiveMeshes;
  107104. private _activeMesh;
  107105. /**
  107106. * Update the transform matrix to update from the current active camera
  107107. * @param force defines a boolean used to force the update even if cache is up to date
  107108. */
  107109. updateTransformMatrix(force?: boolean): void;
  107110. private _bindFrameBuffer;
  107111. /** @hidden */
  107112. _allowPostProcessClearColor: boolean;
  107113. /** @hidden */
  107114. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  107115. private _processSubCameras;
  107116. private _checkIntersections;
  107117. /** @hidden */
  107118. _advancePhysicsEngineStep(step: number): void;
  107119. /**
  107120. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  107121. */
  107122. getDeterministicFrameTime: () => number;
  107123. /** @hidden */
  107124. _animate(): void;
  107125. /** Execute all animations (for a frame) */
  107126. animate(): void;
  107127. /**
  107128. * Render the scene
  107129. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  107130. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  107131. */
  107132. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  107133. /**
  107134. * Freeze all materials
  107135. * A frozen material will not be updatable but should be faster to render
  107136. */
  107137. freezeMaterials(): void;
  107138. /**
  107139. * Unfreeze all materials
  107140. * A frozen material will not be updatable but should be faster to render
  107141. */
  107142. unfreezeMaterials(): void;
  107143. /**
  107144. * Releases all held ressources
  107145. */
  107146. dispose(): void;
  107147. /**
  107148. * Gets if the scene is already disposed
  107149. */
  107150. get isDisposed(): boolean;
  107151. /**
  107152. * Call this function to reduce memory footprint of the scene.
  107153. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  107154. */
  107155. clearCachedVertexData(): void;
  107156. /**
  107157. * This function will remove the local cached buffer data from texture.
  107158. * It will save memory but will prevent the texture from being rebuilt
  107159. */
  107160. cleanCachedTextureBuffer(): void;
  107161. /**
  107162. * Get the world extend vectors with an optional filter
  107163. *
  107164. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  107165. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  107166. */
  107167. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  107168. min: Vector3;
  107169. max: Vector3;
  107170. };
  107171. /**
  107172. * Creates a ray that can be used to pick in the scene
  107173. * @param x defines the x coordinate of the origin (on-screen)
  107174. * @param y defines the y coordinate of the origin (on-screen)
  107175. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  107176. * @param camera defines the camera to use for the picking
  107177. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  107178. * @returns a Ray
  107179. */
  107180. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  107181. /**
  107182. * Creates a ray that can be used to pick in the scene
  107183. * @param x defines the x coordinate of the origin (on-screen)
  107184. * @param y defines the y coordinate of the origin (on-screen)
  107185. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  107186. * @param result defines the ray where to store the picking ray
  107187. * @param camera defines the camera to use for the picking
  107188. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  107189. * @returns the current scene
  107190. */
  107191. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  107192. /**
  107193. * Creates a ray that can be used to pick in the scene
  107194. * @param x defines the x coordinate of the origin (on-screen)
  107195. * @param y defines the y coordinate of the origin (on-screen)
  107196. * @param camera defines the camera to use for the picking
  107197. * @returns a Ray
  107198. */
  107199. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  107200. /**
  107201. * Creates a ray that can be used to pick in the scene
  107202. * @param x defines the x coordinate of the origin (on-screen)
  107203. * @param y defines the y coordinate of the origin (on-screen)
  107204. * @param result defines the ray where to store the picking ray
  107205. * @param camera defines the camera to use for the picking
  107206. * @returns the current scene
  107207. */
  107208. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  107209. /** Launch a ray to try to pick a mesh in the scene
  107210. * @param x position on screen
  107211. * @param y position on screen
  107212. * @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
  107213. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  107214. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  107215. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107216. * @returns a PickingInfo
  107217. */
  107218. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  107219. /** Use the given ray to pick a mesh in the scene
  107220. * @param ray The ray to use to pick meshes
  107221. * @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
  107222. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  107223. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107224. * @returns a PickingInfo
  107225. */
  107226. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  107227. /**
  107228. * Launch a ray to try to pick a mesh in the scene
  107229. * @param x X position on screen
  107230. * @param y Y position on screen
  107231. * @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
  107232. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  107233. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107234. * @returns an array of PickingInfo
  107235. */
  107236. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  107237. /**
  107238. * Launch a ray to try to pick a mesh in the scene
  107239. * @param ray Ray to use
  107240. * @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
  107241. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107242. * @returns an array of PickingInfo
  107243. */
  107244. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  107245. /**
  107246. * Force the value of meshUnderPointer
  107247. * @param mesh defines the mesh to use
  107248. */
  107249. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  107250. /**
  107251. * Gets the mesh under the pointer
  107252. * @returns a Mesh or null if no mesh is under the pointer
  107253. */
  107254. getPointerOverMesh(): Nullable<AbstractMesh>;
  107255. /** @hidden */
  107256. _rebuildGeometries(): void;
  107257. /** @hidden */
  107258. _rebuildTextures(): void;
  107259. private _getByTags;
  107260. /**
  107261. * Get a list of meshes by tags
  107262. * @param tagsQuery defines the tags query to use
  107263. * @param forEach defines a predicate used to filter results
  107264. * @returns an array of Mesh
  107265. */
  107266. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  107267. /**
  107268. * Get a list of cameras by tags
  107269. * @param tagsQuery defines the tags query to use
  107270. * @param forEach defines a predicate used to filter results
  107271. * @returns an array of Camera
  107272. */
  107273. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  107274. /**
  107275. * Get a list of lights by tags
  107276. * @param tagsQuery defines the tags query to use
  107277. * @param forEach defines a predicate used to filter results
  107278. * @returns an array of Light
  107279. */
  107280. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  107281. /**
  107282. * Get a list of materials by tags
  107283. * @param tagsQuery defines the tags query to use
  107284. * @param forEach defines a predicate used to filter results
  107285. * @returns an array of Material
  107286. */
  107287. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  107288. /**
  107289. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  107290. * This allowed control for front to back rendering or reversly depending of the special needs.
  107291. *
  107292. * @param renderingGroupId The rendering group id corresponding to its index
  107293. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  107294. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  107295. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  107296. */
  107297. 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;
  107298. /**
  107299. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  107300. *
  107301. * @param renderingGroupId The rendering group id corresponding to its index
  107302. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  107303. * @param depth Automatically clears depth between groups if true and autoClear is true.
  107304. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  107305. */
  107306. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  107307. /**
  107308. * Gets the current auto clear configuration for one rendering group of the rendering
  107309. * manager.
  107310. * @param index the rendering group index to get the information for
  107311. * @returns The auto clear setup for the requested rendering group
  107312. */
  107313. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  107314. private _blockMaterialDirtyMechanism;
  107315. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  107316. get blockMaterialDirtyMechanism(): boolean;
  107317. set blockMaterialDirtyMechanism(value: boolean);
  107318. /**
  107319. * Will flag all materials as dirty to trigger new shader compilation
  107320. * @param flag defines the flag used to specify which material part must be marked as dirty
  107321. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  107322. */
  107323. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  107324. /** @hidden */
  107325. _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;
  107326. /** @hidden */
  107327. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  107328. /** @hidden */
  107329. _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;
  107330. /** @hidden */
  107331. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  107332. /** @hidden */
  107333. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  107334. /** @hidden */
  107335. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  107336. }
  107337. }
  107338. declare module BABYLON {
  107339. /**
  107340. * Set of assets to keep when moving a scene into an asset container.
  107341. */
  107342. export class KeepAssets extends AbstractScene {
  107343. }
  107344. /**
  107345. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  107346. */
  107347. export class InstantiatedEntries {
  107348. /**
  107349. * List of new root nodes (eg. nodes with no parent)
  107350. */
  107351. rootNodes: TransformNode[];
  107352. /**
  107353. * List of new skeletons
  107354. */
  107355. skeletons: Skeleton[];
  107356. /**
  107357. * List of new animation groups
  107358. */
  107359. animationGroups: AnimationGroup[];
  107360. }
  107361. /**
  107362. * Container with a set of assets that can be added or removed from a scene.
  107363. */
  107364. export class AssetContainer extends AbstractScene {
  107365. /**
  107366. * The scene the AssetContainer belongs to.
  107367. */
  107368. scene: Scene;
  107369. /**
  107370. * Instantiates an AssetContainer.
  107371. * @param scene The scene the AssetContainer belongs to.
  107372. */
  107373. constructor(scene: Scene);
  107374. /**
  107375. * Instantiate or clone all meshes and add the new ones to the scene.
  107376. * Skeletons and animation groups will all be cloned
  107377. * @param nameFunction defines an optional function used to get new names for clones
  107378. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  107379. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  107380. */
  107381. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  107382. /**
  107383. * Adds all the assets from the container to the scene.
  107384. */
  107385. addAllToScene(): void;
  107386. /**
  107387. * Removes all the assets in the container from the scene
  107388. */
  107389. removeAllFromScene(): void;
  107390. /**
  107391. * Disposes all the assets in the container
  107392. */
  107393. dispose(): void;
  107394. private _moveAssets;
  107395. /**
  107396. * Removes all the assets contained in the scene and adds them to the container.
  107397. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  107398. */
  107399. moveAllFromScene(keepAssets?: KeepAssets): void;
  107400. /**
  107401. * 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.
  107402. * @returns the root mesh
  107403. */
  107404. createRootMesh(): Mesh;
  107405. /**
  107406. * Merge animations from this asset container into a scene
  107407. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  107408. * @param animatables set of animatables to retarget to a node from the scene
  107409. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  107410. */
  107411. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  107412. }
  107413. }
  107414. declare module BABYLON {
  107415. /**
  107416. * Defines how the parser contract is defined.
  107417. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  107418. */
  107419. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  107420. /**
  107421. * Defines how the individual parser contract is defined.
  107422. * These parser can parse an individual asset
  107423. */
  107424. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  107425. /**
  107426. * Base class of the scene acting as a container for the different elements composing a scene.
  107427. * This class is dynamically extended by the different components of the scene increasing
  107428. * flexibility and reducing coupling
  107429. */
  107430. export abstract class AbstractScene {
  107431. /**
  107432. * Stores the list of available parsers in the application.
  107433. */
  107434. private static _BabylonFileParsers;
  107435. /**
  107436. * Stores the list of available individual parsers in the application.
  107437. */
  107438. private static _IndividualBabylonFileParsers;
  107439. /**
  107440. * Adds a parser in the list of available ones
  107441. * @param name Defines the name of the parser
  107442. * @param parser Defines the parser to add
  107443. */
  107444. static AddParser(name: string, parser: BabylonFileParser): void;
  107445. /**
  107446. * Gets a general parser from the list of avaialble ones
  107447. * @param name Defines the name of the parser
  107448. * @returns the requested parser or null
  107449. */
  107450. static GetParser(name: string): Nullable<BabylonFileParser>;
  107451. /**
  107452. * Adds n individual parser in the list of available ones
  107453. * @param name Defines the name of the parser
  107454. * @param parser Defines the parser to add
  107455. */
  107456. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  107457. /**
  107458. * Gets an individual parser from the list of avaialble ones
  107459. * @param name Defines the name of the parser
  107460. * @returns the requested parser or null
  107461. */
  107462. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  107463. /**
  107464. * Parser json data and populate both a scene and its associated container object
  107465. * @param jsonData Defines the data to parse
  107466. * @param scene Defines the scene to parse the data for
  107467. * @param container Defines the container attached to the parsing sequence
  107468. * @param rootUrl Defines the root url of the data
  107469. */
  107470. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  107471. /**
  107472. * Gets the list of root nodes (ie. nodes with no parent)
  107473. */
  107474. rootNodes: Node[];
  107475. /** All of the cameras added to this scene
  107476. * @see http://doc.babylonjs.com/babylon101/cameras
  107477. */
  107478. cameras: Camera[];
  107479. /**
  107480. * All of the lights added to this scene
  107481. * @see http://doc.babylonjs.com/babylon101/lights
  107482. */
  107483. lights: Light[];
  107484. /**
  107485. * All of the (abstract) meshes added to this scene
  107486. */
  107487. meshes: AbstractMesh[];
  107488. /**
  107489. * The list of skeletons added to the scene
  107490. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  107491. */
  107492. skeletons: Skeleton[];
  107493. /**
  107494. * All of the particle systems added to this scene
  107495. * @see http://doc.babylonjs.com/babylon101/particles
  107496. */
  107497. particleSystems: IParticleSystem[];
  107498. /**
  107499. * Gets a list of Animations associated with the scene
  107500. */
  107501. animations: Animation[];
  107502. /**
  107503. * All of the animation groups added to this scene
  107504. * @see http://doc.babylonjs.com/how_to/group
  107505. */
  107506. animationGroups: AnimationGroup[];
  107507. /**
  107508. * All of the multi-materials added to this scene
  107509. * @see http://doc.babylonjs.com/how_to/multi_materials
  107510. */
  107511. multiMaterials: MultiMaterial[];
  107512. /**
  107513. * All of the materials added to this scene
  107514. * In the context of a Scene, it is not supposed to be modified manually.
  107515. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  107516. * Note also that the order of the Material within the array is not significant and might change.
  107517. * @see http://doc.babylonjs.com/babylon101/materials
  107518. */
  107519. materials: Material[];
  107520. /**
  107521. * The list of morph target managers added to the scene
  107522. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  107523. */
  107524. morphTargetManagers: MorphTargetManager[];
  107525. /**
  107526. * The list of geometries used in the scene.
  107527. */
  107528. geometries: Geometry[];
  107529. /**
  107530. * All of the tranform nodes added to this scene
  107531. * In the context of a Scene, it is not supposed to be modified manually.
  107532. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  107533. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  107534. * @see http://doc.babylonjs.com/how_to/transformnode
  107535. */
  107536. transformNodes: TransformNode[];
  107537. /**
  107538. * ActionManagers available on the scene.
  107539. */
  107540. actionManagers: AbstractActionManager[];
  107541. /**
  107542. * Textures to keep.
  107543. */
  107544. textures: BaseTexture[];
  107545. /**
  107546. * Environment texture for the scene
  107547. */
  107548. environmentTexture: Nullable<BaseTexture>;
  107549. /**
  107550. * @returns all meshes, lights, cameras, transformNodes and bones
  107551. */
  107552. getNodes(): Array<Node>;
  107553. }
  107554. }
  107555. declare module BABYLON {
  107556. /**
  107557. * Interface used to define options for Sound class
  107558. */
  107559. export interface ISoundOptions {
  107560. /**
  107561. * Does the sound autoplay once loaded.
  107562. */
  107563. autoplay?: boolean;
  107564. /**
  107565. * Does the sound loop after it finishes playing once.
  107566. */
  107567. loop?: boolean;
  107568. /**
  107569. * Sound's volume
  107570. */
  107571. volume?: number;
  107572. /**
  107573. * Is it a spatial sound?
  107574. */
  107575. spatialSound?: boolean;
  107576. /**
  107577. * Maximum distance to hear that sound
  107578. */
  107579. maxDistance?: number;
  107580. /**
  107581. * Uses user defined attenuation function
  107582. */
  107583. useCustomAttenuation?: boolean;
  107584. /**
  107585. * Define the roll off factor of spatial sounds.
  107586. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107587. */
  107588. rolloffFactor?: number;
  107589. /**
  107590. * Define the reference distance the sound should be heard perfectly.
  107591. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107592. */
  107593. refDistance?: number;
  107594. /**
  107595. * Define the distance attenuation model the sound will follow.
  107596. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107597. */
  107598. distanceModel?: string;
  107599. /**
  107600. * Defines the playback speed (1 by default)
  107601. */
  107602. playbackRate?: number;
  107603. /**
  107604. * Defines if the sound is from a streaming source
  107605. */
  107606. streaming?: boolean;
  107607. /**
  107608. * Defines an optional length (in seconds) inside the sound file
  107609. */
  107610. length?: number;
  107611. /**
  107612. * Defines an optional offset (in seconds) inside the sound file
  107613. */
  107614. offset?: number;
  107615. /**
  107616. * If true, URLs will not be required to state the audio file codec to use.
  107617. */
  107618. skipCodecCheck?: boolean;
  107619. }
  107620. /**
  107621. * Defines a sound that can be played in the application.
  107622. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  107623. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107624. */
  107625. export class Sound {
  107626. /**
  107627. * The name of the sound in the scene.
  107628. */
  107629. name: string;
  107630. /**
  107631. * Does the sound autoplay once loaded.
  107632. */
  107633. autoplay: boolean;
  107634. /**
  107635. * Does the sound loop after it finishes playing once.
  107636. */
  107637. loop: boolean;
  107638. /**
  107639. * Does the sound use a custom attenuation curve to simulate the falloff
  107640. * happening when the source gets further away from the camera.
  107641. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  107642. */
  107643. useCustomAttenuation: boolean;
  107644. /**
  107645. * The sound track id this sound belongs to.
  107646. */
  107647. soundTrackId: number;
  107648. /**
  107649. * Is this sound currently played.
  107650. */
  107651. isPlaying: boolean;
  107652. /**
  107653. * Is this sound currently paused.
  107654. */
  107655. isPaused: boolean;
  107656. /**
  107657. * Does this sound enables spatial sound.
  107658. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107659. */
  107660. spatialSound: boolean;
  107661. /**
  107662. * Define the reference distance the sound should be heard perfectly.
  107663. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107664. */
  107665. refDistance: number;
  107666. /**
  107667. * Define the roll off factor of spatial sounds.
  107668. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107669. */
  107670. rolloffFactor: number;
  107671. /**
  107672. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  107673. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107674. */
  107675. maxDistance: number;
  107676. /**
  107677. * Define the distance attenuation model the sound will follow.
  107678. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107679. */
  107680. distanceModel: string;
  107681. /**
  107682. * @hidden
  107683. * Back Compat
  107684. **/
  107685. onended: () => any;
  107686. /**
  107687. * Observable event when the current playing sound finishes.
  107688. */
  107689. onEndedObservable: Observable<Sound>;
  107690. private _panningModel;
  107691. private _playbackRate;
  107692. private _streaming;
  107693. private _startTime;
  107694. private _startOffset;
  107695. private _position;
  107696. /** @hidden */
  107697. _positionInEmitterSpace: boolean;
  107698. private _localDirection;
  107699. private _volume;
  107700. private _isReadyToPlay;
  107701. private _isDirectional;
  107702. private _readyToPlayCallback;
  107703. private _audioBuffer;
  107704. private _soundSource;
  107705. private _streamingSource;
  107706. private _soundPanner;
  107707. private _soundGain;
  107708. private _inputAudioNode;
  107709. private _outputAudioNode;
  107710. private _coneInnerAngle;
  107711. private _coneOuterAngle;
  107712. private _coneOuterGain;
  107713. private _scene;
  107714. private _connectedTransformNode;
  107715. private _customAttenuationFunction;
  107716. private _registerFunc;
  107717. private _isOutputConnected;
  107718. private _htmlAudioElement;
  107719. private _urlType;
  107720. private _length?;
  107721. private _offset?;
  107722. /** @hidden */
  107723. static _SceneComponentInitialization: (scene: Scene) => void;
  107724. /**
  107725. * Create a sound and attach it to a scene
  107726. * @param name Name of your sound
  107727. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  107728. * @param scene defines the scene the sound belongs to
  107729. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  107730. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  107731. */
  107732. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  107733. /**
  107734. * Release the sound and its associated resources
  107735. */
  107736. dispose(): void;
  107737. /**
  107738. * Gets if the sounds is ready to be played or not.
  107739. * @returns true if ready, otherwise false
  107740. */
  107741. isReady(): boolean;
  107742. private _soundLoaded;
  107743. /**
  107744. * Sets the data of the sound from an audiobuffer
  107745. * @param audioBuffer The audioBuffer containing the data
  107746. */
  107747. setAudioBuffer(audioBuffer: AudioBuffer): void;
  107748. /**
  107749. * Updates the current sounds options such as maxdistance, loop...
  107750. * @param options A JSON object containing values named as the object properties
  107751. */
  107752. updateOptions(options: ISoundOptions): void;
  107753. private _createSpatialParameters;
  107754. private _updateSpatialParameters;
  107755. /**
  107756. * Switch the panning model to HRTF:
  107757. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  107758. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107759. */
  107760. switchPanningModelToHRTF(): void;
  107761. /**
  107762. * Switch the panning model to Equal Power:
  107763. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  107764. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107765. */
  107766. switchPanningModelToEqualPower(): void;
  107767. private _switchPanningModel;
  107768. /**
  107769. * Connect this sound to a sound track audio node like gain...
  107770. * @param soundTrackAudioNode the sound track audio node to connect to
  107771. */
  107772. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  107773. /**
  107774. * Transform this sound into a directional source
  107775. * @param coneInnerAngle Size of the inner cone in degree
  107776. * @param coneOuterAngle Size of the outer cone in degree
  107777. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  107778. */
  107779. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  107780. /**
  107781. * Gets or sets the inner angle for the directional cone.
  107782. */
  107783. get directionalConeInnerAngle(): number;
  107784. /**
  107785. * Gets or sets the inner angle for the directional cone.
  107786. */
  107787. set directionalConeInnerAngle(value: number);
  107788. /**
  107789. * Gets or sets the outer angle for the directional cone.
  107790. */
  107791. get directionalConeOuterAngle(): number;
  107792. /**
  107793. * Gets or sets the outer angle for the directional cone.
  107794. */
  107795. set directionalConeOuterAngle(value: number);
  107796. /**
  107797. * Sets the position of the emitter if spatial sound is enabled
  107798. * @param newPosition Defines the new posisiton
  107799. */
  107800. setPosition(newPosition: Vector3): void;
  107801. /**
  107802. * Sets the local direction of the emitter if spatial sound is enabled
  107803. * @param newLocalDirection Defines the new local direction
  107804. */
  107805. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  107806. private _updateDirection;
  107807. /** @hidden */
  107808. updateDistanceFromListener(): void;
  107809. /**
  107810. * Sets a new custom attenuation function for the sound.
  107811. * @param callback Defines the function used for the attenuation
  107812. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  107813. */
  107814. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  107815. /**
  107816. * Play the sound
  107817. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  107818. * @param offset (optional) Start the sound at a specific time in seconds
  107819. * @param length (optional) Sound duration (in seconds)
  107820. */
  107821. play(time?: number, offset?: number, length?: number): void;
  107822. private _onended;
  107823. /**
  107824. * Stop the sound
  107825. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  107826. */
  107827. stop(time?: number): void;
  107828. /**
  107829. * Put the sound in pause
  107830. */
  107831. pause(): void;
  107832. /**
  107833. * Sets a dedicated volume for this sounds
  107834. * @param newVolume Define the new volume of the sound
  107835. * @param time Define time for gradual change to new volume
  107836. */
  107837. setVolume(newVolume: number, time?: number): void;
  107838. /**
  107839. * Set the sound play back rate
  107840. * @param newPlaybackRate Define the playback rate the sound should be played at
  107841. */
  107842. setPlaybackRate(newPlaybackRate: number): void;
  107843. /**
  107844. * Gets the volume of the sound.
  107845. * @returns the volume of the sound
  107846. */
  107847. getVolume(): number;
  107848. /**
  107849. * Attach the sound to a dedicated mesh
  107850. * @param transformNode The transform node to connect the sound with
  107851. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  107852. */
  107853. attachToMesh(transformNode: TransformNode): void;
  107854. /**
  107855. * Detach the sound from the previously attached mesh
  107856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  107857. */
  107858. detachFromMesh(): void;
  107859. private _onRegisterAfterWorldMatrixUpdate;
  107860. /**
  107861. * Clone the current sound in the scene.
  107862. * @returns the new sound clone
  107863. */
  107864. clone(): Nullable<Sound>;
  107865. /**
  107866. * Gets the current underlying audio buffer containing the data
  107867. * @returns the audio buffer
  107868. */
  107869. getAudioBuffer(): Nullable<AudioBuffer>;
  107870. /**
  107871. * Serializes the Sound in a JSON representation
  107872. * @returns the JSON representation of the sound
  107873. */
  107874. serialize(): any;
  107875. /**
  107876. * Parse a JSON representation of a sound to innstantiate in a given scene
  107877. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  107878. * @param scene Define the scene the new parsed sound should be created in
  107879. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  107880. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  107881. * @returns the newly parsed sound
  107882. */
  107883. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  107884. }
  107885. }
  107886. declare module BABYLON {
  107887. /**
  107888. * This defines an action helpful to play a defined sound on a triggered action.
  107889. */
  107890. export class PlaySoundAction extends Action {
  107891. private _sound;
  107892. /**
  107893. * Instantiate the action
  107894. * @param triggerOptions defines the trigger options
  107895. * @param sound defines the sound to play
  107896. * @param condition defines the trigger related conditions
  107897. */
  107898. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  107899. /** @hidden */
  107900. _prepare(): void;
  107901. /**
  107902. * Execute the action and play the sound.
  107903. */
  107904. execute(): void;
  107905. /**
  107906. * Serializes the actions and its related information.
  107907. * @param parent defines the object to serialize in
  107908. * @returns the serialized object
  107909. */
  107910. serialize(parent: any): any;
  107911. }
  107912. /**
  107913. * This defines an action helpful to stop a defined sound on a triggered action.
  107914. */
  107915. export class StopSoundAction extends Action {
  107916. private _sound;
  107917. /**
  107918. * Instantiate the action
  107919. * @param triggerOptions defines the trigger options
  107920. * @param sound defines the sound to stop
  107921. * @param condition defines the trigger related conditions
  107922. */
  107923. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  107924. /** @hidden */
  107925. _prepare(): void;
  107926. /**
  107927. * Execute the action and stop the sound.
  107928. */
  107929. execute(): void;
  107930. /**
  107931. * Serializes the actions and its related information.
  107932. * @param parent defines the object to serialize in
  107933. * @returns the serialized object
  107934. */
  107935. serialize(parent: any): any;
  107936. }
  107937. }
  107938. declare module BABYLON {
  107939. /**
  107940. * This defines an action responsible to change the value of a property
  107941. * by interpolating between its current value and the newly set one once triggered.
  107942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  107943. */
  107944. export class InterpolateValueAction extends Action {
  107945. /**
  107946. * Defines the path of the property where the value should be interpolated
  107947. */
  107948. propertyPath: string;
  107949. /**
  107950. * Defines the target value at the end of the interpolation.
  107951. */
  107952. value: any;
  107953. /**
  107954. * Defines the time it will take for the property to interpolate to the value.
  107955. */
  107956. duration: number;
  107957. /**
  107958. * Defines if the other scene animations should be stopped when the action has been triggered
  107959. */
  107960. stopOtherAnimations?: boolean;
  107961. /**
  107962. * Defines a callback raised once the interpolation animation has been done.
  107963. */
  107964. onInterpolationDone?: () => void;
  107965. /**
  107966. * Observable triggered once the interpolation animation has been done.
  107967. */
  107968. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  107969. private _target;
  107970. private _effectiveTarget;
  107971. private _property;
  107972. /**
  107973. * Instantiate the action
  107974. * @param triggerOptions defines the trigger options
  107975. * @param target defines the object containing the value to interpolate
  107976. * @param propertyPath defines the path to the property in the target object
  107977. * @param value defines the target value at the end of the interpolation
  107978. * @param duration deines the time it will take for the property to interpolate to the value.
  107979. * @param condition defines the trigger related conditions
  107980. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  107981. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  107982. */
  107983. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  107984. /** @hidden */
  107985. _prepare(): void;
  107986. /**
  107987. * Execute the action starts the value interpolation.
  107988. */
  107989. execute(): void;
  107990. /**
  107991. * Serializes the actions and its related information.
  107992. * @param parent defines the object to serialize in
  107993. * @returns the serialized object
  107994. */
  107995. serialize(parent: any): any;
  107996. }
  107997. }
  107998. declare module BABYLON {
  107999. /**
  108000. * Options allowed during the creation of a sound track.
  108001. */
  108002. export interface ISoundTrackOptions {
  108003. /**
  108004. * The volume the sound track should take during creation
  108005. */
  108006. volume?: number;
  108007. /**
  108008. * Define if the sound track is the main sound track of the scene
  108009. */
  108010. mainTrack?: boolean;
  108011. }
  108012. /**
  108013. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  108014. * It will be also used in a future release to apply effects on a specific track.
  108015. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  108016. */
  108017. export class SoundTrack {
  108018. /**
  108019. * The unique identifier of the sound track in the scene.
  108020. */
  108021. id: number;
  108022. /**
  108023. * The list of sounds included in the sound track.
  108024. */
  108025. soundCollection: Array<Sound>;
  108026. private _outputAudioNode;
  108027. private _scene;
  108028. private _connectedAnalyser;
  108029. private _options;
  108030. private _isInitialized;
  108031. /**
  108032. * Creates a new sound track.
  108033. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  108034. * @param scene Define the scene the sound track belongs to
  108035. * @param options
  108036. */
  108037. constructor(scene: Scene, options?: ISoundTrackOptions);
  108038. private _initializeSoundTrackAudioGraph;
  108039. /**
  108040. * Release the sound track and its associated resources
  108041. */
  108042. dispose(): void;
  108043. /**
  108044. * Adds a sound to this sound track
  108045. * @param sound define the cound to add
  108046. * @ignoreNaming
  108047. */
  108048. AddSound(sound: Sound): void;
  108049. /**
  108050. * Removes a sound to this sound track
  108051. * @param sound define the cound to remove
  108052. * @ignoreNaming
  108053. */
  108054. RemoveSound(sound: Sound): void;
  108055. /**
  108056. * Set a global volume for the full sound track.
  108057. * @param newVolume Define the new volume of the sound track
  108058. */
  108059. setVolume(newVolume: number): void;
  108060. /**
  108061. * Switch the panning model to HRTF:
  108062. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  108063. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108064. */
  108065. switchPanningModelToHRTF(): void;
  108066. /**
  108067. * Switch the panning model to Equal Power:
  108068. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  108069. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108070. */
  108071. switchPanningModelToEqualPower(): void;
  108072. /**
  108073. * Connect the sound track to an audio analyser allowing some amazing
  108074. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  108075. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  108076. * @param analyser The analyser to connect to the engine
  108077. */
  108078. connectToAnalyser(analyser: Analyser): void;
  108079. }
  108080. }
  108081. declare module BABYLON {
  108082. interface AbstractScene {
  108083. /**
  108084. * The list of sounds used in the scene.
  108085. */
  108086. sounds: Nullable<Array<Sound>>;
  108087. }
  108088. interface Scene {
  108089. /**
  108090. * @hidden
  108091. * Backing field
  108092. */
  108093. _mainSoundTrack: SoundTrack;
  108094. /**
  108095. * The main sound track played by the scene.
  108096. * It cotains your primary collection of sounds.
  108097. */
  108098. mainSoundTrack: SoundTrack;
  108099. /**
  108100. * The list of sound tracks added to the scene
  108101. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108102. */
  108103. soundTracks: Nullable<Array<SoundTrack>>;
  108104. /**
  108105. * Gets a sound using a given name
  108106. * @param name defines the name to search for
  108107. * @return the found sound or null if not found at all.
  108108. */
  108109. getSoundByName(name: string): Nullable<Sound>;
  108110. /**
  108111. * Gets or sets if audio support is enabled
  108112. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108113. */
  108114. audioEnabled: boolean;
  108115. /**
  108116. * Gets or sets if audio will be output to headphones
  108117. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108118. */
  108119. headphone: boolean;
  108120. /**
  108121. * Gets or sets custom audio listener position provider
  108122. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108123. */
  108124. audioListenerPositionProvider: Nullable<() => Vector3>;
  108125. /**
  108126. * Gets or sets a refresh rate when using 3D audio positioning
  108127. */
  108128. audioPositioningRefreshRate: number;
  108129. }
  108130. /**
  108131. * Defines the sound scene component responsible to manage any sounds
  108132. * in a given scene.
  108133. */
  108134. export class AudioSceneComponent implements ISceneSerializableComponent {
  108135. /**
  108136. * The component name helpfull to identify the component in the list of scene components.
  108137. */
  108138. readonly name: string;
  108139. /**
  108140. * The scene the component belongs to.
  108141. */
  108142. scene: Scene;
  108143. private _audioEnabled;
  108144. /**
  108145. * Gets whether audio is enabled or not.
  108146. * Please use related enable/disable method to switch state.
  108147. */
  108148. get audioEnabled(): boolean;
  108149. private _headphone;
  108150. /**
  108151. * Gets whether audio is outputing to headphone or not.
  108152. * Please use the according Switch methods to change output.
  108153. */
  108154. get headphone(): boolean;
  108155. /**
  108156. * Gets or sets a refresh rate when using 3D audio positioning
  108157. */
  108158. audioPositioningRefreshRate: number;
  108159. private _audioListenerPositionProvider;
  108160. /**
  108161. * Gets the current audio listener position provider
  108162. */
  108163. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  108164. /**
  108165. * Sets a custom listener position for all sounds in the scene
  108166. * By default, this is the position of the first active camera
  108167. */
  108168. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  108169. /**
  108170. * Creates a new instance of the component for the given scene
  108171. * @param scene Defines the scene to register the component in
  108172. */
  108173. constructor(scene: Scene);
  108174. /**
  108175. * Registers the component in a given scene
  108176. */
  108177. register(): void;
  108178. /**
  108179. * Rebuilds the elements related to this component in case of
  108180. * context lost for instance.
  108181. */
  108182. rebuild(): void;
  108183. /**
  108184. * Serializes the component data to the specified json object
  108185. * @param serializationObject The object to serialize to
  108186. */
  108187. serialize(serializationObject: any): void;
  108188. /**
  108189. * Adds all the elements from the container to the scene
  108190. * @param container the container holding the elements
  108191. */
  108192. addFromContainer(container: AbstractScene): void;
  108193. /**
  108194. * Removes all the elements in the container from the scene
  108195. * @param container contains the elements to remove
  108196. * @param dispose if the removed element should be disposed (default: false)
  108197. */
  108198. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  108199. /**
  108200. * Disposes the component and the associated ressources.
  108201. */
  108202. dispose(): void;
  108203. /**
  108204. * Disables audio in the associated scene.
  108205. */
  108206. disableAudio(): void;
  108207. /**
  108208. * Enables audio in the associated scene.
  108209. */
  108210. enableAudio(): void;
  108211. /**
  108212. * Switch audio to headphone output.
  108213. */
  108214. switchAudioModeForHeadphones(): void;
  108215. /**
  108216. * Switch audio to normal speakers.
  108217. */
  108218. switchAudioModeForNormalSpeakers(): void;
  108219. private _cachedCameraDirection;
  108220. private _cachedCameraPosition;
  108221. private _lastCheck;
  108222. private _afterRender;
  108223. }
  108224. }
  108225. declare module BABYLON {
  108226. /**
  108227. * Wraps one or more Sound objects and selects one with random weight for playback.
  108228. */
  108229. export class WeightedSound {
  108230. /** When true a Sound will be selected and played when the current playing Sound completes. */
  108231. loop: boolean;
  108232. private _coneInnerAngle;
  108233. private _coneOuterAngle;
  108234. private _volume;
  108235. /** A Sound is currently playing. */
  108236. isPlaying: boolean;
  108237. /** A Sound is currently paused. */
  108238. isPaused: boolean;
  108239. private _sounds;
  108240. private _weights;
  108241. private _currentIndex?;
  108242. /**
  108243. * Creates a new WeightedSound from the list of sounds given.
  108244. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  108245. * @param sounds Array of Sounds that will be selected from.
  108246. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  108247. */
  108248. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  108249. /**
  108250. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  108251. */
  108252. get directionalConeInnerAngle(): number;
  108253. /**
  108254. * The size of cone in degress for a directional sound in which there will be no attenuation.
  108255. */
  108256. set directionalConeInnerAngle(value: number);
  108257. /**
  108258. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  108259. * Listener angles between innerAngle and outerAngle will falloff linearly.
  108260. */
  108261. get directionalConeOuterAngle(): number;
  108262. /**
  108263. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  108264. * Listener angles between innerAngle and outerAngle will falloff linearly.
  108265. */
  108266. set directionalConeOuterAngle(value: number);
  108267. /**
  108268. * Playback volume.
  108269. */
  108270. get volume(): number;
  108271. /**
  108272. * Playback volume.
  108273. */
  108274. set volume(value: number);
  108275. private _onended;
  108276. /**
  108277. * Suspend playback
  108278. */
  108279. pause(): void;
  108280. /**
  108281. * Stop playback
  108282. */
  108283. stop(): void;
  108284. /**
  108285. * Start playback.
  108286. * @param startOffset Position the clip head at a specific time in seconds.
  108287. */
  108288. play(startOffset?: number): void;
  108289. }
  108290. }
  108291. declare module BABYLON {
  108292. /**
  108293. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  108294. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  108295. */
  108296. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  108297. /**
  108298. * Gets the name of the behavior.
  108299. */
  108300. get name(): string;
  108301. /**
  108302. * The easing function used by animations
  108303. */
  108304. static EasingFunction: BackEase;
  108305. /**
  108306. * The easing mode used by animations
  108307. */
  108308. static EasingMode: number;
  108309. /**
  108310. * The duration of the animation, in milliseconds
  108311. */
  108312. transitionDuration: number;
  108313. /**
  108314. * Length of the distance animated by the transition when lower radius is reached
  108315. */
  108316. lowerRadiusTransitionRange: number;
  108317. /**
  108318. * Length of the distance animated by the transition when upper radius is reached
  108319. */
  108320. upperRadiusTransitionRange: number;
  108321. private _autoTransitionRange;
  108322. /**
  108323. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  108324. */
  108325. get autoTransitionRange(): boolean;
  108326. /**
  108327. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  108328. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  108329. */
  108330. set autoTransitionRange(value: boolean);
  108331. private _attachedCamera;
  108332. private _onAfterCheckInputsObserver;
  108333. private _onMeshTargetChangedObserver;
  108334. /**
  108335. * Initializes the behavior.
  108336. */
  108337. init(): void;
  108338. /**
  108339. * Attaches the behavior to its arc rotate camera.
  108340. * @param camera Defines the camera to attach the behavior to
  108341. */
  108342. attach(camera: ArcRotateCamera): void;
  108343. /**
  108344. * Detaches the behavior from its current arc rotate camera.
  108345. */
  108346. detach(): void;
  108347. private _radiusIsAnimating;
  108348. private _radiusBounceTransition;
  108349. private _animatables;
  108350. private _cachedWheelPrecision;
  108351. /**
  108352. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  108353. * @param radiusLimit The limit to check against.
  108354. * @return Bool to indicate if at limit.
  108355. */
  108356. private _isRadiusAtLimit;
  108357. /**
  108358. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  108359. * @param radiusDelta The delta by which to animate to. Can be negative.
  108360. */
  108361. private _applyBoundRadiusAnimation;
  108362. /**
  108363. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  108364. */
  108365. protected _clearAnimationLocks(): void;
  108366. /**
  108367. * Stops and removes all animations that have been applied to the camera
  108368. */
  108369. stopAllAnimations(): void;
  108370. }
  108371. }
  108372. declare module BABYLON {
  108373. /**
  108374. * 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.
  108375. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  108376. */
  108377. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  108378. /**
  108379. * Gets the name of the behavior.
  108380. */
  108381. get name(): string;
  108382. private _mode;
  108383. private _radiusScale;
  108384. private _positionScale;
  108385. private _defaultElevation;
  108386. private _elevationReturnTime;
  108387. private _elevationReturnWaitTime;
  108388. private _zoomStopsAnimation;
  108389. private _framingTime;
  108390. /**
  108391. * The easing function used by animations
  108392. */
  108393. static EasingFunction: ExponentialEase;
  108394. /**
  108395. * The easing mode used by animations
  108396. */
  108397. static EasingMode: number;
  108398. /**
  108399. * Sets the current mode used by the behavior
  108400. */
  108401. set mode(mode: number);
  108402. /**
  108403. * Gets current mode used by the behavior.
  108404. */
  108405. get mode(): number;
  108406. /**
  108407. * Sets the scale applied to the radius (1 by default)
  108408. */
  108409. set radiusScale(radius: number);
  108410. /**
  108411. * Gets the scale applied to the radius
  108412. */
  108413. get radiusScale(): number;
  108414. /**
  108415. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  108416. */
  108417. set positionScale(scale: number);
  108418. /**
  108419. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  108420. */
  108421. get positionScale(): number;
  108422. /**
  108423. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  108424. * behaviour is triggered, in radians.
  108425. */
  108426. set defaultElevation(elevation: number);
  108427. /**
  108428. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  108429. * behaviour is triggered, in radians.
  108430. */
  108431. get defaultElevation(): number;
  108432. /**
  108433. * Sets the time (in milliseconds) taken to return to the default beta position.
  108434. * Negative value indicates camera should not return to default.
  108435. */
  108436. set elevationReturnTime(speed: number);
  108437. /**
  108438. * Gets the time (in milliseconds) taken to return to the default beta position.
  108439. * Negative value indicates camera should not return to default.
  108440. */
  108441. get elevationReturnTime(): number;
  108442. /**
  108443. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  108444. */
  108445. set elevationReturnWaitTime(time: number);
  108446. /**
  108447. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  108448. */
  108449. get elevationReturnWaitTime(): number;
  108450. /**
  108451. * Sets the flag that indicates if user zooming should stop animation.
  108452. */
  108453. set zoomStopsAnimation(flag: boolean);
  108454. /**
  108455. * Gets the flag that indicates if user zooming should stop animation.
  108456. */
  108457. get zoomStopsAnimation(): boolean;
  108458. /**
  108459. * Sets the transition time when framing the mesh, in milliseconds
  108460. */
  108461. set framingTime(time: number);
  108462. /**
  108463. * Gets the transition time when framing the mesh, in milliseconds
  108464. */
  108465. get framingTime(): number;
  108466. /**
  108467. * Define if the behavior should automatically change the configured
  108468. * camera limits and sensibilities.
  108469. */
  108470. autoCorrectCameraLimitsAndSensibility: boolean;
  108471. private _onPrePointerObservableObserver;
  108472. private _onAfterCheckInputsObserver;
  108473. private _onMeshTargetChangedObserver;
  108474. private _attachedCamera;
  108475. private _isPointerDown;
  108476. private _lastInteractionTime;
  108477. /**
  108478. * Initializes the behavior.
  108479. */
  108480. init(): void;
  108481. /**
  108482. * Attaches the behavior to its arc rotate camera.
  108483. * @param camera Defines the camera to attach the behavior to
  108484. */
  108485. attach(camera: ArcRotateCamera): void;
  108486. /**
  108487. * Detaches the behavior from its current arc rotate camera.
  108488. */
  108489. detach(): void;
  108490. private _animatables;
  108491. private _betaIsAnimating;
  108492. private _betaTransition;
  108493. private _radiusTransition;
  108494. private _vectorTransition;
  108495. /**
  108496. * Targets the given mesh and updates zoom level accordingly.
  108497. * @param mesh The mesh to target.
  108498. * @param radius Optional. If a cached radius position already exists, overrides default.
  108499. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  108500. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  108501. * @param onAnimationEnd Callback triggered at the end of the framing animation
  108502. */
  108503. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  108504. /**
  108505. * Targets the given mesh with its children and updates zoom level accordingly.
  108506. * @param mesh The mesh to target.
  108507. * @param radius Optional. If a cached radius position already exists, overrides default.
  108508. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  108509. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  108510. * @param onAnimationEnd Callback triggered at the end of the framing animation
  108511. */
  108512. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  108513. /**
  108514. * Targets the given meshes with their children and updates zoom level accordingly.
  108515. * @param meshes The mesh to target.
  108516. * @param radius Optional. If a cached radius position already exists, overrides default.
  108517. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  108518. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  108519. * @param onAnimationEnd Callback triggered at the end of the framing animation
  108520. */
  108521. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  108522. /**
  108523. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  108524. * @param minimumWorld Determines the smaller position of the bounding box extend
  108525. * @param maximumWorld Determines the bigger position of the bounding box extend
  108526. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  108527. * @param onAnimationEnd Callback triggered at the end of the framing animation
  108528. */
  108529. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  108530. /**
  108531. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  108532. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  108533. * frustum width.
  108534. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  108535. * to fully enclose the mesh in the viewing frustum.
  108536. */
  108537. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  108538. /**
  108539. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  108540. * is automatically returned to its default position (expected to be above ground plane).
  108541. */
  108542. private _maintainCameraAboveGround;
  108543. /**
  108544. * Returns the frustum slope based on the canvas ratio and camera FOV
  108545. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  108546. */
  108547. private _getFrustumSlope;
  108548. /**
  108549. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  108550. */
  108551. private _clearAnimationLocks;
  108552. /**
  108553. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  108554. */
  108555. private _applyUserInteraction;
  108556. /**
  108557. * Stops and removes all animations that have been applied to the camera
  108558. */
  108559. stopAllAnimations(): void;
  108560. /**
  108561. * Gets a value indicating if the user is moving the camera
  108562. */
  108563. get isUserIsMoving(): boolean;
  108564. /**
  108565. * The camera can move all the way towards the mesh.
  108566. */
  108567. static IgnoreBoundsSizeMode: number;
  108568. /**
  108569. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  108570. */
  108571. static FitFrustumSidesMode: number;
  108572. }
  108573. }
  108574. declare module BABYLON {
  108575. /**
  108576. * Base class for Camera Pointer Inputs.
  108577. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  108578. * for example usage.
  108579. */
  108580. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  108581. /**
  108582. * Defines the camera the input is attached to.
  108583. */
  108584. abstract camera: Camera;
  108585. /**
  108586. * Whether keyboard modifier keys are pressed at time of last mouse event.
  108587. */
  108588. protected _altKey: boolean;
  108589. protected _ctrlKey: boolean;
  108590. protected _metaKey: boolean;
  108591. protected _shiftKey: boolean;
  108592. /**
  108593. * Which mouse buttons were pressed at time of last mouse event.
  108594. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  108595. */
  108596. protected _buttonsPressed: number;
  108597. /**
  108598. * Defines the buttons associated with the input to handle camera move.
  108599. */
  108600. buttons: number[];
  108601. /**
  108602. * Attach the input controls to a specific dom element to get the input from.
  108603. * @param element Defines the element the controls should be listened from
  108604. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108605. */
  108606. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108607. /**
  108608. * Detach the current controls from the specified dom element.
  108609. * @param element Defines the element to stop listening the inputs from
  108610. */
  108611. detachControl(element: Nullable<HTMLElement>): void;
  108612. /**
  108613. * Gets the class name of the current input.
  108614. * @returns the class name
  108615. */
  108616. getClassName(): string;
  108617. /**
  108618. * Get the friendly name associated with the input class.
  108619. * @returns the input friendly name
  108620. */
  108621. getSimpleName(): string;
  108622. /**
  108623. * Called on pointer POINTERDOUBLETAP event.
  108624. * Override this method to provide functionality on POINTERDOUBLETAP event.
  108625. */
  108626. protected onDoubleTap(type: string): void;
  108627. /**
  108628. * Called on pointer POINTERMOVE event if only a single touch is active.
  108629. * Override this method to provide functionality.
  108630. */
  108631. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  108632. /**
  108633. * Called on pointer POINTERMOVE event if multiple touches are active.
  108634. * Override this method to provide functionality.
  108635. */
  108636. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  108637. /**
  108638. * Called on JS contextmenu event.
  108639. * Override this method to provide functionality.
  108640. */
  108641. protected onContextMenu(evt: PointerEvent): void;
  108642. /**
  108643. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  108644. * press.
  108645. * Override this method to provide functionality.
  108646. */
  108647. protected onButtonDown(evt: PointerEvent): void;
  108648. /**
  108649. * Called each time a new POINTERUP event occurs. Ie, for each button
  108650. * release.
  108651. * Override this method to provide functionality.
  108652. */
  108653. protected onButtonUp(evt: PointerEvent): void;
  108654. /**
  108655. * Called when window becomes inactive.
  108656. * Override this method to provide functionality.
  108657. */
  108658. protected onLostFocus(): void;
  108659. private _pointerInput;
  108660. private _observer;
  108661. private _onLostFocus;
  108662. private pointA;
  108663. private pointB;
  108664. }
  108665. }
  108666. declare module BABYLON {
  108667. /**
  108668. * Manage the pointers inputs to control an arc rotate camera.
  108669. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108670. */
  108671. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  108672. /**
  108673. * Defines the camera the input is attached to.
  108674. */
  108675. camera: ArcRotateCamera;
  108676. /**
  108677. * Gets the class name of the current input.
  108678. * @returns the class name
  108679. */
  108680. getClassName(): string;
  108681. /**
  108682. * Defines the buttons associated with the input to handle camera move.
  108683. */
  108684. buttons: number[];
  108685. /**
  108686. * Defines the pointer angular sensibility along the X axis or how fast is
  108687. * the camera rotating.
  108688. */
  108689. angularSensibilityX: number;
  108690. /**
  108691. * Defines the pointer angular sensibility along the Y axis or how fast is
  108692. * the camera rotating.
  108693. */
  108694. angularSensibilityY: number;
  108695. /**
  108696. * Defines the pointer pinch precision or how fast is the camera zooming.
  108697. */
  108698. pinchPrecision: number;
  108699. /**
  108700. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  108701. * from 0.
  108702. * It defines the percentage of current camera.radius to use as delta when
  108703. * pinch zoom is used.
  108704. */
  108705. pinchDeltaPercentage: number;
  108706. /**
  108707. * Defines the pointer panning sensibility or how fast is the camera moving.
  108708. */
  108709. panningSensibility: number;
  108710. /**
  108711. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  108712. */
  108713. multiTouchPanning: boolean;
  108714. /**
  108715. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  108716. * zoom (pinch) through multitouch.
  108717. */
  108718. multiTouchPanAndZoom: boolean;
  108719. /**
  108720. * Revers pinch action direction.
  108721. */
  108722. pinchInwards: boolean;
  108723. private _isPanClick;
  108724. private _twoFingerActivityCount;
  108725. private _isPinching;
  108726. /**
  108727. * Called on pointer POINTERMOVE event if only a single touch is active.
  108728. */
  108729. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  108730. /**
  108731. * Called on pointer POINTERDOUBLETAP event.
  108732. */
  108733. protected onDoubleTap(type: string): void;
  108734. /**
  108735. * Called on pointer POINTERMOVE event if multiple touches are active.
  108736. */
  108737. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  108738. /**
  108739. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  108740. * press.
  108741. */
  108742. protected onButtonDown(evt: PointerEvent): void;
  108743. /**
  108744. * Called each time a new POINTERUP event occurs. Ie, for each button
  108745. * release.
  108746. */
  108747. protected onButtonUp(evt: PointerEvent): void;
  108748. /**
  108749. * Called when window becomes inactive.
  108750. */
  108751. protected onLostFocus(): void;
  108752. }
  108753. }
  108754. declare module BABYLON {
  108755. /**
  108756. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  108757. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108758. */
  108759. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  108760. /**
  108761. * Defines the camera the input is attached to.
  108762. */
  108763. camera: ArcRotateCamera;
  108764. /**
  108765. * Defines the list of key codes associated with the up action (increase alpha)
  108766. */
  108767. keysUp: number[];
  108768. /**
  108769. * Defines the list of key codes associated with the down action (decrease alpha)
  108770. */
  108771. keysDown: number[];
  108772. /**
  108773. * Defines the list of key codes associated with the left action (increase beta)
  108774. */
  108775. keysLeft: number[];
  108776. /**
  108777. * Defines the list of key codes associated with the right action (decrease beta)
  108778. */
  108779. keysRight: number[];
  108780. /**
  108781. * Defines the list of key codes associated with the reset action.
  108782. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  108783. */
  108784. keysReset: number[];
  108785. /**
  108786. * Defines the panning sensibility of the inputs.
  108787. * (How fast is the camera paning)
  108788. */
  108789. panningSensibility: number;
  108790. /**
  108791. * Defines the zooming sensibility of the inputs.
  108792. * (How fast is the camera zooming)
  108793. */
  108794. zoomingSensibility: number;
  108795. /**
  108796. * Defines wether maintaining the alt key down switch the movement mode from
  108797. * orientation to zoom.
  108798. */
  108799. useAltToZoom: boolean;
  108800. /**
  108801. * Rotation speed of the camera
  108802. */
  108803. angularSpeed: number;
  108804. private _keys;
  108805. private _ctrlPressed;
  108806. private _altPressed;
  108807. private _onCanvasBlurObserver;
  108808. private _onKeyboardObserver;
  108809. private _engine;
  108810. private _scene;
  108811. /**
  108812. * Attach the input controls to a specific dom element to get the input from.
  108813. * @param element Defines the element the controls should be listened from
  108814. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108815. */
  108816. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108817. /**
  108818. * Detach the current controls from the specified dom element.
  108819. * @param element Defines the element to stop listening the inputs from
  108820. */
  108821. detachControl(element: Nullable<HTMLElement>): void;
  108822. /**
  108823. * Update the current camera state depending on the inputs that have been used this frame.
  108824. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108825. */
  108826. checkInputs(): void;
  108827. /**
  108828. * Gets the class name of the current intput.
  108829. * @returns the class name
  108830. */
  108831. getClassName(): string;
  108832. /**
  108833. * Get the friendly name associated with the input class.
  108834. * @returns the input friendly name
  108835. */
  108836. getSimpleName(): string;
  108837. }
  108838. }
  108839. declare module BABYLON {
  108840. /**
  108841. * Manage the mouse wheel inputs to control an arc rotate camera.
  108842. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108843. */
  108844. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  108845. /**
  108846. * Defines the camera the input is attached to.
  108847. */
  108848. camera: ArcRotateCamera;
  108849. /**
  108850. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  108851. */
  108852. wheelPrecision: number;
  108853. /**
  108854. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  108855. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  108856. */
  108857. wheelDeltaPercentage: number;
  108858. private _wheel;
  108859. private _observer;
  108860. private computeDeltaFromMouseWheelLegacyEvent;
  108861. /**
  108862. * Attach the input controls to a specific dom element to get the input from.
  108863. * @param element Defines the element the controls should be listened from
  108864. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108865. */
  108866. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108867. /**
  108868. * Detach the current controls from the specified dom element.
  108869. * @param element Defines the element to stop listening the inputs from
  108870. */
  108871. detachControl(element: Nullable<HTMLElement>): void;
  108872. /**
  108873. * Gets the class name of the current intput.
  108874. * @returns the class name
  108875. */
  108876. getClassName(): string;
  108877. /**
  108878. * Get the friendly name associated with the input class.
  108879. * @returns the input friendly name
  108880. */
  108881. getSimpleName(): string;
  108882. }
  108883. }
  108884. declare module BABYLON {
  108885. /**
  108886. * Default Inputs manager for the ArcRotateCamera.
  108887. * It groups all the default supported inputs for ease of use.
  108888. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108889. */
  108890. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  108891. /**
  108892. * Instantiates a new ArcRotateCameraInputsManager.
  108893. * @param camera Defines the camera the inputs belong to
  108894. */
  108895. constructor(camera: ArcRotateCamera);
  108896. /**
  108897. * Add mouse wheel input support to the input manager.
  108898. * @returns the current input manager
  108899. */
  108900. addMouseWheel(): ArcRotateCameraInputsManager;
  108901. /**
  108902. * Add pointers input support to the input manager.
  108903. * @returns the current input manager
  108904. */
  108905. addPointers(): ArcRotateCameraInputsManager;
  108906. /**
  108907. * Add keyboard input support to the input manager.
  108908. * @returns the current input manager
  108909. */
  108910. addKeyboard(): ArcRotateCameraInputsManager;
  108911. }
  108912. }
  108913. declare module BABYLON {
  108914. /**
  108915. * This represents an orbital type of camera.
  108916. *
  108917. * 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.
  108918. * 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.
  108919. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  108920. */
  108921. export class ArcRotateCamera extends TargetCamera {
  108922. /**
  108923. * Defines the rotation angle of the camera along the longitudinal axis.
  108924. */
  108925. alpha: number;
  108926. /**
  108927. * Defines the rotation angle of the camera along the latitudinal axis.
  108928. */
  108929. beta: number;
  108930. /**
  108931. * Defines the radius of the camera from it s target point.
  108932. */
  108933. radius: number;
  108934. protected _target: Vector3;
  108935. protected _targetHost: Nullable<AbstractMesh>;
  108936. /**
  108937. * Defines the target point of the camera.
  108938. * The camera looks towards it form the radius distance.
  108939. */
  108940. get target(): Vector3;
  108941. set target(value: Vector3);
  108942. /**
  108943. * Define the current local position of the camera in the scene
  108944. */
  108945. get position(): Vector3;
  108946. set position(newPosition: Vector3);
  108947. protected _upVector: Vector3;
  108948. protected _upToYMatrix: Matrix;
  108949. protected _YToUpMatrix: Matrix;
  108950. /**
  108951. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  108952. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  108953. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  108954. */
  108955. set upVector(vec: Vector3);
  108956. get upVector(): Vector3;
  108957. /**
  108958. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  108959. */
  108960. setMatUp(): void;
  108961. /**
  108962. * Current inertia value on the longitudinal axis.
  108963. * The bigger this number the longer it will take for the camera to stop.
  108964. */
  108965. inertialAlphaOffset: number;
  108966. /**
  108967. * Current inertia value on the latitudinal axis.
  108968. * The bigger this number the longer it will take for the camera to stop.
  108969. */
  108970. inertialBetaOffset: number;
  108971. /**
  108972. * Current inertia value on the radius axis.
  108973. * The bigger this number the longer it will take for the camera to stop.
  108974. */
  108975. inertialRadiusOffset: number;
  108976. /**
  108977. * Minimum allowed angle on the longitudinal axis.
  108978. * This can help limiting how the Camera is able to move in the scene.
  108979. */
  108980. lowerAlphaLimit: Nullable<number>;
  108981. /**
  108982. * Maximum allowed angle on the longitudinal axis.
  108983. * This can help limiting how the Camera is able to move in the scene.
  108984. */
  108985. upperAlphaLimit: Nullable<number>;
  108986. /**
  108987. * Minimum allowed angle on the latitudinal axis.
  108988. * This can help limiting how the Camera is able to move in the scene.
  108989. */
  108990. lowerBetaLimit: number;
  108991. /**
  108992. * Maximum allowed angle on the latitudinal axis.
  108993. * This can help limiting how the Camera is able to move in the scene.
  108994. */
  108995. upperBetaLimit: number;
  108996. /**
  108997. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  108998. * This can help limiting how the Camera is able to move in the scene.
  108999. */
  109000. lowerRadiusLimit: Nullable<number>;
  109001. /**
  109002. * Maximum allowed distance of the camera to the target (The camera can not get further).
  109003. * This can help limiting how the Camera is able to move in the scene.
  109004. */
  109005. upperRadiusLimit: Nullable<number>;
  109006. /**
  109007. * Defines the current inertia value used during panning of the camera along the X axis.
  109008. */
  109009. inertialPanningX: number;
  109010. /**
  109011. * Defines the current inertia value used during panning of the camera along the Y axis.
  109012. */
  109013. inertialPanningY: number;
  109014. /**
  109015. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  109016. * Basically if your fingers moves away from more than this distance you will be considered
  109017. * in pinch mode.
  109018. */
  109019. pinchToPanMaxDistance: number;
  109020. /**
  109021. * Defines the maximum distance the camera can pan.
  109022. * This could help keeping the cammera always in your scene.
  109023. */
  109024. panningDistanceLimit: Nullable<number>;
  109025. /**
  109026. * Defines the target of the camera before paning.
  109027. */
  109028. panningOriginTarget: Vector3;
  109029. /**
  109030. * Defines the value of the inertia used during panning.
  109031. * 0 would mean stop inertia and one would mean no decelleration at all.
  109032. */
  109033. panningInertia: number;
  109034. /**
  109035. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  109036. */
  109037. get angularSensibilityX(): number;
  109038. set angularSensibilityX(value: number);
  109039. /**
  109040. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  109041. */
  109042. get angularSensibilityY(): number;
  109043. set angularSensibilityY(value: number);
  109044. /**
  109045. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  109046. */
  109047. get pinchPrecision(): number;
  109048. set pinchPrecision(value: number);
  109049. /**
  109050. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  109051. * It will be used instead of pinchDeltaPrecision if different from 0.
  109052. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  109053. */
  109054. get pinchDeltaPercentage(): number;
  109055. set pinchDeltaPercentage(value: number);
  109056. /**
  109057. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  109058. */
  109059. get panningSensibility(): number;
  109060. set panningSensibility(value: number);
  109061. /**
  109062. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  109063. */
  109064. get keysUp(): number[];
  109065. set keysUp(value: number[]);
  109066. /**
  109067. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  109068. */
  109069. get keysDown(): number[];
  109070. set keysDown(value: number[]);
  109071. /**
  109072. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  109073. */
  109074. get keysLeft(): number[];
  109075. set keysLeft(value: number[]);
  109076. /**
  109077. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  109078. */
  109079. get keysRight(): number[];
  109080. set keysRight(value: number[]);
  109081. /**
  109082. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  109083. */
  109084. get wheelPrecision(): number;
  109085. set wheelPrecision(value: number);
  109086. /**
  109087. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  109088. * It will be used instead of pinchDeltaPrecision if different from 0.
  109089. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  109090. */
  109091. get wheelDeltaPercentage(): number;
  109092. set wheelDeltaPercentage(value: number);
  109093. /**
  109094. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  109095. */
  109096. zoomOnFactor: number;
  109097. /**
  109098. * Defines a screen offset for the camera position.
  109099. */
  109100. targetScreenOffset: Vector2;
  109101. /**
  109102. * Allows the camera to be completely reversed.
  109103. * If false the camera can not arrive upside down.
  109104. */
  109105. allowUpsideDown: boolean;
  109106. /**
  109107. * Define if double tap/click is used to restore the previously saved state of the camera.
  109108. */
  109109. useInputToRestoreState: boolean;
  109110. /** @hidden */
  109111. _viewMatrix: Matrix;
  109112. /** @hidden */
  109113. _useCtrlForPanning: boolean;
  109114. /** @hidden */
  109115. _panningMouseButton: number;
  109116. /**
  109117. * Defines the input associated to the camera.
  109118. */
  109119. inputs: ArcRotateCameraInputsManager;
  109120. /** @hidden */
  109121. _reset: () => void;
  109122. /**
  109123. * Defines the allowed panning axis.
  109124. */
  109125. panningAxis: Vector3;
  109126. protected _localDirection: Vector3;
  109127. protected _transformedDirection: Vector3;
  109128. private _bouncingBehavior;
  109129. /**
  109130. * Gets the bouncing behavior of the camera if it has been enabled.
  109131. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  109132. */
  109133. get bouncingBehavior(): Nullable<BouncingBehavior>;
  109134. /**
  109135. * Defines if the bouncing behavior of the camera is enabled on the camera.
  109136. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  109137. */
  109138. get useBouncingBehavior(): boolean;
  109139. set useBouncingBehavior(value: boolean);
  109140. private _framingBehavior;
  109141. /**
  109142. * Gets the framing behavior of the camera if it has been enabled.
  109143. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  109144. */
  109145. get framingBehavior(): Nullable<FramingBehavior>;
  109146. /**
  109147. * Defines if the framing behavior of the camera is enabled on the camera.
  109148. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  109149. */
  109150. get useFramingBehavior(): boolean;
  109151. set useFramingBehavior(value: boolean);
  109152. private _autoRotationBehavior;
  109153. /**
  109154. * Gets the auto rotation behavior of the camera if it has been enabled.
  109155. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  109156. */
  109157. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  109158. /**
  109159. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  109160. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  109161. */
  109162. get useAutoRotationBehavior(): boolean;
  109163. set useAutoRotationBehavior(value: boolean);
  109164. /**
  109165. * Observable triggered when the mesh target has been changed on the camera.
  109166. */
  109167. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  109168. /**
  109169. * Event raised when the camera is colliding with a mesh.
  109170. */
  109171. onCollide: (collidedMesh: AbstractMesh) => void;
  109172. /**
  109173. * Defines whether the camera should check collision with the objects oh the scene.
  109174. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  109175. */
  109176. checkCollisions: boolean;
  109177. /**
  109178. * Defines the collision radius of the camera.
  109179. * This simulates a sphere around the camera.
  109180. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  109181. */
  109182. collisionRadius: Vector3;
  109183. protected _collider: Collider;
  109184. protected _previousPosition: Vector3;
  109185. protected _collisionVelocity: Vector3;
  109186. protected _newPosition: Vector3;
  109187. protected _previousAlpha: number;
  109188. protected _previousBeta: number;
  109189. protected _previousRadius: number;
  109190. protected _collisionTriggered: boolean;
  109191. protected _targetBoundingCenter: Nullable<Vector3>;
  109192. private _computationVector;
  109193. /**
  109194. * Instantiates a new ArcRotateCamera in a given scene
  109195. * @param name Defines the name of the camera
  109196. * @param alpha Defines the camera rotation along the logitudinal axis
  109197. * @param beta Defines the camera rotation along the latitudinal axis
  109198. * @param radius Defines the camera distance from its target
  109199. * @param target Defines the camera target
  109200. * @param scene Defines the scene the camera belongs to
  109201. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  109202. */
  109203. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  109204. /** @hidden */
  109205. _initCache(): void;
  109206. /** @hidden */
  109207. _updateCache(ignoreParentClass?: boolean): void;
  109208. protected _getTargetPosition(): Vector3;
  109209. private _storedAlpha;
  109210. private _storedBeta;
  109211. private _storedRadius;
  109212. private _storedTarget;
  109213. private _storedTargetScreenOffset;
  109214. /**
  109215. * Stores the current state of the camera (alpha, beta, radius and target)
  109216. * @returns the camera itself
  109217. */
  109218. storeState(): Camera;
  109219. /**
  109220. * @hidden
  109221. * Restored camera state. You must call storeState() first
  109222. */
  109223. _restoreStateValues(): boolean;
  109224. /** @hidden */
  109225. _isSynchronizedViewMatrix(): boolean;
  109226. /**
  109227. * Attached controls to the current camera.
  109228. * @param element Defines the element the controls should be listened from
  109229. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109230. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  109231. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  109232. */
  109233. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  109234. /**
  109235. * Detach the current controls from the camera.
  109236. * The camera will stop reacting to inputs.
  109237. * @param element Defines the element to stop listening the inputs from
  109238. */
  109239. detachControl(element: HTMLElement): void;
  109240. /** @hidden */
  109241. _checkInputs(): void;
  109242. protected _checkLimits(): void;
  109243. /**
  109244. * Rebuilds angles (alpha, beta) and radius from the give position and target
  109245. */
  109246. rebuildAnglesAndRadius(): void;
  109247. /**
  109248. * Use a position to define the current camera related information like alpha, beta and radius
  109249. * @param position Defines the position to set the camera at
  109250. */
  109251. setPosition(position: Vector3): void;
  109252. /**
  109253. * Defines the target the camera should look at.
  109254. * This will automatically adapt alpha beta and radius to fit within the new target.
  109255. * @param target Defines the new target as a Vector or a mesh
  109256. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  109257. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  109258. */
  109259. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  109260. /** @hidden */
  109261. _getViewMatrix(): Matrix;
  109262. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  109263. /**
  109264. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  109265. * @param meshes Defines the mesh to zoom on
  109266. * @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)
  109267. */
  109268. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  109269. /**
  109270. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  109271. * The target will be changed but the radius
  109272. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  109273. * @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)
  109274. */
  109275. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  109276. min: Vector3;
  109277. max: Vector3;
  109278. distance: number;
  109279. }, doNotUpdateMaxZ?: boolean): void;
  109280. /**
  109281. * @override
  109282. * Override Camera.createRigCamera
  109283. */
  109284. createRigCamera(name: string, cameraIndex: number): Camera;
  109285. /**
  109286. * @hidden
  109287. * @override
  109288. * Override Camera._updateRigCameras
  109289. */
  109290. _updateRigCameras(): void;
  109291. /**
  109292. * Destroy the camera and release the current resources hold by it.
  109293. */
  109294. dispose(): void;
  109295. /**
  109296. * Gets the current object class name.
  109297. * @return the class name
  109298. */
  109299. getClassName(): string;
  109300. }
  109301. }
  109302. declare module BABYLON {
  109303. /**
  109304. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  109305. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  109306. */
  109307. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  109308. /**
  109309. * Gets the name of the behavior.
  109310. */
  109311. get name(): string;
  109312. private _zoomStopsAnimation;
  109313. private _idleRotationSpeed;
  109314. private _idleRotationWaitTime;
  109315. private _idleRotationSpinupTime;
  109316. /**
  109317. * Sets the flag that indicates if user zooming should stop animation.
  109318. */
  109319. set zoomStopsAnimation(flag: boolean);
  109320. /**
  109321. * Gets the flag that indicates if user zooming should stop animation.
  109322. */
  109323. get zoomStopsAnimation(): boolean;
  109324. /**
  109325. * Sets the default speed at which the camera rotates around the model.
  109326. */
  109327. set idleRotationSpeed(speed: number);
  109328. /**
  109329. * Gets the default speed at which the camera rotates around the model.
  109330. */
  109331. get idleRotationSpeed(): number;
  109332. /**
  109333. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  109334. */
  109335. set idleRotationWaitTime(time: number);
  109336. /**
  109337. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  109338. */
  109339. get idleRotationWaitTime(): number;
  109340. /**
  109341. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  109342. */
  109343. set idleRotationSpinupTime(time: number);
  109344. /**
  109345. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  109346. */
  109347. get idleRotationSpinupTime(): number;
  109348. /**
  109349. * Gets a value indicating if the camera is currently rotating because of this behavior
  109350. */
  109351. get rotationInProgress(): boolean;
  109352. private _onPrePointerObservableObserver;
  109353. private _onAfterCheckInputsObserver;
  109354. private _attachedCamera;
  109355. private _isPointerDown;
  109356. private _lastFrameTime;
  109357. private _lastInteractionTime;
  109358. private _cameraRotationSpeed;
  109359. /**
  109360. * Initializes the behavior.
  109361. */
  109362. init(): void;
  109363. /**
  109364. * Attaches the behavior to its arc rotate camera.
  109365. * @param camera Defines the camera to attach the behavior to
  109366. */
  109367. attach(camera: ArcRotateCamera): void;
  109368. /**
  109369. * Detaches the behavior from its current arc rotate camera.
  109370. */
  109371. detach(): void;
  109372. /**
  109373. * Returns true if user is scrolling.
  109374. * @return true if user is scrolling.
  109375. */
  109376. private _userIsZooming;
  109377. private _lastFrameRadius;
  109378. private _shouldAnimationStopForInteraction;
  109379. /**
  109380. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  109381. */
  109382. private _applyUserInteraction;
  109383. private _userIsMoving;
  109384. }
  109385. }
  109386. declare module BABYLON {
  109387. /**
  109388. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  109389. */
  109390. export class AttachToBoxBehavior implements Behavior<Mesh> {
  109391. private ui;
  109392. /**
  109393. * The name of the behavior
  109394. */
  109395. name: string;
  109396. /**
  109397. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  109398. */
  109399. distanceAwayFromFace: number;
  109400. /**
  109401. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  109402. */
  109403. distanceAwayFromBottomOfFace: number;
  109404. private _faceVectors;
  109405. private _target;
  109406. private _scene;
  109407. private _onRenderObserver;
  109408. private _tmpMatrix;
  109409. private _tmpVector;
  109410. /**
  109411. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  109412. * @param ui The transform node that should be attched to the mesh
  109413. */
  109414. constructor(ui: TransformNode);
  109415. /**
  109416. * Initializes the behavior
  109417. */
  109418. init(): void;
  109419. private _closestFace;
  109420. private _zeroVector;
  109421. private _lookAtTmpMatrix;
  109422. private _lookAtToRef;
  109423. /**
  109424. * Attaches the AttachToBoxBehavior to the passed in mesh
  109425. * @param target The mesh that the specified node will be attached to
  109426. */
  109427. attach(target: Mesh): void;
  109428. /**
  109429. * Detaches the behavior from the mesh
  109430. */
  109431. detach(): void;
  109432. }
  109433. }
  109434. declare module BABYLON {
  109435. /**
  109436. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  109437. */
  109438. export class FadeInOutBehavior implements Behavior<Mesh> {
  109439. /**
  109440. * Time in milliseconds to delay before fading in (Default: 0)
  109441. */
  109442. delay: number;
  109443. /**
  109444. * Time in milliseconds for the mesh to fade in (Default: 300)
  109445. */
  109446. fadeInTime: number;
  109447. private _millisecondsPerFrame;
  109448. private _hovered;
  109449. private _hoverValue;
  109450. private _ownerNode;
  109451. /**
  109452. * Instatiates the FadeInOutBehavior
  109453. */
  109454. constructor();
  109455. /**
  109456. * The name of the behavior
  109457. */
  109458. get name(): string;
  109459. /**
  109460. * Initializes the behavior
  109461. */
  109462. init(): void;
  109463. /**
  109464. * Attaches the fade behavior on the passed in mesh
  109465. * @param ownerNode The mesh that will be faded in/out once attached
  109466. */
  109467. attach(ownerNode: Mesh): void;
  109468. /**
  109469. * Detaches the behavior from the mesh
  109470. */
  109471. detach(): void;
  109472. /**
  109473. * Triggers the mesh to begin fading in or out
  109474. * @param value if the object should fade in or out (true to fade in)
  109475. */
  109476. fadeIn(value: boolean): void;
  109477. private _update;
  109478. private _setAllVisibility;
  109479. }
  109480. }
  109481. declare module BABYLON {
  109482. /**
  109483. * Class containing a set of static utilities functions for managing Pivots
  109484. * @hidden
  109485. */
  109486. export class PivotTools {
  109487. private static _PivotCached;
  109488. private static _OldPivotPoint;
  109489. private static _PivotTranslation;
  109490. private static _PivotTmpVector;
  109491. /** @hidden */
  109492. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  109493. /** @hidden */
  109494. static _RestorePivotPoint(mesh: AbstractMesh): void;
  109495. }
  109496. }
  109497. declare module BABYLON {
  109498. /**
  109499. * Class containing static functions to help procedurally build meshes
  109500. */
  109501. export class PlaneBuilder {
  109502. /**
  109503. * Creates a plane mesh
  109504. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  109505. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  109506. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  109507. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109508. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109510. * @param name defines the name of the mesh
  109511. * @param options defines the options used to create the mesh
  109512. * @param scene defines the hosting scene
  109513. * @returns the plane mesh
  109514. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  109515. */
  109516. static CreatePlane(name: string, options: {
  109517. size?: number;
  109518. width?: number;
  109519. height?: number;
  109520. sideOrientation?: number;
  109521. frontUVs?: Vector4;
  109522. backUVs?: Vector4;
  109523. updatable?: boolean;
  109524. sourcePlane?: Plane;
  109525. }, scene?: Nullable<Scene>): Mesh;
  109526. }
  109527. }
  109528. declare module BABYLON {
  109529. /**
  109530. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  109531. */
  109532. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  109533. private static _AnyMouseID;
  109534. /**
  109535. * Abstract mesh the behavior is set on
  109536. */
  109537. attachedNode: AbstractMesh;
  109538. private _dragPlane;
  109539. private _scene;
  109540. private _pointerObserver;
  109541. private _beforeRenderObserver;
  109542. private static _planeScene;
  109543. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  109544. /**
  109545. * 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)
  109546. */
  109547. maxDragAngle: number;
  109548. /**
  109549. * @hidden
  109550. */
  109551. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  109552. /**
  109553. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  109554. */
  109555. currentDraggingPointerID: number;
  109556. /**
  109557. * The last position where the pointer hit the drag plane in world space
  109558. */
  109559. lastDragPosition: Vector3;
  109560. /**
  109561. * If the behavior is currently in a dragging state
  109562. */
  109563. dragging: boolean;
  109564. /**
  109565. * 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)
  109566. */
  109567. dragDeltaRatio: number;
  109568. /**
  109569. * If the drag plane orientation should be updated during the dragging (Default: true)
  109570. */
  109571. updateDragPlane: boolean;
  109572. private _debugMode;
  109573. private _moving;
  109574. /**
  109575. * Fires each time the attached mesh is dragged with the pointer
  109576. * * delta between last drag position and current drag position in world space
  109577. * * dragDistance along the drag axis
  109578. * * dragPlaneNormal normal of the current drag plane used during the drag
  109579. * * dragPlanePoint in world space where the drag intersects the drag plane
  109580. */
  109581. onDragObservable: Observable<{
  109582. delta: Vector3;
  109583. dragPlanePoint: Vector3;
  109584. dragPlaneNormal: Vector3;
  109585. dragDistance: number;
  109586. pointerId: number;
  109587. }>;
  109588. /**
  109589. * Fires each time a drag begins (eg. mouse down on mesh)
  109590. */
  109591. onDragStartObservable: Observable<{
  109592. dragPlanePoint: Vector3;
  109593. pointerId: number;
  109594. }>;
  109595. /**
  109596. * Fires each time a drag ends (eg. mouse release after drag)
  109597. */
  109598. onDragEndObservable: Observable<{
  109599. dragPlanePoint: Vector3;
  109600. pointerId: number;
  109601. }>;
  109602. /**
  109603. * If the attached mesh should be moved when dragged
  109604. */
  109605. moveAttached: boolean;
  109606. /**
  109607. * If the drag behavior will react to drag events (Default: true)
  109608. */
  109609. enabled: boolean;
  109610. /**
  109611. * If pointer events should start and release the drag (Default: true)
  109612. */
  109613. startAndReleaseDragOnPointerEvents: boolean;
  109614. /**
  109615. * If camera controls should be detached during the drag
  109616. */
  109617. detachCameraControls: boolean;
  109618. /**
  109619. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  109620. */
  109621. useObjectOrienationForDragging: boolean;
  109622. private _options;
  109623. /**
  109624. * Gets the options used by the behavior
  109625. */
  109626. get options(): {
  109627. dragAxis?: Vector3;
  109628. dragPlaneNormal?: Vector3;
  109629. };
  109630. /**
  109631. * Sets the options used by the behavior
  109632. */
  109633. set options(options: {
  109634. dragAxis?: Vector3;
  109635. dragPlaneNormal?: Vector3;
  109636. });
  109637. /**
  109638. * Creates a pointer drag behavior that can be attached to a mesh
  109639. * @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)
  109640. */
  109641. constructor(options?: {
  109642. dragAxis?: Vector3;
  109643. dragPlaneNormal?: Vector3;
  109644. });
  109645. /**
  109646. * Predicate to determine if it is valid to move the object to a new position when it is moved
  109647. */
  109648. validateDrag: (targetPosition: Vector3) => boolean;
  109649. /**
  109650. * The name of the behavior
  109651. */
  109652. get name(): string;
  109653. /**
  109654. * Initializes the behavior
  109655. */
  109656. init(): void;
  109657. private _tmpVector;
  109658. private _alternatePickedPoint;
  109659. private _worldDragAxis;
  109660. private _targetPosition;
  109661. private _attachedElement;
  109662. /**
  109663. * Attaches the drag behavior the passed in mesh
  109664. * @param ownerNode The mesh that will be dragged around once attached
  109665. * @param predicate Predicate to use for pick filtering
  109666. */
  109667. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  109668. /**
  109669. * Force relase the drag action by code.
  109670. */
  109671. releaseDrag(): void;
  109672. private _startDragRay;
  109673. private _lastPointerRay;
  109674. /**
  109675. * Simulates the start of a pointer drag event on the behavior
  109676. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  109677. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  109678. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  109679. */
  109680. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  109681. private _startDrag;
  109682. private _dragDelta;
  109683. private _moveDrag;
  109684. private _pickWithRayOnDragPlane;
  109685. private _pointA;
  109686. private _pointB;
  109687. private _pointC;
  109688. private _lineA;
  109689. private _lineB;
  109690. private _localAxis;
  109691. private _lookAt;
  109692. private _updateDragPlanePosition;
  109693. /**
  109694. * Detaches the behavior from the mesh
  109695. */
  109696. detach(): void;
  109697. }
  109698. }
  109699. declare module BABYLON {
  109700. /**
  109701. * A behavior that when attached to a mesh will allow the mesh to be scaled
  109702. */
  109703. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  109704. private _dragBehaviorA;
  109705. private _dragBehaviorB;
  109706. private _startDistance;
  109707. private _initialScale;
  109708. private _targetScale;
  109709. private _ownerNode;
  109710. private _sceneRenderObserver;
  109711. /**
  109712. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  109713. */
  109714. constructor();
  109715. /**
  109716. * The name of the behavior
  109717. */
  109718. get name(): string;
  109719. /**
  109720. * Initializes the behavior
  109721. */
  109722. init(): void;
  109723. private _getCurrentDistance;
  109724. /**
  109725. * Attaches the scale behavior the passed in mesh
  109726. * @param ownerNode The mesh that will be scaled around once attached
  109727. */
  109728. attach(ownerNode: Mesh): void;
  109729. /**
  109730. * Detaches the behavior from the mesh
  109731. */
  109732. detach(): void;
  109733. }
  109734. }
  109735. declare module BABYLON {
  109736. /**
  109737. * 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
  109738. */
  109739. export class SixDofDragBehavior implements Behavior<Mesh> {
  109740. private static _virtualScene;
  109741. private _ownerNode;
  109742. private _sceneRenderObserver;
  109743. private _scene;
  109744. private _targetPosition;
  109745. private _virtualOriginMesh;
  109746. private _virtualDragMesh;
  109747. private _pointerObserver;
  109748. private _moving;
  109749. private _startingOrientation;
  109750. /**
  109751. * 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)
  109752. */
  109753. private zDragFactor;
  109754. /**
  109755. * If the object should rotate to face the drag origin
  109756. */
  109757. rotateDraggedObject: boolean;
  109758. /**
  109759. * If the behavior is currently in a dragging state
  109760. */
  109761. dragging: boolean;
  109762. /**
  109763. * 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)
  109764. */
  109765. dragDeltaRatio: number;
  109766. /**
  109767. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  109768. */
  109769. currentDraggingPointerID: number;
  109770. /**
  109771. * If camera controls should be detached during the drag
  109772. */
  109773. detachCameraControls: boolean;
  109774. /**
  109775. * Fires each time a drag starts
  109776. */
  109777. onDragStartObservable: Observable<{}>;
  109778. /**
  109779. * Fires each time a drag ends (eg. mouse release after drag)
  109780. */
  109781. onDragEndObservable: Observable<{}>;
  109782. /**
  109783. * 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
  109784. */
  109785. constructor();
  109786. /**
  109787. * The name of the behavior
  109788. */
  109789. get name(): string;
  109790. /**
  109791. * Initializes the behavior
  109792. */
  109793. init(): void;
  109794. /**
  109795. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  109796. */
  109797. private get _pointerCamera();
  109798. /**
  109799. * Attaches the scale behavior the passed in mesh
  109800. * @param ownerNode The mesh that will be scaled around once attached
  109801. */
  109802. attach(ownerNode: Mesh): void;
  109803. /**
  109804. * Detaches the behavior from the mesh
  109805. */
  109806. detach(): void;
  109807. }
  109808. }
  109809. declare module BABYLON {
  109810. /**
  109811. * Class used to apply inverse kinematics to bones
  109812. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  109813. */
  109814. export class BoneIKController {
  109815. private static _tmpVecs;
  109816. private static _tmpQuat;
  109817. private static _tmpMats;
  109818. /**
  109819. * Gets or sets the target mesh
  109820. */
  109821. targetMesh: AbstractMesh;
  109822. /** Gets or sets the mesh used as pole */
  109823. poleTargetMesh: AbstractMesh;
  109824. /**
  109825. * Gets or sets the bone used as pole
  109826. */
  109827. poleTargetBone: Nullable<Bone>;
  109828. /**
  109829. * Gets or sets the target position
  109830. */
  109831. targetPosition: Vector3;
  109832. /**
  109833. * Gets or sets the pole target position
  109834. */
  109835. poleTargetPosition: Vector3;
  109836. /**
  109837. * Gets or sets the pole target local offset
  109838. */
  109839. poleTargetLocalOffset: Vector3;
  109840. /**
  109841. * Gets or sets the pole angle
  109842. */
  109843. poleAngle: number;
  109844. /**
  109845. * Gets or sets the mesh associated with the controller
  109846. */
  109847. mesh: AbstractMesh;
  109848. /**
  109849. * 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)
  109850. */
  109851. slerpAmount: number;
  109852. private _bone1Quat;
  109853. private _bone1Mat;
  109854. private _bone2Ang;
  109855. private _bone1;
  109856. private _bone2;
  109857. private _bone1Length;
  109858. private _bone2Length;
  109859. private _maxAngle;
  109860. private _maxReach;
  109861. private _rightHandedSystem;
  109862. private _bendAxis;
  109863. private _slerping;
  109864. private _adjustRoll;
  109865. /**
  109866. * Gets or sets maximum allowed angle
  109867. */
  109868. get maxAngle(): number;
  109869. set maxAngle(value: number);
  109870. /**
  109871. * Creates a new BoneIKController
  109872. * @param mesh defines the mesh to control
  109873. * @param bone defines the bone to control
  109874. * @param options defines options to set up the controller
  109875. */
  109876. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  109877. targetMesh?: AbstractMesh;
  109878. poleTargetMesh?: AbstractMesh;
  109879. poleTargetBone?: Bone;
  109880. poleTargetLocalOffset?: Vector3;
  109881. poleAngle?: number;
  109882. bendAxis?: Vector3;
  109883. maxAngle?: number;
  109884. slerpAmount?: number;
  109885. });
  109886. private _setMaxAngle;
  109887. /**
  109888. * Force the controller to update the bones
  109889. */
  109890. update(): void;
  109891. }
  109892. }
  109893. declare module BABYLON {
  109894. /**
  109895. * Class used to make a bone look toward a point in space
  109896. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  109897. */
  109898. export class BoneLookController {
  109899. private static _tmpVecs;
  109900. private static _tmpQuat;
  109901. private static _tmpMats;
  109902. /**
  109903. * The target Vector3 that the bone will look at
  109904. */
  109905. target: Vector3;
  109906. /**
  109907. * The mesh that the bone is attached to
  109908. */
  109909. mesh: AbstractMesh;
  109910. /**
  109911. * The bone that will be looking to the target
  109912. */
  109913. bone: Bone;
  109914. /**
  109915. * The up axis of the coordinate system that is used when the bone is rotated
  109916. */
  109917. upAxis: Vector3;
  109918. /**
  109919. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  109920. */
  109921. upAxisSpace: Space;
  109922. /**
  109923. * Used to make an adjustment to the yaw of the bone
  109924. */
  109925. adjustYaw: number;
  109926. /**
  109927. * Used to make an adjustment to the pitch of the bone
  109928. */
  109929. adjustPitch: number;
  109930. /**
  109931. * Used to make an adjustment to the roll of the bone
  109932. */
  109933. adjustRoll: number;
  109934. /**
  109935. * 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)
  109936. */
  109937. slerpAmount: number;
  109938. private _minYaw;
  109939. private _maxYaw;
  109940. private _minPitch;
  109941. private _maxPitch;
  109942. private _minYawSin;
  109943. private _minYawCos;
  109944. private _maxYawSin;
  109945. private _maxYawCos;
  109946. private _midYawConstraint;
  109947. private _minPitchTan;
  109948. private _maxPitchTan;
  109949. private _boneQuat;
  109950. private _slerping;
  109951. private _transformYawPitch;
  109952. private _transformYawPitchInv;
  109953. private _firstFrameSkipped;
  109954. private _yawRange;
  109955. private _fowardAxis;
  109956. /**
  109957. * Gets or sets the minimum yaw angle that the bone can look to
  109958. */
  109959. get minYaw(): number;
  109960. set minYaw(value: number);
  109961. /**
  109962. * Gets or sets the maximum yaw angle that the bone can look to
  109963. */
  109964. get maxYaw(): number;
  109965. set maxYaw(value: number);
  109966. /**
  109967. * Gets or sets the minimum pitch angle that the bone can look to
  109968. */
  109969. get minPitch(): number;
  109970. set minPitch(value: number);
  109971. /**
  109972. * Gets or sets the maximum pitch angle that the bone can look to
  109973. */
  109974. get maxPitch(): number;
  109975. set maxPitch(value: number);
  109976. /**
  109977. * Create a BoneLookController
  109978. * @param mesh the mesh that the bone belongs to
  109979. * @param bone the bone that will be looking to the target
  109980. * @param target the target Vector3 to look at
  109981. * @param options optional settings:
  109982. * * maxYaw: the maximum angle the bone will yaw to
  109983. * * minYaw: the minimum angle the bone will yaw to
  109984. * * maxPitch: the maximum angle the bone will pitch to
  109985. * * minPitch: the minimum angle the bone will yaw to
  109986. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  109987. * * upAxis: the up axis of the coordinate system
  109988. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  109989. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  109990. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  109991. * * adjustYaw: used to make an adjustment to the yaw of the bone
  109992. * * adjustPitch: used to make an adjustment to the pitch of the bone
  109993. * * adjustRoll: used to make an adjustment to the roll of the bone
  109994. **/
  109995. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  109996. maxYaw?: number;
  109997. minYaw?: number;
  109998. maxPitch?: number;
  109999. minPitch?: number;
  110000. slerpAmount?: number;
  110001. upAxis?: Vector3;
  110002. upAxisSpace?: Space;
  110003. yawAxis?: Vector3;
  110004. pitchAxis?: Vector3;
  110005. adjustYaw?: number;
  110006. adjustPitch?: number;
  110007. adjustRoll?: number;
  110008. });
  110009. /**
  110010. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  110011. */
  110012. update(): void;
  110013. private _getAngleDiff;
  110014. private _getAngleBetween;
  110015. private _isAngleBetween;
  110016. }
  110017. }
  110018. declare module BABYLON {
  110019. /**
  110020. * Manage the gamepad inputs to control an arc rotate camera.
  110021. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110022. */
  110023. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  110024. /**
  110025. * Defines the camera the input is attached to.
  110026. */
  110027. camera: ArcRotateCamera;
  110028. /**
  110029. * Defines the gamepad the input is gathering event from.
  110030. */
  110031. gamepad: Nullable<Gamepad>;
  110032. /**
  110033. * Defines the gamepad rotation sensiblity.
  110034. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  110035. */
  110036. gamepadRotationSensibility: number;
  110037. /**
  110038. * Defines the gamepad move sensiblity.
  110039. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  110040. */
  110041. gamepadMoveSensibility: number;
  110042. private _yAxisScale;
  110043. /**
  110044. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  110045. */
  110046. get invertYAxis(): boolean;
  110047. set invertYAxis(value: boolean);
  110048. private _onGamepadConnectedObserver;
  110049. private _onGamepadDisconnectedObserver;
  110050. /**
  110051. * Attach the input controls to a specific dom element to get the input from.
  110052. * @param element Defines the element the controls should be listened from
  110053. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110054. */
  110055. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110056. /**
  110057. * Detach the current controls from the specified dom element.
  110058. * @param element Defines the element to stop listening the inputs from
  110059. */
  110060. detachControl(element: Nullable<HTMLElement>): void;
  110061. /**
  110062. * Update the current camera state depending on the inputs that have been used this frame.
  110063. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110064. */
  110065. checkInputs(): void;
  110066. /**
  110067. * Gets the class name of the current intput.
  110068. * @returns the class name
  110069. */
  110070. getClassName(): string;
  110071. /**
  110072. * Get the friendly name associated with the input class.
  110073. * @returns the input friendly name
  110074. */
  110075. getSimpleName(): string;
  110076. }
  110077. }
  110078. declare module BABYLON {
  110079. interface ArcRotateCameraInputsManager {
  110080. /**
  110081. * Add orientation input support to the input manager.
  110082. * @returns the current input manager
  110083. */
  110084. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  110085. }
  110086. /**
  110087. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  110088. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110089. */
  110090. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  110091. /**
  110092. * Defines the camera the input is attached to.
  110093. */
  110094. camera: ArcRotateCamera;
  110095. /**
  110096. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  110097. */
  110098. alphaCorrection: number;
  110099. /**
  110100. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  110101. */
  110102. gammaCorrection: number;
  110103. private _alpha;
  110104. private _gamma;
  110105. private _dirty;
  110106. private _deviceOrientationHandler;
  110107. /**
  110108. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  110109. */
  110110. constructor();
  110111. /**
  110112. * Attach the input controls to a specific dom element to get the input from.
  110113. * @param element Defines the element the controls should be listened from
  110114. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110115. */
  110116. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110117. /** @hidden */
  110118. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  110119. /**
  110120. * Update the current camera state depending on the inputs that have been used this frame.
  110121. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110122. */
  110123. checkInputs(): void;
  110124. /**
  110125. * Detach the current controls from the specified dom element.
  110126. * @param element Defines the element to stop listening the inputs from
  110127. */
  110128. detachControl(element: Nullable<HTMLElement>): void;
  110129. /**
  110130. * Gets the class name of the current intput.
  110131. * @returns the class name
  110132. */
  110133. getClassName(): string;
  110134. /**
  110135. * Get the friendly name associated with the input class.
  110136. * @returns the input friendly name
  110137. */
  110138. getSimpleName(): string;
  110139. }
  110140. }
  110141. declare module BABYLON {
  110142. /**
  110143. * Listen to mouse events to control the camera.
  110144. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110145. */
  110146. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  110147. /**
  110148. * Defines the camera the input is attached to.
  110149. */
  110150. camera: FlyCamera;
  110151. /**
  110152. * Defines if touch is enabled. (Default is true.)
  110153. */
  110154. touchEnabled: boolean;
  110155. /**
  110156. * Defines the buttons associated with the input to handle camera rotation.
  110157. */
  110158. buttons: number[];
  110159. /**
  110160. * Assign buttons for Yaw control.
  110161. */
  110162. buttonsYaw: number[];
  110163. /**
  110164. * Assign buttons for Pitch control.
  110165. */
  110166. buttonsPitch: number[];
  110167. /**
  110168. * Assign buttons for Roll control.
  110169. */
  110170. buttonsRoll: number[];
  110171. /**
  110172. * Detect if any button is being pressed while mouse is moved.
  110173. * -1 = Mouse locked.
  110174. * 0 = Left button.
  110175. * 1 = Middle Button.
  110176. * 2 = Right Button.
  110177. */
  110178. activeButton: number;
  110179. /**
  110180. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  110181. * Higher values reduce its sensitivity.
  110182. */
  110183. angularSensibility: number;
  110184. private _mousemoveCallback;
  110185. private _observer;
  110186. private _rollObserver;
  110187. private previousPosition;
  110188. private noPreventDefault;
  110189. private element;
  110190. /**
  110191. * Listen to mouse events to control the camera.
  110192. * @param touchEnabled Define if touch is enabled. (Default is true.)
  110193. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110194. */
  110195. constructor(touchEnabled?: boolean);
  110196. /**
  110197. * Attach the mouse control to the HTML DOM element.
  110198. * @param element Defines the element that listens to the input events.
  110199. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  110200. */
  110201. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110202. /**
  110203. * Detach the current controls from the specified dom element.
  110204. * @param element Defines the element to stop listening the inputs from
  110205. */
  110206. detachControl(element: Nullable<HTMLElement>): void;
  110207. /**
  110208. * Gets the class name of the current input.
  110209. * @returns the class name.
  110210. */
  110211. getClassName(): string;
  110212. /**
  110213. * Get the friendly name associated with the input class.
  110214. * @returns the input's friendly name.
  110215. */
  110216. getSimpleName(): string;
  110217. private _pointerInput;
  110218. private _onMouseMove;
  110219. /**
  110220. * Rotate camera by mouse offset.
  110221. */
  110222. private rotateCamera;
  110223. }
  110224. }
  110225. declare module BABYLON {
  110226. /**
  110227. * Default Inputs manager for the FlyCamera.
  110228. * It groups all the default supported inputs for ease of use.
  110229. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110230. */
  110231. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  110232. /**
  110233. * Instantiates a new FlyCameraInputsManager.
  110234. * @param camera Defines the camera the inputs belong to.
  110235. */
  110236. constructor(camera: FlyCamera);
  110237. /**
  110238. * Add keyboard input support to the input manager.
  110239. * @returns the new FlyCameraKeyboardMoveInput().
  110240. */
  110241. addKeyboard(): FlyCameraInputsManager;
  110242. /**
  110243. * Add mouse input support to the input manager.
  110244. * @param touchEnabled Enable touch screen support.
  110245. * @returns the new FlyCameraMouseInput().
  110246. */
  110247. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  110248. }
  110249. }
  110250. declare module BABYLON {
  110251. /**
  110252. * This is a flying camera, designed for 3D movement and rotation in all directions,
  110253. * such as in a 3D Space Shooter or a Flight Simulator.
  110254. */
  110255. export class FlyCamera extends TargetCamera {
  110256. /**
  110257. * Define the collision ellipsoid of the camera.
  110258. * This is helpful for simulating a camera body, like a player's body.
  110259. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  110260. */
  110261. ellipsoid: Vector3;
  110262. /**
  110263. * Define an offset for the position of the ellipsoid around the camera.
  110264. * This can be helpful if the camera is attached away from the player's body center,
  110265. * such as at its head.
  110266. */
  110267. ellipsoidOffset: Vector3;
  110268. /**
  110269. * Enable or disable collisions of the camera with the rest of the scene objects.
  110270. */
  110271. checkCollisions: boolean;
  110272. /**
  110273. * Enable or disable gravity on the camera.
  110274. */
  110275. applyGravity: boolean;
  110276. /**
  110277. * Define the current direction the camera is moving to.
  110278. */
  110279. cameraDirection: Vector3;
  110280. /**
  110281. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  110282. * This overrides and empties cameraRotation.
  110283. */
  110284. rotationQuaternion: Quaternion;
  110285. /**
  110286. * Track Roll to maintain the wanted Rolling when looking around.
  110287. */
  110288. _trackRoll: number;
  110289. /**
  110290. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  110291. */
  110292. rollCorrect: number;
  110293. /**
  110294. * Mimic a banked turn, Rolling the camera when Yawing.
  110295. * It's recommended to use rollCorrect = 10 for faster banking correction.
  110296. */
  110297. bankedTurn: boolean;
  110298. /**
  110299. * Limit in radians for how much Roll banking will add. (Default: 90°)
  110300. */
  110301. bankedTurnLimit: number;
  110302. /**
  110303. * Value of 0 disables the banked Roll.
  110304. * Value of 1 is equal to the Yaw angle in radians.
  110305. */
  110306. bankedTurnMultiplier: number;
  110307. /**
  110308. * The inputs manager loads all the input sources, such as keyboard and mouse.
  110309. */
  110310. inputs: FlyCameraInputsManager;
  110311. /**
  110312. * Gets the input sensibility for mouse input.
  110313. * Higher values reduce sensitivity.
  110314. */
  110315. get angularSensibility(): number;
  110316. /**
  110317. * Sets the input sensibility for a mouse input.
  110318. * Higher values reduce sensitivity.
  110319. */
  110320. set angularSensibility(value: number);
  110321. /**
  110322. * Get the keys for camera movement forward.
  110323. */
  110324. get keysForward(): number[];
  110325. /**
  110326. * Set the keys for camera movement forward.
  110327. */
  110328. set keysForward(value: number[]);
  110329. /**
  110330. * Get the keys for camera movement backward.
  110331. */
  110332. get keysBackward(): number[];
  110333. set keysBackward(value: number[]);
  110334. /**
  110335. * Get the keys for camera movement up.
  110336. */
  110337. get keysUp(): number[];
  110338. /**
  110339. * Set the keys for camera movement up.
  110340. */
  110341. set keysUp(value: number[]);
  110342. /**
  110343. * Get the keys for camera movement down.
  110344. */
  110345. get keysDown(): number[];
  110346. /**
  110347. * Set the keys for camera movement down.
  110348. */
  110349. set keysDown(value: number[]);
  110350. /**
  110351. * Get the keys for camera movement left.
  110352. */
  110353. get keysLeft(): number[];
  110354. /**
  110355. * Set the keys for camera movement left.
  110356. */
  110357. set keysLeft(value: number[]);
  110358. /**
  110359. * Set the keys for camera movement right.
  110360. */
  110361. get keysRight(): number[];
  110362. /**
  110363. * Set the keys for camera movement right.
  110364. */
  110365. set keysRight(value: number[]);
  110366. /**
  110367. * Event raised when the camera collides with a mesh in the scene.
  110368. */
  110369. onCollide: (collidedMesh: AbstractMesh) => void;
  110370. private _collider;
  110371. private _needMoveForGravity;
  110372. private _oldPosition;
  110373. private _diffPosition;
  110374. private _newPosition;
  110375. /** @hidden */
  110376. _localDirection: Vector3;
  110377. /** @hidden */
  110378. _transformedDirection: Vector3;
  110379. /**
  110380. * Instantiates a FlyCamera.
  110381. * This is a flying camera, designed for 3D movement and rotation in all directions,
  110382. * such as in a 3D Space Shooter or a Flight Simulator.
  110383. * @param name Define the name of the camera in the scene.
  110384. * @param position Define the starting position of the camera in the scene.
  110385. * @param scene Define the scene the camera belongs to.
  110386. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  110387. */
  110388. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  110389. /**
  110390. * Attach a control to the HTML DOM element.
  110391. * @param element Defines the element that listens to the input events.
  110392. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  110393. */
  110394. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110395. /**
  110396. * Detach a control from the HTML DOM element.
  110397. * The camera will stop reacting to that input.
  110398. * @param element Defines the element that listens to the input events.
  110399. */
  110400. detachControl(element: HTMLElement): void;
  110401. private _collisionMask;
  110402. /**
  110403. * Get the mask that the camera ignores in collision events.
  110404. */
  110405. get collisionMask(): number;
  110406. /**
  110407. * Set the mask that the camera ignores in collision events.
  110408. */
  110409. set collisionMask(mask: number);
  110410. /** @hidden */
  110411. _collideWithWorld(displacement: Vector3): void;
  110412. /** @hidden */
  110413. private _onCollisionPositionChange;
  110414. /** @hidden */
  110415. _checkInputs(): void;
  110416. /** @hidden */
  110417. _decideIfNeedsToMove(): boolean;
  110418. /** @hidden */
  110419. _updatePosition(): void;
  110420. /**
  110421. * Restore the Roll to its target value at the rate specified.
  110422. * @param rate - Higher means slower restoring.
  110423. * @hidden
  110424. */
  110425. restoreRoll(rate: number): void;
  110426. /**
  110427. * Destroy the camera and release the current resources held by it.
  110428. */
  110429. dispose(): void;
  110430. /**
  110431. * Get the current object class name.
  110432. * @returns the class name.
  110433. */
  110434. getClassName(): string;
  110435. }
  110436. }
  110437. declare module BABYLON {
  110438. /**
  110439. * Listen to keyboard events to control the camera.
  110440. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110441. */
  110442. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  110443. /**
  110444. * Defines the camera the input is attached to.
  110445. */
  110446. camera: FlyCamera;
  110447. /**
  110448. * The list of keyboard keys used to control the forward move of the camera.
  110449. */
  110450. keysForward: number[];
  110451. /**
  110452. * The list of keyboard keys used to control the backward move of the camera.
  110453. */
  110454. keysBackward: number[];
  110455. /**
  110456. * The list of keyboard keys used to control the forward move of the camera.
  110457. */
  110458. keysUp: number[];
  110459. /**
  110460. * The list of keyboard keys used to control the backward move of the camera.
  110461. */
  110462. keysDown: number[];
  110463. /**
  110464. * The list of keyboard keys used to control the right strafe move of the camera.
  110465. */
  110466. keysRight: number[];
  110467. /**
  110468. * The list of keyboard keys used to control the left strafe move of the camera.
  110469. */
  110470. keysLeft: number[];
  110471. private _keys;
  110472. private _onCanvasBlurObserver;
  110473. private _onKeyboardObserver;
  110474. private _engine;
  110475. private _scene;
  110476. /**
  110477. * Attach the input controls to a specific dom element to get the input from.
  110478. * @param element Defines the element the controls should be listened from
  110479. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110480. */
  110481. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110482. /**
  110483. * Detach the current controls from the specified dom element.
  110484. * @param element Defines the element to stop listening the inputs from
  110485. */
  110486. detachControl(element: Nullable<HTMLElement>): void;
  110487. /**
  110488. * Gets the class name of the current intput.
  110489. * @returns the class name
  110490. */
  110491. getClassName(): string;
  110492. /** @hidden */
  110493. _onLostFocus(e: FocusEvent): void;
  110494. /**
  110495. * Get the friendly name associated with the input class.
  110496. * @returns the input friendly name
  110497. */
  110498. getSimpleName(): string;
  110499. /**
  110500. * Update the current camera state depending on the inputs that have been used this frame.
  110501. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110502. */
  110503. checkInputs(): void;
  110504. }
  110505. }
  110506. declare module BABYLON {
  110507. /**
  110508. * Manage the mouse wheel inputs to control a follow camera.
  110509. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110510. */
  110511. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  110512. /**
  110513. * Defines the camera the input is attached to.
  110514. */
  110515. camera: FollowCamera;
  110516. /**
  110517. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  110518. */
  110519. axisControlRadius: boolean;
  110520. /**
  110521. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  110522. */
  110523. axisControlHeight: boolean;
  110524. /**
  110525. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  110526. */
  110527. axisControlRotation: boolean;
  110528. /**
  110529. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  110530. * relation to mouseWheel events.
  110531. */
  110532. wheelPrecision: number;
  110533. /**
  110534. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  110535. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  110536. */
  110537. wheelDeltaPercentage: number;
  110538. private _wheel;
  110539. private _observer;
  110540. /**
  110541. * Attach the input controls to a specific dom element to get the input from.
  110542. * @param element Defines the element the controls should be listened from
  110543. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110544. */
  110545. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110546. /**
  110547. * Detach the current controls from the specified dom element.
  110548. * @param element Defines the element to stop listening the inputs from
  110549. */
  110550. detachControl(element: Nullable<HTMLElement>): void;
  110551. /**
  110552. * Gets the class name of the current intput.
  110553. * @returns the class name
  110554. */
  110555. getClassName(): string;
  110556. /**
  110557. * Get the friendly name associated with the input class.
  110558. * @returns the input friendly name
  110559. */
  110560. getSimpleName(): string;
  110561. }
  110562. }
  110563. declare module BABYLON {
  110564. /**
  110565. * Manage the pointers inputs to control an follow camera.
  110566. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110567. */
  110568. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  110569. /**
  110570. * Defines the camera the input is attached to.
  110571. */
  110572. camera: FollowCamera;
  110573. /**
  110574. * Gets the class name of the current input.
  110575. * @returns the class name
  110576. */
  110577. getClassName(): string;
  110578. /**
  110579. * Defines the pointer angular sensibility along the X axis or how fast is
  110580. * the camera rotating.
  110581. * A negative number will reverse the axis direction.
  110582. */
  110583. angularSensibilityX: number;
  110584. /**
  110585. * Defines the pointer angular sensibility along the Y axis or how fast is
  110586. * the camera rotating.
  110587. * A negative number will reverse the axis direction.
  110588. */
  110589. angularSensibilityY: number;
  110590. /**
  110591. * Defines the pointer pinch precision or how fast is the camera zooming.
  110592. * A negative number will reverse the axis direction.
  110593. */
  110594. pinchPrecision: number;
  110595. /**
  110596. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  110597. * from 0.
  110598. * It defines the percentage of current camera.radius to use as delta when
  110599. * pinch zoom is used.
  110600. */
  110601. pinchDeltaPercentage: number;
  110602. /**
  110603. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  110604. */
  110605. axisXControlRadius: boolean;
  110606. /**
  110607. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  110608. */
  110609. axisXControlHeight: boolean;
  110610. /**
  110611. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  110612. */
  110613. axisXControlRotation: boolean;
  110614. /**
  110615. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  110616. */
  110617. axisYControlRadius: boolean;
  110618. /**
  110619. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  110620. */
  110621. axisYControlHeight: boolean;
  110622. /**
  110623. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  110624. */
  110625. axisYControlRotation: boolean;
  110626. /**
  110627. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  110628. */
  110629. axisPinchControlRadius: boolean;
  110630. /**
  110631. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  110632. */
  110633. axisPinchControlHeight: boolean;
  110634. /**
  110635. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  110636. */
  110637. axisPinchControlRotation: boolean;
  110638. /**
  110639. * Log error messages if basic misconfiguration has occurred.
  110640. */
  110641. warningEnable: boolean;
  110642. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  110643. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  110644. private _warningCounter;
  110645. private _warning;
  110646. }
  110647. }
  110648. declare module BABYLON {
  110649. /**
  110650. * Default Inputs manager for the FollowCamera.
  110651. * It groups all the default supported inputs for ease of use.
  110652. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110653. */
  110654. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  110655. /**
  110656. * Instantiates a new FollowCameraInputsManager.
  110657. * @param camera Defines the camera the inputs belong to
  110658. */
  110659. constructor(camera: FollowCamera);
  110660. /**
  110661. * Add keyboard input support to the input manager.
  110662. * @returns the current input manager
  110663. */
  110664. addKeyboard(): FollowCameraInputsManager;
  110665. /**
  110666. * Add mouse wheel input support to the input manager.
  110667. * @returns the current input manager
  110668. */
  110669. addMouseWheel(): FollowCameraInputsManager;
  110670. /**
  110671. * Add pointers input support to the input manager.
  110672. * @returns the current input manager
  110673. */
  110674. addPointers(): FollowCameraInputsManager;
  110675. /**
  110676. * Add orientation input support to the input manager.
  110677. * @returns the current input manager
  110678. */
  110679. addVRDeviceOrientation(): FollowCameraInputsManager;
  110680. }
  110681. }
  110682. declare module BABYLON {
  110683. /**
  110684. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  110685. * an arc rotate version arcFollowCamera are available.
  110686. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  110687. */
  110688. export class FollowCamera extends TargetCamera {
  110689. /**
  110690. * Distance the follow camera should follow an object at
  110691. */
  110692. radius: number;
  110693. /**
  110694. * Minimum allowed distance of the camera to the axis of rotation
  110695. * (The camera can not get closer).
  110696. * This can help limiting how the Camera is able to move in the scene.
  110697. */
  110698. lowerRadiusLimit: Nullable<number>;
  110699. /**
  110700. * Maximum allowed distance of the camera to the axis of rotation
  110701. * (The camera can not get further).
  110702. * This can help limiting how the Camera is able to move in the scene.
  110703. */
  110704. upperRadiusLimit: Nullable<number>;
  110705. /**
  110706. * Define a rotation offset between the camera and the object it follows
  110707. */
  110708. rotationOffset: number;
  110709. /**
  110710. * Minimum allowed angle to camera position relative to target object.
  110711. * This can help limiting how the Camera is able to move in the scene.
  110712. */
  110713. lowerRotationOffsetLimit: Nullable<number>;
  110714. /**
  110715. * Maximum allowed angle to camera position relative to target object.
  110716. * This can help limiting how the Camera is able to move in the scene.
  110717. */
  110718. upperRotationOffsetLimit: Nullable<number>;
  110719. /**
  110720. * Define a height offset between the camera and the object it follows.
  110721. * It can help following an object from the top (like a car chaing a plane)
  110722. */
  110723. heightOffset: number;
  110724. /**
  110725. * Minimum allowed height of camera position relative to target object.
  110726. * This can help limiting how the Camera is able to move in the scene.
  110727. */
  110728. lowerHeightOffsetLimit: Nullable<number>;
  110729. /**
  110730. * Maximum allowed height of camera position relative to target object.
  110731. * This can help limiting how the Camera is able to move in the scene.
  110732. */
  110733. upperHeightOffsetLimit: Nullable<number>;
  110734. /**
  110735. * Define how fast the camera can accelerate to follow it s target.
  110736. */
  110737. cameraAcceleration: number;
  110738. /**
  110739. * Define the speed limit of the camera following an object.
  110740. */
  110741. maxCameraSpeed: number;
  110742. /**
  110743. * Define the target of the camera.
  110744. */
  110745. lockedTarget: Nullable<AbstractMesh>;
  110746. /**
  110747. * Defines the input associated with the camera.
  110748. */
  110749. inputs: FollowCameraInputsManager;
  110750. /**
  110751. * Instantiates the follow camera.
  110752. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  110753. * @param name Define the name of the camera in the scene
  110754. * @param position Define the position of the camera
  110755. * @param scene Define the scene the camera belong to
  110756. * @param lockedTarget Define the target of the camera
  110757. */
  110758. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  110759. private _follow;
  110760. /**
  110761. * Attached controls to the current camera.
  110762. * @param element Defines the element the controls should be listened from
  110763. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110764. */
  110765. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110766. /**
  110767. * Detach the current controls from the camera.
  110768. * The camera will stop reacting to inputs.
  110769. * @param element Defines the element to stop listening the inputs from
  110770. */
  110771. detachControl(element: HTMLElement): void;
  110772. /** @hidden */
  110773. _checkInputs(): void;
  110774. private _checkLimits;
  110775. /**
  110776. * Gets the camera class name.
  110777. * @returns the class name
  110778. */
  110779. getClassName(): string;
  110780. }
  110781. /**
  110782. * Arc Rotate version of the follow camera.
  110783. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  110784. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  110785. */
  110786. export class ArcFollowCamera extends TargetCamera {
  110787. /** The longitudinal angle of the camera */
  110788. alpha: number;
  110789. /** The latitudinal angle of the camera */
  110790. beta: number;
  110791. /** The radius of the camera from its target */
  110792. radius: number;
  110793. /** Define the camera target (the messh it should follow) */
  110794. target: Nullable<AbstractMesh>;
  110795. private _cartesianCoordinates;
  110796. /**
  110797. * Instantiates a new ArcFollowCamera
  110798. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  110799. * @param name Define the name of the camera
  110800. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  110801. * @param beta Define the rotation angle of the camera around the elevation axis
  110802. * @param radius Define the radius of the camera from its target point
  110803. * @param target Define the target of the camera
  110804. * @param scene Define the scene the camera belongs to
  110805. */
  110806. constructor(name: string,
  110807. /** The longitudinal angle of the camera */
  110808. alpha: number,
  110809. /** The latitudinal angle of the camera */
  110810. beta: number,
  110811. /** The radius of the camera from its target */
  110812. radius: number,
  110813. /** Define the camera target (the messh it should follow) */
  110814. target: Nullable<AbstractMesh>, scene: Scene);
  110815. private _follow;
  110816. /** @hidden */
  110817. _checkInputs(): void;
  110818. /**
  110819. * Returns the class name of the object.
  110820. * It is mostly used internally for serialization purposes.
  110821. */
  110822. getClassName(): string;
  110823. }
  110824. }
  110825. declare module BABYLON {
  110826. /**
  110827. * Manage the keyboard inputs to control the movement of a follow camera.
  110828. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110829. */
  110830. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  110831. /**
  110832. * Defines the camera the input is attached to.
  110833. */
  110834. camera: FollowCamera;
  110835. /**
  110836. * Defines the list of key codes associated with the up action (increase heightOffset)
  110837. */
  110838. keysHeightOffsetIncr: number[];
  110839. /**
  110840. * Defines the list of key codes associated with the down action (decrease heightOffset)
  110841. */
  110842. keysHeightOffsetDecr: number[];
  110843. /**
  110844. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  110845. */
  110846. keysHeightOffsetModifierAlt: boolean;
  110847. /**
  110848. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  110849. */
  110850. keysHeightOffsetModifierCtrl: boolean;
  110851. /**
  110852. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  110853. */
  110854. keysHeightOffsetModifierShift: boolean;
  110855. /**
  110856. * Defines the list of key codes associated with the left action (increase rotationOffset)
  110857. */
  110858. keysRotationOffsetIncr: number[];
  110859. /**
  110860. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  110861. */
  110862. keysRotationOffsetDecr: number[];
  110863. /**
  110864. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  110865. */
  110866. keysRotationOffsetModifierAlt: boolean;
  110867. /**
  110868. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  110869. */
  110870. keysRotationOffsetModifierCtrl: boolean;
  110871. /**
  110872. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  110873. */
  110874. keysRotationOffsetModifierShift: boolean;
  110875. /**
  110876. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  110877. */
  110878. keysRadiusIncr: number[];
  110879. /**
  110880. * Defines the list of key codes associated with the zoom-out action (increase radius)
  110881. */
  110882. keysRadiusDecr: number[];
  110883. /**
  110884. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  110885. */
  110886. keysRadiusModifierAlt: boolean;
  110887. /**
  110888. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  110889. */
  110890. keysRadiusModifierCtrl: boolean;
  110891. /**
  110892. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  110893. */
  110894. keysRadiusModifierShift: boolean;
  110895. /**
  110896. * Defines the rate of change of heightOffset.
  110897. */
  110898. heightSensibility: number;
  110899. /**
  110900. * Defines the rate of change of rotationOffset.
  110901. */
  110902. rotationSensibility: number;
  110903. /**
  110904. * Defines the rate of change of radius.
  110905. */
  110906. radiusSensibility: number;
  110907. private _keys;
  110908. private _ctrlPressed;
  110909. private _altPressed;
  110910. private _shiftPressed;
  110911. private _onCanvasBlurObserver;
  110912. private _onKeyboardObserver;
  110913. private _engine;
  110914. private _scene;
  110915. /**
  110916. * Attach the input controls to a specific dom element to get the input from.
  110917. * @param element Defines the element the controls should be listened from
  110918. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110919. */
  110920. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110921. /**
  110922. * Detach the current controls from the specified dom element.
  110923. * @param element Defines the element to stop listening the inputs from
  110924. */
  110925. detachControl(element: Nullable<HTMLElement>): void;
  110926. /**
  110927. * Update the current camera state depending on the inputs that have been used this frame.
  110928. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110929. */
  110930. checkInputs(): void;
  110931. /**
  110932. * Gets the class name of the current input.
  110933. * @returns the class name
  110934. */
  110935. getClassName(): string;
  110936. /**
  110937. * Get the friendly name associated with the input class.
  110938. * @returns the input friendly name
  110939. */
  110940. getSimpleName(): string;
  110941. /**
  110942. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  110943. * allow modification of the heightOffset value.
  110944. */
  110945. private _modifierHeightOffset;
  110946. /**
  110947. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  110948. * allow modification of the rotationOffset value.
  110949. */
  110950. private _modifierRotationOffset;
  110951. /**
  110952. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  110953. * allow modification of the radius value.
  110954. */
  110955. private _modifierRadius;
  110956. }
  110957. }
  110958. declare module BABYLON {
  110959. interface FreeCameraInputsManager {
  110960. /**
  110961. * @hidden
  110962. */
  110963. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  110964. /**
  110965. * Add orientation input support to the input manager.
  110966. * @returns the current input manager
  110967. */
  110968. addDeviceOrientation(): FreeCameraInputsManager;
  110969. }
  110970. /**
  110971. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  110972. * Screen rotation is taken into account.
  110973. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110974. */
  110975. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  110976. private _camera;
  110977. private _screenOrientationAngle;
  110978. private _constantTranform;
  110979. private _screenQuaternion;
  110980. private _alpha;
  110981. private _beta;
  110982. private _gamma;
  110983. /**
  110984. * Can be used to detect if a device orientation sensor is available on a device
  110985. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  110986. * @returns a promise that will resolve on orientation change
  110987. */
  110988. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  110989. /**
  110990. * @hidden
  110991. */
  110992. _onDeviceOrientationChangedObservable: Observable<void>;
  110993. /**
  110994. * Instantiates a new input
  110995. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110996. */
  110997. constructor();
  110998. /**
  110999. * Define the camera controlled by the input.
  111000. */
  111001. get camera(): FreeCamera;
  111002. set camera(camera: FreeCamera);
  111003. /**
  111004. * Attach the input controls to a specific dom element to get the input from.
  111005. * @param element Defines the element the controls should be listened from
  111006. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111007. */
  111008. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111009. private _orientationChanged;
  111010. private _deviceOrientation;
  111011. /**
  111012. * Detach the current controls from the specified dom element.
  111013. * @param element Defines the element to stop listening the inputs from
  111014. */
  111015. detachControl(element: Nullable<HTMLElement>): void;
  111016. /**
  111017. * Update the current camera state depending on the inputs that have been used this frame.
  111018. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111019. */
  111020. checkInputs(): void;
  111021. /**
  111022. * Gets the class name of the current intput.
  111023. * @returns the class name
  111024. */
  111025. getClassName(): string;
  111026. /**
  111027. * Get the friendly name associated with the input class.
  111028. * @returns the input friendly name
  111029. */
  111030. getSimpleName(): string;
  111031. }
  111032. }
  111033. declare module BABYLON {
  111034. /**
  111035. * Manage the gamepad inputs to control a free camera.
  111036. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111037. */
  111038. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  111039. /**
  111040. * Define the camera the input is attached to.
  111041. */
  111042. camera: FreeCamera;
  111043. /**
  111044. * Define the Gamepad controlling the input
  111045. */
  111046. gamepad: Nullable<Gamepad>;
  111047. /**
  111048. * Defines the gamepad rotation sensiblity.
  111049. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  111050. */
  111051. gamepadAngularSensibility: number;
  111052. /**
  111053. * Defines the gamepad move sensiblity.
  111054. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  111055. */
  111056. gamepadMoveSensibility: number;
  111057. private _yAxisScale;
  111058. /**
  111059. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  111060. */
  111061. get invertYAxis(): boolean;
  111062. set invertYAxis(value: boolean);
  111063. private _onGamepadConnectedObserver;
  111064. private _onGamepadDisconnectedObserver;
  111065. private _cameraTransform;
  111066. private _deltaTransform;
  111067. private _vector3;
  111068. private _vector2;
  111069. /**
  111070. * Attach the input controls to a specific dom element to get the input from.
  111071. * @param element Defines the element the controls should be listened from
  111072. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111073. */
  111074. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111075. /**
  111076. * Detach the current controls from the specified dom element.
  111077. * @param element Defines the element to stop listening the inputs from
  111078. */
  111079. detachControl(element: Nullable<HTMLElement>): void;
  111080. /**
  111081. * Update the current camera state depending on the inputs that have been used this frame.
  111082. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111083. */
  111084. checkInputs(): void;
  111085. /**
  111086. * Gets the class name of the current intput.
  111087. * @returns the class name
  111088. */
  111089. getClassName(): string;
  111090. /**
  111091. * Get the friendly name associated with the input class.
  111092. * @returns the input friendly name
  111093. */
  111094. getSimpleName(): string;
  111095. }
  111096. }
  111097. declare module BABYLON {
  111098. /**
  111099. * Defines the potential axis of a Joystick
  111100. */
  111101. export enum JoystickAxis {
  111102. /** X axis */
  111103. X = 0,
  111104. /** Y axis */
  111105. Y = 1,
  111106. /** Z axis */
  111107. Z = 2
  111108. }
  111109. /**
  111110. * Class used to define virtual joystick (used in touch mode)
  111111. */
  111112. export class VirtualJoystick {
  111113. /**
  111114. * Gets or sets a boolean indicating that left and right values must be inverted
  111115. */
  111116. reverseLeftRight: boolean;
  111117. /**
  111118. * Gets or sets a boolean indicating that up and down values must be inverted
  111119. */
  111120. reverseUpDown: boolean;
  111121. /**
  111122. * Gets the offset value for the position (ie. the change of the position value)
  111123. */
  111124. deltaPosition: Vector3;
  111125. /**
  111126. * Gets a boolean indicating if the virtual joystick was pressed
  111127. */
  111128. pressed: boolean;
  111129. /**
  111130. * Canvas the virtual joystick will render onto, default z-index of this is 5
  111131. */
  111132. static Canvas: Nullable<HTMLCanvasElement>;
  111133. private static _globalJoystickIndex;
  111134. private static vjCanvasContext;
  111135. private static vjCanvasWidth;
  111136. private static vjCanvasHeight;
  111137. private static halfWidth;
  111138. private _action;
  111139. private _axisTargetedByLeftAndRight;
  111140. private _axisTargetedByUpAndDown;
  111141. private _joystickSensibility;
  111142. private _inversedSensibility;
  111143. private _joystickPointerID;
  111144. private _joystickColor;
  111145. private _joystickPointerPos;
  111146. private _joystickPreviousPointerPos;
  111147. private _joystickPointerStartPos;
  111148. private _deltaJoystickVector;
  111149. private _leftJoystick;
  111150. private _touches;
  111151. private _onPointerDownHandlerRef;
  111152. private _onPointerMoveHandlerRef;
  111153. private _onPointerUpHandlerRef;
  111154. private _onResize;
  111155. /**
  111156. * Creates a new virtual joystick
  111157. * @param leftJoystick defines that the joystick is for left hand (false by default)
  111158. */
  111159. constructor(leftJoystick?: boolean);
  111160. /**
  111161. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  111162. * @param newJoystickSensibility defines the new sensibility
  111163. */
  111164. setJoystickSensibility(newJoystickSensibility: number): void;
  111165. private _onPointerDown;
  111166. private _onPointerMove;
  111167. private _onPointerUp;
  111168. /**
  111169. * Change the color of the virtual joystick
  111170. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  111171. */
  111172. setJoystickColor(newColor: string): void;
  111173. /**
  111174. * Defines a callback to call when the joystick is touched
  111175. * @param action defines the callback
  111176. */
  111177. setActionOnTouch(action: () => any): void;
  111178. /**
  111179. * Defines which axis you'd like to control for left & right
  111180. * @param axis defines the axis to use
  111181. */
  111182. setAxisForLeftRight(axis: JoystickAxis): void;
  111183. /**
  111184. * Defines which axis you'd like to control for up & down
  111185. * @param axis defines the axis to use
  111186. */
  111187. setAxisForUpDown(axis: JoystickAxis): void;
  111188. private _drawVirtualJoystick;
  111189. /**
  111190. * Release internal HTML canvas
  111191. */
  111192. releaseCanvas(): void;
  111193. }
  111194. }
  111195. declare module BABYLON {
  111196. interface FreeCameraInputsManager {
  111197. /**
  111198. * Add virtual joystick input support to the input manager.
  111199. * @returns the current input manager
  111200. */
  111201. addVirtualJoystick(): FreeCameraInputsManager;
  111202. }
  111203. /**
  111204. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  111205. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111206. */
  111207. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  111208. /**
  111209. * Defines the camera the input is attached to.
  111210. */
  111211. camera: FreeCamera;
  111212. private _leftjoystick;
  111213. private _rightjoystick;
  111214. /**
  111215. * Gets the left stick of the virtual joystick.
  111216. * @returns The virtual Joystick
  111217. */
  111218. getLeftJoystick(): VirtualJoystick;
  111219. /**
  111220. * Gets the right stick of the virtual joystick.
  111221. * @returns The virtual Joystick
  111222. */
  111223. getRightJoystick(): VirtualJoystick;
  111224. /**
  111225. * Update the current camera state depending on the inputs that have been used this frame.
  111226. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111227. */
  111228. checkInputs(): void;
  111229. /**
  111230. * Attach the input controls to a specific dom element to get the input from.
  111231. * @param element Defines the element the controls should be listened from
  111232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111233. */
  111234. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111235. /**
  111236. * Detach the current controls from the specified dom element.
  111237. * @param element Defines the element to stop listening the inputs from
  111238. */
  111239. detachControl(element: Nullable<HTMLElement>): void;
  111240. /**
  111241. * Gets the class name of the current intput.
  111242. * @returns the class name
  111243. */
  111244. getClassName(): string;
  111245. /**
  111246. * Get the friendly name associated with the input class.
  111247. * @returns the input friendly name
  111248. */
  111249. getSimpleName(): string;
  111250. }
  111251. }
  111252. declare module BABYLON {
  111253. /**
  111254. * This represents a FPS type of camera controlled by touch.
  111255. * This is like a universal camera minus the Gamepad controls.
  111256. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111257. */
  111258. export class TouchCamera extends FreeCamera {
  111259. /**
  111260. * Defines the touch sensibility for rotation.
  111261. * The higher the faster.
  111262. */
  111263. get touchAngularSensibility(): number;
  111264. set touchAngularSensibility(value: number);
  111265. /**
  111266. * Defines the touch sensibility for move.
  111267. * The higher the faster.
  111268. */
  111269. get touchMoveSensibility(): number;
  111270. set touchMoveSensibility(value: number);
  111271. /**
  111272. * Instantiates a new touch camera.
  111273. * This represents a FPS type of camera controlled by touch.
  111274. * This is like a universal camera minus the Gamepad controls.
  111275. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111276. * @param name Define the name of the camera in the scene
  111277. * @param position Define the start position of the camera in the scene
  111278. * @param scene Define the scene the camera belongs to
  111279. */
  111280. constructor(name: string, position: Vector3, scene: Scene);
  111281. /**
  111282. * Gets the current object class name.
  111283. * @return the class name
  111284. */
  111285. getClassName(): string;
  111286. /** @hidden */
  111287. _setupInputs(): void;
  111288. }
  111289. }
  111290. declare module BABYLON {
  111291. /**
  111292. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  111293. * being tilted forward or back and left or right.
  111294. */
  111295. export class DeviceOrientationCamera extends FreeCamera {
  111296. private _initialQuaternion;
  111297. private _quaternionCache;
  111298. private _tmpDragQuaternion;
  111299. private _disablePointerInputWhenUsingDeviceOrientation;
  111300. /**
  111301. * Creates a new device orientation camera
  111302. * @param name The name of the camera
  111303. * @param position The start position camera
  111304. * @param scene The scene the camera belongs to
  111305. */
  111306. constructor(name: string, position: Vector3, scene: Scene);
  111307. /**
  111308. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  111309. */
  111310. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  111311. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  111312. private _dragFactor;
  111313. /**
  111314. * Enabled turning on the y axis when the orientation sensor is active
  111315. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  111316. */
  111317. enableHorizontalDragging(dragFactor?: number): void;
  111318. /**
  111319. * Gets the current instance class name ("DeviceOrientationCamera").
  111320. * This helps avoiding instanceof at run time.
  111321. * @returns the class name
  111322. */
  111323. getClassName(): string;
  111324. /**
  111325. * @hidden
  111326. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  111327. */
  111328. _checkInputs(): void;
  111329. /**
  111330. * Reset the camera to its default orientation on the specified axis only.
  111331. * @param axis The axis to reset
  111332. */
  111333. resetToCurrentRotation(axis?: Axis): void;
  111334. }
  111335. }
  111336. declare module BABYLON {
  111337. /**
  111338. * Defines supported buttons for XBox360 compatible gamepads
  111339. */
  111340. export enum Xbox360Button {
  111341. /** A */
  111342. A = 0,
  111343. /** B */
  111344. B = 1,
  111345. /** X */
  111346. X = 2,
  111347. /** Y */
  111348. Y = 3,
  111349. /** Start */
  111350. Start = 4,
  111351. /** Back */
  111352. Back = 5,
  111353. /** Left button */
  111354. LB = 6,
  111355. /** Right button */
  111356. RB = 7,
  111357. /** Left stick */
  111358. LeftStick = 8,
  111359. /** Right stick */
  111360. RightStick = 9
  111361. }
  111362. /** Defines values for XBox360 DPad */
  111363. export enum Xbox360Dpad {
  111364. /** Up */
  111365. Up = 0,
  111366. /** Down */
  111367. Down = 1,
  111368. /** Left */
  111369. Left = 2,
  111370. /** Right */
  111371. Right = 3
  111372. }
  111373. /**
  111374. * Defines a XBox360 gamepad
  111375. */
  111376. export class Xbox360Pad extends Gamepad {
  111377. private _leftTrigger;
  111378. private _rightTrigger;
  111379. private _onlefttriggerchanged;
  111380. private _onrighttriggerchanged;
  111381. private _onbuttondown;
  111382. private _onbuttonup;
  111383. private _ondpaddown;
  111384. private _ondpadup;
  111385. /** Observable raised when a button is pressed */
  111386. onButtonDownObservable: Observable<Xbox360Button>;
  111387. /** Observable raised when a button is released */
  111388. onButtonUpObservable: Observable<Xbox360Button>;
  111389. /** Observable raised when a pad is pressed */
  111390. onPadDownObservable: Observable<Xbox360Dpad>;
  111391. /** Observable raised when a pad is released */
  111392. onPadUpObservable: Observable<Xbox360Dpad>;
  111393. private _buttonA;
  111394. private _buttonB;
  111395. private _buttonX;
  111396. private _buttonY;
  111397. private _buttonBack;
  111398. private _buttonStart;
  111399. private _buttonLB;
  111400. private _buttonRB;
  111401. private _buttonLeftStick;
  111402. private _buttonRightStick;
  111403. private _dPadUp;
  111404. private _dPadDown;
  111405. private _dPadLeft;
  111406. private _dPadRight;
  111407. private _isXboxOnePad;
  111408. /**
  111409. * Creates a new XBox360 gamepad object
  111410. * @param id defines the id of this gamepad
  111411. * @param index defines its index
  111412. * @param gamepad defines the internal HTML gamepad object
  111413. * @param xboxOne defines if it is a XBox One gamepad
  111414. */
  111415. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  111416. /**
  111417. * Defines the callback to call when left trigger is pressed
  111418. * @param callback defines the callback to use
  111419. */
  111420. onlefttriggerchanged(callback: (value: number) => void): void;
  111421. /**
  111422. * Defines the callback to call when right trigger is pressed
  111423. * @param callback defines the callback to use
  111424. */
  111425. onrighttriggerchanged(callback: (value: number) => void): void;
  111426. /**
  111427. * Gets the left trigger value
  111428. */
  111429. get leftTrigger(): number;
  111430. /**
  111431. * Sets the left trigger value
  111432. */
  111433. set leftTrigger(newValue: number);
  111434. /**
  111435. * Gets the right trigger value
  111436. */
  111437. get rightTrigger(): number;
  111438. /**
  111439. * Sets the right trigger value
  111440. */
  111441. set rightTrigger(newValue: number);
  111442. /**
  111443. * Defines the callback to call when a button is pressed
  111444. * @param callback defines the callback to use
  111445. */
  111446. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  111447. /**
  111448. * Defines the callback to call when a button is released
  111449. * @param callback defines the callback to use
  111450. */
  111451. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  111452. /**
  111453. * Defines the callback to call when a pad is pressed
  111454. * @param callback defines the callback to use
  111455. */
  111456. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  111457. /**
  111458. * Defines the callback to call when a pad is released
  111459. * @param callback defines the callback to use
  111460. */
  111461. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  111462. private _setButtonValue;
  111463. private _setDPadValue;
  111464. /**
  111465. * Gets the value of the `A` button
  111466. */
  111467. get buttonA(): number;
  111468. /**
  111469. * Sets the value of the `A` button
  111470. */
  111471. set buttonA(value: number);
  111472. /**
  111473. * Gets the value of the `B` button
  111474. */
  111475. get buttonB(): number;
  111476. /**
  111477. * Sets the value of the `B` button
  111478. */
  111479. set buttonB(value: number);
  111480. /**
  111481. * Gets the value of the `X` button
  111482. */
  111483. get buttonX(): number;
  111484. /**
  111485. * Sets the value of the `X` button
  111486. */
  111487. set buttonX(value: number);
  111488. /**
  111489. * Gets the value of the `Y` button
  111490. */
  111491. get buttonY(): number;
  111492. /**
  111493. * Sets the value of the `Y` button
  111494. */
  111495. set buttonY(value: number);
  111496. /**
  111497. * Gets the value of the `Start` button
  111498. */
  111499. get buttonStart(): number;
  111500. /**
  111501. * Sets the value of the `Start` button
  111502. */
  111503. set buttonStart(value: number);
  111504. /**
  111505. * Gets the value of the `Back` button
  111506. */
  111507. get buttonBack(): number;
  111508. /**
  111509. * Sets the value of the `Back` button
  111510. */
  111511. set buttonBack(value: number);
  111512. /**
  111513. * Gets the value of the `Left` button
  111514. */
  111515. get buttonLB(): number;
  111516. /**
  111517. * Sets the value of the `Left` button
  111518. */
  111519. set buttonLB(value: number);
  111520. /**
  111521. * Gets the value of the `Right` button
  111522. */
  111523. get buttonRB(): number;
  111524. /**
  111525. * Sets the value of the `Right` button
  111526. */
  111527. set buttonRB(value: number);
  111528. /**
  111529. * Gets the value of the Left joystick
  111530. */
  111531. get buttonLeftStick(): number;
  111532. /**
  111533. * Sets the value of the Left joystick
  111534. */
  111535. set buttonLeftStick(value: number);
  111536. /**
  111537. * Gets the value of the Right joystick
  111538. */
  111539. get buttonRightStick(): number;
  111540. /**
  111541. * Sets the value of the Right joystick
  111542. */
  111543. set buttonRightStick(value: number);
  111544. /**
  111545. * Gets the value of D-pad up
  111546. */
  111547. get dPadUp(): number;
  111548. /**
  111549. * Sets the value of D-pad up
  111550. */
  111551. set dPadUp(value: number);
  111552. /**
  111553. * Gets the value of D-pad down
  111554. */
  111555. get dPadDown(): number;
  111556. /**
  111557. * Sets the value of D-pad down
  111558. */
  111559. set dPadDown(value: number);
  111560. /**
  111561. * Gets the value of D-pad left
  111562. */
  111563. get dPadLeft(): number;
  111564. /**
  111565. * Sets the value of D-pad left
  111566. */
  111567. set dPadLeft(value: number);
  111568. /**
  111569. * Gets the value of D-pad right
  111570. */
  111571. get dPadRight(): number;
  111572. /**
  111573. * Sets the value of D-pad right
  111574. */
  111575. set dPadRight(value: number);
  111576. /**
  111577. * Force the gamepad to synchronize with device values
  111578. */
  111579. update(): void;
  111580. /**
  111581. * Disposes the gamepad
  111582. */
  111583. dispose(): void;
  111584. }
  111585. }
  111586. declare module BABYLON {
  111587. /**
  111588. * Defines supported buttons for DualShock compatible gamepads
  111589. */
  111590. export enum DualShockButton {
  111591. /** Cross */
  111592. Cross = 0,
  111593. /** Circle */
  111594. Circle = 1,
  111595. /** Square */
  111596. Square = 2,
  111597. /** Triangle */
  111598. Triangle = 3,
  111599. /** Options */
  111600. Options = 4,
  111601. /** Share */
  111602. Share = 5,
  111603. /** L1 */
  111604. L1 = 6,
  111605. /** R1 */
  111606. R1 = 7,
  111607. /** Left stick */
  111608. LeftStick = 8,
  111609. /** Right stick */
  111610. RightStick = 9
  111611. }
  111612. /** Defines values for DualShock DPad */
  111613. export enum DualShockDpad {
  111614. /** Up */
  111615. Up = 0,
  111616. /** Down */
  111617. Down = 1,
  111618. /** Left */
  111619. Left = 2,
  111620. /** Right */
  111621. Right = 3
  111622. }
  111623. /**
  111624. * Defines a DualShock gamepad
  111625. */
  111626. export class DualShockPad extends Gamepad {
  111627. private _leftTrigger;
  111628. private _rightTrigger;
  111629. private _onlefttriggerchanged;
  111630. private _onrighttriggerchanged;
  111631. private _onbuttondown;
  111632. private _onbuttonup;
  111633. private _ondpaddown;
  111634. private _ondpadup;
  111635. /** Observable raised when a button is pressed */
  111636. onButtonDownObservable: Observable<DualShockButton>;
  111637. /** Observable raised when a button is released */
  111638. onButtonUpObservable: Observable<DualShockButton>;
  111639. /** Observable raised when a pad is pressed */
  111640. onPadDownObservable: Observable<DualShockDpad>;
  111641. /** Observable raised when a pad is released */
  111642. onPadUpObservable: Observable<DualShockDpad>;
  111643. private _buttonCross;
  111644. private _buttonCircle;
  111645. private _buttonSquare;
  111646. private _buttonTriangle;
  111647. private _buttonShare;
  111648. private _buttonOptions;
  111649. private _buttonL1;
  111650. private _buttonR1;
  111651. private _buttonLeftStick;
  111652. private _buttonRightStick;
  111653. private _dPadUp;
  111654. private _dPadDown;
  111655. private _dPadLeft;
  111656. private _dPadRight;
  111657. /**
  111658. * Creates a new DualShock gamepad object
  111659. * @param id defines the id of this gamepad
  111660. * @param index defines its index
  111661. * @param gamepad defines the internal HTML gamepad object
  111662. */
  111663. constructor(id: string, index: number, gamepad: any);
  111664. /**
  111665. * Defines the callback to call when left trigger is pressed
  111666. * @param callback defines the callback to use
  111667. */
  111668. onlefttriggerchanged(callback: (value: number) => void): void;
  111669. /**
  111670. * Defines the callback to call when right trigger is pressed
  111671. * @param callback defines the callback to use
  111672. */
  111673. onrighttriggerchanged(callback: (value: number) => void): void;
  111674. /**
  111675. * Gets the left trigger value
  111676. */
  111677. get leftTrigger(): number;
  111678. /**
  111679. * Sets the left trigger value
  111680. */
  111681. set leftTrigger(newValue: number);
  111682. /**
  111683. * Gets the right trigger value
  111684. */
  111685. get rightTrigger(): number;
  111686. /**
  111687. * Sets the right trigger value
  111688. */
  111689. set rightTrigger(newValue: number);
  111690. /**
  111691. * Defines the callback to call when a button is pressed
  111692. * @param callback defines the callback to use
  111693. */
  111694. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  111695. /**
  111696. * Defines the callback to call when a button is released
  111697. * @param callback defines the callback to use
  111698. */
  111699. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  111700. /**
  111701. * Defines the callback to call when a pad is pressed
  111702. * @param callback defines the callback to use
  111703. */
  111704. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  111705. /**
  111706. * Defines the callback to call when a pad is released
  111707. * @param callback defines the callback to use
  111708. */
  111709. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  111710. private _setButtonValue;
  111711. private _setDPadValue;
  111712. /**
  111713. * Gets the value of the `Cross` button
  111714. */
  111715. get buttonCross(): number;
  111716. /**
  111717. * Sets the value of the `Cross` button
  111718. */
  111719. set buttonCross(value: number);
  111720. /**
  111721. * Gets the value of the `Circle` button
  111722. */
  111723. get buttonCircle(): number;
  111724. /**
  111725. * Sets the value of the `Circle` button
  111726. */
  111727. set buttonCircle(value: number);
  111728. /**
  111729. * Gets the value of the `Square` button
  111730. */
  111731. get buttonSquare(): number;
  111732. /**
  111733. * Sets the value of the `Square` button
  111734. */
  111735. set buttonSquare(value: number);
  111736. /**
  111737. * Gets the value of the `Triangle` button
  111738. */
  111739. get buttonTriangle(): number;
  111740. /**
  111741. * Sets the value of the `Triangle` button
  111742. */
  111743. set buttonTriangle(value: number);
  111744. /**
  111745. * Gets the value of the `Options` button
  111746. */
  111747. get buttonOptions(): number;
  111748. /**
  111749. * Sets the value of the `Options` button
  111750. */
  111751. set buttonOptions(value: number);
  111752. /**
  111753. * Gets the value of the `Share` button
  111754. */
  111755. get buttonShare(): number;
  111756. /**
  111757. * Sets the value of the `Share` button
  111758. */
  111759. set buttonShare(value: number);
  111760. /**
  111761. * Gets the value of the `L1` button
  111762. */
  111763. get buttonL1(): number;
  111764. /**
  111765. * Sets the value of the `L1` button
  111766. */
  111767. set buttonL1(value: number);
  111768. /**
  111769. * Gets the value of the `R1` button
  111770. */
  111771. get buttonR1(): number;
  111772. /**
  111773. * Sets the value of the `R1` button
  111774. */
  111775. set buttonR1(value: number);
  111776. /**
  111777. * Gets the value of the Left joystick
  111778. */
  111779. get buttonLeftStick(): number;
  111780. /**
  111781. * Sets the value of the Left joystick
  111782. */
  111783. set buttonLeftStick(value: number);
  111784. /**
  111785. * Gets the value of the Right joystick
  111786. */
  111787. get buttonRightStick(): number;
  111788. /**
  111789. * Sets the value of the Right joystick
  111790. */
  111791. set buttonRightStick(value: number);
  111792. /**
  111793. * Gets the value of D-pad up
  111794. */
  111795. get dPadUp(): number;
  111796. /**
  111797. * Sets the value of D-pad up
  111798. */
  111799. set dPadUp(value: number);
  111800. /**
  111801. * Gets the value of D-pad down
  111802. */
  111803. get dPadDown(): number;
  111804. /**
  111805. * Sets the value of D-pad down
  111806. */
  111807. set dPadDown(value: number);
  111808. /**
  111809. * Gets the value of D-pad left
  111810. */
  111811. get dPadLeft(): number;
  111812. /**
  111813. * Sets the value of D-pad left
  111814. */
  111815. set dPadLeft(value: number);
  111816. /**
  111817. * Gets the value of D-pad right
  111818. */
  111819. get dPadRight(): number;
  111820. /**
  111821. * Sets the value of D-pad right
  111822. */
  111823. set dPadRight(value: number);
  111824. /**
  111825. * Force the gamepad to synchronize with device values
  111826. */
  111827. update(): void;
  111828. /**
  111829. * Disposes the gamepad
  111830. */
  111831. dispose(): void;
  111832. }
  111833. }
  111834. declare module BABYLON {
  111835. /**
  111836. * Manager for handling gamepads
  111837. */
  111838. export class GamepadManager {
  111839. private _scene?;
  111840. private _babylonGamepads;
  111841. private _oneGamepadConnected;
  111842. /** @hidden */
  111843. _isMonitoring: boolean;
  111844. private _gamepadEventSupported;
  111845. private _gamepadSupport?;
  111846. /**
  111847. * observable to be triggered when the gamepad controller has been connected
  111848. */
  111849. onGamepadConnectedObservable: Observable<Gamepad>;
  111850. /**
  111851. * observable to be triggered when the gamepad controller has been disconnected
  111852. */
  111853. onGamepadDisconnectedObservable: Observable<Gamepad>;
  111854. private _onGamepadConnectedEvent;
  111855. private _onGamepadDisconnectedEvent;
  111856. /**
  111857. * Initializes the gamepad manager
  111858. * @param _scene BabylonJS scene
  111859. */
  111860. constructor(_scene?: Scene | undefined);
  111861. /**
  111862. * The gamepads in the game pad manager
  111863. */
  111864. get gamepads(): Gamepad[];
  111865. /**
  111866. * Get the gamepad controllers based on type
  111867. * @param type The type of gamepad controller
  111868. * @returns Nullable gamepad
  111869. */
  111870. getGamepadByType(type?: number): Nullable<Gamepad>;
  111871. /**
  111872. * Disposes the gamepad manager
  111873. */
  111874. dispose(): void;
  111875. private _addNewGamepad;
  111876. private _startMonitoringGamepads;
  111877. private _stopMonitoringGamepads;
  111878. /** @hidden */
  111879. _checkGamepadsStatus(): void;
  111880. private _updateGamepadObjects;
  111881. }
  111882. }
  111883. declare module BABYLON {
  111884. interface Scene {
  111885. /** @hidden */
  111886. _gamepadManager: Nullable<GamepadManager>;
  111887. /**
  111888. * Gets the gamepad manager associated with the scene
  111889. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  111890. */
  111891. gamepadManager: GamepadManager;
  111892. }
  111893. /**
  111894. * Interface representing a free camera inputs manager
  111895. */
  111896. interface FreeCameraInputsManager {
  111897. /**
  111898. * Adds gamepad input support to the FreeCameraInputsManager.
  111899. * @returns the FreeCameraInputsManager
  111900. */
  111901. addGamepad(): FreeCameraInputsManager;
  111902. }
  111903. /**
  111904. * Interface representing an arc rotate camera inputs manager
  111905. */
  111906. interface ArcRotateCameraInputsManager {
  111907. /**
  111908. * Adds gamepad input support to the ArcRotateCamera InputManager.
  111909. * @returns the camera inputs manager
  111910. */
  111911. addGamepad(): ArcRotateCameraInputsManager;
  111912. }
  111913. /**
  111914. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  111915. */
  111916. export class GamepadSystemSceneComponent implements ISceneComponent {
  111917. /**
  111918. * The component name helpfull to identify the component in the list of scene components.
  111919. */
  111920. readonly name: string;
  111921. /**
  111922. * The scene the component belongs to.
  111923. */
  111924. scene: Scene;
  111925. /**
  111926. * Creates a new instance of the component for the given scene
  111927. * @param scene Defines the scene to register the component in
  111928. */
  111929. constructor(scene: Scene);
  111930. /**
  111931. * Registers the component in a given scene
  111932. */
  111933. register(): void;
  111934. /**
  111935. * Rebuilds the elements related to this component in case of
  111936. * context lost for instance.
  111937. */
  111938. rebuild(): void;
  111939. /**
  111940. * Disposes the component and the associated ressources
  111941. */
  111942. dispose(): void;
  111943. private _beforeCameraUpdate;
  111944. }
  111945. }
  111946. declare module BABYLON {
  111947. /**
  111948. * 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,
  111949. * which still works and will still be found in many Playgrounds.
  111950. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111951. */
  111952. export class UniversalCamera extends TouchCamera {
  111953. /**
  111954. * Defines the gamepad rotation sensiblity.
  111955. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  111956. */
  111957. get gamepadAngularSensibility(): number;
  111958. set gamepadAngularSensibility(value: number);
  111959. /**
  111960. * Defines the gamepad move sensiblity.
  111961. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  111962. */
  111963. get gamepadMoveSensibility(): number;
  111964. set gamepadMoveSensibility(value: number);
  111965. /**
  111966. * 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,
  111967. * which still works and will still be found in many Playgrounds.
  111968. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111969. * @param name Define the name of the camera in the scene
  111970. * @param position Define the start position of the camera in the scene
  111971. * @param scene Define the scene the camera belongs to
  111972. */
  111973. constructor(name: string, position: Vector3, scene: Scene);
  111974. /**
  111975. * Gets the current object class name.
  111976. * @return the class name
  111977. */
  111978. getClassName(): string;
  111979. }
  111980. }
  111981. declare module BABYLON {
  111982. /**
  111983. * This represents a FPS type of camera. This is only here for back compat purpose.
  111984. * Please use the UniversalCamera instead as both are identical.
  111985. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111986. */
  111987. export class GamepadCamera extends UniversalCamera {
  111988. /**
  111989. * Instantiates a new Gamepad Camera
  111990. * This represents a FPS type of camera. This is only here for back compat purpose.
  111991. * Please use the UniversalCamera instead as both are identical.
  111992. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111993. * @param name Define the name of the camera in the scene
  111994. * @param position Define the start position of the camera in the scene
  111995. * @param scene Define the scene the camera belongs to
  111996. */
  111997. constructor(name: string, position: Vector3, scene: Scene);
  111998. /**
  111999. * Gets the current object class name.
  112000. * @return the class name
  112001. */
  112002. getClassName(): string;
  112003. }
  112004. }
  112005. declare module BABYLON {
  112006. /** @hidden */
  112007. export var passPixelShader: {
  112008. name: string;
  112009. shader: string;
  112010. };
  112011. }
  112012. declare module BABYLON {
  112013. /** @hidden */
  112014. export var passCubePixelShader: {
  112015. name: string;
  112016. shader: string;
  112017. };
  112018. }
  112019. declare module BABYLON {
  112020. /**
  112021. * PassPostProcess which produces an output the same as it's input
  112022. */
  112023. export class PassPostProcess extends PostProcess {
  112024. /**
  112025. * Creates the PassPostProcess
  112026. * @param name The name of the effect.
  112027. * @param options The required width/height ratio to downsize to before computing the render pass.
  112028. * @param camera The camera to apply the render pass to.
  112029. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112030. * @param engine The engine which the post process will be applied. (default: current engine)
  112031. * @param reusable If the post process can be reused on the same frame. (default: false)
  112032. * @param textureType The type of texture to be used when performing the post processing.
  112033. * @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)
  112034. */
  112035. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112036. }
  112037. /**
  112038. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  112039. */
  112040. export class PassCubePostProcess extends PostProcess {
  112041. private _face;
  112042. /**
  112043. * Gets or sets the cube face to display.
  112044. * * 0 is +X
  112045. * * 1 is -X
  112046. * * 2 is +Y
  112047. * * 3 is -Y
  112048. * * 4 is +Z
  112049. * * 5 is -Z
  112050. */
  112051. get face(): number;
  112052. set face(value: number);
  112053. /**
  112054. * Creates the PassCubePostProcess
  112055. * @param name The name of the effect.
  112056. * @param options The required width/height ratio to downsize to before computing the render pass.
  112057. * @param camera The camera to apply the render pass to.
  112058. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112059. * @param engine The engine which the post process will be applied. (default: current engine)
  112060. * @param reusable If the post process can be reused on the same frame. (default: false)
  112061. * @param textureType The type of texture to be used when performing the post processing.
  112062. * @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)
  112063. */
  112064. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112065. }
  112066. }
  112067. declare module BABYLON {
  112068. /** @hidden */
  112069. export var anaglyphPixelShader: {
  112070. name: string;
  112071. shader: string;
  112072. };
  112073. }
  112074. declare module BABYLON {
  112075. /**
  112076. * Postprocess used to generate anaglyphic rendering
  112077. */
  112078. export class AnaglyphPostProcess extends PostProcess {
  112079. private _passedProcess;
  112080. /**
  112081. * Creates a new AnaglyphPostProcess
  112082. * @param name defines postprocess name
  112083. * @param options defines creation options or target ratio scale
  112084. * @param rigCameras defines cameras using this postprocess
  112085. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  112086. * @param engine defines hosting engine
  112087. * @param reusable defines if the postprocess will be reused multiple times per frame
  112088. */
  112089. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  112090. }
  112091. }
  112092. declare module BABYLON {
  112093. /**
  112094. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  112095. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112096. */
  112097. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  112098. /**
  112099. * Creates a new AnaglyphArcRotateCamera
  112100. * @param name defines camera name
  112101. * @param alpha defines alpha angle (in radians)
  112102. * @param beta defines beta angle (in radians)
  112103. * @param radius defines radius
  112104. * @param target defines camera target
  112105. * @param interaxialDistance defines distance between each color axis
  112106. * @param scene defines the hosting scene
  112107. */
  112108. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  112109. /**
  112110. * Gets camera class name
  112111. * @returns AnaglyphArcRotateCamera
  112112. */
  112113. getClassName(): string;
  112114. }
  112115. }
  112116. declare module BABYLON {
  112117. /**
  112118. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  112119. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112120. */
  112121. export class AnaglyphFreeCamera extends FreeCamera {
  112122. /**
  112123. * Creates a new AnaglyphFreeCamera
  112124. * @param name defines camera name
  112125. * @param position defines initial position
  112126. * @param interaxialDistance defines distance between each color axis
  112127. * @param scene defines the hosting scene
  112128. */
  112129. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  112130. /**
  112131. * Gets camera class name
  112132. * @returns AnaglyphFreeCamera
  112133. */
  112134. getClassName(): string;
  112135. }
  112136. }
  112137. declare module BABYLON {
  112138. /**
  112139. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  112140. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112141. */
  112142. export class AnaglyphGamepadCamera extends GamepadCamera {
  112143. /**
  112144. * Creates a new AnaglyphGamepadCamera
  112145. * @param name defines camera name
  112146. * @param position defines initial position
  112147. * @param interaxialDistance defines distance between each color axis
  112148. * @param scene defines the hosting scene
  112149. */
  112150. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  112151. /**
  112152. * Gets camera class name
  112153. * @returns AnaglyphGamepadCamera
  112154. */
  112155. getClassName(): string;
  112156. }
  112157. }
  112158. declare module BABYLON {
  112159. /**
  112160. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  112161. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112162. */
  112163. export class AnaglyphUniversalCamera extends UniversalCamera {
  112164. /**
  112165. * Creates a new AnaglyphUniversalCamera
  112166. * @param name defines camera name
  112167. * @param position defines initial position
  112168. * @param interaxialDistance defines distance between each color axis
  112169. * @param scene defines the hosting scene
  112170. */
  112171. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  112172. /**
  112173. * Gets camera class name
  112174. * @returns AnaglyphUniversalCamera
  112175. */
  112176. getClassName(): string;
  112177. }
  112178. }
  112179. declare module BABYLON {
  112180. /** @hidden */
  112181. export var stereoscopicInterlacePixelShader: {
  112182. name: string;
  112183. shader: string;
  112184. };
  112185. }
  112186. declare module BABYLON {
  112187. /**
  112188. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  112189. */
  112190. export class StereoscopicInterlacePostProcess extends PostProcess {
  112191. private _stepSize;
  112192. private _passedProcess;
  112193. /**
  112194. * Initializes a StereoscopicInterlacePostProcess
  112195. * @param name The name of the effect.
  112196. * @param rigCameras The rig cameras to be appled to the post process
  112197. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  112198. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112199. * @param engine The engine which the post process will be applied. (default: current engine)
  112200. * @param reusable If the post process can be reused on the same frame. (default: false)
  112201. */
  112202. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112203. }
  112204. }
  112205. declare module BABYLON {
  112206. /**
  112207. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  112208. * @see http://doc.babylonjs.com/features/cameras
  112209. */
  112210. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  112211. /**
  112212. * Creates a new StereoscopicArcRotateCamera
  112213. * @param name defines camera name
  112214. * @param alpha defines alpha angle (in radians)
  112215. * @param beta defines beta angle (in radians)
  112216. * @param radius defines radius
  112217. * @param target defines camera target
  112218. * @param interaxialDistance defines distance between each color axis
  112219. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112220. * @param scene defines the hosting scene
  112221. */
  112222. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112223. /**
  112224. * Gets camera class name
  112225. * @returns StereoscopicArcRotateCamera
  112226. */
  112227. getClassName(): string;
  112228. }
  112229. }
  112230. declare module BABYLON {
  112231. /**
  112232. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  112233. * @see http://doc.babylonjs.com/features/cameras
  112234. */
  112235. export class StereoscopicFreeCamera extends FreeCamera {
  112236. /**
  112237. * Creates a new StereoscopicFreeCamera
  112238. * @param name defines camera name
  112239. * @param position defines initial position
  112240. * @param interaxialDistance defines distance between each color axis
  112241. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112242. * @param scene defines the hosting scene
  112243. */
  112244. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112245. /**
  112246. * Gets camera class name
  112247. * @returns StereoscopicFreeCamera
  112248. */
  112249. getClassName(): string;
  112250. }
  112251. }
  112252. declare module BABYLON {
  112253. /**
  112254. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  112255. * @see http://doc.babylonjs.com/features/cameras
  112256. */
  112257. export class StereoscopicGamepadCamera extends GamepadCamera {
  112258. /**
  112259. * Creates a new StereoscopicGamepadCamera
  112260. * @param name defines camera name
  112261. * @param position defines initial position
  112262. * @param interaxialDistance defines distance between each color axis
  112263. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112264. * @param scene defines the hosting scene
  112265. */
  112266. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112267. /**
  112268. * Gets camera class name
  112269. * @returns StereoscopicGamepadCamera
  112270. */
  112271. getClassName(): string;
  112272. }
  112273. }
  112274. declare module BABYLON {
  112275. /**
  112276. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  112277. * @see http://doc.babylonjs.com/features/cameras
  112278. */
  112279. export class StereoscopicUniversalCamera extends UniversalCamera {
  112280. /**
  112281. * Creates a new StereoscopicUniversalCamera
  112282. * @param name defines camera name
  112283. * @param position defines initial position
  112284. * @param interaxialDistance defines distance between each color axis
  112285. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112286. * @param scene defines the hosting scene
  112287. */
  112288. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112289. /**
  112290. * Gets camera class name
  112291. * @returns StereoscopicUniversalCamera
  112292. */
  112293. getClassName(): string;
  112294. }
  112295. }
  112296. declare module BABYLON {
  112297. /**
  112298. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  112299. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  112300. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  112301. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  112302. */
  112303. export class VirtualJoysticksCamera extends FreeCamera {
  112304. /**
  112305. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  112306. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  112307. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  112308. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  112309. * @param name Define the name of the camera in the scene
  112310. * @param position Define the start position of the camera in the scene
  112311. * @param scene Define the scene the camera belongs to
  112312. */
  112313. constructor(name: string, position: Vector3, scene: Scene);
  112314. /**
  112315. * Gets the current object class name.
  112316. * @return the class name
  112317. */
  112318. getClassName(): string;
  112319. }
  112320. }
  112321. declare module BABYLON {
  112322. /**
  112323. * This represents all the required metrics to create a VR camera.
  112324. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  112325. */
  112326. export class VRCameraMetrics {
  112327. /**
  112328. * Define the horizontal resolution off the screen.
  112329. */
  112330. hResolution: number;
  112331. /**
  112332. * Define the vertical resolution off the screen.
  112333. */
  112334. vResolution: number;
  112335. /**
  112336. * Define the horizontal screen size.
  112337. */
  112338. hScreenSize: number;
  112339. /**
  112340. * Define the vertical screen size.
  112341. */
  112342. vScreenSize: number;
  112343. /**
  112344. * Define the vertical screen center position.
  112345. */
  112346. vScreenCenter: number;
  112347. /**
  112348. * Define the distance of the eyes to the screen.
  112349. */
  112350. eyeToScreenDistance: number;
  112351. /**
  112352. * Define the distance between both lenses
  112353. */
  112354. lensSeparationDistance: number;
  112355. /**
  112356. * Define the distance between both viewer's eyes.
  112357. */
  112358. interpupillaryDistance: number;
  112359. /**
  112360. * Define the distortion factor of the VR postprocess.
  112361. * Please, touch with care.
  112362. */
  112363. distortionK: number[];
  112364. /**
  112365. * Define the chromatic aberration correction factors for the VR post process.
  112366. */
  112367. chromaAbCorrection: number[];
  112368. /**
  112369. * Define the scale factor of the post process.
  112370. * The smaller the better but the slower.
  112371. */
  112372. postProcessScaleFactor: number;
  112373. /**
  112374. * Define an offset for the lens center.
  112375. */
  112376. lensCenterOffset: number;
  112377. /**
  112378. * Define if the current vr camera should compensate the distortion of the lense or not.
  112379. */
  112380. compensateDistortion: boolean;
  112381. /**
  112382. * Defines if multiview should be enabled when rendering (Default: false)
  112383. */
  112384. multiviewEnabled: boolean;
  112385. /**
  112386. * Gets the rendering aspect ratio based on the provided resolutions.
  112387. */
  112388. get aspectRatio(): number;
  112389. /**
  112390. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  112391. */
  112392. get aspectRatioFov(): number;
  112393. /**
  112394. * @hidden
  112395. */
  112396. get leftHMatrix(): Matrix;
  112397. /**
  112398. * @hidden
  112399. */
  112400. get rightHMatrix(): Matrix;
  112401. /**
  112402. * @hidden
  112403. */
  112404. get leftPreViewMatrix(): Matrix;
  112405. /**
  112406. * @hidden
  112407. */
  112408. get rightPreViewMatrix(): Matrix;
  112409. /**
  112410. * Get the default VRMetrics based on the most generic setup.
  112411. * @returns the default vr metrics
  112412. */
  112413. static GetDefault(): VRCameraMetrics;
  112414. }
  112415. }
  112416. declare module BABYLON {
  112417. /** @hidden */
  112418. export var vrDistortionCorrectionPixelShader: {
  112419. name: string;
  112420. shader: string;
  112421. };
  112422. }
  112423. declare module BABYLON {
  112424. /**
  112425. * VRDistortionCorrectionPostProcess used for mobile VR
  112426. */
  112427. export class VRDistortionCorrectionPostProcess extends PostProcess {
  112428. private _isRightEye;
  112429. private _distortionFactors;
  112430. private _postProcessScaleFactor;
  112431. private _lensCenterOffset;
  112432. private _scaleIn;
  112433. private _scaleFactor;
  112434. private _lensCenter;
  112435. /**
  112436. * Initializes the VRDistortionCorrectionPostProcess
  112437. * @param name The name of the effect.
  112438. * @param camera The camera to apply the render pass to.
  112439. * @param isRightEye If this is for the right eye distortion
  112440. * @param vrMetrics All the required metrics for the VR camera
  112441. */
  112442. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  112443. }
  112444. }
  112445. declare module BABYLON {
  112446. /**
  112447. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  112448. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  112449. */
  112450. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  112451. /**
  112452. * Creates a new VRDeviceOrientationArcRotateCamera
  112453. * @param name defines camera name
  112454. * @param alpha defines the camera rotation along the logitudinal axis
  112455. * @param beta defines the camera rotation along the latitudinal axis
  112456. * @param radius defines the camera distance from its target
  112457. * @param target defines the camera target
  112458. * @param scene defines the scene the camera belongs to
  112459. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  112460. * @param vrCameraMetrics defines the vr metrics associated to the camera
  112461. */
  112462. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  112463. /**
  112464. * Gets camera class name
  112465. * @returns VRDeviceOrientationArcRotateCamera
  112466. */
  112467. getClassName(): string;
  112468. }
  112469. }
  112470. declare module BABYLON {
  112471. /**
  112472. * Camera used to simulate VR rendering (based on FreeCamera)
  112473. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  112474. */
  112475. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  112476. /**
  112477. * Creates a new VRDeviceOrientationFreeCamera
  112478. * @param name defines camera name
  112479. * @param position defines the start position of the camera
  112480. * @param scene defines the scene the camera belongs to
  112481. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  112482. * @param vrCameraMetrics defines the vr metrics associated to the camera
  112483. */
  112484. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  112485. /**
  112486. * Gets camera class name
  112487. * @returns VRDeviceOrientationFreeCamera
  112488. */
  112489. getClassName(): string;
  112490. }
  112491. }
  112492. declare module BABYLON {
  112493. /**
  112494. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  112495. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  112496. */
  112497. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  112498. /**
  112499. * Creates a new VRDeviceOrientationGamepadCamera
  112500. * @param name defines camera name
  112501. * @param position defines the start position of the camera
  112502. * @param scene defines the scene the camera belongs to
  112503. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  112504. * @param vrCameraMetrics defines the vr metrics associated to the camera
  112505. */
  112506. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  112507. /**
  112508. * Gets camera class name
  112509. * @returns VRDeviceOrientationGamepadCamera
  112510. */
  112511. getClassName(): string;
  112512. }
  112513. }
  112514. declare module BABYLON {
  112515. /** @hidden */
  112516. export var imageProcessingPixelShader: {
  112517. name: string;
  112518. shader: string;
  112519. };
  112520. }
  112521. declare module BABYLON {
  112522. /**
  112523. * ImageProcessingPostProcess
  112524. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  112525. */
  112526. export class ImageProcessingPostProcess extends PostProcess {
  112527. /**
  112528. * Default configuration related to image processing available in the PBR Material.
  112529. */
  112530. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  112531. /**
  112532. * Gets the image processing configuration used either in this material.
  112533. */
  112534. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  112535. /**
  112536. * Sets the Default image processing configuration used either in the this material.
  112537. *
  112538. * If sets to null, the scene one is in use.
  112539. */
  112540. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  112541. /**
  112542. * Keep track of the image processing observer to allow dispose and replace.
  112543. */
  112544. private _imageProcessingObserver;
  112545. /**
  112546. * Attaches a new image processing configuration to the PBR Material.
  112547. * @param configuration
  112548. */
  112549. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  112550. /**
  112551. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  112552. */
  112553. get colorCurves(): Nullable<ColorCurves>;
  112554. /**
  112555. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  112556. */
  112557. set colorCurves(value: Nullable<ColorCurves>);
  112558. /**
  112559. * Gets wether the color curves effect is enabled.
  112560. */
  112561. get colorCurvesEnabled(): boolean;
  112562. /**
  112563. * Sets wether the color curves effect is enabled.
  112564. */
  112565. set colorCurvesEnabled(value: boolean);
  112566. /**
  112567. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  112568. */
  112569. get colorGradingTexture(): Nullable<BaseTexture>;
  112570. /**
  112571. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  112572. */
  112573. set colorGradingTexture(value: Nullable<BaseTexture>);
  112574. /**
  112575. * Gets wether the color grading effect is enabled.
  112576. */
  112577. get colorGradingEnabled(): boolean;
  112578. /**
  112579. * Gets wether the color grading effect is enabled.
  112580. */
  112581. set colorGradingEnabled(value: boolean);
  112582. /**
  112583. * Gets exposure used in the effect.
  112584. */
  112585. get exposure(): number;
  112586. /**
  112587. * Sets exposure used in the effect.
  112588. */
  112589. set exposure(value: number);
  112590. /**
  112591. * Gets wether tonemapping is enabled or not.
  112592. */
  112593. get toneMappingEnabled(): boolean;
  112594. /**
  112595. * Sets wether tonemapping is enabled or not
  112596. */
  112597. set toneMappingEnabled(value: boolean);
  112598. /**
  112599. * Gets the type of tone mapping effect.
  112600. */
  112601. get toneMappingType(): number;
  112602. /**
  112603. * Sets the type of tone mapping effect.
  112604. */
  112605. set toneMappingType(value: number);
  112606. /**
  112607. * Gets contrast used in the effect.
  112608. */
  112609. get contrast(): number;
  112610. /**
  112611. * Sets contrast used in the effect.
  112612. */
  112613. set contrast(value: number);
  112614. /**
  112615. * Gets Vignette stretch size.
  112616. */
  112617. get vignetteStretch(): number;
  112618. /**
  112619. * Sets Vignette stretch size.
  112620. */
  112621. set vignetteStretch(value: number);
  112622. /**
  112623. * Gets Vignette centre X Offset.
  112624. */
  112625. get vignetteCentreX(): number;
  112626. /**
  112627. * Sets Vignette centre X Offset.
  112628. */
  112629. set vignetteCentreX(value: number);
  112630. /**
  112631. * Gets Vignette centre Y Offset.
  112632. */
  112633. get vignetteCentreY(): number;
  112634. /**
  112635. * Sets Vignette centre Y Offset.
  112636. */
  112637. set vignetteCentreY(value: number);
  112638. /**
  112639. * Gets Vignette weight or intensity of the vignette effect.
  112640. */
  112641. get vignetteWeight(): number;
  112642. /**
  112643. * Sets Vignette weight or intensity of the vignette effect.
  112644. */
  112645. set vignetteWeight(value: number);
  112646. /**
  112647. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  112648. * if vignetteEnabled is set to true.
  112649. */
  112650. get vignetteColor(): Color4;
  112651. /**
  112652. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  112653. * if vignetteEnabled is set to true.
  112654. */
  112655. set vignetteColor(value: Color4);
  112656. /**
  112657. * Gets Camera field of view used by the Vignette effect.
  112658. */
  112659. get vignetteCameraFov(): number;
  112660. /**
  112661. * Sets Camera field of view used by the Vignette effect.
  112662. */
  112663. set vignetteCameraFov(value: number);
  112664. /**
  112665. * Gets the vignette blend mode allowing different kind of effect.
  112666. */
  112667. get vignetteBlendMode(): number;
  112668. /**
  112669. * Sets the vignette blend mode allowing different kind of effect.
  112670. */
  112671. set vignetteBlendMode(value: number);
  112672. /**
  112673. * Gets wether the vignette effect is enabled.
  112674. */
  112675. get vignetteEnabled(): boolean;
  112676. /**
  112677. * Sets wether the vignette effect is enabled.
  112678. */
  112679. set vignetteEnabled(value: boolean);
  112680. private _fromLinearSpace;
  112681. /**
  112682. * Gets wether the input of the processing is in Gamma or Linear Space.
  112683. */
  112684. get fromLinearSpace(): boolean;
  112685. /**
  112686. * Sets wether the input of the processing is in Gamma or Linear Space.
  112687. */
  112688. set fromLinearSpace(value: boolean);
  112689. /**
  112690. * Defines cache preventing GC.
  112691. */
  112692. private _defines;
  112693. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  112694. /**
  112695. * "ImageProcessingPostProcess"
  112696. * @returns "ImageProcessingPostProcess"
  112697. */
  112698. getClassName(): string;
  112699. protected _updateParameters(): void;
  112700. dispose(camera?: Camera): void;
  112701. }
  112702. }
  112703. declare module BABYLON {
  112704. /**
  112705. * Class containing static functions to help procedurally build meshes
  112706. */
  112707. export class GroundBuilder {
  112708. /**
  112709. * Creates a ground mesh
  112710. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  112711. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  112712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112713. * @param name defines the name of the mesh
  112714. * @param options defines the options used to create the mesh
  112715. * @param scene defines the hosting scene
  112716. * @returns the ground mesh
  112717. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  112718. */
  112719. static CreateGround(name: string, options: {
  112720. width?: number;
  112721. height?: number;
  112722. subdivisions?: number;
  112723. subdivisionsX?: number;
  112724. subdivisionsY?: number;
  112725. updatable?: boolean;
  112726. }, scene: any): Mesh;
  112727. /**
  112728. * Creates a tiled ground mesh
  112729. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  112730. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  112731. * * 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
  112732. * * 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
  112733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112734. * @param name defines the name of the mesh
  112735. * @param options defines the options used to create the mesh
  112736. * @param scene defines the hosting scene
  112737. * @returns the tiled ground mesh
  112738. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  112739. */
  112740. static CreateTiledGround(name: string, options: {
  112741. xmin: number;
  112742. zmin: number;
  112743. xmax: number;
  112744. zmax: number;
  112745. subdivisions?: {
  112746. w: number;
  112747. h: number;
  112748. };
  112749. precision?: {
  112750. w: number;
  112751. h: number;
  112752. };
  112753. updatable?: boolean;
  112754. }, scene?: Nullable<Scene>): Mesh;
  112755. /**
  112756. * Creates a ground mesh from a height map
  112757. * * The parameter `url` sets the URL of the height map image resource.
  112758. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  112759. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  112760. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  112761. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  112762. * * 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.
  112763. * * 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).
  112764. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  112765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112766. * @param name defines the name of the mesh
  112767. * @param url defines the url to the height map
  112768. * @param options defines the options used to create the mesh
  112769. * @param scene defines the hosting scene
  112770. * @returns the ground mesh
  112771. * @see https://doc.babylonjs.com/babylon101/height_map
  112772. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  112773. */
  112774. static CreateGroundFromHeightMap(name: string, url: string, options: {
  112775. width?: number;
  112776. height?: number;
  112777. subdivisions?: number;
  112778. minHeight?: number;
  112779. maxHeight?: number;
  112780. colorFilter?: Color3;
  112781. alphaFilter?: number;
  112782. updatable?: boolean;
  112783. onReady?: (mesh: GroundMesh) => void;
  112784. }, scene?: Nullable<Scene>): GroundMesh;
  112785. }
  112786. }
  112787. declare module BABYLON {
  112788. /**
  112789. * Class containing static functions to help procedurally build meshes
  112790. */
  112791. export class TorusBuilder {
  112792. /**
  112793. * Creates a torus mesh
  112794. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  112795. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  112796. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  112797. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112798. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112800. * @param name defines the name of the mesh
  112801. * @param options defines the options used to create the mesh
  112802. * @param scene defines the hosting scene
  112803. * @returns the torus mesh
  112804. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  112805. */
  112806. static CreateTorus(name: string, options: {
  112807. diameter?: number;
  112808. thickness?: number;
  112809. tessellation?: number;
  112810. updatable?: boolean;
  112811. sideOrientation?: number;
  112812. frontUVs?: Vector4;
  112813. backUVs?: Vector4;
  112814. }, scene: any): Mesh;
  112815. }
  112816. }
  112817. declare module BABYLON {
  112818. /**
  112819. * Class containing static functions to help procedurally build meshes
  112820. */
  112821. export class CylinderBuilder {
  112822. /**
  112823. * Creates a cylinder or a cone mesh
  112824. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  112825. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  112826. * * 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.
  112827. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  112828. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  112829. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  112830. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  112831. * * 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).
  112832. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  112833. * * 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).
  112834. * * 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
  112835. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  112836. * * 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
  112837. * * 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.
  112838. * * If `enclose` is false, a ring surface is one element.
  112839. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  112840. * * 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
  112841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112842. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112844. * @param name defines the name of the mesh
  112845. * @param options defines the options used to create the mesh
  112846. * @param scene defines the hosting scene
  112847. * @returns the cylinder mesh
  112848. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  112849. */
  112850. static CreateCylinder(name: string, options: {
  112851. height?: number;
  112852. diameterTop?: number;
  112853. diameterBottom?: number;
  112854. diameter?: number;
  112855. tessellation?: number;
  112856. subdivisions?: number;
  112857. arc?: number;
  112858. faceColors?: Color4[];
  112859. faceUV?: Vector4[];
  112860. updatable?: boolean;
  112861. hasRings?: boolean;
  112862. enclose?: boolean;
  112863. cap?: number;
  112864. sideOrientation?: number;
  112865. frontUVs?: Vector4;
  112866. backUVs?: Vector4;
  112867. }, scene: any): Mesh;
  112868. }
  112869. }
  112870. declare module BABYLON {
  112871. /**
  112872. * States of the webXR experience
  112873. */
  112874. export enum WebXRState {
  112875. /**
  112876. * Transitioning to being in XR mode
  112877. */
  112878. ENTERING_XR = 0,
  112879. /**
  112880. * Transitioning to non XR mode
  112881. */
  112882. EXITING_XR = 1,
  112883. /**
  112884. * In XR mode and presenting
  112885. */
  112886. IN_XR = 2,
  112887. /**
  112888. * Not entered XR mode
  112889. */
  112890. NOT_IN_XR = 3
  112891. }
  112892. /**
  112893. * Abstraction of the XR render target
  112894. */
  112895. export interface WebXRRenderTarget extends IDisposable {
  112896. /**
  112897. * xrpresent context of the canvas which can be used to display/mirror xr content
  112898. */
  112899. canvasContext: WebGLRenderingContext;
  112900. /**
  112901. * xr layer for the canvas
  112902. */
  112903. xrLayer: Nullable<XRWebGLLayer>;
  112904. /**
  112905. * Initializes the xr layer for the session
  112906. * @param xrSession xr session
  112907. * @returns a promise that will resolve once the XR Layer has been created
  112908. */
  112909. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  112910. }
  112911. }
  112912. declare module BABYLON {
  112913. /**
  112914. * COnfiguration object for WebXR output canvas
  112915. */
  112916. export class WebXRManagedOutputCanvasOptions {
  112917. /**
  112918. * Options for this XR Layer output
  112919. */
  112920. canvasOptions: XRWebGLLayerOptions;
  112921. /**
  112922. * CSS styling for a newly created canvas (if not provided)
  112923. */
  112924. newCanvasCssStyle?: string;
  112925. /**
  112926. * Get the default values of the configuration object
  112927. * @returns default values of this configuration object
  112928. */
  112929. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  112930. }
  112931. /**
  112932. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  112933. */
  112934. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  112935. private configuration;
  112936. private _engine;
  112937. private _canvas;
  112938. /**
  112939. * xrpresent context of the canvas which can be used to display/mirror xr content
  112940. */
  112941. canvasContext: WebGLRenderingContext;
  112942. /**
  112943. * xr layer for the canvas
  112944. */
  112945. xrLayer: Nullable<XRWebGLLayer>;
  112946. /**
  112947. * Initializes the xr layer for the session
  112948. * @param xrSession xr session
  112949. * @returns a promise that will resolve once the XR Layer has been created
  112950. */
  112951. initializeXRLayerAsync(xrSession: any): any;
  112952. /**
  112953. * Initializes the canvas to be added/removed upon entering/exiting xr
  112954. * @param engine the Babylon engine
  112955. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  112956. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  112957. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  112958. */
  112959. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  112960. /**
  112961. * Disposes of the object
  112962. */
  112963. dispose(): void;
  112964. private _setManagedOutputCanvas;
  112965. private _addCanvas;
  112966. private _removeCanvas;
  112967. }
  112968. }
  112969. declare module BABYLON {
  112970. /**
  112971. * Manages an XRSession to work with Babylon's engine
  112972. * @see https://doc.babylonjs.com/how_to/webxr
  112973. */
  112974. export class WebXRSessionManager implements IDisposable {
  112975. /** The scene which the session should be created for */
  112976. scene: Scene;
  112977. /**
  112978. * Fires every time a new xrFrame arrives which can be used to update the camera
  112979. */
  112980. onXRFrameObservable: Observable<XRFrame>;
  112981. /**
  112982. * Fires when the xr session is ended either by the device or manually done
  112983. */
  112984. onXRSessionEnded: Observable<any>;
  112985. /**
  112986. * Fires when the xr session is ended either by the device or manually done
  112987. */
  112988. onXRSessionInit: Observable<XRSession>;
  112989. /**
  112990. * Underlying xr session
  112991. */
  112992. session: XRSession;
  112993. /**
  112994. * Type of reference space used when creating the session
  112995. */
  112996. referenceSpace: XRReferenceSpace;
  112997. /**
  112998. * Current XR frame
  112999. */
  113000. currentFrame: Nullable<XRFrame>;
  113001. /** WebXR timestamp updated every frame */
  113002. currentTimestamp: number;
  113003. private _xrNavigator;
  113004. private baseLayer;
  113005. private _rttProvider;
  113006. private _sessionEnded;
  113007. /**
  113008. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  113009. * @param scene The scene which the session should be created for
  113010. */
  113011. constructor(
  113012. /** The scene which the session should be created for */
  113013. scene: Scene);
  113014. /**
  113015. * Initializes the manager
  113016. * After initialization enterXR can be called to start an XR session
  113017. * @returns Promise which resolves after it is initialized
  113018. */
  113019. initializeAsync(): Promise<void>;
  113020. /**
  113021. * Initializes an xr session
  113022. * @param xrSessionMode mode to initialize
  113023. * @param optionalFeatures defines optional values to pass to the session builder
  113024. * @returns a promise which will resolve once the session has been initialized
  113025. */
  113026. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  113027. /**
  113028. * Sets the reference space on the xr session
  113029. * @param referenceSpace space to set
  113030. * @returns a promise that will resolve once the reference space has been set
  113031. */
  113032. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  113033. /**
  113034. * Updates the render state of the session
  113035. * @param state state to set
  113036. * @returns a promise that resolves once the render state has been updated
  113037. */
  113038. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  113039. /**
  113040. * Starts rendering to the xr layer
  113041. * @returns a promise that will resolve once rendering has started
  113042. */
  113043. startRenderingToXRAsync(): Promise<void>;
  113044. /**
  113045. * Gets the correct render target texture to be rendered this frame for this eye
  113046. * @param eye the eye for which to get the render target
  113047. * @returns the render target for the specified eye
  113048. */
  113049. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  113050. /**
  113051. * Stops the xrSession and restores the renderloop
  113052. * @returns Promise which resolves after it exits XR
  113053. */
  113054. exitXRAsync(): Promise<void>;
  113055. /**
  113056. * Checks if a session would be supported for the creation options specified
  113057. * @param sessionMode session mode to check if supported eg. immersive-vr
  113058. * @returns true if supported
  113059. */
  113060. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  113061. /**
  113062. * Creates a WebXRRenderTarget object for the XR session
  113063. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  113064. * @param options optional options to provide when creating a new render target
  113065. * @returns a WebXR render target to which the session can render
  113066. */
  113067. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  113068. /**
  113069. * @hidden
  113070. * Converts the render layer of xrSession to a render target
  113071. * @param session session to create render target for
  113072. * @param scene scene the new render target should be created for
  113073. * @param baseLayer the webgl layer to create the render target for
  113074. */
  113075. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  113076. /**
  113077. * Disposes of the session manager
  113078. */
  113079. dispose(): void;
  113080. /**
  113081. * Gets a promise returning true when fullfiled if the given session mode is supported
  113082. * @param sessionMode defines the session to test
  113083. * @returns a promise
  113084. */
  113085. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  113086. }
  113087. }
  113088. declare module BABYLON {
  113089. /**
  113090. * WebXR Camera which holds the views for the xrSession
  113091. * @see https://doc.babylonjs.com/how_to/webxr
  113092. */
  113093. export class WebXRCamera extends FreeCamera {
  113094. /**
  113095. * Is the camera in debug mode. Used when using an emulator
  113096. */
  113097. debugMode: boolean;
  113098. /**
  113099. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  113100. * @param name the name of the camera
  113101. * @param scene the scene to add the camera to
  113102. */
  113103. constructor(name: string, scene: Scene);
  113104. private _updateNumberOfRigCameras;
  113105. /** @hidden */
  113106. _updateForDualEyeDebugging(): void;
  113107. /**
  113108. * Updates the cameras position from the current pose information of the XR session
  113109. * @param xrSessionManager the session containing pose information
  113110. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  113111. */
  113112. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  113113. }
  113114. }
  113115. declare module BABYLON {
  113116. /**
  113117. * Defining the interface required for a (webxr) feature
  113118. */
  113119. export interface IWebXRFeature extends IDisposable {
  113120. /**
  113121. * Attach the feature to the session
  113122. * Will usually be called by the features manager
  113123. *
  113124. * @returns true if successful.
  113125. */
  113126. attach(): boolean;
  113127. /**
  113128. * Detach the feature from the session
  113129. * Will usually be called by the features manager
  113130. *
  113131. * @returns true if successful.
  113132. */
  113133. detach(): boolean;
  113134. }
  113135. /**
  113136. * Defining the constructor of a feature. Used to register the modules.
  113137. */
  113138. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  113139. /**
  113140. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  113141. * It is mainly used in AR sessions.
  113142. *
  113143. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  113144. */
  113145. export class WebXRFeaturesManager implements IDisposable {
  113146. private _xrSessionManager;
  113147. private static readonly _AvailableFeatures;
  113148. /**
  113149. * Used to register a module. After calling this function a developer can use this feature in the scene.
  113150. * Mainly used internally.
  113151. *
  113152. * @param featureName the name of the feature to register
  113153. * @param constructorFunction the function used to construct the module
  113154. * @param version the (babylon) version of the module
  113155. * @param stable is that a stable version of this module
  113156. */
  113157. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  113158. /**
  113159. * Returns a constructor of a specific feature.
  113160. *
  113161. * @param featureName the name of the feature to construct
  113162. * @param version the version of the feature to load
  113163. * @param xrSessionManager the xrSessionManager. Used to construct the module
  113164. * @param options optional options provided to the module.
  113165. * @returns a function that, when called, will return a new instance of this feature
  113166. */
  113167. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  113168. /**
  113169. * Return the latest unstable version of this feature
  113170. * @param featureName the name of the feature to search
  113171. * @returns the version number. if not found will return -1
  113172. */
  113173. static GetLatestVersionOfFeature(featureName: string): number;
  113174. /**
  113175. * Return the latest stable version of this feature
  113176. * @param featureName the name of the feature to search
  113177. * @returns the version number. if not found will return -1
  113178. */
  113179. static GetStableVersionOfFeature(featureName: string): number;
  113180. /**
  113181. * Can be used to return the list of features currently registered
  113182. *
  113183. * @returns an Array of available features
  113184. */
  113185. static GetAvailableFeatures(): string[];
  113186. /**
  113187. * Gets the versions available for a specific feature
  113188. * @param featureName the name of the feature
  113189. * @returns an array with the available versions
  113190. */
  113191. static GetAvailableVersions(featureName: string): string[];
  113192. private _features;
  113193. /**
  113194. * constructs a new features manages.
  113195. *
  113196. * @param _xrSessionManager an instance of WebXRSessionManager
  113197. */
  113198. constructor(_xrSessionManager: WebXRSessionManager);
  113199. /**
  113200. * 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.
  113201. *
  113202. * @param featureName the name of the feature to load or the class of the feature
  113203. * @param version optional version to load. if not provided the latest version will be enabled
  113204. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  113205. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  113206. * @returns a new constructed feature or throws an error if feature not found.
  113207. */
  113208. enableFeature(featureName: string | {
  113209. Name: string;
  113210. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  113211. /**
  113212. * Used to disable an already-enabled feature
  113213. * @param featureName the feature to disable
  113214. * @returns true if disable was successful
  113215. */
  113216. disableFeature(featureName: string | {
  113217. Name: string;
  113218. }): boolean;
  113219. /**
  113220. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  113221. * Can be used during a session to start a feature
  113222. * @param featureName the name of feature to attach
  113223. */
  113224. attachFeature(featureName: string): void;
  113225. /**
  113226. * Can be used inside a session or when the session ends to detach a specific feature
  113227. * @param featureName the name of the feature to detach
  113228. */
  113229. detachFeature(featureName: string): void;
  113230. /**
  113231. * Get the list of enabled features
  113232. * @returns an array of enabled features
  113233. */
  113234. getEnabledFeatures(): string[];
  113235. /**
  113236. * get the implementation of an enabled feature.
  113237. * @param featureName the name of the feature to load
  113238. * @returns the feature class, if found
  113239. */
  113240. getEnabledFeature(featureName: string): IWebXRFeature;
  113241. /**
  113242. * dispose this features manager
  113243. */
  113244. dispose(): void;
  113245. }
  113246. }
  113247. declare module BABYLON {
  113248. /**
  113249. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  113250. * @see https://doc.babylonjs.com/how_to/webxr
  113251. */
  113252. export class WebXRExperienceHelper implements IDisposable {
  113253. private scene;
  113254. /**
  113255. * 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
  113256. */
  113257. container: AbstractMesh;
  113258. /**
  113259. * Camera used to render xr content
  113260. */
  113261. camera: WebXRCamera;
  113262. /**
  113263. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  113264. */
  113265. state: WebXRState;
  113266. private _setState;
  113267. private static _TmpVector;
  113268. /**
  113269. * Fires when the state of the experience helper has changed
  113270. */
  113271. onStateChangedObservable: Observable<WebXRState>;
  113272. /** Session manager used to keep track of xr session */
  113273. sessionManager: WebXRSessionManager;
  113274. /** A features manager for this xr session */
  113275. featuresManager: WebXRFeaturesManager;
  113276. private _nonVRCamera;
  113277. private _originalSceneAutoClear;
  113278. private _supported;
  113279. /**
  113280. * Creates the experience helper
  113281. * @param scene the scene to attach the experience helper to
  113282. * @returns a promise for the experience helper
  113283. */
  113284. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  113285. /**
  113286. * Creates a WebXRExperienceHelper
  113287. * @param scene The scene the helper should be created in
  113288. */
  113289. private constructor();
  113290. /**
  113291. * Exits XR mode and returns the scene to its original state
  113292. * @returns promise that resolves after xr mode has exited
  113293. */
  113294. exitXRAsync(): Promise<void>;
  113295. /**
  113296. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  113297. * @param sessionMode options for the XR session
  113298. * @param referenceSpaceType frame of reference of the XR session
  113299. * @param renderTarget the output canvas that will be used to enter XR mode
  113300. * @returns promise that resolves after xr mode has entered
  113301. */
  113302. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  113303. /**
  113304. * Updates the global position of the camera by moving the camera's container
  113305. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  113306. * @param position The desired global position of the camera
  113307. */
  113308. setPositionOfCameraUsingContainer(position: Vector3): void;
  113309. /**
  113310. * Rotates the xr camera by rotating the camera's container around the camera's position
  113311. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  113312. * @param rotation the desired quaternion rotation to apply to the camera
  113313. */
  113314. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  113315. /**
  113316. * Disposes of the experience helper
  113317. */
  113318. dispose(): void;
  113319. }
  113320. }
  113321. declare module BABYLON {
  113322. /**
  113323. * Represents an XR input
  113324. */
  113325. export class WebXRController {
  113326. private scene;
  113327. /** The underlying input source for the controller */
  113328. inputSource: XRInputSource;
  113329. private parentContainer;
  113330. /**
  113331. * 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
  113332. */
  113333. grip?: AbstractMesh;
  113334. /**
  113335. * Pointer which can be used to select objects or attach a visible laser to
  113336. */
  113337. pointer: AbstractMesh;
  113338. private _gamepadMode;
  113339. /**
  113340. * If available, this is the gamepad object related to this controller.
  113341. * Using this object it is possible to get click events and trackpad changes of the
  113342. * webxr controller that is currently being used.
  113343. */
  113344. gamepadController?: WebVRController;
  113345. /**
  113346. * Event that fires when the controller is removed/disposed
  113347. */
  113348. onDisposeObservable: Observable<{}>;
  113349. private _tmpQuaternion;
  113350. private _tmpVector;
  113351. /**
  113352. * Creates the controller
  113353. * @see https://doc.babylonjs.com/how_to/webxr
  113354. * @param scene the scene which the controller should be associated to
  113355. * @param inputSource the underlying input source for the controller
  113356. * @param parentContainer parent that the controller meshes should be children of
  113357. */
  113358. constructor(scene: Scene,
  113359. /** The underlying input source for the controller */
  113360. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  113361. /**
  113362. * Updates the controller pose based on the given XRFrame
  113363. * @param xrFrame xr frame to update the pose with
  113364. * @param referenceSpace reference space to use
  113365. */
  113366. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  113367. /**
  113368. * Gets a world space ray coming from the controller
  113369. * @param result the resulting ray
  113370. */
  113371. getWorldPointerRayToRef(result: Ray): void;
  113372. /**
  113373. * Get the scene associated with this controller
  113374. * @returns the scene object
  113375. */
  113376. getScene(): Scene;
  113377. /**
  113378. * Disposes of the object
  113379. */
  113380. dispose(): void;
  113381. }
  113382. }
  113383. declare module BABYLON {
  113384. /**
  113385. * XR input used to track XR inputs such as controllers/rays
  113386. */
  113387. export class WebXRInput implements IDisposable {
  113388. /**
  113389. * Base experience the input listens to
  113390. */
  113391. baseExperience: WebXRExperienceHelper;
  113392. /**
  113393. * XR controllers being tracked
  113394. */
  113395. controllers: Array<WebXRController>;
  113396. private _frameObserver;
  113397. private _stateObserver;
  113398. /**
  113399. * Event when a controller has been connected/added
  113400. */
  113401. onControllerAddedObservable: Observable<WebXRController>;
  113402. /**
  113403. * Event when a controller has been removed/disconnected
  113404. */
  113405. onControllerRemovedObservable: Observable<WebXRController>;
  113406. /**
  113407. * Initializes the WebXRInput
  113408. * @param baseExperience experience helper which the input should be created for
  113409. */
  113410. constructor(
  113411. /**
  113412. * Base experience the input listens to
  113413. */
  113414. baseExperience: WebXRExperienceHelper);
  113415. private _onInputSourcesChange;
  113416. private _addAndRemoveControllers;
  113417. /**
  113418. * Disposes of the object
  113419. */
  113420. dispose(): void;
  113421. }
  113422. }
  113423. declare module BABYLON {
  113424. /**
  113425. * Class used to represent data loading progression
  113426. */
  113427. export class SceneLoaderProgressEvent {
  113428. /** defines if data length to load can be evaluated */
  113429. readonly lengthComputable: boolean;
  113430. /** defines the loaded data length */
  113431. readonly loaded: number;
  113432. /** defines the data length to load */
  113433. readonly total: number;
  113434. /**
  113435. * Create a new progress event
  113436. * @param lengthComputable defines if data length to load can be evaluated
  113437. * @param loaded defines the loaded data length
  113438. * @param total defines the data length to load
  113439. */
  113440. constructor(
  113441. /** defines if data length to load can be evaluated */
  113442. lengthComputable: boolean,
  113443. /** defines the loaded data length */
  113444. loaded: number,
  113445. /** defines the data length to load */
  113446. total: number);
  113447. /**
  113448. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  113449. * @param event defines the source event
  113450. * @returns a new SceneLoaderProgressEvent
  113451. */
  113452. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  113453. }
  113454. /**
  113455. * Interface used by SceneLoader plugins to define supported file extensions
  113456. */
  113457. export interface ISceneLoaderPluginExtensions {
  113458. /**
  113459. * Defines the list of supported extensions
  113460. */
  113461. [extension: string]: {
  113462. isBinary: boolean;
  113463. };
  113464. }
  113465. /**
  113466. * Interface used by SceneLoader plugin factory
  113467. */
  113468. export interface ISceneLoaderPluginFactory {
  113469. /**
  113470. * Defines the name of the factory
  113471. */
  113472. name: string;
  113473. /**
  113474. * Function called to create a new plugin
  113475. * @return the new plugin
  113476. */
  113477. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  113478. /**
  113479. * The callback that returns true if the data can be directly loaded.
  113480. * @param data string containing the file data
  113481. * @returns if the data can be loaded directly
  113482. */
  113483. canDirectLoad?(data: string): boolean;
  113484. }
  113485. /**
  113486. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  113487. */
  113488. export interface ISceneLoaderPluginBase {
  113489. /**
  113490. * The friendly name of this plugin.
  113491. */
  113492. name: string;
  113493. /**
  113494. * The file extensions supported by this plugin.
  113495. */
  113496. extensions: string | ISceneLoaderPluginExtensions;
  113497. /**
  113498. * The callback called when loading from a url.
  113499. * @param scene scene loading this url
  113500. * @param url url to load
  113501. * @param onSuccess callback called when the file successfully loads
  113502. * @param onProgress callback called while file is loading (if the server supports this mode)
  113503. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  113504. * @param onError callback called when the file fails to load
  113505. * @returns a file request object
  113506. */
  113507. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  113508. /**
  113509. * The callback called when loading from a file object.
  113510. * @param scene scene loading this file
  113511. * @param file defines the file to load
  113512. * @param onSuccess defines the callback to call when data is loaded
  113513. * @param onProgress defines the callback to call during loading process
  113514. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  113515. * @param onError defines the callback to call when an error occurs
  113516. * @returns a file request object
  113517. */
  113518. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  113519. /**
  113520. * The callback that returns true if the data can be directly loaded.
  113521. * @param data string containing the file data
  113522. * @returns if the data can be loaded directly
  113523. */
  113524. canDirectLoad?(data: string): boolean;
  113525. /**
  113526. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  113527. * @param scene scene loading this data
  113528. * @param data string containing the data
  113529. * @returns data to pass to the plugin
  113530. */
  113531. directLoad?(scene: Scene, data: string): any;
  113532. /**
  113533. * The callback that allows custom handling of the root url based on the response url.
  113534. * @param rootUrl the original root url
  113535. * @param responseURL the response url if available
  113536. * @returns the new root url
  113537. */
  113538. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  113539. }
  113540. /**
  113541. * Interface used to define a SceneLoader plugin
  113542. */
  113543. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  113544. /**
  113545. * Import meshes into a scene.
  113546. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  113547. * @param scene The scene to import into
  113548. * @param data The data to import
  113549. * @param rootUrl The root url for scene and resources
  113550. * @param meshes The meshes array to import into
  113551. * @param particleSystems The particle systems array to import into
  113552. * @param skeletons The skeletons array to import into
  113553. * @param onError The callback when import fails
  113554. * @returns True if successful or false otherwise
  113555. */
  113556. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  113557. /**
  113558. * Load into a scene.
  113559. * @param scene The scene to load into
  113560. * @param data The data to import
  113561. * @param rootUrl The root url for scene and resources
  113562. * @param onError The callback when import fails
  113563. * @returns True if successful or false otherwise
  113564. */
  113565. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  113566. /**
  113567. * Load into an asset container.
  113568. * @param scene The scene to load into
  113569. * @param data The data to import
  113570. * @param rootUrl The root url for scene and resources
  113571. * @param onError The callback when import fails
  113572. * @returns The loaded asset container
  113573. */
  113574. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  113575. }
  113576. /**
  113577. * Interface used to define an async SceneLoader plugin
  113578. */
  113579. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  113580. /**
  113581. * Import meshes into a scene.
  113582. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  113583. * @param scene The scene to import into
  113584. * @param data The data to import
  113585. * @param rootUrl The root url for scene and resources
  113586. * @param onProgress The callback when the load progresses
  113587. * @param fileName Defines the name of the file to load
  113588. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  113589. */
  113590. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  113591. meshes: AbstractMesh[];
  113592. particleSystems: IParticleSystem[];
  113593. skeletons: Skeleton[];
  113594. animationGroups: AnimationGroup[];
  113595. }>;
  113596. /**
  113597. * Load into a scene.
  113598. * @param scene The scene to load into
  113599. * @param data The data to import
  113600. * @param rootUrl The root url for scene and resources
  113601. * @param onProgress The callback when the load progresses
  113602. * @param fileName Defines the name of the file to load
  113603. * @returns Nothing
  113604. */
  113605. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  113606. /**
  113607. * Load into an asset container.
  113608. * @param scene The scene to load into
  113609. * @param data The data to import
  113610. * @param rootUrl The root url for scene and resources
  113611. * @param onProgress The callback when the load progresses
  113612. * @param fileName Defines the name of the file to load
  113613. * @returns The loaded asset container
  113614. */
  113615. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  113616. }
  113617. /**
  113618. * Mode that determines how to handle old animation groups before loading new ones.
  113619. */
  113620. export enum SceneLoaderAnimationGroupLoadingMode {
  113621. /**
  113622. * Reset all old animations to initial state then dispose them.
  113623. */
  113624. Clean = 0,
  113625. /**
  113626. * Stop all old animations.
  113627. */
  113628. Stop = 1,
  113629. /**
  113630. * Restart old animations from first frame.
  113631. */
  113632. Sync = 2,
  113633. /**
  113634. * Old animations remains untouched.
  113635. */
  113636. NoSync = 3
  113637. }
  113638. /**
  113639. * Class used to load scene from various file formats using registered plugins
  113640. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  113641. */
  113642. export class SceneLoader {
  113643. /**
  113644. * No logging while loading
  113645. */
  113646. static readonly NO_LOGGING: number;
  113647. /**
  113648. * Minimal logging while loading
  113649. */
  113650. static readonly MINIMAL_LOGGING: number;
  113651. /**
  113652. * Summary logging while loading
  113653. */
  113654. static readonly SUMMARY_LOGGING: number;
  113655. /**
  113656. * Detailled logging while loading
  113657. */
  113658. static readonly DETAILED_LOGGING: number;
  113659. /**
  113660. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  113661. */
  113662. static get ForceFullSceneLoadingForIncremental(): boolean;
  113663. static set ForceFullSceneLoadingForIncremental(value: boolean);
  113664. /**
  113665. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  113666. */
  113667. static get ShowLoadingScreen(): boolean;
  113668. static set ShowLoadingScreen(value: boolean);
  113669. /**
  113670. * Defines the current logging level (while loading the scene)
  113671. * @ignorenaming
  113672. */
  113673. static get loggingLevel(): number;
  113674. static set loggingLevel(value: number);
  113675. /**
  113676. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  113677. */
  113678. static get CleanBoneMatrixWeights(): boolean;
  113679. static set CleanBoneMatrixWeights(value: boolean);
  113680. /**
  113681. * Event raised when a plugin is used to load a scene
  113682. */
  113683. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  113684. private static _registeredPlugins;
  113685. private static _getDefaultPlugin;
  113686. private static _getPluginForExtension;
  113687. private static _getPluginForDirectLoad;
  113688. private static _getPluginForFilename;
  113689. private static _getDirectLoad;
  113690. private static _loadData;
  113691. private static _getFileInfo;
  113692. /**
  113693. * Gets a plugin that can load the given extension
  113694. * @param extension defines the extension to load
  113695. * @returns a plugin or null if none works
  113696. */
  113697. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  113698. /**
  113699. * Gets a boolean indicating that the given extension can be loaded
  113700. * @param extension defines the extension to load
  113701. * @returns true if the extension is supported
  113702. */
  113703. static IsPluginForExtensionAvailable(extension: string): boolean;
  113704. /**
  113705. * Adds a new plugin to the list of registered plugins
  113706. * @param plugin defines the plugin to add
  113707. */
  113708. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  113709. /**
  113710. * Import meshes into a scene
  113711. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  113712. * @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)
  113713. * @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)
  113714. * @param scene the instance of BABYLON.Scene to append to
  113715. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  113716. * @param onProgress a callback with a progress event for each file being loaded
  113717. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113718. * @param pluginExtension the extension used to determine the plugin
  113719. * @returns The loaded plugin
  113720. */
  113721. 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>;
  113722. /**
  113723. * Import meshes into a scene
  113724. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  113725. * @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)
  113726. * @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)
  113727. * @param scene the instance of BABYLON.Scene to append to
  113728. * @param onProgress a callback with a progress event for each file being loaded
  113729. * @param pluginExtension the extension used to determine the plugin
  113730. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  113731. */
  113732. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  113733. meshes: AbstractMesh[];
  113734. particleSystems: IParticleSystem[];
  113735. skeletons: Skeleton[];
  113736. animationGroups: AnimationGroup[];
  113737. }>;
  113738. /**
  113739. * Load a scene
  113740. * @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)
  113741. * @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)
  113742. * @param engine is the instance of BABYLON.Engine to use to create the scene
  113743. * @param onSuccess a callback with the scene when import succeeds
  113744. * @param onProgress a callback with a progress event for each file being loaded
  113745. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113746. * @param pluginExtension the extension used to determine the plugin
  113747. * @returns The loaded plugin
  113748. */
  113749. 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>;
  113750. /**
  113751. * Load a scene
  113752. * @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)
  113753. * @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)
  113754. * @param engine is the instance of BABYLON.Engine to use to create the scene
  113755. * @param onProgress a callback with a progress event for each file being loaded
  113756. * @param pluginExtension the extension used to determine the plugin
  113757. * @returns The loaded scene
  113758. */
  113759. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  113760. /**
  113761. * Append a scene
  113762. * @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)
  113763. * @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)
  113764. * @param scene is the instance of BABYLON.Scene to append to
  113765. * @param onSuccess a callback with the scene when import succeeds
  113766. * @param onProgress a callback with a progress event for each file being loaded
  113767. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113768. * @param pluginExtension the extension used to determine the plugin
  113769. * @returns The loaded plugin
  113770. */
  113771. 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>;
  113772. /**
  113773. * Append a scene
  113774. * @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)
  113775. * @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)
  113776. * @param scene is the instance of BABYLON.Scene to append to
  113777. * @param onProgress a callback with a progress event for each file being loaded
  113778. * @param pluginExtension the extension used to determine the plugin
  113779. * @returns The given scene
  113780. */
  113781. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  113782. /**
  113783. * Load a scene into an asset container
  113784. * @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)
  113785. * @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)
  113786. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  113787. * @param onSuccess a callback with the scene when import succeeds
  113788. * @param onProgress a callback with a progress event for each file being loaded
  113789. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113790. * @param pluginExtension the extension used to determine the plugin
  113791. * @returns The loaded plugin
  113792. */
  113793. 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>;
  113794. /**
  113795. * Load a scene into an asset container
  113796. * @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)
  113797. * @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)
  113798. * @param scene is the instance of Scene to append to
  113799. * @param onProgress a callback with a progress event for each file being loaded
  113800. * @param pluginExtension the extension used to determine the plugin
  113801. * @returns The loaded asset container
  113802. */
  113803. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  113804. /**
  113805. * Import animations from a file into a scene
  113806. * @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)
  113807. * @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)
  113808. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  113809. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  113810. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  113811. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  113812. * @param onSuccess a callback with the scene when import succeeds
  113813. * @param onProgress a callback with a progress event for each file being loaded
  113814. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113815. */
  113816. 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;
  113817. /**
  113818. * Import animations from a file into a scene
  113819. * @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)
  113820. * @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)
  113821. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  113822. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  113823. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  113824. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  113825. * @param onSuccess a callback with the scene when import succeeds
  113826. * @param onProgress a callback with a progress event for each file being loaded
  113827. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113828. * @returns the updated scene with imported animations
  113829. */
  113830. 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>;
  113831. }
  113832. }
  113833. declare module BABYLON {
  113834. /**
  113835. * Generic Controller
  113836. */
  113837. export class GenericController extends WebVRController {
  113838. /**
  113839. * Base Url for the controller model.
  113840. */
  113841. static readonly MODEL_BASE_URL: string;
  113842. /**
  113843. * File name for the controller model.
  113844. */
  113845. static readonly MODEL_FILENAME: string;
  113846. /**
  113847. * Creates a new GenericController from a gamepad
  113848. * @param vrGamepad the gamepad that the controller should be created from
  113849. */
  113850. constructor(vrGamepad: any);
  113851. /**
  113852. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113853. * @param scene scene in which to add meshes
  113854. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113855. */
  113856. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113857. /**
  113858. * Called once for each button that changed state since the last frame
  113859. * @param buttonIdx Which button index changed
  113860. * @param state New state of the button
  113861. * @param changes Which properties on the state changed since last frame
  113862. */
  113863. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113864. }
  113865. }
  113866. declare module BABYLON {
  113867. /**
  113868. * Defines the WindowsMotionController object that the state of the windows motion controller
  113869. */
  113870. export class WindowsMotionController extends WebVRController {
  113871. /**
  113872. * The base url used to load the left and right controller models
  113873. */
  113874. static MODEL_BASE_URL: string;
  113875. /**
  113876. * The name of the left controller model file
  113877. */
  113878. static MODEL_LEFT_FILENAME: string;
  113879. /**
  113880. * The name of the right controller model file
  113881. */
  113882. static MODEL_RIGHT_FILENAME: string;
  113883. /**
  113884. * The controller name prefix for this controller type
  113885. */
  113886. static readonly GAMEPAD_ID_PREFIX: string;
  113887. /**
  113888. * The controller id pattern for this controller type
  113889. */
  113890. private static readonly GAMEPAD_ID_PATTERN;
  113891. private _loadedMeshInfo;
  113892. protected readonly _mapping: {
  113893. buttons: string[];
  113894. buttonMeshNames: {
  113895. 'trigger': string;
  113896. 'menu': string;
  113897. 'grip': string;
  113898. 'thumbstick': string;
  113899. 'trackpad': string;
  113900. };
  113901. buttonObservableNames: {
  113902. 'trigger': string;
  113903. 'menu': string;
  113904. 'grip': string;
  113905. 'thumbstick': string;
  113906. 'trackpad': string;
  113907. };
  113908. axisMeshNames: string[];
  113909. pointingPoseMeshName: string;
  113910. };
  113911. /**
  113912. * Fired when the trackpad on this controller is clicked
  113913. */
  113914. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  113915. /**
  113916. * Fired when the trackpad on this controller is modified
  113917. */
  113918. onTrackpadValuesChangedObservable: Observable<StickValues>;
  113919. /**
  113920. * The current x and y values of this controller's trackpad
  113921. */
  113922. trackpad: StickValues;
  113923. /**
  113924. * Creates a new WindowsMotionController from a gamepad
  113925. * @param vrGamepad the gamepad that the controller should be created from
  113926. */
  113927. constructor(vrGamepad: any);
  113928. /**
  113929. * Fired when the trigger on this controller is modified
  113930. */
  113931. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113932. /**
  113933. * Fired when the menu button on this controller is modified
  113934. */
  113935. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113936. /**
  113937. * Fired when the grip button on this controller is modified
  113938. */
  113939. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113940. /**
  113941. * Fired when the thumbstick button on this controller is modified
  113942. */
  113943. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113944. /**
  113945. * Fired when the touchpad button on this controller is modified
  113946. */
  113947. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113948. /**
  113949. * Fired when the touchpad values on this controller are modified
  113950. */
  113951. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  113952. protected _updateTrackpad(): void;
  113953. /**
  113954. * Called once per frame by the engine.
  113955. */
  113956. update(): void;
  113957. /**
  113958. * Called once for each button that changed state since the last frame
  113959. * @param buttonIdx Which button index changed
  113960. * @param state New state of the button
  113961. * @param changes Which properties on the state changed since last frame
  113962. */
  113963. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113964. /**
  113965. * Moves the buttons on the controller mesh based on their current state
  113966. * @param buttonName the name of the button to move
  113967. * @param buttonValue the value of the button which determines the buttons new position
  113968. */
  113969. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  113970. /**
  113971. * Moves the axis on the controller mesh based on its current state
  113972. * @param axis the index of the axis
  113973. * @param axisValue the value of the axis which determines the meshes new position
  113974. * @hidden
  113975. */
  113976. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  113977. /**
  113978. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113979. * @param scene scene in which to add meshes
  113980. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113981. */
  113982. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  113983. /**
  113984. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  113985. * can be transformed by button presses and axes values, based on this._mapping.
  113986. *
  113987. * @param scene scene in which the meshes exist
  113988. * @param meshes list of meshes that make up the controller model to process
  113989. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  113990. */
  113991. private processModel;
  113992. private createMeshInfo;
  113993. /**
  113994. * Gets the ray of the controller in the direction the controller is pointing
  113995. * @param length the length the resulting ray should be
  113996. * @returns a ray in the direction the controller is pointing
  113997. */
  113998. getForwardRay(length?: number): Ray;
  113999. /**
  114000. * Disposes of the controller
  114001. */
  114002. dispose(): void;
  114003. }
  114004. /**
  114005. * This class represents a new windows motion controller in XR.
  114006. */
  114007. export class XRWindowsMotionController extends WindowsMotionController {
  114008. /**
  114009. * Changing the original WIndowsMotionController mapping to fir the new mapping
  114010. */
  114011. protected readonly _mapping: {
  114012. buttons: string[];
  114013. buttonMeshNames: {
  114014. 'trigger': string;
  114015. 'menu': string;
  114016. 'grip': string;
  114017. 'thumbstick': string;
  114018. 'trackpad': string;
  114019. };
  114020. buttonObservableNames: {
  114021. 'trigger': string;
  114022. 'menu': string;
  114023. 'grip': string;
  114024. 'thumbstick': string;
  114025. 'trackpad': string;
  114026. };
  114027. axisMeshNames: string[];
  114028. pointingPoseMeshName: string;
  114029. };
  114030. /**
  114031. * Construct a new XR-Based windows motion controller
  114032. *
  114033. * @param gamepadInfo the gamepad object from the browser
  114034. */
  114035. constructor(gamepadInfo: any);
  114036. /**
  114037. * holds the thumbstick values (X,Y)
  114038. */
  114039. thumbstickValues: StickValues;
  114040. /**
  114041. * Fired when the thumbstick on this controller is clicked
  114042. */
  114043. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  114044. /**
  114045. * Fired when the thumbstick on this controller is modified
  114046. */
  114047. onThumbstickValuesChangedObservable: Observable<StickValues>;
  114048. /**
  114049. * Fired when the touchpad button on this controller is modified
  114050. */
  114051. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  114052. /**
  114053. * Fired when the touchpad values on this controller are modified
  114054. */
  114055. onTrackpadValuesChangedObservable: Observable<StickValues>;
  114056. /**
  114057. * Fired when the thumbstick button on this controller is modified
  114058. * here to prevent breaking changes
  114059. */
  114060. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114061. /**
  114062. * updating the thumbstick(!) and not the trackpad.
  114063. * This is named this way due to the difference between WebVR and XR and to avoid
  114064. * changing the parent class.
  114065. */
  114066. protected _updateTrackpad(): void;
  114067. /**
  114068. * Disposes the class with joy
  114069. */
  114070. dispose(): void;
  114071. }
  114072. }
  114073. declare module BABYLON {
  114074. /**
  114075. * Oculus Touch Controller
  114076. */
  114077. export class OculusTouchController extends WebVRController {
  114078. /**
  114079. * Base Url for the controller model.
  114080. */
  114081. static MODEL_BASE_URL: string;
  114082. /**
  114083. * File name for the left controller model.
  114084. */
  114085. static MODEL_LEFT_FILENAME: string;
  114086. /**
  114087. * File name for the right controller model.
  114088. */
  114089. static MODEL_RIGHT_FILENAME: string;
  114090. /**
  114091. * Base Url for the Quest controller model.
  114092. */
  114093. static QUEST_MODEL_BASE_URL: string;
  114094. /**
  114095. * @hidden
  114096. * If the controllers are running on a device that needs the updated Quest controller models
  114097. */
  114098. static _IsQuest: boolean;
  114099. /**
  114100. * Fired when the secondary trigger on this controller is modified
  114101. */
  114102. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  114103. /**
  114104. * Fired when the thumb rest on this controller is modified
  114105. */
  114106. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  114107. /**
  114108. * Creates a new OculusTouchController from a gamepad
  114109. * @param vrGamepad the gamepad that the controller should be created from
  114110. */
  114111. constructor(vrGamepad: any);
  114112. /**
  114113. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  114114. * @param scene scene in which to add meshes
  114115. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  114116. */
  114117. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  114118. /**
  114119. * Fired when the A button on this controller is modified
  114120. */
  114121. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114122. /**
  114123. * Fired when the B button on this controller is modified
  114124. */
  114125. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114126. /**
  114127. * Fired when the X button on this controller is modified
  114128. */
  114129. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114130. /**
  114131. * Fired when the Y button on this controller is modified
  114132. */
  114133. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114134. /**
  114135. * Called once for each button that changed state since the last frame
  114136. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  114137. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  114138. * 2) secondary trigger (same)
  114139. * 3) A (right) X (left), touch, pressed = value
  114140. * 4) B / Y
  114141. * 5) thumb rest
  114142. * @param buttonIdx Which button index changed
  114143. * @param state New state of the button
  114144. * @param changes Which properties on the state changed since last frame
  114145. */
  114146. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  114147. }
  114148. }
  114149. declare module BABYLON {
  114150. /**
  114151. * Vive Controller
  114152. */
  114153. export class ViveController extends WebVRController {
  114154. /**
  114155. * Base Url for the controller model.
  114156. */
  114157. static MODEL_BASE_URL: string;
  114158. /**
  114159. * File name for the controller model.
  114160. */
  114161. static MODEL_FILENAME: string;
  114162. /**
  114163. * Creates a new ViveController from a gamepad
  114164. * @param vrGamepad the gamepad that the controller should be created from
  114165. */
  114166. constructor(vrGamepad: any);
  114167. /**
  114168. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  114169. * @param scene scene in which to add meshes
  114170. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  114171. */
  114172. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  114173. /**
  114174. * Fired when the left button on this controller is modified
  114175. */
  114176. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114177. /**
  114178. * Fired when the right button on this controller is modified
  114179. */
  114180. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114181. /**
  114182. * Fired when the menu button on this controller is modified
  114183. */
  114184. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114185. /**
  114186. * Called once for each button that changed state since the last frame
  114187. * Vive mapping:
  114188. * 0: touchpad
  114189. * 1: trigger
  114190. * 2: left AND right buttons
  114191. * 3: menu button
  114192. * @param buttonIdx Which button index changed
  114193. * @param state New state of the button
  114194. * @param changes Which properties on the state changed since last frame
  114195. */
  114196. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  114197. }
  114198. }
  114199. declare module BABYLON {
  114200. /**
  114201. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  114202. */
  114203. export class WebXRControllerModelLoader {
  114204. /**
  114205. * an observable that triggers when a new model (the mesh itself) was initialized.
  114206. * To know when the mesh was loaded use the controller's own modelLoaded() method
  114207. */
  114208. onControllerModelLoaded: Observable<WebXRController>;
  114209. /**
  114210. * Creates the WebXRControllerModelLoader
  114211. * @param input xr input that creates the controllers
  114212. */
  114213. constructor(input: WebXRInput);
  114214. }
  114215. }
  114216. declare module BABYLON {
  114217. /**
  114218. * Handles pointer input automatically for the pointer of XR controllers
  114219. */
  114220. export class WebXRControllerPointerSelection {
  114221. private static _idCounter;
  114222. private _tmpRay;
  114223. /**
  114224. * Creates a WebXRControllerPointerSelection
  114225. * @param input input manager to setup pointer selection
  114226. */
  114227. constructor(input: WebXRInput);
  114228. private _convertNormalToDirectionOfRay;
  114229. private _updatePointerDistance;
  114230. }
  114231. }
  114232. declare module BABYLON {
  114233. /**
  114234. * Enables teleportation
  114235. */
  114236. export class WebXRControllerTeleportation {
  114237. private _teleportationFillColor;
  114238. private _teleportationBorderColor;
  114239. private _tmpRay;
  114240. private _tmpVector;
  114241. /**
  114242. * when set to true (default) teleportation will wait for thumbstick changes.
  114243. * When set to false teleportation will be disabled.
  114244. *
  114245. * If set to false while teleporting results can be unexpected.
  114246. */
  114247. enabled: boolean;
  114248. /**
  114249. * Creates a WebXRControllerTeleportation
  114250. * @param input input manager to add teleportation to
  114251. * @param floorMeshes floormeshes which can be teleported to
  114252. */
  114253. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  114254. }
  114255. }
  114256. declare module BABYLON {
  114257. /**
  114258. * Button which can be used to enter a different mode of XR
  114259. */
  114260. export class WebXREnterExitUIButton {
  114261. /** button element */
  114262. element: HTMLElement;
  114263. /** XR initialization options for the button */
  114264. sessionMode: XRSessionMode;
  114265. /** Reference space type */
  114266. referenceSpaceType: XRReferenceSpaceType;
  114267. /**
  114268. * Creates a WebXREnterExitUIButton
  114269. * @param element button element
  114270. * @param sessionMode XR initialization session mode
  114271. * @param referenceSpaceType the type of reference space to be used
  114272. */
  114273. constructor(
  114274. /** button element */
  114275. element: HTMLElement,
  114276. /** XR initialization options for the button */
  114277. sessionMode: XRSessionMode,
  114278. /** Reference space type */
  114279. referenceSpaceType: XRReferenceSpaceType);
  114280. /**
  114281. * Overwritable function which can be used to update the button's visuals when the state changes
  114282. * @param activeButton the current active button in the UI
  114283. */
  114284. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  114285. }
  114286. /**
  114287. * Options to create the webXR UI
  114288. */
  114289. export class WebXREnterExitUIOptions {
  114290. /**
  114291. * Context to enter xr with
  114292. */
  114293. renderTarget?: Nullable<WebXRRenderTarget>;
  114294. /**
  114295. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  114296. */
  114297. customButtons?: Array<WebXREnterExitUIButton>;
  114298. /**
  114299. * A session mode to use when creating the default button.
  114300. * Default is immersive-vr
  114301. */
  114302. sessionMode?: XRSessionMode;
  114303. /**
  114304. * A reference space type to use when creating the default button.
  114305. * Default is local-floor
  114306. */
  114307. referenceSpaceType?: XRReferenceSpaceType;
  114308. }
  114309. /**
  114310. * UI to allow the user to enter/exit XR mode
  114311. */
  114312. export class WebXREnterExitUI implements IDisposable {
  114313. private scene;
  114314. /** version of the options passed to this UI */
  114315. options: WebXREnterExitUIOptions;
  114316. private _overlay;
  114317. private _buttons;
  114318. private _activeButton;
  114319. /**
  114320. * Fired every time the active button is changed.
  114321. *
  114322. * When xr is entered via a button that launches xr that button will be the callback parameter
  114323. *
  114324. * When exiting xr the callback parameter will be null)
  114325. */
  114326. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  114327. /**
  114328. * Creates UI to allow the user to enter/exit XR mode
  114329. * @param scene the scene to add the ui to
  114330. * @param helper the xr experience helper to enter/exit xr with
  114331. * @param options options to configure the UI
  114332. * @returns the created ui
  114333. */
  114334. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  114335. /**
  114336. *
  114337. * @param scene babylon scene object to use
  114338. * @param options (read-only) version of the options passed to this UI
  114339. */
  114340. private constructor();
  114341. private _updateButtons;
  114342. /**
  114343. * Disposes of the object
  114344. */
  114345. dispose(): void;
  114346. }
  114347. }
  114348. declare module BABYLON {
  114349. /**
  114350. * Options for the default xr helper
  114351. */
  114352. export class WebXRDefaultExperienceOptions {
  114353. /**
  114354. * Floor meshes that should be used for teleporting
  114355. */
  114356. floorMeshes: Array<AbstractMesh>;
  114357. /**
  114358. * Enable or disable default UI to enter XR
  114359. */
  114360. disableDefaultUI?: boolean;
  114361. /**
  114362. * optional configuration for the output canvas
  114363. */
  114364. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  114365. /**
  114366. * optional UI options. This can be used among other to change session mode and reference space type
  114367. */
  114368. uiOptions?: WebXREnterExitUIOptions;
  114369. }
  114370. /**
  114371. * Default experience which provides a similar setup to the previous webVRExperience
  114372. */
  114373. export class WebXRDefaultExperience {
  114374. /**
  114375. * Base experience
  114376. */
  114377. baseExperience: WebXRExperienceHelper;
  114378. /**
  114379. * Input experience extension
  114380. */
  114381. input: WebXRInput;
  114382. /**
  114383. * Loads the controller models
  114384. */
  114385. controllerModelLoader: WebXRControllerModelLoader;
  114386. /**
  114387. * Enables laser pointer and selection
  114388. */
  114389. pointerSelection: WebXRControllerPointerSelection;
  114390. /**
  114391. * Enables teleportation
  114392. */
  114393. teleportation: WebXRControllerTeleportation;
  114394. /**
  114395. * Enables ui for entering/exiting xr
  114396. */
  114397. enterExitUI: WebXREnterExitUI;
  114398. /**
  114399. * Default target xr should render to
  114400. */
  114401. renderTarget: WebXRRenderTarget;
  114402. /**
  114403. * Creates the default xr experience
  114404. * @param scene scene
  114405. * @param options options for basic configuration
  114406. * @returns resulting WebXRDefaultExperience
  114407. */
  114408. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  114409. private constructor();
  114410. /**
  114411. * DIsposes of the experience helper
  114412. */
  114413. dispose(): void;
  114414. }
  114415. }
  114416. declare module BABYLON {
  114417. /**
  114418. * Options to modify the vr teleportation behavior.
  114419. */
  114420. export interface VRTeleportationOptions {
  114421. /**
  114422. * The name of the mesh which should be used as the teleportation floor. (default: null)
  114423. */
  114424. floorMeshName?: string;
  114425. /**
  114426. * A list of meshes to be used as the teleportation floor. (default: empty)
  114427. */
  114428. floorMeshes?: Mesh[];
  114429. /**
  114430. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  114431. */
  114432. teleportationMode?: number;
  114433. /**
  114434. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  114435. */
  114436. teleportationTime?: number;
  114437. /**
  114438. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  114439. */
  114440. teleportationSpeed?: number;
  114441. /**
  114442. * The easing function used in the animation or null for Linear. (default CircleEase)
  114443. */
  114444. easingFunction?: EasingFunction;
  114445. }
  114446. /**
  114447. * Options to modify the vr experience helper's behavior.
  114448. */
  114449. export interface VRExperienceHelperOptions extends WebVROptions {
  114450. /**
  114451. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  114452. */
  114453. createDeviceOrientationCamera?: boolean;
  114454. /**
  114455. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  114456. */
  114457. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  114458. /**
  114459. * Uses the main button on the controller to toggle the laser casted. (default: true)
  114460. */
  114461. laserToggle?: boolean;
  114462. /**
  114463. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  114464. */
  114465. floorMeshes?: Mesh[];
  114466. /**
  114467. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  114468. */
  114469. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  114470. /**
  114471. * Defines if WebXR should be used instead of WebVR (if available)
  114472. */
  114473. useXR?: boolean;
  114474. }
  114475. /**
  114476. * Event containing information after VR has been entered
  114477. */
  114478. export class OnAfterEnteringVRObservableEvent {
  114479. /**
  114480. * If entering vr was successful
  114481. */
  114482. success: boolean;
  114483. }
  114484. /**
  114485. * Helps to quickly add VR support to an existing scene.
  114486. * See http://doc.babylonjs.com/how_to/webvr_helper
  114487. */
  114488. export class VRExperienceHelper {
  114489. /** Options to modify the vr experience helper's behavior. */
  114490. webVROptions: VRExperienceHelperOptions;
  114491. private _scene;
  114492. private _position;
  114493. private _btnVR;
  114494. private _btnVRDisplayed;
  114495. private _webVRsupported;
  114496. private _webVRready;
  114497. private _webVRrequesting;
  114498. private _webVRpresenting;
  114499. private _hasEnteredVR;
  114500. private _fullscreenVRpresenting;
  114501. private _inputElement;
  114502. private _webVRCamera;
  114503. private _vrDeviceOrientationCamera;
  114504. private _deviceOrientationCamera;
  114505. private _existingCamera;
  114506. private _onKeyDown;
  114507. private _onVrDisplayPresentChange;
  114508. private _onVRDisplayChanged;
  114509. private _onVRRequestPresentStart;
  114510. private _onVRRequestPresentComplete;
  114511. /**
  114512. * 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)
  114513. */
  114514. enableGazeEvenWhenNoPointerLock: boolean;
  114515. /**
  114516. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  114517. */
  114518. exitVROnDoubleTap: boolean;
  114519. /**
  114520. * Observable raised right before entering VR.
  114521. */
  114522. onEnteringVRObservable: Observable<VRExperienceHelper>;
  114523. /**
  114524. * Observable raised when entering VR has completed.
  114525. */
  114526. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  114527. /**
  114528. * Observable raised when exiting VR.
  114529. */
  114530. onExitingVRObservable: Observable<VRExperienceHelper>;
  114531. /**
  114532. * Observable raised when controller mesh is loaded.
  114533. */
  114534. onControllerMeshLoadedObservable: Observable<WebVRController>;
  114535. /** Return this.onEnteringVRObservable
  114536. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  114537. */
  114538. get onEnteringVR(): Observable<VRExperienceHelper>;
  114539. /** Return this.onExitingVRObservable
  114540. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  114541. */
  114542. get onExitingVR(): Observable<VRExperienceHelper>;
  114543. /** Return this.onControllerMeshLoadedObservable
  114544. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  114545. */
  114546. get onControllerMeshLoaded(): Observable<WebVRController>;
  114547. private _rayLength;
  114548. private _useCustomVRButton;
  114549. private _teleportationRequested;
  114550. private _teleportActive;
  114551. private _floorMeshName;
  114552. private _floorMeshesCollection;
  114553. private _teleportationMode;
  114554. private _teleportationTime;
  114555. private _teleportationSpeed;
  114556. private _teleportationEasing;
  114557. private _rotationAllowed;
  114558. private _teleportBackwardsVector;
  114559. private _teleportationTarget;
  114560. private _isDefaultTeleportationTarget;
  114561. private _postProcessMove;
  114562. private _teleportationFillColor;
  114563. private _teleportationBorderColor;
  114564. private _rotationAngle;
  114565. private _haloCenter;
  114566. private _cameraGazer;
  114567. private _padSensibilityUp;
  114568. private _padSensibilityDown;
  114569. private _leftController;
  114570. private _rightController;
  114571. private _gazeColor;
  114572. private _laserColor;
  114573. private _pickedLaserColor;
  114574. private _pickedGazeColor;
  114575. /**
  114576. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  114577. */
  114578. onNewMeshSelected: Observable<AbstractMesh>;
  114579. /**
  114580. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  114581. * This observable will provide the mesh and the controller used to select the mesh
  114582. */
  114583. onMeshSelectedWithController: Observable<{
  114584. mesh: AbstractMesh;
  114585. controller: WebVRController;
  114586. }>;
  114587. /**
  114588. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  114589. */
  114590. onNewMeshPicked: Observable<PickingInfo>;
  114591. private _circleEase;
  114592. /**
  114593. * Observable raised before camera teleportation
  114594. */
  114595. onBeforeCameraTeleport: Observable<Vector3>;
  114596. /**
  114597. * Observable raised after camera teleportation
  114598. */
  114599. onAfterCameraTeleport: Observable<Vector3>;
  114600. /**
  114601. * Observable raised when current selected mesh gets unselected
  114602. */
  114603. onSelectedMeshUnselected: Observable<AbstractMesh>;
  114604. private _raySelectionPredicate;
  114605. /**
  114606. * To be optionaly changed by user to define custom ray selection
  114607. */
  114608. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  114609. /**
  114610. * To be optionaly changed by user to define custom selection logic (after ray selection)
  114611. */
  114612. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  114613. /**
  114614. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  114615. */
  114616. teleportationEnabled: boolean;
  114617. private _defaultHeight;
  114618. private _teleportationInitialized;
  114619. private _interactionsEnabled;
  114620. private _interactionsRequested;
  114621. private _displayGaze;
  114622. private _displayLaserPointer;
  114623. /**
  114624. * The mesh used to display where the user is going to teleport.
  114625. */
  114626. get teleportationTarget(): Mesh;
  114627. /**
  114628. * Sets the mesh to be used to display where the user is going to teleport.
  114629. */
  114630. set teleportationTarget(value: Mesh);
  114631. /**
  114632. * 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
  114633. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  114634. * See http://doc.babylonjs.com/resources/baking_transformations
  114635. */
  114636. get gazeTrackerMesh(): Mesh;
  114637. set gazeTrackerMesh(value: Mesh);
  114638. /**
  114639. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  114640. */
  114641. updateGazeTrackerScale: boolean;
  114642. /**
  114643. * If the gaze trackers color should be updated when selecting meshes
  114644. */
  114645. updateGazeTrackerColor: boolean;
  114646. /**
  114647. * If the controller laser color should be updated when selecting meshes
  114648. */
  114649. updateControllerLaserColor: boolean;
  114650. /**
  114651. * The gaze tracking mesh corresponding to the left controller
  114652. */
  114653. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  114654. /**
  114655. * The gaze tracking mesh corresponding to the right controller
  114656. */
  114657. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  114658. /**
  114659. * If the ray of the gaze should be displayed.
  114660. */
  114661. get displayGaze(): boolean;
  114662. /**
  114663. * Sets if the ray of the gaze should be displayed.
  114664. */
  114665. set displayGaze(value: boolean);
  114666. /**
  114667. * If the ray of the LaserPointer should be displayed.
  114668. */
  114669. get displayLaserPointer(): boolean;
  114670. /**
  114671. * Sets if the ray of the LaserPointer should be displayed.
  114672. */
  114673. set displayLaserPointer(value: boolean);
  114674. /**
  114675. * The deviceOrientationCamera used as the camera when not in VR.
  114676. */
  114677. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  114678. /**
  114679. * Based on the current WebVR support, returns the current VR camera used.
  114680. */
  114681. get currentVRCamera(): Nullable<Camera>;
  114682. /**
  114683. * The webVRCamera which is used when in VR.
  114684. */
  114685. get webVRCamera(): WebVRFreeCamera;
  114686. /**
  114687. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  114688. */
  114689. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  114690. /**
  114691. * The html button that is used to trigger entering into VR.
  114692. */
  114693. get vrButton(): Nullable<HTMLButtonElement>;
  114694. private get _teleportationRequestInitiated();
  114695. /**
  114696. * Defines wether or not Pointer lock should be requested when switching to
  114697. * full screen.
  114698. */
  114699. requestPointerLockOnFullScreen: boolean;
  114700. /**
  114701. * If asking to force XR, this will be populated with the default xr experience
  114702. */
  114703. xr: WebXRDefaultExperience;
  114704. /**
  114705. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  114706. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  114707. */
  114708. xrTestDone: boolean;
  114709. /**
  114710. * Instantiates a VRExperienceHelper.
  114711. * Helps to quickly add VR support to an existing scene.
  114712. * @param scene The scene the VRExperienceHelper belongs to.
  114713. * @param webVROptions Options to modify the vr experience helper's behavior.
  114714. */
  114715. constructor(scene: Scene,
  114716. /** Options to modify the vr experience helper's behavior. */
  114717. webVROptions?: VRExperienceHelperOptions);
  114718. private completeVRInit;
  114719. private _onDefaultMeshLoaded;
  114720. private _onResize;
  114721. private _onFullscreenChange;
  114722. /**
  114723. * Gets a value indicating if we are currently in VR mode.
  114724. */
  114725. get isInVRMode(): boolean;
  114726. private onVrDisplayPresentChange;
  114727. private onVRDisplayChanged;
  114728. private moveButtonToBottomRight;
  114729. private displayVRButton;
  114730. private updateButtonVisibility;
  114731. private _cachedAngularSensibility;
  114732. /**
  114733. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  114734. * Otherwise, will use the fullscreen API.
  114735. */
  114736. enterVR(): void;
  114737. /**
  114738. * Attempt to exit VR, or fullscreen.
  114739. */
  114740. exitVR(): void;
  114741. /**
  114742. * The position of the vr experience helper.
  114743. */
  114744. get position(): Vector3;
  114745. /**
  114746. * Sets the position of the vr experience helper.
  114747. */
  114748. set position(value: Vector3);
  114749. /**
  114750. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  114751. */
  114752. enableInteractions(): void;
  114753. private get _noControllerIsActive();
  114754. private beforeRender;
  114755. private _isTeleportationFloor;
  114756. /**
  114757. * Adds a floor mesh to be used for teleportation.
  114758. * @param floorMesh the mesh to be used for teleportation.
  114759. */
  114760. addFloorMesh(floorMesh: Mesh): void;
  114761. /**
  114762. * Removes a floor mesh from being used for teleportation.
  114763. * @param floorMesh the mesh to be removed.
  114764. */
  114765. removeFloorMesh(floorMesh: Mesh): void;
  114766. /**
  114767. * Enables interactions and teleportation using the VR controllers and gaze.
  114768. * @param vrTeleportationOptions options to modify teleportation behavior.
  114769. */
  114770. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  114771. private _onNewGamepadConnected;
  114772. private _tryEnableInteractionOnController;
  114773. private _onNewGamepadDisconnected;
  114774. private _enableInteractionOnController;
  114775. private _checkTeleportWithRay;
  114776. private _checkRotate;
  114777. private _checkTeleportBackwards;
  114778. private _enableTeleportationOnController;
  114779. private _createTeleportationCircles;
  114780. private _displayTeleportationTarget;
  114781. private _hideTeleportationTarget;
  114782. private _rotateCamera;
  114783. private _moveTeleportationSelectorTo;
  114784. private _workingVector;
  114785. private _workingQuaternion;
  114786. private _workingMatrix;
  114787. /**
  114788. * Time Constant Teleportation Mode
  114789. */
  114790. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  114791. /**
  114792. * Speed Constant Teleportation Mode
  114793. */
  114794. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  114795. /**
  114796. * Teleports the users feet to the desired location
  114797. * @param location The location where the user's feet should be placed
  114798. */
  114799. teleportCamera(location: Vector3): void;
  114800. private _convertNormalToDirectionOfRay;
  114801. private _castRayAndSelectObject;
  114802. private _notifySelectedMeshUnselected;
  114803. /**
  114804. * Permanently set new colors for the laser pointer
  114805. * @param color the new laser color
  114806. * @param pickedColor the new laser color when picked mesh detected
  114807. */
  114808. setLaserColor(color: Color3, pickedColor?: Color3): void;
  114809. /**
  114810. * Permanently set new colors for the gaze pointer
  114811. * @param color the new gaze color
  114812. * @param pickedColor the new gaze color when picked mesh detected
  114813. */
  114814. setGazeColor(color: Color3, pickedColor?: Color3): void;
  114815. /**
  114816. * Sets the color of the laser ray from the vr controllers.
  114817. * @param color new color for the ray.
  114818. */
  114819. changeLaserColor(color: Color3): void;
  114820. /**
  114821. * Sets the color of the ray from the vr headsets gaze.
  114822. * @param color new color for the ray.
  114823. */
  114824. changeGazeColor(color: Color3): void;
  114825. /**
  114826. * Exits VR and disposes of the vr experience helper
  114827. */
  114828. dispose(): void;
  114829. /**
  114830. * Gets the name of the VRExperienceHelper class
  114831. * @returns "VRExperienceHelper"
  114832. */
  114833. getClassName(): string;
  114834. }
  114835. }
  114836. declare module BABYLON {
  114837. /**
  114838. * Options used for hit testing
  114839. */
  114840. export interface IWebXRHitTestOptions {
  114841. /**
  114842. * Only test when user interacted with the scene. Default - hit test every frame
  114843. */
  114844. testOnPointerDownOnly?: boolean;
  114845. /**
  114846. * The node to use to transform the local results to world coordinates
  114847. */
  114848. worldParentNode?: TransformNode;
  114849. }
  114850. /**
  114851. * Interface defining the babylon result of raycasting/hit-test
  114852. */
  114853. export interface IWebXRHitResult {
  114854. /**
  114855. * The native hit test result
  114856. */
  114857. xrHitResult: XRHitResult;
  114858. /**
  114859. * Transformation matrix that can be applied to a node that will put it in the hit point location
  114860. */
  114861. transformationMatrix: Matrix;
  114862. }
  114863. /**
  114864. * The currently-working hit-test module.
  114865. * Hit test (or raycasting) is used to interact with the real world.
  114866. * For further information read here - https://github.com/immersive-web/hit-test
  114867. */
  114868. export class WebXRHitTestLegacy implements IWebXRFeature {
  114869. private _xrSessionManager;
  114870. /**
  114871. * options to use when constructing this feature
  114872. */
  114873. readonly options: IWebXRHitTestOptions;
  114874. /**
  114875. * The module's name
  114876. */
  114877. static readonly Name: string;
  114878. /**
  114879. * The (Babylon) version of this module.
  114880. * This is an integer representing the implementation version.
  114881. * This number does not correspond to the webxr specs version
  114882. */
  114883. static readonly Version: number;
  114884. /**
  114885. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  114886. * @param event the (select) event to use to select with
  114887. * @param referenceSpace the reference space to use for this hit test
  114888. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  114889. */
  114890. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  114891. /**
  114892. * execute a hit test with an XR Ray
  114893. *
  114894. * @param xrSession a native xrSession that will execute this hit test
  114895. * @param xrRay the ray (position and direction) to use for raycasting
  114896. * @param referenceSpace native XR reference space to use for the hit-test
  114897. * @param filter filter function that will filter the results
  114898. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  114899. */
  114900. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  114901. /**
  114902. * Triggered when new babylon (transformed) hit test results are available
  114903. */
  114904. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  114905. /**
  114906. * Creates a new instance of the (legacy version) hit test feature
  114907. * @param _xrSessionManager an instance of WebXRSessionManager
  114908. * @param options options to use when constructing this feature
  114909. */
  114910. constructor(_xrSessionManager: WebXRSessionManager,
  114911. /**
  114912. * options to use when constructing this feature
  114913. */
  114914. options?: IWebXRHitTestOptions);
  114915. private _onSelectEnabled;
  114916. private _xrFrameObserver;
  114917. private _attached;
  114918. /**
  114919. * Populated with the last native XR Hit Results
  114920. */
  114921. lastNativeXRHitResults: XRHitResult[];
  114922. /**
  114923. * attach this feature
  114924. * Will usually be called by the features manager
  114925. *
  114926. * @returns true if successful.
  114927. */
  114928. attach(): boolean;
  114929. /**
  114930. * detach this feature.
  114931. * Will usually be called by the features manager
  114932. *
  114933. * @returns true if successful.
  114934. */
  114935. detach(): boolean;
  114936. private _onHitTestResults;
  114937. private _onSelect;
  114938. /**
  114939. * Dispose this feature and all of the resources attached
  114940. */
  114941. dispose(): void;
  114942. }
  114943. }
  114944. declare module BABYLON {
  114945. /**
  114946. * Options used in the plane detector module
  114947. */
  114948. export interface IWebXRPlaneDetectorOptions {
  114949. /**
  114950. * The node to use to transform the local results to world coordinates
  114951. */
  114952. worldParentNode?: TransformNode;
  114953. }
  114954. /**
  114955. * A babylon interface for a webxr plane.
  114956. * A Plane is actually a polygon, built from N points in space
  114957. */
  114958. export interface IWebXRPlane {
  114959. /**
  114960. * a babylon-assigned ID for this polygon
  114961. */
  114962. id: number;
  114963. /**
  114964. * the native xr-plane object
  114965. */
  114966. xrPlane: XRPlane;
  114967. /**
  114968. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  114969. */
  114970. polygonDefinition: Array<Vector3>;
  114971. /**
  114972. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  114973. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  114974. */
  114975. transformationMatrix: Matrix;
  114976. }
  114977. /**
  114978. * The plane detector is used to detect planes in the real world when in AR
  114979. * For more information see https://github.com/immersive-web/real-world-geometry/
  114980. */
  114981. export class WebXRPlaneDetector implements IWebXRFeature {
  114982. private _xrSessionManager;
  114983. private _options;
  114984. /**
  114985. * The module's name
  114986. */
  114987. static readonly Name: string;
  114988. /**
  114989. * The (Babylon) version of this module.
  114990. * This is an integer representing the implementation version.
  114991. * This number does not correspond to the webxr specs version
  114992. */
  114993. static readonly Version: number;
  114994. /**
  114995. * Observers registered here will be executed when a new plane was added to the session
  114996. */
  114997. onPlaneAddedObservable: Observable<IWebXRPlane>;
  114998. /**
  114999. * Observers registered here will be executed when a plane is no longer detected in the session
  115000. */
  115001. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  115002. /**
  115003. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  115004. * This can execute N times every frame
  115005. */
  115006. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  115007. private _enabled;
  115008. private _attached;
  115009. private _detectedPlanes;
  115010. private _lastFrameDetected;
  115011. private _observerTracked;
  115012. /**
  115013. * construct a new Plane Detector
  115014. * @param _xrSessionManager an instance of xr Session manager
  115015. * @param _options configuration to use when constructing this feature
  115016. */
  115017. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  115018. /**
  115019. * attach this feature
  115020. * Will usually be called by the features manager
  115021. *
  115022. * @returns true if successful.
  115023. */
  115024. attach(): boolean;
  115025. /**
  115026. * detach this feature.
  115027. * Will usually be called by the features manager
  115028. *
  115029. * @returns true if successful.
  115030. */
  115031. detach(): boolean;
  115032. /**
  115033. * Dispose this feature and all of the resources attached
  115034. */
  115035. dispose(): void;
  115036. private _updatePlaneWithXRPlane;
  115037. /**
  115038. * avoiding using Array.find for global support.
  115039. * @param xrPlane the plane to find in the array
  115040. */
  115041. private findIndexInPlaneArray;
  115042. }
  115043. }
  115044. declare module BABYLON {
  115045. /**
  115046. * Configuration options of the anchor system
  115047. */
  115048. export interface IWebXRAnchorSystemOptions {
  115049. /**
  115050. * a node that will be used to convert local to world coordinates
  115051. */
  115052. worldParentNode?: TransformNode;
  115053. /**
  115054. * should the anchor system use plane detection.
  115055. * If set to true, the plane-detection feature should be set using setPlaneDetector
  115056. */
  115057. usePlaneDetection?: boolean;
  115058. /**
  115059. * Should a new anchor be added every time a select event is triggered
  115060. */
  115061. addAnchorOnSelect?: boolean;
  115062. }
  115063. /**
  115064. * A babylon container for an XR Anchor
  115065. */
  115066. export interface IWebXRAnchor {
  115067. /**
  115068. * A babylon-assigned ID for this anchor
  115069. */
  115070. id: number;
  115071. /**
  115072. * The native anchor object
  115073. */
  115074. xrAnchor: XRAnchor;
  115075. /**
  115076. * Transformation matrix to apply to an object attached to this anchor
  115077. */
  115078. transformationMatrix: Matrix;
  115079. }
  115080. /**
  115081. * An implementation of the anchor system of WebXR.
  115082. * Note that the current documented implementation is not available in any browser. Future implementations
  115083. * will use the frame to create an anchor and not the session or a detected plane
  115084. * For further information see https://github.com/immersive-web/anchors/
  115085. */
  115086. export class WebXRAnchorSystem implements IWebXRFeature {
  115087. private _xrSessionManager;
  115088. private _options;
  115089. /**
  115090. * The module's name
  115091. */
  115092. static readonly Name: string;
  115093. /**
  115094. * The (Babylon) version of this module.
  115095. * This is an integer representing the implementation version.
  115096. * This number does not correspond to the webxr specs version
  115097. */
  115098. static readonly Version: number;
  115099. /**
  115100. * Observers registered here will be executed when a new anchor was added to the session
  115101. */
  115102. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  115103. /**
  115104. * Observers registered here will be executed when an existing anchor updates
  115105. * This can execute N times every frame
  115106. */
  115107. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  115108. /**
  115109. * Observers registered here will be executed when an anchor was removed from the session
  115110. */
  115111. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  115112. private _planeDetector;
  115113. private _hitTestModule;
  115114. private _enabled;
  115115. private _attached;
  115116. private _trackedAnchors;
  115117. private _lastFrameDetected;
  115118. private _observerTracked;
  115119. /**
  115120. * constructs a new anchor system
  115121. * @param _xrSessionManager an instance of WebXRSessionManager
  115122. * @param _options configuration object for this feature
  115123. */
  115124. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  115125. /**
  115126. * set the plane detector to use in order to create anchors from frames
  115127. * @param planeDetector the plane-detector module to use
  115128. * @param enable enable plane-anchors. default is true
  115129. */
  115130. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  115131. /**
  115132. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  115133. * @param hitTestModule the hit-test module to use.
  115134. */
  115135. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  115136. /**
  115137. * attach this feature
  115138. * Will usually be called by the features manager
  115139. *
  115140. * @returns true if successful.
  115141. */
  115142. attach(): boolean;
  115143. /**
  115144. * detach this feature.
  115145. * Will usually be called by the features manager
  115146. *
  115147. * @returns true if successful.
  115148. */
  115149. detach(): boolean;
  115150. /**
  115151. * Dispose this feature and all of the resources attached
  115152. */
  115153. dispose(): void;
  115154. private _onSelect;
  115155. /**
  115156. * Add anchor at a specific XR point.
  115157. *
  115158. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  115159. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  115160. * @returns a promise the fulfills when the anchor was created
  115161. */
  115162. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  115163. private _updateAnchorWithXRFrame;
  115164. /**
  115165. * avoiding using Array.find for global support.
  115166. * @param xrAnchor the plane to find in the array
  115167. */
  115168. private _findIndexInAnchorArray;
  115169. }
  115170. }
  115171. declare module BABYLON {
  115172. /**
  115173. * Options interface for the background remover plugin
  115174. */
  115175. export interface IWebXRBackgroundRemoverOptions {
  115176. /**
  115177. * don't disable the environment helper
  115178. */
  115179. ignoreEnvironmentHelper?: boolean;
  115180. /**
  115181. * flags to configure the removal of the environment helper.
  115182. * If not set, the entire background will be removed. If set, flags should be set as well.
  115183. */
  115184. environmentHelperRemovalFlags?: {
  115185. /**
  115186. * Should the skybox be removed (default false)
  115187. */
  115188. skyBox?: boolean;
  115189. /**
  115190. * Should the ground be removed (default false)
  115191. */
  115192. ground?: boolean;
  115193. };
  115194. /**
  115195. * Further background meshes to disable when entering AR
  115196. */
  115197. backgroundMeshes?: AbstractMesh[];
  115198. }
  115199. /**
  115200. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  115201. */
  115202. export class WebXRBackgroundRemover implements IWebXRFeature {
  115203. private _xrSessionManager;
  115204. /**
  115205. * read-only options to be used in this module
  115206. */
  115207. readonly options: IWebXRBackgroundRemoverOptions;
  115208. /**
  115209. * The module's name
  115210. */
  115211. static readonly Name: string;
  115212. /**
  115213. * The (Babylon) version of this module.
  115214. * This is an integer representing the implementation version.
  115215. * This number does not correspond to the webxr specs version
  115216. */
  115217. static readonly Version: number;
  115218. /**
  115219. * registered observers will be triggered when the background state changes
  115220. */
  115221. onBackgroundStateChangedObservable: Observable<boolean>;
  115222. /**
  115223. * constructs a new background remover module
  115224. * @param _xrSessionManager the session manager for this module
  115225. * @param options read-only options to be used in this module
  115226. */
  115227. constructor(_xrSessionManager: WebXRSessionManager,
  115228. /**
  115229. * read-only options to be used in this module
  115230. */
  115231. options?: IWebXRBackgroundRemoverOptions);
  115232. /**
  115233. * attach this feature
  115234. * Will usually be called by the features manager
  115235. *
  115236. * @returns true if successful.
  115237. */
  115238. attach(): boolean;
  115239. /**
  115240. * detach this feature.
  115241. * Will usually be called by the features manager
  115242. *
  115243. * @returns true if successful.
  115244. */
  115245. detach(): boolean;
  115246. private _setBackgroundState;
  115247. /**
  115248. * Dispose this feature and all of the resources attached
  115249. */
  115250. dispose(): void;
  115251. }
  115252. }
  115253. declare module BABYLON {
  115254. /**
  115255. * Contains an array of blocks representing the octree
  115256. */
  115257. export interface IOctreeContainer<T> {
  115258. /**
  115259. * Blocks within the octree
  115260. */
  115261. blocks: Array<OctreeBlock<T>>;
  115262. }
  115263. /**
  115264. * Class used to store a cell in an octree
  115265. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115266. */
  115267. export class OctreeBlock<T> {
  115268. /**
  115269. * Gets the content of the current block
  115270. */
  115271. entries: T[];
  115272. /**
  115273. * Gets the list of block children
  115274. */
  115275. blocks: Array<OctreeBlock<T>>;
  115276. private _depth;
  115277. private _maxDepth;
  115278. private _capacity;
  115279. private _minPoint;
  115280. private _maxPoint;
  115281. private _boundingVectors;
  115282. private _creationFunc;
  115283. /**
  115284. * Creates a new block
  115285. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  115286. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  115287. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  115288. * @param depth defines the current depth of this block in the octree
  115289. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  115290. * @param creationFunc defines a callback to call when an element is added to the block
  115291. */
  115292. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  115293. /**
  115294. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  115295. */
  115296. get capacity(): number;
  115297. /**
  115298. * Gets the minimum vector (in world space) of the block's bounding box
  115299. */
  115300. get minPoint(): Vector3;
  115301. /**
  115302. * Gets the maximum vector (in world space) of the block's bounding box
  115303. */
  115304. get maxPoint(): Vector3;
  115305. /**
  115306. * Add a new element to this block
  115307. * @param entry defines the element to add
  115308. */
  115309. addEntry(entry: T): void;
  115310. /**
  115311. * Remove an element from this block
  115312. * @param entry defines the element to remove
  115313. */
  115314. removeEntry(entry: T): void;
  115315. /**
  115316. * Add an array of elements to this block
  115317. * @param entries defines the array of elements to add
  115318. */
  115319. addEntries(entries: T[]): void;
  115320. /**
  115321. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  115322. * @param frustumPlanes defines the frustum planes to test
  115323. * @param selection defines the array to store current content if selection is positive
  115324. * @param allowDuplicate defines if the selection array can contains duplicated entries
  115325. */
  115326. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  115327. /**
  115328. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  115329. * @param sphereCenter defines the bounding sphere center
  115330. * @param sphereRadius defines the bounding sphere radius
  115331. * @param selection defines the array to store current content if selection is positive
  115332. * @param allowDuplicate defines if the selection array can contains duplicated entries
  115333. */
  115334. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  115335. /**
  115336. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  115337. * @param ray defines the ray to test with
  115338. * @param selection defines the array to store current content if selection is positive
  115339. */
  115340. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  115341. /**
  115342. * Subdivide the content into child blocks (this block will then be empty)
  115343. */
  115344. createInnerBlocks(): void;
  115345. /**
  115346. * @hidden
  115347. */
  115348. 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;
  115349. }
  115350. }
  115351. declare module BABYLON {
  115352. /**
  115353. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  115354. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115355. */
  115356. export class Octree<T> {
  115357. /** 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.) */
  115358. maxDepth: number;
  115359. /**
  115360. * Blocks within the octree containing objects
  115361. */
  115362. blocks: Array<OctreeBlock<T>>;
  115363. /**
  115364. * Content stored in the octree
  115365. */
  115366. dynamicContent: T[];
  115367. private _maxBlockCapacity;
  115368. private _selectionContent;
  115369. private _creationFunc;
  115370. /**
  115371. * Creates a octree
  115372. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115373. * @param creationFunc function to be used to instatiate the octree
  115374. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  115375. * @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.)
  115376. */
  115377. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  115378. /** 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.) */
  115379. maxDepth?: number);
  115380. /**
  115381. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  115382. * @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);
  115383. * @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);
  115384. * @param entries meshes to be added to the octree blocks
  115385. */
  115386. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  115387. /**
  115388. * Adds a mesh to the octree
  115389. * @param entry Mesh to add to the octree
  115390. */
  115391. addMesh(entry: T): void;
  115392. /**
  115393. * Remove an element from the octree
  115394. * @param entry defines the element to remove
  115395. */
  115396. removeMesh(entry: T): void;
  115397. /**
  115398. * Selects an array of meshes within the frustum
  115399. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  115400. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  115401. * @returns array of meshes within the frustum
  115402. */
  115403. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  115404. /**
  115405. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  115406. * @param sphereCenter defines the bounding sphere center
  115407. * @param sphereRadius defines the bounding sphere radius
  115408. * @param allowDuplicate defines if the selection array can contains duplicated entries
  115409. * @returns an array of objects that intersect the sphere
  115410. */
  115411. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  115412. /**
  115413. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  115414. * @param ray defines the ray to test with
  115415. * @returns array of intersected objects
  115416. */
  115417. intersectsRay(ray: Ray): SmartArray<T>;
  115418. /**
  115419. * Adds a mesh into the octree block if it intersects the block
  115420. */
  115421. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  115422. /**
  115423. * Adds a submesh into the octree block if it intersects the block
  115424. */
  115425. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  115426. }
  115427. }
  115428. declare module BABYLON {
  115429. interface Scene {
  115430. /**
  115431. * @hidden
  115432. * Backing Filed
  115433. */
  115434. _selectionOctree: Octree<AbstractMesh>;
  115435. /**
  115436. * Gets the octree used to boost mesh selection (picking)
  115437. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115438. */
  115439. selectionOctree: Octree<AbstractMesh>;
  115440. /**
  115441. * Creates or updates the octree used to boost selection (picking)
  115442. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115443. * @param maxCapacity defines the maximum capacity per leaf
  115444. * @param maxDepth defines the maximum depth of the octree
  115445. * @returns an octree of AbstractMesh
  115446. */
  115447. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  115448. }
  115449. interface AbstractMesh {
  115450. /**
  115451. * @hidden
  115452. * Backing Field
  115453. */
  115454. _submeshesOctree: Octree<SubMesh>;
  115455. /**
  115456. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  115457. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  115458. * @param maxCapacity defines the maximum size of each block (64 by default)
  115459. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  115460. * @returns the new octree
  115461. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  115462. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115463. */
  115464. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  115465. }
  115466. /**
  115467. * Defines the octree scene component responsible to manage any octrees
  115468. * in a given scene.
  115469. */
  115470. export class OctreeSceneComponent {
  115471. /**
  115472. * The component name help to identify the component in the list of scene components.
  115473. */
  115474. readonly name: string;
  115475. /**
  115476. * The scene the component belongs to.
  115477. */
  115478. scene: Scene;
  115479. /**
  115480. * Indicates if the meshes have been checked to make sure they are isEnabled()
  115481. */
  115482. readonly checksIsEnabled: boolean;
  115483. /**
  115484. * Creates a new instance of the component for the given scene
  115485. * @param scene Defines the scene to register the component in
  115486. */
  115487. constructor(scene: Scene);
  115488. /**
  115489. * Registers the component in a given scene
  115490. */
  115491. register(): void;
  115492. /**
  115493. * Return the list of active meshes
  115494. * @returns the list of active meshes
  115495. */
  115496. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  115497. /**
  115498. * Return the list of active sub meshes
  115499. * @param mesh The mesh to get the candidates sub meshes from
  115500. * @returns the list of active sub meshes
  115501. */
  115502. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  115503. private _tempRay;
  115504. /**
  115505. * Return the list of sub meshes intersecting with a given local ray
  115506. * @param mesh defines the mesh to find the submesh for
  115507. * @param localRay defines the ray in local space
  115508. * @returns the list of intersecting sub meshes
  115509. */
  115510. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  115511. /**
  115512. * Return the list of sub meshes colliding with a collider
  115513. * @param mesh defines the mesh to find the submesh for
  115514. * @param collider defines the collider to evaluate the collision against
  115515. * @returns the list of colliding sub meshes
  115516. */
  115517. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  115518. /**
  115519. * Rebuilds the elements related to this component in case of
  115520. * context lost for instance.
  115521. */
  115522. rebuild(): void;
  115523. /**
  115524. * Disposes the component and the associated ressources.
  115525. */
  115526. dispose(): void;
  115527. }
  115528. }
  115529. declare module BABYLON {
  115530. /**
  115531. * Renders a layer on top of an existing scene
  115532. */
  115533. export class UtilityLayerRenderer implements IDisposable {
  115534. /** the original scene that will be rendered on top of */
  115535. originalScene: Scene;
  115536. private _pointerCaptures;
  115537. private _lastPointerEvents;
  115538. private static _DefaultUtilityLayer;
  115539. private static _DefaultKeepDepthUtilityLayer;
  115540. private _sharedGizmoLight;
  115541. private _renderCamera;
  115542. /**
  115543. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  115544. * @returns the camera that is used when rendering the utility layer
  115545. */
  115546. getRenderCamera(): Nullable<Camera>;
  115547. /**
  115548. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  115549. * @param cam the camera that should be used when rendering the utility layer
  115550. */
  115551. setRenderCamera(cam: Nullable<Camera>): void;
  115552. /**
  115553. * @hidden
  115554. * Light which used by gizmos to get light shading
  115555. */
  115556. _getSharedGizmoLight(): HemisphericLight;
  115557. /**
  115558. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  115559. */
  115560. pickUtilitySceneFirst: boolean;
  115561. /**
  115562. * 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)
  115563. */
  115564. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  115565. /**
  115566. * 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)
  115567. */
  115568. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  115569. /**
  115570. * The scene that is rendered on top of the original scene
  115571. */
  115572. utilityLayerScene: Scene;
  115573. /**
  115574. * If the utility layer should automatically be rendered on top of existing scene
  115575. */
  115576. shouldRender: boolean;
  115577. /**
  115578. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  115579. */
  115580. onlyCheckPointerDownEvents: boolean;
  115581. /**
  115582. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  115583. */
  115584. processAllEvents: boolean;
  115585. /**
  115586. * Observable raised when the pointer move from the utility layer scene to the main scene
  115587. */
  115588. onPointerOutObservable: Observable<number>;
  115589. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  115590. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  115591. private _afterRenderObserver;
  115592. private _sceneDisposeObserver;
  115593. private _originalPointerObserver;
  115594. /**
  115595. * Instantiates a UtilityLayerRenderer
  115596. * @param originalScene the original scene that will be rendered on top of
  115597. * @param handleEvents boolean indicating if the utility layer should handle events
  115598. */
  115599. constructor(
  115600. /** the original scene that will be rendered on top of */
  115601. originalScene: Scene, handleEvents?: boolean);
  115602. private _notifyObservers;
  115603. /**
  115604. * Renders the utility layers scene on top of the original scene
  115605. */
  115606. render(): void;
  115607. /**
  115608. * Disposes of the renderer
  115609. */
  115610. dispose(): void;
  115611. private _updateCamera;
  115612. }
  115613. }
  115614. declare module BABYLON {
  115615. /**
  115616. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  115617. */
  115618. export class Gizmo implements IDisposable {
  115619. /** The utility layer the gizmo will be added to */
  115620. gizmoLayer: UtilityLayerRenderer;
  115621. /**
  115622. * The root mesh of the gizmo
  115623. */
  115624. _rootMesh: Mesh;
  115625. private _attachedMesh;
  115626. /**
  115627. * Ratio for the scale of the gizmo (Default: 1)
  115628. */
  115629. scaleRatio: number;
  115630. /**
  115631. * If a custom mesh has been set (Default: false)
  115632. */
  115633. protected _customMeshSet: boolean;
  115634. /**
  115635. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  115636. * * When set, interactions will be enabled
  115637. */
  115638. get attachedMesh(): Nullable<AbstractMesh>;
  115639. set attachedMesh(value: Nullable<AbstractMesh>);
  115640. /**
  115641. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  115642. * @param mesh The mesh to replace the default mesh of the gizmo
  115643. */
  115644. setCustomMesh(mesh: Mesh): void;
  115645. /**
  115646. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  115647. */
  115648. updateGizmoRotationToMatchAttachedMesh: boolean;
  115649. /**
  115650. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  115651. */
  115652. updateGizmoPositionToMatchAttachedMesh: boolean;
  115653. /**
  115654. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  115655. */
  115656. updateScale: boolean;
  115657. protected _interactionsEnabled: boolean;
  115658. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115659. private _beforeRenderObserver;
  115660. private _tempVector;
  115661. /**
  115662. * Creates a gizmo
  115663. * @param gizmoLayer The utility layer the gizmo will be added to
  115664. */
  115665. constructor(
  115666. /** The utility layer the gizmo will be added to */
  115667. gizmoLayer?: UtilityLayerRenderer);
  115668. /**
  115669. * Updates the gizmo to match the attached mesh's position/rotation
  115670. */
  115671. protected _update(): void;
  115672. /**
  115673. * Disposes of the gizmo
  115674. */
  115675. dispose(): void;
  115676. }
  115677. }
  115678. declare module BABYLON {
  115679. /**
  115680. * Single plane drag gizmo
  115681. */
  115682. export class PlaneDragGizmo extends Gizmo {
  115683. /**
  115684. * Drag behavior responsible for the gizmos dragging interactions
  115685. */
  115686. dragBehavior: PointerDragBehavior;
  115687. private _pointerObserver;
  115688. /**
  115689. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115690. */
  115691. snapDistance: number;
  115692. /**
  115693. * Event that fires each time the gizmo snaps to a new location.
  115694. * * snapDistance is the the change in distance
  115695. */
  115696. onSnapObservable: Observable<{
  115697. snapDistance: number;
  115698. }>;
  115699. private _plane;
  115700. private _coloredMaterial;
  115701. private _hoverMaterial;
  115702. private _isEnabled;
  115703. private _parent;
  115704. /** @hidden */
  115705. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  115706. /** @hidden */
  115707. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  115708. /**
  115709. * Creates a PlaneDragGizmo
  115710. * @param gizmoLayer The utility layer the gizmo will be added to
  115711. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  115712. * @param color The color of the gizmo
  115713. */
  115714. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  115715. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115716. /**
  115717. * If the gizmo is enabled
  115718. */
  115719. set isEnabled(value: boolean);
  115720. get isEnabled(): boolean;
  115721. /**
  115722. * Disposes of the gizmo
  115723. */
  115724. dispose(): void;
  115725. }
  115726. }
  115727. declare module BABYLON {
  115728. /**
  115729. * Gizmo that enables dragging a mesh along 3 axis
  115730. */
  115731. export class PositionGizmo extends Gizmo {
  115732. /**
  115733. * Internal gizmo used for interactions on the x axis
  115734. */
  115735. xGizmo: AxisDragGizmo;
  115736. /**
  115737. * Internal gizmo used for interactions on the y axis
  115738. */
  115739. yGizmo: AxisDragGizmo;
  115740. /**
  115741. * Internal gizmo used for interactions on the z axis
  115742. */
  115743. zGizmo: AxisDragGizmo;
  115744. /**
  115745. * Internal gizmo used for interactions on the yz plane
  115746. */
  115747. xPlaneGizmo: PlaneDragGizmo;
  115748. /**
  115749. * Internal gizmo used for interactions on the xz plane
  115750. */
  115751. yPlaneGizmo: PlaneDragGizmo;
  115752. /**
  115753. * Internal gizmo used for interactions on the xy plane
  115754. */
  115755. zPlaneGizmo: PlaneDragGizmo;
  115756. /**
  115757. * private variables
  115758. */
  115759. private _meshAttached;
  115760. private _updateGizmoRotationToMatchAttachedMesh;
  115761. private _snapDistance;
  115762. private _scaleRatio;
  115763. /** Fires an event when any of it's sub gizmos are dragged */
  115764. onDragStartObservable: Observable<unknown>;
  115765. /** Fires an event when any of it's sub gizmos are released from dragging */
  115766. onDragEndObservable: Observable<unknown>;
  115767. /**
  115768. * If set to true, planar drag is enabled
  115769. */
  115770. private _planarGizmoEnabled;
  115771. get attachedMesh(): Nullable<AbstractMesh>;
  115772. set attachedMesh(mesh: Nullable<AbstractMesh>);
  115773. /**
  115774. * Creates a PositionGizmo
  115775. * @param gizmoLayer The utility layer the gizmo will be added to
  115776. */
  115777. constructor(gizmoLayer?: UtilityLayerRenderer);
  115778. /**
  115779. * If the planar drag gizmo is enabled
  115780. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  115781. */
  115782. set planarGizmoEnabled(value: boolean);
  115783. get planarGizmoEnabled(): boolean;
  115784. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  115785. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  115786. /**
  115787. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115788. */
  115789. set snapDistance(value: number);
  115790. get snapDistance(): number;
  115791. /**
  115792. * Ratio for the scale of the gizmo (Default: 1)
  115793. */
  115794. set scaleRatio(value: number);
  115795. get scaleRatio(): number;
  115796. /**
  115797. * Disposes of the gizmo
  115798. */
  115799. dispose(): void;
  115800. /**
  115801. * CustomMeshes are not supported by this gizmo
  115802. * @param mesh The mesh to replace the default mesh of the gizmo
  115803. */
  115804. setCustomMesh(mesh: Mesh): void;
  115805. }
  115806. }
  115807. declare module BABYLON {
  115808. /**
  115809. * Single axis drag gizmo
  115810. */
  115811. export class AxisDragGizmo extends Gizmo {
  115812. /**
  115813. * Drag behavior responsible for the gizmos dragging interactions
  115814. */
  115815. dragBehavior: PointerDragBehavior;
  115816. private _pointerObserver;
  115817. /**
  115818. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115819. */
  115820. snapDistance: number;
  115821. /**
  115822. * Event that fires each time the gizmo snaps to a new location.
  115823. * * snapDistance is the the change in distance
  115824. */
  115825. onSnapObservable: Observable<{
  115826. snapDistance: number;
  115827. }>;
  115828. private _isEnabled;
  115829. private _parent;
  115830. private _arrow;
  115831. private _coloredMaterial;
  115832. private _hoverMaterial;
  115833. /** @hidden */
  115834. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  115835. /** @hidden */
  115836. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  115837. /**
  115838. * Creates an AxisDragGizmo
  115839. * @param gizmoLayer The utility layer the gizmo will be added to
  115840. * @param dragAxis The axis which the gizmo will be able to drag on
  115841. * @param color The color of the gizmo
  115842. */
  115843. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  115844. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115845. /**
  115846. * If the gizmo is enabled
  115847. */
  115848. set isEnabled(value: boolean);
  115849. get isEnabled(): boolean;
  115850. /**
  115851. * Disposes of the gizmo
  115852. */
  115853. dispose(): void;
  115854. }
  115855. }
  115856. declare module BABYLON.Debug {
  115857. /**
  115858. * The Axes viewer will show 3 axes in a specific point in space
  115859. */
  115860. export class AxesViewer {
  115861. private _xAxis;
  115862. private _yAxis;
  115863. private _zAxis;
  115864. private _scaleLinesFactor;
  115865. private _instanced;
  115866. /**
  115867. * Gets the hosting scene
  115868. */
  115869. scene: Scene;
  115870. /**
  115871. * Gets or sets a number used to scale line length
  115872. */
  115873. scaleLines: number;
  115874. /** Gets the node hierarchy used to render x-axis */
  115875. get xAxis(): TransformNode;
  115876. /** Gets the node hierarchy used to render y-axis */
  115877. get yAxis(): TransformNode;
  115878. /** Gets the node hierarchy used to render z-axis */
  115879. get zAxis(): TransformNode;
  115880. /**
  115881. * Creates a new AxesViewer
  115882. * @param scene defines the hosting scene
  115883. * @param scaleLines defines a number used to scale line length (1 by default)
  115884. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  115885. * @param xAxis defines the node hierarchy used to render the x-axis
  115886. * @param yAxis defines the node hierarchy used to render the y-axis
  115887. * @param zAxis defines the node hierarchy used to render the z-axis
  115888. */
  115889. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  115890. /**
  115891. * Force the viewer to update
  115892. * @param position defines the position of the viewer
  115893. * @param xaxis defines the x axis of the viewer
  115894. * @param yaxis defines the y axis of the viewer
  115895. * @param zaxis defines the z axis of the viewer
  115896. */
  115897. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  115898. /**
  115899. * Creates an instance of this axes viewer.
  115900. * @returns a new axes viewer with instanced meshes
  115901. */
  115902. createInstance(): AxesViewer;
  115903. /** Releases resources */
  115904. dispose(): void;
  115905. private static _SetRenderingGroupId;
  115906. }
  115907. }
  115908. declare module BABYLON.Debug {
  115909. /**
  115910. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  115911. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  115912. */
  115913. export class BoneAxesViewer extends AxesViewer {
  115914. /**
  115915. * Gets or sets the target mesh where to display the axes viewer
  115916. */
  115917. mesh: Nullable<Mesh>;
  115918. /**
  115919. * Gets or sets the target bone where to display the axes viewer
  115920. */
  115921. bone: Nullable<Bone>;
  115922. /** Gets current position */
  115923. pos: Vector3;
  115924. /** Gets direction of X axis */
  115925. xaxis: Vector3;
  115926. /** Gets direction of Y axis */
  115927. yaxis: Vector3;
  115928. /** Gets direction of Z axis */
  115929. zaxis: Vector3;
  115930. /**
  115931. * Creates a new BoneAxesViewer
  115932. * @param scene defines the hosting scene
  115933. * @param bone defines the target bone
  115934. * @param mesh defines the target mesh
  115935. * @param scaleLines defines a scaling factor for line length (1 by default)
  115936. */
  115937. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  115938. /**
  115939. * Force the viewer to update
  115940. */
  115941. update(): void;
  115942. /** Releases resources */
  115943. dispose(): void;
  115944. }
  115945. }
  115946. declare module BABYLON {
  115947. /**
  115948. * Interface used to define scene explorer extensibility option
  115949. */
  115950. export interface IExplorerExtensibilityOption {
  115951. /**
  115952. * Define the option label
  115953. */
  115954. label: string;
  115955. /**
  115956. * Defines the action to execute on click
  115957. */
  115958. action: (entity: any) => void;
  115959. }
  115960. /**
  115961. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  115962. */
  115963. export interface IExplorerExtensibilityGroup {
  115964. /**
  115965. * Defines a predicate to test if a given type mut be extended
  115966. */
  115967. predicate: (entity: any) => boolean;
  115968. /**
  115969. * Gets the list of options added to a type
  115970. */
  115971. entries: IExplorerExtensibilityOption[];
  115972. }
  115973. /**
  115974. * Interface used to define the options to use to create the Inspector
  115975. */
  115976. export interface IInspectorOptions {
  115977. /**
  115978. * Display in overlay mode (default: false)
  115979. */
  115980. overlay?: boolean;
  115981. /**
  115982. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  115983. */
  115984. globalRoot?: HTMLElement;
  115985. /**
  115986. * Display the Scene explorer
  115987. */
  115988. showExplorer?: boolean;
  115989. /**
  115990. * Display the property inspector
  115991. */
  115992. showInspector?: boolean;
  115993. /**
  115994. * Display in embed mode (both panes on the right)
  115995. */
  115996. embedMode?: boolean;
  115997. /**
  115998. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  115999. */
  116000. handleResize?: boolean;
  116001. /**
  116002. * Allow the panes to popup (default: true)
  116003. */
  116004. enablePopup?: boolean;
  116005. /**
  116006. * Allow the panes to be closed by users (default: true)
  116007. */
  116008. enableClose?: boolean;
  116009. /**
  116010. * Optional list of extensibility entries
  116011. */
  116012. explorerExtensibility?: IExplorerExtensibilityGroup[];
  116013. /**
  116014. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  116015. */
  116016. inspectorURL?: string;
  116017. /**
  116018. * Optional initial tab (default to DebugLayerTab.Properties)
  116019. */
  116020. initialTab?: DebugLayerTab;
  116021. }
  116022. interface Scene {
  116023. /**
  116024. * @hidden
  116025. * Backing field
  116026. */
  116027. _debugLayer: DebugLayer;
  116028. /**
  116029. * Gets the debug layer (aka Inspector) associated with the scene
  116030. * @see http://doc.babylonjs.com/features/playground_debuglayer
  116031. */
  116032. debugLayer: DebugLayer;
  116033. }
  116034. /**
  116035. * Enum of inspector action tab
  116036. */
  116037. export enum DebugLayerTab {
  116038. /**
  116039. * Properties tag (default)
  116040. */
  116041. Properties = 0,
  116042. /**
  116043. * Debug tab
  116044. */
  116045. Debug = 1,
  116046. /**
  116047. * Statistics tab
  116048. */
  116049. Statistics = 2,
  116050. /**
  116051. * Tools tab
  116052. */
  116053. Tools = 3,
  116054. /**
  116055. * Settings tab
  116056. */
  116057. Settings = 4
  116058. }
  116059. /**
  116060. * The debug layer (aka Inspector) is the go to tool in order to better understand
  116061. * what is happening in your scene
  116062. * @see http://doc.babylonjs.com/features/playground_debuglayer
  116063. */
  116064. export class DebugLayer {
  116065. /**
  116066. * Define the url to get the inspector script from.
  116067. * By default it uses the babylonjs CDN.
  116068. * @ignoreNaming
  116069. */
  116070. static InspectorURL: string;
  116071. private _scene;
  116072. private BJSINSPECTOR;
  116073. private _onPropertyChangedObservable?;
  116074. /**
  116075. * Observable triggered when a property is changed through the inspector.
  116076. */
  116077. get onPropertyChangedObservable(): any;
  116078. /**
  116079. * Instantiates a new debug layer.
  116080. * The debug layer (aka Inspector) is the go to tool in order to better understand
  116081. * what is happening in your scene
  116082. * @see http://doc.babylonjs.com/features/playground_debuglayer
  116083. * @param scene Defines the scene to inspect
  116084. */
  116085. constructor(scene: Scene);
  116086. /** Creates the inspector window. */
  116087. private _createInspector;
  116088. /**
  116089. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  116090. * @param entity defines the entity to select
  116091. * @param lineContainerTitle defines the specific block to highlight
  116092. */
  116093. select(entity: any, lineContainerTitle?: string): void;
  116094. /** Get the inspector from bundle or global */
  116095. private _getGlobalInspector;
  116096. /**
  116097. * Get if the inspector is visible or not.
  116098. * @returns true if visible otherwise, false
  116099. */
  116100. isVisible(): boolean;
  116101. /**
  116102. * Hide the inspector and close its window.
  116103. */
  116104. hide(): void;
  116105. /**
  116106. * Launch the debugLayer.
  116107. * @param config Define the configuration of the inspector
  116108. * @return a promise fulfilled when the debug layer is visible
  116109. */
  116110. show(config?: IInspectorOptions): Promise<DebugLayer>;
  116111. }
  116112. }
  116113. declare module BABYLON {
  116114. /**
  116115. * Class containing static functions to help procedurally build meshes
  116116. */
  116117. export class BoxBuilder {
  116118. /**
  116119. * Creates a box mesh
  116120. * * The parameter `size` sets the size (float) of each box side (default 1)
  116121. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  116122. * * 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)
  116123. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  116124. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116125. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116127. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  116128. * @param name defines the name of the mesh
  116129. * @param options defines the options used to create the mesh
  116130. * @param scene defines the hosting scene
  116131. * @returns the box mesh
  116132. */
  116133. static CreateBox(name: string, options: {
  116134. size?: number;
  116135. width?: number;
  116136. height?: number;
  116137. depth?: number;
  116138. faceUV?: Vector4[];
  116139. faceColors?: Color4[];
  116140. sideOrientation?: number;
  116141. frontUVs?: Vector4;
  116142. backUVs?: Vector4;
  116143. wrap?: boolean;
  116144. topBaseAt?: number;
  116145. bottomBaseAt?: number;
  116146. updatable?: boolean;
  116147. }, scene?: Nullable<Scene>): Mesh;
  116148. }
  116149. }
  116150. declare module BABYLON {
  116151. /**
  116152. * Class containing static functions to help procedurally build meshes
  116153. */
  116154. export class SphereBuilder {
  116155. /**
  116156. * Creates a sphere mesh
  116157. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  116158. * * 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`)
  116159. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  116160. * * 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
  116161. * * 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)
  116162. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116163. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116165. * @param name defines the name of the mesh
  116166. * @param options defines the options used to create the mesh
  116167. * @param scene defines the hosting scene
  116168. * @returns the sphere mesh
  116169. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  116170. */
  116171. static CreateSphere(name: string, options: {
  116172. segments?: number;
  116173. diameter?: number;
  116174. diameterX?: number;
  116175. diameterY?: number;
  116176. diameterZ?: number;
  116177. arc?: number;
  116178. slice?: number;
  116179. sideOrientation?: number;
  116180. frontUVs?: Vector4;
  116181. backUVs?: Vector4;
  116182. updatable?: boolean;
  116183. }, scene?: Nullable<Scene>): Mesh;
  116184. }
  116185. }
  116186. declare module BABYLON.Debug {
  116187. /**
  116188. * Used to show the physics impostor around the specific mesh
  116189. */
  116190. export class PhysicsViewer {
  116191. /** @hidden */
  116192. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  116193. /** @hidden */
  116194. protected _meshes: Array<Nullable<AbstractMesh>>;
  116195. /** @hidden */
  116196. protected _scene: Nullable<Scene>;
  116197. /** @hidden */
  116198. protected _numMeshes: number;
  116199. /** @hidden */
  116200. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  116201. private _renderFunction;
  116202. private _utilityLayer;
  116203. private _debugBoxMesh;
  116204. private _debugSphereMesh;
  116205. private _debugCylinderMesh;
  116206. private _debugMaterial;
  116207. private _debugMeshMeshes;
  116208. /**
  116209. * Creates a new PhysicsViewer
  116210. * @param scene defines the hosting scene
  116211. */
  116212. constructor(scene: Scene);
  116213. /** @hidden */
  116214. protected _updateDebugMeshes(): void;
  116215. /**
  116216. * Renders a specified physic impostor
  116217. * @param impostor defines the impostor to render
  116218. * @param targetMesh defines the mesh represented by the impostor
  116219. * @returns the new debug mesh used to render the impostor
  116220. */
  116221. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  116222. /**
  116223. * Hides a specified physic impostor
  116224. * @param impostor defines the impostor to hide
  116225. */
  116226. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  116227. private _getDebugMaterial;
  116228. private _getDebugBoxMesh;
  116229. private _getDebugSphereMesh;
  116230. private _getDebugCylinderMesh;
  116231. private _getDebugMeshMesh;
  116232. private _getDebugMesh;
  116233. /** Releases all resources */
  116234. dispose(): void;
  116235. }
  116236. }
  116237. declare module BABYLON {
  116238. /**
  116239. * Class containing static functions to help procedurally build meshes
  116240. */
  116241. export class LinesBuilder {
  116242. /**
  116243. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  116244. * * 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
  116245. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  116246. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  116247. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  116248. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  116249. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  116250. * * 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
  116251. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  116252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116253. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  116254. * @param name defines the name of the new line system
  116255. * @param options defines the options used to create the line system
  116256. * @param scene defines the hosting scene
  116257. * @returns a new line system mesh
  116258. */
  116259. static CreateLineSystem(name: string, options: {
  116260. lines: Vector3[][];
  116261. updatable?: boolean;
  116262. instance?: Nullable<LinesMesh>;
  116263. colors?: Nullable<Color4[][]>;
  116264. useVertexAlpha?: boolean;
  116265. }, scene: Nullable<Scene>): LinesMesh;
  116266. /**
  116267. * Creates a line mesh
  116268. * 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
  116269. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116270. * * The parameter `points` is an array successive Vector3
  116271. * * 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
  116272. * * The optional parameter `colors` is an array of successive Color4, one per line point
  116273. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  116274. * * When updating an instance, remember that only point positions can change, not the number of points
  116275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116276. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  116277. * @param name defines the name of the new line system
  116278. * @param options defines the options used to create the line system
  116279. * @param scene defines the hosting scene
  116280. * @returns a new line mesh
  116281. */
  116282. static CreateLines(name: string, options: {
  116283. points: Vector3[];
  116284. updatable?: boolean;
  116285. instance?: Nullable<LinesMesh>;
  116286. colors?: Color4[];
  116287. useVertexAlpha?: boolean;
  116288. }, scene?: Nullable<Scene>): LinesMesh;
  116289. /**
  116290. * Creates a dashed line mesh
  116291. * * 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
  116292. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116293. * * The parameter `points` is an array successive Vector3
  116294. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  116295. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  116296. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  116297. * * 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
  116298. * * When updating an instance, remember that only point positions can change, not the number of points
  116299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116300. * @param name defines the name of the mesh
  116301. * @param options defines the options used to create the mesh
  116302. * @param scene defines the hosting scene
  116303. * @returns the dashed line mesh
  116304. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  116305. */
  116306. static CreateDashedLines(name: string, options: {
  116307. points: Vector3[];
  116308. dashSize?: number;
  116309. gapSize?: number;
  116310. dashNb?: number;
  116311. updatable?: boolean;
  116312. instance?: LinesMesh;
  116313. }, scene?: Nullable<Scene>): LinesMesh;
  116314. }
  116315. }
  116316. declare module BABYLON {
  116317. /**
  116318. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  116319. * in order to better appreciate the issue one might have.
  116320. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  116321. */
  116322. export class RayHelper {
  116323. /**
  116324. * Defines the ray we are currently tryin to visualize.
  116325. */
  116326. ray: Nullable<Ray>;
  116327. private _renderPoints;
  116328. private _renderLine;
  116329. private _renderFunction;
  116330. private _scene;
  116331. private _updateToMeshFunction;
  116332. private _attachedToMesh;
  116333. private _meshSpaceDirection;
  116334. private _meshSpaceOrigin;
  116335. /**
  116336. * Helper function to create a colored helper in a scene in one line.
  116337. * @param ray Defines the ray we are currently tryin to visualize
  116338. * @param scene Defines the scene the ray is used in
  116339. * @param color Defines the color we want to see the ray in
  116340. * @returns The newly created ray helper.
  116341. */
  116342. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  116343. /**
  116344. * Instantiate a new ray helper.
  116345. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  116346. * in order to better appreciate the issue one might have.
  116347. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  116348. * @param ray Defines the ray we are currently tryin to visualize
  116349. */
  116350. constructor(ray: Ray);
  116351. /**
  116352. * Shows the ray we are willing to debug.
  116353. * @param scene Defines the scene the ray needs to be rendered in
  116354. * @param color Defines the color the ray needs to be rendered in
  116355. */
  116356. show(scene: Scene, color?: Color3): void;
  116357. /**
  116358. * Hides the ray we are debugging.
  116359. */
  116360. hide(): void;
  116361. private _render;
  116362. /**
  116363. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  116364. * @param mesh Defines the mesh we want the helper attached to
  116365. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  116366. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  116367. * @param length Defines the length of the ray
  116368. */
  116369. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  116370. /**
  116371. * Detach the ray helper from the mesh it has previously been attached to.
  116372. */
  116373. detachFromMesh(): void;
  116374. private _updateToMesh;
  116375. /**
  116376. * Dispose the helper and release its associated resources.
  116377. */
  116378. dispose(): void;
  116379. }
  116380. }
  116381. declare module BABYLON.Debug {
  116382. /**
  116383. * Class used to render a debug view of a given skeleton
  116384. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  116385. */
  116386. export class SkeletonViewer {
  116387. /** defines the skeleton to render */
  116388. skeleton: Skeleton;
  116389. /** defines the mesh attached to the skeleton */
  116390. mesh: AbstractMesh;
  116391. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  116392. autoUpdateBonesMatrices: boolean;
  116393. /** defines the rendering group id to use with the viewer */
  116394. renderingGroupId: number;
  116395. /** Gets or sets the color used to render the skeleton */
  116396. color: Color3;
  116397. private _scene;
  116398. private _debugLines;
  116399. private _debugMesh;
  116400. private _isEnabled;
  116401. private _renderFunction;
  116402. private _utilityLayer;
  116403. /**
  116404. * Returns the mesh used to render the bones
  116405. */
  116406. get debugMesh(): Nullable<LinesMesh>;
  116407. /**
  116408. * Creates a new SkeletonViewer
  116409. * @param skeleton defines the skeleton to render
  116410. * @param mesh defines the mesh attached to the skeleton
  116411. * @param scene defines the hosting scene
  116412. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  116413. * @param renderingGroupId defines the rendering group id to use with the viewer
  116414. */
  116415. constructor(
  116416. /** defines the skeleton to render */
  116417. skeleton: Skeleton,
  116418. /** defines the mesh attached to the skeleton */
  116419. mesh: AbstractMesh, scene: Scene,
  116420. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  116421. autoUpdateBonesMatrices?: boolean,
  116422. /** defines the rendering group id to use with the viewer */
  116423. renderingGroupId?: number);
  116424. /** Gets or sets a boolean indicating if the viewer is enabled */
  116425. set isEnabled(value: boolean);
  116426. get isEnabled(): boolean;
  116427. private _getBonePosition;
  116428. private _getLinesForBonesWithLength;
  116429. private _getLinesForBonesNoLength;
  116430. /** Update the viewer to sync with current skeleton state */
  116431. update(): void;
  116432. /** Release associated resources */
  116433. dispose(): void;
  116434. }
  116435. }
  116436. declare module BABYLON {
  116437. /**
  116438. * Options to create the null engine
  116439. */
  116440. export class NullEngineOptions {
  116441. /**
  116442. * Render width (Default: 512)
  116443. */
  116444. renderWidth: number;
  116445. /**
  116446. * Render height (Default: 256)
  116447. */
  116448. renderHeight: number;
  116449. /**
  116450. * Texture size (Default: 512)
  116451. */
  116452. textureSize: number;
  116453. /**
  116454. * If delta time between frames should be constant
  116455. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116456. */
  116457. deterministicLockstep: boolean;
  116458. /**
  116459. * Maximum about of steps between frames (Default: 4)
  116460. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116461. */
  116462. lockstepMaxSteps: number;
  116463. }
  116464. /**
  116465. * The null engine class provides support for headless version of babylon.js.
  116466. * This can be used in server side scenario or for testing purposes
  116467. */
  116468. export class NullEngine extends Engine {
  116469. private _options;
  116470. /**
  116471. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  116472. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116473. * @returns true if engine is in deterministic lock step mode
  116474. */
  116475. isDeterministicLockStep(): boolean;
  116476. /**
  116477. * Gets the max steps when engine is running in deterministic lock step
  116478. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116479. * @returns the max steps
  116480. */
  116481. getLockstepMaxSteps(): number;
  116482. /**
  116483. * Gets the current hardware scaling level.
  116484. * By default the hardware scaling level is computed from the window device ratio.
  116485. * 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.
  116486. * @returns a number indicating the current hardware scaling level
  116487. */
  116488. getHardwareScalingLevel(): number;
  116489. constructor(options?: NullEngineOptions);
  116490. /**
  116491. * Creates a vertex buffer
  116492. * @param vertices the data for the vertex buffer
  116493. * @returns the new WebGL static buffer
  116494. */
  116495. createVertexBuffer(vertices: FloatArray): DataBuffer;
  116496. /**
  116497. * Creates a new index buffer
  116498. * @param indices defines the content of the index buffer
  116499. * @param updatable defines if the index buffer must be updatable
  116500. * @returns a new webGL buffer
  116501. */
  116502. createIndexBuffer(indices: IndicesArray): DataBuffer;
  116503. /**
  116504. * Clear the current render buffer or the current render target (if any is set up)
  116505. * @param color defines the color to use
  116506. * @param backBuffer defines if the back buffer must be cleared
  116507. * @param depth defines if the depth buffer must be cleared
  116508. * @param stencil defines if the stencil buffer must be cleared
  116509. */
  116510. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  116511. /**
  116512. * Gets the current render width
  116513. * @param useScreen defines if screen size must be used (or the current render target if any)
  116514. * @returns a number defining the current render width
  116515. */
  116516. getRenderWidth(useScreen?: boolean): number;
  116517. /**
  116518. * Gets the current render height
  116519. * @param useScreen defines if screen size must be used (or the current render target if any)
  116520. * @returns a number defining the current render height
  116521. */
  116522. getRenderHeight(useScreen?: boolean): number;
  116523. /**
  116524. * Set the WebGL's viewport
  116525. * @param viewport defines the viewport element to be used
  116526. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  116527. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  116528. */
  116529. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  116530. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  116531. /**
  116532. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  116533. * @param pipelineContext defines the pipeline context to use
  116534. * @param uniformsNames defines the list of uniform names
  116535. * @returns an array of webGL uniform locations
  116536. */
  116537. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  116538. /**
  116539. * Gets the lsit of active attributes for a given webGL program
  116540. * @param pipelineContext defines the pipeline context to use
  116541. * @param attributesNames defines the list of attribute names to get
  116542. * @returns an array of indices indicating the offset of each attribute
  116543. */
  116544. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  116545. /**
  116546. * Binds an effect to the webGL context
  116547. * @param effect defines the effect to bind
  116548. */
  116549. bindSamplers(effect: Effect): void;
  116550. /**
  116551. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  116552. * @param effect defines the effect to activate
  116553. */
  116554. enableEffect(effect: Effect): void;
  116555. /**
  116556. * Set various states to the webGL context
  116557. * @param culling defines backface culling state
  116558. * @param zOffset defines the value to apply to zOffset (0 by default)
  116559. * @param force defines if states must be applied even if cache is up to date
  116560. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  116561. */
  116562. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  116563. /**
  116564. * Set the value of an uniform to an array of int32
  116565. * @param uniform defines the webGL uniform location where to store the value
  116566. * @param array defines the array of int32 to store
  116567. */
  116568. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  116569. /**
  116570. * Set the value of an uniform to an array of int32 (stored as vec2)
  116571. * @param uniform defines the webGL uniform location where to store the value
  116572. * @param array defines the array of int32 to store
  116573. */
  116574. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  116575. /**
  116576. * Set the value of an uniform to an array of int32 (stored as vec3)
  116577. * @param uniform defines the webGL uniform location where to store the value
  116578. * @param array defines the array of int32 to store
  116579. */
  116580. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  116581. /**
  116582. * Set the value of an uniform to an array of int32 (stored as vec4)
  116583. * @param uniform defines the webGL uniform location where to store the value
  116584. * @param array defines the array of int32 to store
  116585. */
  116586. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  116587. /**
  116588. * Set the value of an uniform to an array of float32
  116589. * @param uniform defines the webGL uniform location where to store the value
  116590. * @param array defines the array of float32 to store
  116591. */
  116592. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  116593. /**
  116594. * Set the value of an uniform to an array of float32 (stored as vec2)
  116595. * @param uniform defines the webGL uniform location where to store the value
  116596. * @param array defines the array of float32 to store
  116597. */
  116598. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  116599. /**
  116600. * Set the value of an uniform to an array of float32 (stored as vec3)
  116601. * @param uniform defines the webGL uniform location where to store the value
  116602. * @param array defines the array of float32 to store
  116603. */
  116604. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  116605. /**
  116606. * Set the value of an uniform to an array of float32 (stored as vec4)
  116607. * @param uniform defines the webGL uniform location where to store the value
  116608. * @param array defines the array of float32 to store
  116609. */
  116610. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  116611. /**
  116612. * Set the value of an uniform to an array of number
  116613. * @param uniform defines the webGL uniform location where to store the value
  116614. * @param array defines the array of number to store
  116615. */
  116616. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  116617. /**
  116618. * Set the value of an uniform to an array of number (stored as vec2)
  116619. * @param uniform defines the webGL uniform location where to store the value
  116620. * @param array defines the array of number to store
  116621. */
  116622. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  116623. /**
  116624. * Set the value of an uniform to an array of number (stored as vec3)
  116625. * @param uniform defines the webGL uniform location where to store the value
  116626. * @param array defines the array of number to store
  116627. */
  116628. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  116629. /**
  116630. * Set the value of an uniform to an array of number (stored as vec4)
  116631. * @param uniform defines the webGL uniform location where to store the value
  116632. * @param array defines the array of number to store
  116633. */
  116634. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  116635. /**
  116636. * Set the value of an uniform to an array of float32 (stored as matrices)
  116637. * @param uniform defines the webGL uniform location where to store the value
  116638. * @param matrices defines the array of float32 to store
  116639. */
  116640. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  116641. /**
  116642. * Set the value of an uniform to a matrix (3x3)
  116643. * @param uniform defines the webGL uniform location where to store the value
  116644. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  116645. */
  116646. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  116647. /**
  116648. * Set the value of an uniform to a matrix (2x2)
  116649. * @param uniform defines the webGL uniform location where to store the value
  116650. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  116651. */
  116652. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  116653. /**
  116654. * Set the value of an uniform to a number (float)
  116655. * @param uniform defines the webGL uniform location where to store the value
  116656. * @param value defines the float number to store
  116657. */
  116658. setFloat(uniform: WebGLUniformLocation, value: number): void;
  116659. /**
  116660. * Set the value of an uniform to a vec2
  116661. * @param uniform defines the webGL uniform location where to store the value
  116662. * @param x defines the 1st component of the value
  116663. * @param y defines the 2nd component of the value
  116664. */
  116665. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  116666. /**
  116667. * Set the value of an uniform to a vec3
  116668. * @param uniform defines the webGL uniform location where to store the value
  116669. * @param x defines the 1st component of the value
  116670. * @param y defines the 2nd component of the value
  116671. * @param z defines the 3rd component of the value
  116672. */
  116673. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  116674. /**
  116675. * Set the value of an uniform to a boolean
  116676. * @param uniform defines the webGL uniform location where to store the value
  116677. * @param bool defines the boolean to store
  116678. */
  116679. setBool(uniform: WebGLUniformLocation, bool: number): void;
  116680. /**
  116681. * Set the value of an uniform to a vec4
  116682. * @param uniform defines the webGL uniform location where to store the value
  116683. * @param x defines the 1st component of the value
  116684. * @param y defines the 2nd component of the value
  116685. * @param z defines the 3rd component of the value
  116686. * @param w defines the 4th component of the value
  116687. */
  116688. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  116689. /**
  116690. * Sets the current alpha mode
  116691. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  116692. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  116693. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  116694. */
  116695. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  116696. /**
  116697. * Bind webGl buffers directly to the webGL context
  116698. * @param vertexBuffers defines the vertex buffer to bind
  116699. * @param indexBuffer defines the index buffer to bind
  116700. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  116701. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  116702. * @param effect defines the effect associated with the vertex buffer
  116703. */
  116704. bindBuffers(vertexBuffers: {
  116705. [key: string]: VertexBuffer;
  116706. }, indexBuffer: DataBuffer, effect: Effect): void;
  116707. /**
  116708. * Force the entire cache to be cleared
  116709. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  116710. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  116711. */
  116712. wipeCaches(bruteForce?: boolean): void;
  116713. /**
  116714. * Send a draw order
  116715. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  116716. * @param indexStart defines the starting index
  116717. * @param indexCount defines the number of index to draw
  116718. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116719. */
  116720. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  116721. /**
  116722. * Draw a list of indexed primitives
  116723. * @param fillMode defines the primitive to use
  116724. * @param indexStart defines the starting index
  116725. * @param indexCount defines the number of index to draw
  116726. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116727. */
  116728. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  116729. /**
  116730. * Draw a list of unindexed primitives
  116731. * @param fillMode defines the primitive to use
  116732. * @param verticesStart defines the index of first vertex to draw
  116733. * @param verticesCount defines the count of vertices to draw
  116734. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116735. */
  116736. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116737. /** @hidden */
  116738. _createTexture(): WebGLTexture;
  116739. /** @hidden */
  116740. _releaseTexture(texture: InternalTexture): void;
  116741. /**
  116742. * Usually called from Texture.ts.
  116743. * Passed information to create a WebGLTexture
  116744. * @param urlArg defines a value which contains one of the following:
  116745. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  116746. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  116747. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  116748. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  116749. * @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)
  116750. * @param scene needed for loading to the correct scene
  116751. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  116752. * @param onLoad optional callback to be called upon successful completion
  116753. * @param onError optional callback to be called upon failure
  116754. * @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
  116755. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  116756. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  116757. * @param forcedExtension defines the extension to use to pick the right loader
  116758. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  116759. * @returns a InternalTexture for assignment back into BABYLON.Texture
  116760. */
  116761. 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;
  116762. /**
  116763. * Creates a new render target texture
  116764. * @param size defines the size of the texture
  116765. * @param options defines the options used to create the texture
  116766. * @returns a new render target texture stored in an InternalTexture
  116767. */
  116768. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  116769. /**
  116770. * Update the sampling mode of a given texture
  116771. * @param samplingMode defines the required sampling mode
  116772. * @param texture defines the texture to update
  116773. */
  116774. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  116775. /**
  116776. * Binds the frame buffer to the specified texture.
  116777. * @param texture The texture to render to or null for the default canvas
  116778. * @param faceIndex The face of the texture to render to in case of cube texture
  116779. * @param requiredWidth The width of the target to render to
  116780. * @param requiredHeight The height of the target to render to
  116781. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  116782. * @param depthStencilTexture The depth stencil texture to use to render
  116783. * @param lodLevel defines le lod level to bind to the frame buffer
  116784. */
  116785. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  116786. /**
  116787. * Unbind the current render target texture from the webGL context
  116788. * @param texture defines the render target texture to unbind
  116789. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  116790. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  116791. */
  116792. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  116793. /**
  116794. * Creates a dynamic vertex buffer
  116795. * @param vertices the data for the dynamic vertex buffer
  116796. * @returns the new WebGL dynamic buffer
  116797. */
  116798. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  116799. /**
  116800. * Update the content of a dynamic texture
  116801. * @param texture defines the texture to update
  116802. * @param canvas defines the canvas containing the source
  116803. * @param invertY defines if data must be stored with Y axis inverted
  116804. * @param premulAlpha defines if alpha is stored as premultiplied
  116805. * @param format defines the format of the data
  116806. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  116807. */
  116808. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  116809. /**
  116810. * Gets a boolean indicating if all created effects are ready
  116811. * @returns true if all effects are ready
  116812. */
  116813. areAllEffectsReady(): boolean;
  116814. /**
  116815. * @hidden
  116816. * Get the current error code of the webGL context
  116817. * @returns the error code
  116818. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  116819. */
  116820. getError(): number;
  116821. /** @hidden */
  116822. _getUnpackAlignement(): number;
  116823. /** @hidden */
  116824. _unpackFlipY(value: boolean): void;
  116825. /**
  116826. * Update a dynamic index buffer
  116827. * @param indexBuffer defines the target index buffer
  116828. * @param indices defines the data to update
  116829. * @param offset defines the offset in the target index buffer where update should start
  116830. */
  116831. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  116832. /**
  116833. * Updates a dynamic vertex buffer.
  116834. * @param vertexBuffer the vertex buffer to update
  116835. * @param vertices the data used to update the vertex buffer
  116836. * @param byteOffset the byte offset of the data (optional)
  116837. * @param byteLength the byte length of the data (optional)
  116838. */
  116839. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  116840. /** @hidden */
  116841. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  116842. /** @hidden */
  116843. _bindTexture(channel: number, texture: InternalTexture): void;
  116844. protected _deleteBuffer(buffer: WebGLBuffer): void;
  116845. /**
  116846. * 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
  116847. */
  116848. releaseEffects(): void;
  116849. displayLoadingUI(): void;
  116850. hideLoadingUI(): void;
  116851. /** @hidden */
  116852. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116853. /** @hidden */
  116854. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116855. /** @hidden */
  116856. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116857. /** @hidden */
  116858. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  116859. }
  116860. }
  116861. declare module BABYLON {
  116862. /** @hidden */
  116863. export class _OcclusionDataStorage {
  116864. /** @hidden */
  116865. occlusionInternalRetryCounter: number;
  116866. /** @hidden */
  116867. isOcclusionQueryInProgress: boolean;
  116868. /** @hidden */
  116869. isOccluded: boolean;
  116870. /** @hidden */
  116871. occlusionRetryCount: number;
  116872. /** @hidden */
  116873. occlusionType: number;
  116874. /** @hidden */
  116875. occlusionQueryAlgorithmType: number;
  116876. }
  116877. interface Engine {
  116878. /**
  116879. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  116880. * @return the new query
  116881. */
  116882. createQuery(): WebGLQuery;
  116883. /**
  116884. * Delete and release a webGL query
  116885. * @param query defines the query to delete
  116886. * @return the current engine
  116887. */
  116888. deleteQuery(query: WebGLQuery): Engine;
  116889. /**
  116890. * Check if a given query has resolved and got its value
  116891. * @param query defines the query to check
  116892. * @returns true if the query got its value
  116893. */
  116894. isQueryResultAvailable(query: WebGLQuery): boolean;
  116895. /**
  116896. * Gets the value of a given query
  116897. * @param query defines the query to check
  116898. * @returns the value of the query
  116899. */
  116900. getQueryResult(query: WebGLQuery): number;
  116901. /**
  116902. * Initiates an occlusion query
  116903. * @param algorithmType defines the algorithm to use
  116904. * @param query defines the query to use
  116905. * @returns the current engine
  116906. * @see http://doc.babylonjs.com/features/occlusionquery
  116907. */
  116908. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  116909. /**
  116910. * Ends an occlusion query
  116911. * @see http://doc.babylonjs.com/features/occlusionquery
  116912. * @param algorithmType defines the algorithm to use
  116913. * @returns the current engine
  116914. */
  116915. endOcclusionQuery(algorithmType: number): Engine;
  116916. /**
  116917. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  116918. * Please note that only one query can be issued at a time
  116919. * @returns a time token used to track the time span
  116920. */
  116921. startTimeQuery(): Nullable<_TimeToken>;
  116922. /**
  116923. * Ends a time query
  116924. * @param token defines the token used to measure the time span
  116925. * @returns the time spent (in ns)
  116926. */
  116927. endTimeQuery(token: _TimeToken): int;
  116928. /** @hidden */
  116929. _currentNonTimestampToken: Nullable<_TimeToken>;
  116930. /** @hidden */
  116931. _createTimeQuery(): WebGLQuery;
  116932. /** @hidden */
  116933. _deleteTimeQuery(query: WebGLQuery): void;
  116934. /** @hidden */
  116935. _getGlAlgorithmType(algorithmType: number): number;
  116936. /** @hidden */
  116937. _getTimeQueryResult(query: WebGLQuery): any;
  116938. /** @hidden */
  116939. _getTimeQueryAvailability(query: WebGLQuery): any;
  116940. }
  116941. interface AbstractMesh {
  116942. /**
  116943. * Backing filed
  116944. * @hidden
  116945. */
  116946. __occlusionDataStorage: _OcclusionDataStorage;
  116947. /**
  116948. * Access property
  116949. * @hidden
  116950. */
  116951. _occlusionDataStorage: _OcclusionDataStorage;
  116952. /**
  116953. * 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.
  116954. * The default value is -1 which means don't break the query and wait till the result
  116955. * @see http://doc.babylonjs.com/features/occlusionquery
  116956. */
  116957. occlusionRetryCount: number;
  116958. /**
  116959. * 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:
  116960. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  116961. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  116962. * * 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.
  116963. * @see http://doc.babylonjs.com/features/occlusionquery
  116964. */
  116965. occlusionType: number;
  116966. /**
  116967. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  116968. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  116969. * * 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.
  116970. * @see http://doc.babylonjs.com/features/occlusionquery
  116971. */
  116972. occlusionQueryAlgorithmType: number;
  116973. /**
  116974. * 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
  116975. * @see http://doc.babylonjs.com/features/occlusionquery
  116976. */
  116977. isOccluded: boolean;
  116978. /**
  116979. * Flag to check the progress status of the query
  116980. * @see http://doc.babylonjs.com/features/occlusionquery
  116981. */
  116982. isOcclusionQueryInProgress: boolean;
  116983. }
  116984. }
  116985. declare module BABYLON {
  116986. /** @hidden */
  116987. export var _forceTransformFeedbackToBundle: boolean;
  116988. interface Engine {
  116989. /**
  116990. * Creates a webGL transform feedback object
  116991. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  116992. * @returns the webGL transform feedback object
  116993. */
  116994. createTransformFeedback(): WebGLTransformFeedback;
  116995. /**
  116996. * Delete a webGL transform feedback object
  116997. * @param value defines the webGL transform feedback object to delete
  116998. */
  116999. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  117000. /**
  117001. * Bind a webGL transform feedback object to the webgl context
  117002. * @param value defines the webGL transform feedback object to bind
  117003. */
  117004. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  117005. /**
  117006. * Begins a transform feedback operation
  117007. * @param usePoints defines if points or triangles must be used
  117008. */
  117009. beginTransformFeedback(usePoints: boolean): void;
  117010. /**
  117011. * Ends a transform feedback operation
  117012. */
  117013. endTransformFeedback(): void;
  117014. /**
  117015. * Specify the varyings to use with transform feedback
  117016. * @param program defines the associated webGL program
  117017. * @param value defines the list of strings representing the varying names
  117018. */
  117019. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  117020. /**
  117021. * Bind a webGL buffer for a transform feedback operation
  117022. * @param value defines the webGL buffer to bind
  117023. */
  117024. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  117025. }
  117026. }
  117027. declare module BABYLON {
  117028. /**
  117029. * Creation options of the multi render target texture.
  117030. */
  117031. export interface IMultiRenderTargetOptions {
  117032. /**
  117033. * Define if the texture needs to create mip maps after render.
  117034. */
  117035. generateMipMaps?: boolean;
  117036. /**
  117037. * Define the types of all the draw buffers we want to create
  117038. */
  117039. types?: number[];
  117040. /**
  117041. * Define the sampling modes of all the draw buffers we want to create
  117042. */
  117043. samplingModes?: number[];
  117044. /**
  117045. * Define if a depth buffer is required
  117046. */
  117047. generateDepthBuffer?: boolean;
  117048. /**
  117049. * Define if a stencil buffer is required
  117050. */
  117051. generateStencilBuffer?: boolean;
  117052. /**
  117053. * Define if a depth texture is required instead of a depth buffer
  117054. */
  117055. generateDepthTexture?: boolean;
  117056. /**
  117057. * Define the number of desired draw buffers
  117058. */
  117059. textureCount?: number;
  117060. /**
  117061. * Define if aspect ratio should be adapted to the texture or stay the scene one
  117062. */
  117063. doNotChangeAspectRatio?: boolean;
  117064. /**
  117065. * Define the default type of the buffers we are creating
  117066. */
  117067. defaultType?: number;
  117068. }
  117069. /**
  117070. * A multi render target, like a render target provides the ability to render to a texture.
  117071. * Unlike the render target, it can render to several draw buffers in one draw.
  117072. * This is specially interesting in deferred rendering or for any effects requiring more than
  117073. * just one color from a single pass.
  117074. */
  117075. export class MultiRenderTarget extends RenderTargetTexture {
  117076. private _internalTextures;
  117077. private _textures;
  117078. private _multiRenderTargetOptions;
  117079. /**
  117080. * Get if draw buffers are currently supported by the used hardware and browser.
  117081. */
  117082. get isSupported(): boolean;
  117083. /**
  117084. * Get the list of textures generated by the multi render target.
  117085. */
  117086. get textures(): Texture[];
  117087. /**
  117088. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  117089. */
  117090. get depthTexture(): Texture;
  117091. /**
  117092. * Set the wrapping mode on U of all the textures we are rendering to.
  117093. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  117094. */
  117095. set wrapU(wrap: number);
  117096. /**
  117097. * Set the wrapping mode on V of all the textures we are rendering to.
  117098. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  117099. */
  117100. set wrapV(wrap: number);
  117101. /**
  117102. * Instantiate a new multi render target texture.
  117103. * A multi render target, like a render target provides the ability to render to a texture.
  117104. * Unlike the render target, it can render to several draw buffers in one draw.
  117105. * This is specially interesting in deferred rendering or for any effects requiring more than
  117106. * just one color from a single pass.
  117107. * @param name Define the name of the texture
  117108. * @param size Define the size of the buffers to render to
  117109. * @param count Define the number of target we are rendering into
  117110. * @param scene Define the scene the texture belongs to
  117111. * @param options Define the options used to create the multi render target
  117112. */
  117113. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  117114. /** @hidden */
  117115. _rebuild(): void;
  117116. private _createInternalTextures;
  117117. private _createTextures;
  117118. /**
  117119. * Define the number of samples used if MSAA is enabled.
  117120. */
  117121. get samples(): number;
  117122. set samples(value: number);
  117123. /**
  117124. * Resize all the textures in the multi render target.
  117125. * Be carrefull as it will recreate all the data in the new texture.
  117126. * @param size Define the new size
  117127. */
  117128. resize(size: any): void;
  117129. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  117130. /**
  117131. * Dispose the render targets and their associated resources
  117132. */
  117133. dispose(): void;
  117134. /**
  117135. * Release all the underlying texture used as draw buffers.
  117136. */
  117137. releaseInternalTextures(): void;
  117138. }
  117139. }
  117140. declare module BABYLON {
  117141. interface ThinEngine {
  117142. /**
  117143. * Unbind a list of render target textures from the webGL context
  117144. * This is used only when drawBuffer extension or webGL2 are active
  117145. * @param textures defines the render target textures to unbind
  117146. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  117147. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  117148. */
  117149. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  117150. /**
  117151. * Create a multi render target texture
  117152. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  117153. * @param size defines the size of the texture
  117154. * @param options defines the creation options
  117155. * @returns the cube texture as an InternalTexture
  117156. */
  117157. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  117158. /**
  117159. * Update the sample count for a given multiple render target texture
  117160. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  117161. * @param textures defines the textures to update
  117162. * @param samples defines the sample count to set
  117163. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  117164. */
  117165. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  117166. }
  117167. }
  117168. declare module BABYLON {
  117169. /**
  117170. * Class used to define an additional view for the engine
  117171. * @see https://doc.babylonjs.com/how_to/multi_canvases
  117172. */
  117173. export class EngineView {
  117174. /** Defines the canvas where to render the view */
  117175. target: HTMLCanvasElement;
  117176. /** Defines an optional camera used to render the view (will use active camera else) */
  117177. camera?: Camera;
  117178. }
  117179. interface Engine {
  117180. /**
  117181. * Gets or sets the HTML element to use for attaching events
  117182. */
  117183. inputElement: Nullable<HTMLElement>;
  117184. /**
  117185. * Gets the current engine view
  117186. * @see https://doc.babylonjs.com/how_to/multi_canvases
  117187. */
  117188. activeView: Nullable<EngineView>;
  117189. /** Gets or sets the list of views */
  117190. views: EngineView[];
  117191. /**
  117192. * Register a new child canvas
  117193. * @param canvas defines the canvas to register
  117194. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  117195. * @returns the associated view
  117196. */
  117197. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  117198. /**
  117199. * Remove a registered child canvas
  117200. * @param canvas defines the canvas to remove
  117201. * @returns the current engine
  117202. */
  117203. unRegisterView(canvas: HTMLCanvasElement): Engine;
  117204. }
  117205. }
  117206. declare module BABYLON {
  117207. /**
  117208. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  117209. */
  117210. export interface CubeMapInfo {
  117211. /**
  117212. * The pixel array for the front face.
  117213. * This is stored in format, left to right, up to down format.
  117214. */
  117215. front: Nullable<ArrayBufferView>;
  117216. /**
  117217. * The pixel array for the back face.
  117218. * This is stored in format, left to right, up to down format.
  117219. */
  117220. back: Nullable<ArrayBufferView>;
  117221. /**
  117222. * The pixel array for the left face.
  117223. * This is stored in format, left to right, up to down format.
  117224. */
  117225. left: Nullable<ArrayBufferView>;
  117226. /**
  117227. * The pixel array for the right face.
  117228. * This is stored in format, left to right, up to down format.
  117229. */
  117230. right: Nullable<ArrayBufferView>;
  117231. /**
  117232. * The pixel array for the up face.
  117233. * This is stored in format, left to right, up to down format.
  117234. */
  117235. up: Nullable<ArrayBufferView>;
  117236. /**
  117237. * The pixel array for the down face.
  117238. * This is stored in format, left to right, up to down format.
  117239. */
  117240. down: Nullable<ArrayBufferView>;
  117241. /**
  117242. * The size of the cubemap stored.
  117243. *
  117244. * Each faces will be size * size pixels.
  117245. */
  117246. size: number;
  117247. /**
  117248. * The format of the texture.
  117249. *
  117250. * RGBA, RGB.
  117251. */
  117252. format: number;
  117253. /**
  117254. * The type of the texture data.
  117255. *
  117256. * UNSIGNED_INT, FLOAT.
  117257. */
  117258. type: number;
  117259. /**
  117260. * Specifies whether the texture is in gamma space.
  117261. */
  117262. gammaSpace: boolean;
  117263. }
  117264. /**
  117265. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  117266. */
  117267. export class PanoramaToCubeMapTools {
  117268. private static FACE_FRONT;
  117269. private static FACE_BACK;
  117270. private static FACE_RIGHT;
  117271. private static FACE_LEFT;
  117272. private static FACE_DOWN;
  117273. private static FACE_UP;
  117274. /**
  117275. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  117276. *
  117277. * @param float32Array The source data.
  117278. * @param inputWidth The width of the input panorama.
  117279. * @param inputHeight The height of the input panorama.
  117280. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  117281. * @return The cubemap data
  117282. */
  117283. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  117284. private static CreateCubemapTexture;
  117285. private static CalcProjectionSpherical;
  117286. }
  117287. }
  117288. declare module BABYLON {
  117289. /**
  117290. * Helper class dealing with the extraction of spherical polynomial dataArray
  117291. * from a cube map.
  117292. */
  117293. export class CubeMapToSphericalPolynomialTools {
  117294. private static FileFaces;
  117295. /**
  117296. * Converts a texture to the according Spherical Polynomial data.
  117297. * This extracts the first 3 orders only as they are the only one used in the lighting.
  117298. *
  117299. * @param texture The texture to extract the information from.
  117300. * @return The Spherical Polynomial data.
  117301. */
  117302. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  117303. /**
  117304. * Converts a cubemap to the according Spherical Polynomial data.
  117305. * This extracts the first 3 orders only as they are the only one used in the lighting.
  117306. *
  117307. * @param cubeInfo The Cube map to extract the information from.
  117308. * @return The Spherical Polynomial data.
  117309. */
  117310. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  117311. }
  117312. }
  117313. declare module BABYLON {
  117314. interface BaseTexture {
  117315. /**
  117316. * Get the polynomial representation of the texture data.
  117317. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  117318. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  117319. */
  117320. sphericalPolynomial: Nullable<SphericalPolynomial>;
  117321. }
  117322. }
  117323. declare module BABYLON {
  117324. /** @hidden */
  117325. export var rgbdEncodePixelShader: {
  117326. name: string;
  117327. shader: string;
  117328. };
  117329. }
  117330. declare module BABYLON {
  117331. /** @hidden */
  117332. export var rgbdDecodePixelShader: {
  117333. name: string;
  117334. shader: string;
  117335. };
  117336. }
  117337. declare module BABYLON {
  117338. /**
  117339. * Raw texture data and descriptor sufficient for WebGL texture upload
  117340. */
  117341. export interface EnvironmentTextureInfo {
  117342. /**
  117343. * Version of the environment map
  117344. */
  117345. version: number;
  117346. /**
  117347. * Width of image
  117348. */
  117349. width: number;
  117350. /**
  117351. * Irradiance information stored in the file.
  117352. */
  117353. irradiance: any;
  117354. /**
  117355. * Specular information stored in the file.
  117356. */
  117357. specular: any;
  117358. }
  117359. /**
  117360. * Defines One Image in the file. It requires only the position in the file
  117361. * as well as the length.
  117362. */
  117363. interface BufferImageData {
  117364. /**
  117365. * Length of the image data.
  117366. */
  117367. length: number;
  117368. /**
  117369. * Position of the data from the null terminator delimiting the end of the JSON.
  117370. */
  117371. position: number;
  117372. }
  117373. /**
  117374. * Defines the specular data enclosed in the file.
  117375. * This corresponds to the version 1 of the data.
  117376. */
  117377. export interface EnvironmentTextureSpecularInfoV1 {
  117378. /**
  117379. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  117380. */
  117381. specularDataPosition?: number;
  117382. /**
  117383. * This contains all the images data needed to reconstruct the cubemap.
  117384. */
  117385. mipmaps: Array<BufferImageData>;
  117386. /**
  117387. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  117388. */
  117389. lodGenerationScale: number;
  117390. }
  117391. /**
  117392. * Sets of helpers addressing the serialization and deserialization of environment texture
  117393. * stored in a BabylonJS env file.
  117394. * Those files are usually stored as .env files.
  117395. */
  117396. export class EnvironmentTextureTools {
  117397. /**
  117398. * Magic number identifying the env file.
  117399. */
  117400. private static _MagicBytes;
  117401. /**
  117402. * Gets the environment info from an env file.
  117403. * @param data The array buffer containing the .env bytes.
  117404. * @returns the environment file info (the json header) if successfully parsed.
  117405. */
  117406. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  117407. /**
  117408. * Creates an environment texture from a loaded cube texture.
  117409. * @param texture defines the cube texture to convert in env file
  117410. * @return a promise containing the environment data if succesfull.
  117411. */
  117412. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  117413. /**
  117414. * Creates a JSON representation of the spherical data.
  117415. * @param texture defines the texture containing the polynomials
  117416. * @return the JSON representation of the spherical info
  117417. */
  117418. private static _CreateEnvTextureIrradiance;
  117419. /**
  117420. * Creates the ArrayBufferViews used for initializing environment texture image data.
  117421. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  117422. * @param info parameters that determine what views will be created for accessing the underlying buffer
  117423. * @return the views described by info providing access to the underlying buffer
  117424. */
  117425. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  117426. /**
  117427. * Uploads the texture info contained in the env file to the GPU.
  117428. * @param texture defines the internal texture to upload to
  117429. * @param arrayBuffer defines the buffer cotaining the data to load
  117430. * @param info defines the texture info retrieved through the GetEnvInfo method
  117431. * @returns a promise
  117432. */
  117433. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  117434. private static _OnImageReadyAsync;
  117435. /**
  117436. * Uploads the levels of image data to the GPU.
  117437. * @param texture defines the internal texture to upload to
  117438. * @param imageData defines the array buffer views of image data [mipmap][face]
  117439. * @returns a promise
  117440. */
  117441. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  117442. /**
  117443. * Uploads spherical polynomials information to the texture.
  117444. * @param texture defines the texture we are trying to upload the information to
  117445. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  117446. */
  117447. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  117448. /** @hidden */
  117449. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  117450. }
  117451. }
  117452. declare module BABYLON {
  117453. /**
  117454. * Contains position and normal vectors for a vertex
  117455. */
  117456. export class PositionNormalVertex {
  117457. /** the position of the vertex (defaut: 0,0,0) */
  117458. position: Vector3;
  117459. /** the normal of the vertex (defaut: 0,1,0) */
  117460. normal: Vector3;
  117461. /**
  117462. * Creates a PositionNormalVertex
  117463. * @param position the position of the vertex (defaut: 0,0,0)
  117464. * @param normal the normal of the vertex (defaut: 0,1,0)
  117465. */
  117466. constructor(
  117467. /** the position of the vertex (defaut: 0,0,0) */
  117468. position?: Vector3,
  117469. /** the normal of the vertex (defaut: 0,1,0) */
  117470. normal?: Vector3);
  117471. /**
  117472. * Clones the PositionNormalVertex
  117473. * @returns the cloned PositionNormalVertex
  117474. */
  117475. clone(): PositionNormalVertex;
  117476. }
  117477. /**
  117478. * Contains position, normal and uv vectors for a vertex
  117479. */
  117480. export class PositionNormalTextureVertex {
  117481. /** the position of the vertex (defaut: 0,0,0) */
  117482. position: Vector3;
  117483. /** the normal of the vertex (defaut: 0,1,0) */
  117484. normal: Vector3;
  117485. /** the uv of the vertex (default: 0,0) */
  117486. uv: Vector2;
  117487. /**
  117488. * Creates a PositionNormalTextureVertex
  117489. * @param position the position of the vertex (defaut: 0,0,0)
  117490. * @param normal the normal of the vertex (defaut: 0,1,0)
  117491. * @param uv the uv of the vertex (default: 0,0)
  117492. */
  117493. constructor(
  117494. /** the position of the vertex (defaut: 0,0,0) */
  117495. position?: Vector3,
  117496. /** the normal of the vertex (defaut: 0,1,0) */
  117497. normal?: Vector3,
  117498. /** the uv of the vertex (default: 0,0) */
  117499. uv?: Vector2);
  117500. /**
  117501. * Clones the PositionNormalTextureVertex
  117502. * @returns the cloned PositionNormalTextureVertex
  117503. */
  117504. clone(): PositionNormalTextureVertex;
  117505. }
  117506. }
  117507. declare module BABYLON {
  117508. /** @hidden */
  117509. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  117510. private _genericAttributeLocation;
  117511. private _varyingLocationCount;
  117512. private _varyingLocationMap;
  117513. private _replacements;
  117514. private _textureCount;
  117515. private _uniforms;
  117516. lineProcessor(line: string): string;
  117517. attributeProcessor(attribute: string): string;
  117518. varyingProcessor(varying: string, isFragment: boolean): string;
  117519. uniformProcessor(uniform: string): string;
  117520. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  117521. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  117522. }
  117523. }
  117524. declare module BABYLON {
  117525. /**
  117526. * Container for accessors for natively-stored mesh data buffers.
  117527. */
  117528. class NativeDataBuffer extends DataBuffer {
  117529. /**
  117530. * Accessor value used to identify/retrieve a natively-stored index buffer.
  117531. */
  117532. nativeIndexBuffer?: any;
  117533. /**
  117534. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  117535. */
  117536. nativeVertexBuffer?: any;
  117537. }
  117538. /** @hidden */
  117539. class NativeTexture extends InternalTexture {
  117540. getInternalTexture(): InternalTexture;
  117541. getViewCount(): number;
  117542. }
  117543. /** @hidden */
  117544. export class NativeEngine extends Engine {
  117545. private readonly _native;
  117546. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  117547. private readonly INVALID_HANDLE;
  117548. getHardwareScalingLevel(): number;
  117549. constructor();
  117550. /**
  117551. * Can be used to override the current requestAnimationFrame requester.
  117552. * @hidden
  117553. */
  117554. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  117555. /**
  117556. * Override default engine behavior.
  117557. * @param color
  117558. * @param backBuffer
  117559. * @param depth
  117560. * @param stencil
  117561. */
  117562. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  117563. /**
  117564. * Gets host document
  117565. * @returns the host document object
  117566. */
  117567. getHostDocument(): Nullable<Document>;
  117568. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  117569. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  117570. createVertexBuffer(data: DataArray): NativeDataBuffer;
  117571. recordVertexArrayObject(vertexBuffers: {
  117572. [key: string]: VertexBuffer;
  117573. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  117574. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  117575. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  117576. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  117577. /**
  117578. * Draw a list of indexed primitives
  117579. * @param fillMode defines the primitive to use
  117580. * @param indexStart defines the starting index
  117581. * @param indexCount defines the number of index to draw
  117582. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  117583. */
  117584. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  117585. /**
  117586. * Draw a list of unindexed primitives
  117587. * @param fillMode defines the primitive to use
  117588. * @param verticesStart defines the index of first vertex to draw
  117589. * @param verticesCount defines the count of vertices to draw
  117590. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  117591. */
  117592. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  117593. createPipelineContext(): IPipelineContext;
  117594. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  117595. /** @hidden */
  117596. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  117597. /** @hidden */
  117598. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  117599. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  117600. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  117601. protected _setProgram(program: WebGLProgram): void;
  117602. _releaseEffect(effect: Effect): void;
  117603. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  117604. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  117605. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  117606. bindSamplers(effect: Effect): void;
  117607. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  117608. getRenderWidth(useScreen?: boolean): number;
  117609. getRenderHeight(useScreen?: boolean): number;
  117610. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  117611. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  117612. /**
  117613. * Set the z offset to apply to current rendering
  117614. * @param value defines the offset to apply
  117615. */
  117616. setZOffset(value: number): void;
  117617. /**
  117618. * Gets the current value of the zOffset
  117619. * @returns the current zOffset state
  117620. */
  117621. getZOffset(): number;
  117622. /**
  117623. * Enable or disable depth buffering
  117624. * @param enable defines the state to set
  117625. */
  117626. setDepthBuffer(enable: boolean): void;
  117627. /**
  117628. * Gets a boolean indicating if depth writing is enabled
  117629. * @returns the current depth writing state
  117630. */
  117631. getDepthWrite(): boolean;
  117632. /**
  117633. * Enable or disable depth writing
  117634. * @param enable defines the state to set
  117635. */
  117636. setDepthWrite(enable: boolean): void;
  117637. /**
  117638. * Enable or disable color writing
  117639. * @param enable defines the state to set
  117640. */
  117641. setColorWrite(enable: boolean): void;
  117642. /**
  117643. * Gets a boolean indicating if color writing is enabled
  117644. * @returns the current color writing state
  117645. */
  117646. getColorWrite(): boolean;
  117647. /**
  117648. * Sets alpha constants used by some alpha blending modes
  117649. * @param r defines the red component
  117650. * @param g defines the green component
  117651. * @param b defines the blue component
  117652. * @param a defines the alpha component
  117653. */
  117654. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  117655. /**
  117656. * Sets the current alpha mode
  117657. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  117658. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  117659. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  117660. */
  117661. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  117662. /**
  117663. * Gets the current alpha mode
  117664. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  117665. * @returns the current alpha mode
  117666. */
  117667. getAlphaMode(): number;
  117668. setInt(uniform: WebGLUniformLocation, int: number): void;
  117669. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  117670. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  117671. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  117672. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  117673. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  117674. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  117675. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  117676. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  117677. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  117678. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  117679. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  117680. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  117681. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  117682. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  117683. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  117684. setFloat(uniform: WebGLUniformLocation, value: number): void;
  117685. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  117686. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  117687. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  117688. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  117689. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  117690. wipeCaches(bruteForce?: boolean): void;
  117691. _createTexture(): WebGLTexture;
  117692. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  117693. /**
  117694. * Usually called from BABYLON.Texture.ts.
  117695. * Passed information to create a WebGLTexture
  117696. * @param urlArg defines a value which contains one of the following:
  117697. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  117698. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  117699. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  117700. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  117701. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  117702. * @param scene needed for loading to the correct scene
  117703. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  117704. * @param onLoad optional callback to be called upon successful completion
  117705. * @param onError optional callback to be called upon failure
  117706. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  117707. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  117708. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  117709. * @param forcedExtension defines the extension to use to pick the right loader
  117710. * @returns a InternalTexture for assignment back into BABYLON.Texture
  117711. */
  117712. 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;
  117713. /**
  117714. * Creates a cube texture
  117715. * @param rootUrl defines the url where the files to load is located
  117716. * @param scene defines the current scene
  117717. * @param files defines the list of files to load (1 per face)
  117718. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  117719. * @param onLoad defines an optional callback raised when the texture is loaded
  117720. * @param onError defines an optional callback raised if there is an issue to load the texture
  117721. * @param format defines the format of the data
  117722. * @param forcedExtension defines the extension to use to pick the right loader
  117723. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  117724. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  117725. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  117726. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  117727. * @returns the cube texture as an InternalTexture
  117728. */
  117729. 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;
  117730. private _getSamplingFilter;
  117731. private static _GetNativeTextureFormat;
  117732. createRenderTargetTexture(size: number | {
  117733. width: number;
  117734. height: number;
  117735. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  117736. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  117737. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  117738. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  117739. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  117740. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  117741. /**
  117742. * Updates a dynamic vertex buffer.
  117743. * @param vertexBuffer the vertex buffer to update
  117744. * @param data the data used to update the vertex buffer
  117745. * @param byteOffset the byte offset of the data (optional)
  117746. * @param byteLength the byte length of the data (optional)
  117747. */
  117748. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  117749. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  117750. private _updateAnisotropicLevel;
  117751. private _getAddressMode;
  117752. /** @hidden */
  117753. _bindTexture(channel: number, texture: InternalTexture): void;
  117754. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  117755. releaseEffects(): void;
  117756. /** @hidden */
  117757. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  117758. /** @hidden */
  117759. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  117760. /** @hidden */
  117761. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  117762. /** @hidden */
  117763. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  117764. }
  117765. }
  117766. declare module BABYLON {
  117767. /**
  117768. * Gather the list of clipboard event types as constants.
  117769. */
  117770. export class ClipboardEventTypes {
  117771. /**
  117772. * The clipboard event is fired when a copy command is active (pressed).
  117773. */
  117774. static readonly COPY: number;
  117775. /**
  117776. * The clipboard event is fired when a cut command is active (pressed).
  117777. */
  117778. static readonly CUT: number;
  117779. /**
  117780. * The clipboard event is fired when a paste command is active (pressed).
  117781. */
  117782. static readonly PASTE: number;
  117783. }
  117784. /**
  117785. * This class is used to store clipboard related info for the onClipboardObservable event.
  117786. */
  117787. export class ClipboardInfo {
  117788. /**
  117789. * Defines the type of event (BABYLON.ClipboardEventTypes)
  117790. */
  117791. type: number;
  117792. /**
  117793. * Defines the related dom event
  117794. */
  117795. event: ClipboardEvent;
  117796. /**
  117797. *Creates an instance of ClipboardInfo.
  117798. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  117799. * @param event Defines the related dom event
  117800. */
  117801. constructor(
  117802. /**
  117803. * Defines the type of event (BABYLON.ClipboardEventTypes)
  117804. */
  117805. type: number,
  117806. /**
  117807. * Defines the related dom event
  117808. */
  117809. event: ClipboardEvent);
  117810. /**
  117811. * Get the clipboard event's type from the keycode.
  117812. * @param keyCode Defines the keyCode for the current keyboard event.
  117813. * @return {number}
  117814. */
  117815. static GetTypeFromCharacter(keyCode: number): number;
  117816. }
  117817. }
  117818. declare module BABYLON {
  117819. /**
  117820. * Google Daydream controller
  117821. */
  117822. export class DaydreamController extends WebVRController {
  117823. /**
  117824. * Base Url for the controller model.
  117825. */
  117826. static MODEL_BASE_URL: string;
  117827. /**
  117828. * File name for the controller model.
  117829. */
  117830. static MODEL_FILENAME: string;
  117831. /**
  117832. * Gamepad Id prefix used to identify Daydream Controller.
  117833. */
  117834. static readonly GAMEPAD_ID_PREFIX: string;
  117835. /**
  117836. * Creates a new DaydreamController from a gamepad
  117837. * @param vrGamepad the gamepad that the controller should be created from
  117838. */
  117839. constructor(vrGamepad: any);
  117840. /**
  117841. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  117842. * @param scene scene in which to add meshes
  117843. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  117844. */
  117845. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  117846. /**
  117847. * Called once for each button that changed state since the last frame
  117848. * @param buttonIdx Which button index changed
  117849. * @param state New state of the button
  117850. * @param changes Which properties on the state changed since last frame
  117851. */
  117852. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  117853. }
  117854. }
  117855. declare module BABYLON {
  117856. /**
  117857. * Gear VR Controller
  117858. */
  117859. export class GearVRController extends WebVRController {
  117860. /**
  117861. * Base Url for the controller model.
  117862. */
  117863. static MODEL_BASE_URL: string;
  117864. /**
  117865. * File name for the controller model.
  117866. */
  117867. static MODEL_FILENAME: string;
  117868. /**
  117869. * Gamepad Id prefix used to identify this controller.
  117870. */
  117871. static readonly GAMEPAD_ID_PREFIX: string;
  117872. private readonly _buttonIndexToObservableNameMap;
  117873. /**
  117874. * Creates a new GearVRController from a gamepad
  117875. * @param vrGamepad the gamepad that the controller should be created from
  117876. */
  117877. constructor(vrGamepad: any);
  117878. /**
  117879. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  117880. * @param scene scene in which to add meshes
  117881. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  117882. */
  117883. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  117884. /**
  117885. * Called once for each button that changed state since the last frame
  117886. * @param buttonIdx Which button index changed
  117887. * @param state New state of the button
  117888. * @param changes Which properties on the state changed since last frame
  117889. */
  117890. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  117891. }
  117892. }
  117893. declare module BABYLON {
  117894. /**
  117895. * Class containing static functions to help procedurally build meshes
  117896. */
  117897. export class PolyhedronBuilder {
  117898. /**
  117899. * Creates a polyhedron mesh
  117900. * * 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
  117901. * * The parameter `size` (positive float, default 1) sets the polygon size
  117902. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  117903. * * 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`
  117904. * * 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
  117905. * * 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)`)
  117906. * * 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
  117907. * * 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
  117908. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117909. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117911. * @param name defines the name of the mesh
  117912. * @param options defines the options used to create the mesh
  117913. * @param scene defines the hosting scene
  117914. * @returns the polyhedron mesh
  117915. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  117916. */
  117917. static CreatePolyhedron(name: string, options: {
  117918. type?: number;
  117919. size?: number;
  117920. sizeX?: number;
  117921. sizeY?: number;
  117922. sizeZ?: number;
  117923. custom?: any;
  117924. faceUV?: Vector4[];
  117925. faceColors?: Color4[];
  117926. flat?: boolean;
  117927. updatable?: boolean;
  117928. sideOrientation?: number;
  117929. frontUVs?: Vector4;
  117930. backUVs?: Vector4;
  117931. }, scene?: Nullable<Scene>): Mesh;
  117932. }
  117933. }
  117934. declare module BABYLON {
  117935. /**
  117936. * Gizmo that enables scaling a mesh along 3 axis
  117937. */
  117938. export class ScaleGizmo extends Gizmo {
  117939. /**
  117940. * Internal gizmo used for interactions on the x axis
  117941. */
  117942. xGizmo: AxisScaleGizmo;
  117943. /**
  117944. * Internal gizmo used for interactions on the y axis
  117945. */
  117946. yGizmo: AxisScaleGizmo;
  117947. /**
  117948. * Internal gizmo used for interactions on the z axis
  117949. */
  117950. zGizmo: AxisScaleGizmo;
  117951. /**
  117952. * Internal gizmo used to scale all axis equally
  117953. */
  117954. uniformScaleGizmo: AxisScaleGizmo;
  117955. private _meshAttached;
  117956. private _updateGizmoRotationToMatchAttachedMesh;
  117957. private _snapDistance;
  117958. private _scaleRatio;
  117959. private _uniformScalingMesh;
  117960. private _octahedron;
  117961. private _sensitivity;
  117962. /** Fires an event when any of it's sub gizmos are dragged */
  117963. onDragStartObservable: Observable<unknown>;
  117964. /** Fires an event when any of it's sub gizmos are released from dragging */
  117965. onDragEndObservable: Observable<unknown>;
  117966. get attachedMesh(): Nullable<AbstractMesh>;
  117967. set attachedMesh(mesh: Nullable<AbstractMesh>);
  117968. /**
  117969. * Creates a ScaleGizmo
  117970. * @param gizmoLayer The utility layer the gizmo will be added to
  117971. */
  117972. constructor(gizmoLayer?: UtilityLayerRenderer);
  117973. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  117974. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  117975. /**
  117976. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  117977. */
  117978. set snapDistance(value: number);
  117979. get snapDistance(): number;
  117980. /**
  117981. * Ratio for the scale of the gizmo (Default: 1)
  117982. */
  117983. set scaleRatio(value: number);
  117984. get scaleRatio(): number;
  117985. /**
  117986. * Sensitivity factor for dragging (Default: 1)
  117987. */
  117988. set sensitivity(value: number);
  117989. get sensitivity(): number;
  117990. /**
  117991. * Disposes of the gizmo
  117992. */
  117993. dispose(): void;
  117994. }
  117995. }
  117996. declare module BABYLON {
  117997. /**
  117998. * Single axis scale gizmo
  117999. */
  118000. export class AxisScaleGizmo extends Gizmo {
  118001. /**
  118002. * Drag behavior responsible for the gizmos dragging interactions
  118003. */
  118004. dragBehavior: PointerDragBehavior;
  118005. private _pointerObserver;
  118006. /**
  118007. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118008. */
  118009. snapDistance: number;
  118010. /**
  118011. * Event that fires each time the gizmo snaps to a new location.
  118012. * * snapDistance is the the change in distance
  118013. */
  118014. onSnapObservable: Observable<{
  118015. snapDistance: number;
  118016. }>;
  118017. /**
  118018. * If the scaling operation should be done on all axis (default: false)
  118019. */
  118020. uniformScaling: boolean;
  118021. /**
  118022. * Custom sensitivity value for the drag strength
  118023. */
  118024. sensitivity: number;
  118025. private _isEnabled;
  118026. private _parent;
  118027. private _arrow;
  118028. private _coloredMaterial;
  118029. private _hoverMaterial;
  118030. /**
  118031. * Creates an AxisScaleGizmo
  118032. * @param gizmoLayer The utility layer the gizmo will be added to
  118033. * @param dragAxis The axis which the gizmo will be able to scale on
  118034. * @param color The color of the gizmo
  118035. */
  118036. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  118037. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118038. /**
  118039. * If the gizmo is enabled
  118040. */
  118041. set isEnabled(value: boolean);
  118042. get isEnabled(): boolean;
  118043. /**
  118044. * Disposes of the gizmo
  118045. */
  118046. dispose(): void;
  118047. /**
  118048. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  118049. * @param mesh The mesh to replace the default mesh of the gizmo
  118050. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  118051. */
  118052. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  118053. }
  118054. }
  118055. declare module BABYLON {
  118056. /**
  118057. * Bounding box gizmo
  118058. */
  118059. export class BoundingBoxGizmo extends Gizmo {
  118060. private _lineBoundingBox;
  118061. private _rotateSpheresParent;
  118062. private _scaleBoxesParent;
  118063. private _boundingDimensions;
  118064. private _renderObserver;
  118065. private _pointerObserver;
  118066. private _scaleDragSpeed;
  118067. private _tmpQuaternion;
  118068. private _tmpVector;
  118069. private _tmpRotationMatrix;
  118070. /**
  118071. * 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)
  118072. */
  118073. ignoreChildren: boolean;
  118074. /**
  118075. * 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)
  118076. */
  118077. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  118078. /**
  118079. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  118080. */
  118081. rotationSphereSize: number;
  118082. /**
  118083. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  118084. */
  118085. scaleBoxSize: number;
  118086. /**
  118087. * 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)
  118088. */
  118089. fixedDragMeshScreenSize: boolean;
  118090. /**
  118091. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  118092. */
  118093. fixedDragMeshScreenSizeDistanceFactor: number;
  118094. /**
  118095. * Fired when a rotation sphere or scale box is dragged
  118096. */
  118097. onDragStartObservable: Observable<{}>;
  118098. /**
  118099. * Fired when a scale box is dragged
  118100. */
  118101. onScaleBoxDragObservable: Observable<{}>;
  118102. /**
  118103. * Fired when a scale box drag is ended
  118104. */
  118105. onScaleBoxDragEndObservable: Observable<{}>;
  118106. /**
  118107. * Fired when a rotation sphere is dragged
  118108. */
  118109. onRotationSphereDragObservable: Observable<{}>;
  118110. /**
  118111. * Fired when a rotation sphere drag is ended
  118112. */
  118113. onRotationSphereDragEndObservable: Observable<{}>;
  118114. /**
  118115. * 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)
  118116. */
  118117. scalePivot: Nullable<Vector3>;
  118118. /**
  118119. * Mesh used as a pivot to rotate the attached mesh
  118120. */
  118121. private _anchorMesh;
  118122. private _existingMeshScale;
  118123. private _dragMesh;
  118124. private pointerDragBehavior;
  118125. private coloredMaterial;
  118126. private hoverColoredMaterial;
  118127. /**
  118128. * Sets the color of the bounding box gizmo
  118129. * @param color the color to set
  118130. */
  118131. setColor(color: Color3): void;
  118132. /**
  118133. * Creates an BoundingBoxGizmo
  118134. * @param gizmoLayer The utility layer the gizmo will be added to
  118135. * @param color The color of the gizmo
  118136. */
  118137. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  118138. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118139. private _selectNode;
  118140. /**
  118141. * Updates the bounding box information for the Gizmo
  118142. */
  118143. updateBoundingBox(): void;
  118144. private _updateRotationSpheres;
  118145. private _updateScaleBoxes;
  118146. /**
  118147. * Enables rotation on the specified axis and disables rotation on the others
  118148. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  118149. */
  118150. setEnabledRotationAxis(axis: string): void;
  118151. /**
  118152. * Enables/disables scaling
  118153. * @param enable if scaling should be enabled
  118154. */
  118155. setEnabledScaling(enable: boolean): void;
  118156. private _updateDummy;
  118157. /**
  118158. * Enables a pointer drag behavior on the bounding box of the gizmo
  118159. */
  118160. enableDragBehavior(): void;
  118161. /**
  118162. * Disposes of the gizmo
  118163. */
  118164. dispose(): void;
  118165. /**
  118166. * 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)
  118167. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  118168. * @returns the bounding box mesh with the passed in mesh as a child
  118169. */
  118170. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  118171. /**
  118172. * CustomMeshes are not supported by this gizmo
  118173. * @param mesh The mesh to replace the default mesh of the gizmo
  118174. */
  118175. setCustomMesh(mesh: Mesh): void;
  118176. }
  118177. }
  118178. declare module BABYLON {
  118179. /**
  118180. * Single plane rotation gizmo
  118181. */
  118182. export class PlaneRotationGizmo extends Gizmo {
  118183. /**
  118184. * Drag behavior responsible for the gizmos dragging interactions
  118185. */
  118186. dragBehavior: PointerDragBehavior;
  118187. private _pointerObserver;
  118188. /**
  118189. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  118190. */
  118191. snapDistance: number;
  118192. /**
  118193. * Event that fires each time the gizmo snaps to a new location.
  118194. * * snapDistance is the the change in distance
  118195. */
  118196. onSnapObservable: Observable<{
  118197. snapDistance: number;
  118198. }>;
  118199. private _isEnabled;
  118200. private _parent;
  118201. /**
  118202. * Creates a PlaneRotationGizmo
  118203. * @param gizmoLayer The utility layer the gizmo will be added to
  118204. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  118205. * @param color The color of the gizmo
  118206. * @param tessellation Amount of tessellation to be used when creating rotation circles
  118207. * @param useEulerRotation Use and update Euler angle instead of quaternion
  118208. */
  118209. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  118210. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118211. /**
  118212. * If the gizmo is enabled
  118213. */
  118214. set isEnabled(value: boolean);
  118215. get isEnabled(): boolean;
  118216. /**
  118217. * Disposes of the gizmo
  118218. */
  118219. dispose(): void;
  118220. }
  118221. }
  118222. declare module BABYLON {
  118223. /**
  118224. * Gizmo that enables rotating a mesh along 3 axis
  118225. */
  118226. export class RotationGizmo extends Gizmo {
  118227. /**
  118228. * Internal gizmo used for interactions on the x axis
  118229. */
  118230. xGizmo: PlaneRotationGizmo;
  118231. /**
  118232. * Internal gizmo used for interactions on the y axis
  118233. */
  118234. yGizmo: PlaneRotationGizmo;
  118235. /**
  118236. * Internal gizmo used for interactions on the z axis
  118237. */
  118238. zGizmo: PlaneRotationGizmo;
  118239. /** Fires an event when any of it's sub gizmos are dragged */
  118240. onDragStartObservable: Observable<unknown>;
  118241. /** Fires an event when any of it's sub gizmos are released from dragging */
  118242. onDragEndObservable: Observable<unknown>;
  118243. private _meshAttached;
  118244. get attachedMesh(): Nullable<AbstractMesh>;
  118245. set attachedMesh(mesh: Nullable<AbstractMesh>);
  118246. /**
  118247. * Creates a RotationGizmo
  118248. * @param gizmoLayer The utility layer the gizmo will be added to
  118249. * @param tessellation Amount of tessellation to be used when creating rotation circles
  118250. * @param useEulerRotation Use and update Euler angle instead of quaternion
  118251. */
  118252. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  118253. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  118254. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  118255. /**
  118256. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118257. */
  118258. set snapDistance(value: number);
  118259. get snapDistance(): number;
  118260. /**
  118261. * Ratio for the scale of the gizmo (Default: 1)
  118262. */
  118263. set scaleRatio(value: number);
  118264. get scaleRatio(): number;
  118265. /**
  118266. * Disposes of the gizmo
  118267. */
  118268. dispose(): void;
  118269. /**
  118270. * CustomMeshes are not supported by this gizmo
  118271. * @param mesh The mesh to replace the default mesh of the gizmo
  118272. */
  118273. setCustomMesh(mesh: Mesh): void;
  118274. }
  118275. }
  118276. declare module BABYLON {
  118277. /**
  118278. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  118279. */
  118280. export class GizmoManager implements IDisposable {
  118281. private scene;
  118282. /**
  118283. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  118284. */
  118285. gizmos: {
  118286. positionGizmo: Nullable<PositionGizmo>;
  118287. rotationGizmo: Nullable<RotationGizmo>;
  118288. scaleGizmo: Nullable<ScaleGizmo>;
  118289. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  118290. };
  118291. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  118292. clearGizmoOnEmptyPointerEvent: boolean;
  118293. /** Fires an event when the manager is attached to a mesh */
  118294. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  118295. private _gizmosEnabled;
  118296. private _pointerObserver;
  118297. private _attachedMesh;
  118298. private _boundingBoxColor;
  118299. private _defaultUtilityLayer;
  118300. private _defaultKeepDepthUtilityLayer;
  118301. /**
  118302. * When bounding box gizmo is enabled, this can be used to track drag/end events
  118303. */
  118304. boundingBoxDragBehavior: SixDofDragBehavior;
  118305. /**
  118306. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  118307. */
  118308. attachableMeshes: Nullable<Array<AbstractMesh>>;
  118309. /**
  118310. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  118311. */
  118312. usePointerToAttachGizmos: boolean;
  118313. /**
  118314. * Utility layer that the bounding box gizmo belongs to
  118315. */
  118316. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  118317. /**
  118318. * Utility layer that all gizmos besides bounding box belong to
  118319. */
  118320. get utilityLayer(): UtilityLayerRenderer;
  118321. /**
  118322. * Instatiates a gizmo manager
  118323. * @param scene the scene to overlay the gizmos on top of
  118324. */
  118325. constructor(scene: Scene);
  118326. /**
  118327. * Attaches a set of gizmos to the specified mesh
  118328. * @param mesh The mesh the gizmo's should be attached to
  118329. */
  118330. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  118331. /**
  118332. * If the position gizmo is enabled
  118333. */
  118334. set positionGizmoEnabled(value: boolean);
  118335. get positionGizmoEnabled(): boolean;
  118336. /**
  118337. * If the rotation gizmo is enabled
  118338. */
  118339. set rotationGizmoEnabled(value: boolean);
  118340. get rotationGizmoEnabled(): boolean;
  118341. /**
  118342. * If the scale gizmo is enabled
  118343. */
  118344. set scaleGizmoEnabled(value: boolean);
  118345. get scaleGizmoEnabled(): boolean;
  118346. /**
  118347. * If the boundingBox gizmo is enabled
  118348. */
  118349. set boundingBoxGizmoEnabled(value: boolean);
  118350. get boundingBoxGizmoEnabled(): boolean;
  118351. /**
  118352. * Disposes of the gizmo manager
  118353. */
  118354. dispose(): void;
  118355. }
  118356. }
  118357. declare module BABYLON {
  118358. /**
  118359. * A directional light is defined by a direction (what a surprise!).
  118360. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  118361. * 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.
  118362. * Documentation: https://doc.babylonjs.com/babylon101/lights
  118363. */
  118364. export class DirectionalLight extends ShadowLight {
  118365. private _shadowFrustumSize;
  118366. /**
  118367. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  118368. */
  118369. get shadowFrustumSize(): number;
  118370. /**
  118371. * Specifies a fix frustum size for the shadow generation.
  118372. */
  118373. set shadowFrustumSize(value: number);
  118374. private _shadowOrthoScale;
  118375. /**
  118376. * Gets the shadow projection scale against the optimal computed one.
  118377. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  118378. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  118379. */
  118380. get shadowOrthoScale(): number;
  118381. /**
  118382. * Sets the shadow projection scale against the optimal computed one.
  118383. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  118384. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  118385. */
  118386. set shadowOrthoScale(value: number);
  118387. /**
  118388. * Automatically compute the projection matrix to best fit (including all the casters)
  118389. * on each frame.
  118390. */
  118391. autoUpdateExtends: boolean;
  118392. private _orthoLeft;
  118393. private _orthoRight;
  118394. private _orthoTop;
  118395. private _orthoBottom;
  118396. /**
  118397. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  118398. * The directional light is emitted from everywhere in the given direction.
  118399. * It can cast shadows.
  118400. * Documentation : https://doc.babylonjs.com/babylon101/lights
  118401. * @param name The friendly name of the light
  118402. * @param direction The direction of the light
  118403. * @param scene The scene the light belongs to
  118404. */
  118405. constructor(name: string, direction: Vector3, scene: Scene);
  118406. /**
  118407. * Returns the string "DirectionalLight".
  118408. * @return The class name
  118409. */
  118410. getClassName(): string;
  118411. /**
  118412. * Returns the integer 1.
  118413. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  118414. */
  118415. getTypeID(): number;
  118416. /**
  118417. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  118418. * Returns the DirectionalLight Shadow projection matrix.
  118419. */
  118420. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  118421. /**
  118422. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  118423. * Returns the DirectionalLight Shadow projection matrix.
  118424. */
  118425. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  118426. /**
  118427. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  118428. * Returns the DirectionalLight Shadow projection matrix.
  118429. */
  118430. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  118431. protected _buildUniformLayout(): void;
  118432. /**
  118433. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  118434. * @param effect The effect to update
  118435. * @param lightIndex The index of the light in the effect to update
  118436. * @returns The directional light
  118437. */
  118438. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  118439. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  118440. /**
  118441. * Gets the minZ used for shadow according to both the scene and the light.
  118442. *
  118443. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  118444. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  118445. * @param activeCamera The camera we are returning the min for
  118446. * @returns the depth min z
  118447. */
  118448. getDepthMinZ(activeCamera: Camera): number;
  118449. /**
  118450. * Gets the maxZ used for shadow according to both the scene and the light.
  118451. *
  118452. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  118453. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  118454. * @param activeCamera The camera we are returning the max for
  118455. * @returns the depth max z
  118456. */
  118457. getDepthMaxZ(activeCamera: Camera): number;
  118458. /**
  118459. * Prepares the list of defines specific to the light type.
  118460. * @param defines the list of defines
  118461. * @param lightIndex defines the index of the light for the effect
  118462. */
  118463. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  118464. }
  118465. }
  118466. declare module BABYLON {
  118467. /**
  118468. * Class containing static functions to help procedurally build meshes
  118469. */
  118470. export class HemisphereBuilder {
  118471. /**
  118472. * Creates a hemisphere mesh
  118473. * @param name defines the name of the mesh
  118474. * @param options defines the options used to create the mesh
  118475. * @param scene defines the hosting scene
  118476. * @returns the hemisphere mesh
  118477. */
  118478. static CreateHemisphere(name: string, options: {
  118479. segments?: number;
  118480. diameter?: number;
  118481. sideOrientation?: number;
  118482. }, scene: any): Mesh;
  118483. }
  118484. }
  118485. declare module BABYLON {
  118486. /**
  118487. * A spot light is defined by a position, a direction, an angle, and an exponent.
  118488. * These values define a cone of light starting from the position, emitting toward the direction.
  118489. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  118490. * and the exponent defines the speed of the decay of the light with distance (reach).
  118491. * Documentation: https://doc.babylonjs.com/babylon101/lights
  118492. */
  118493. export class SpotLight extends ShadowLight {
  118494. private _angle;
  118495. private _innerAngle;
  118496. private _cosHalfAngle;
  118497. private _lightAngleScale;
  118498. private _lightAngleOffset;
  118499. /**
  118500. * Gets the cone angle of the spot light in Radians.
  118501. */
  118502. get angle(): number;
  118503. /**
  118504. * Sets the cone angle of the spot light in Radians.
  118505. */
  118506. set angle(value: number);
  118507. /**
  118508. * Only used in gltf falloff mode, this defines the angle where
  118509. * the directional falloff will start before cutting at angle which could be seen
  118510. * as outer angle.
  118511. */
  118512. get innerAngle(): number;
  118513. /**
  118514. * Only used in gltf falloff mode, this defines the angle where
  118515. * the directional falloff will start before cutting at angle which could be seen
  118516. * as outer angle.
  118517. */
  118518. set innerAngle(value: number);
  118519. private _shadowAngleScale;
  118520. /**
  118521. * Allows scaling the angle of the light for shadow generation only.
  118522. */
  118523. get shadowAngleScale(): number;
  118524. /**
  118525. * Allows scaling the angle of the light for shadow generation only.
  118526. */
  118527. set shadowAngleScale(value: number);
  118528. /**
  118529. * The light decay speed with the distance from the emission spot.
  118530. */
  118531. exponent: number;
  118532. private _projectionTextureMatrix;
  118533. /**
  118534. * Allows reading the projecton texture
  118535. */
  118536. get projectionTextureMatrix(): Matrix;
  118537. protected _projectionTextureLightNear: number;
  118538. /**
  118539. * Gets the near clip of the Spotlight for texture projection.
  118540. */
  118541. get projectionTextureLightNear(): number;
  118542. /**
  118543. * Sets the near clip of the Spotlight for texture projection.
  118544. */
  118545. set projectionTextureLightNear(value: number);
  118546. protected _projectionTextureLightFar: number;
  118547. /**
  118548. * Gets the far clip of the Spotlight for texture projection.
  118549. */
  118550. get projectionTextureLightFar(): number;
  118551. /**
  118552. * Sets the far clip of the Spotlight for texture projection.
  118553. */
  118554. set projectionTextureLightFar(value: number);
  118555. protected _projectionTextureUpDirection: Vector3;
  118556. /**
  118557. * Gets the Up vector of the Spotlight for texture projection.
  118558. */
  118559. get projectionTextureUpDirection(): Vector3;
  118560. /**
  118561. * Sets the Up vector of the Spotlight for texture projection.
  118562. */
  118563. set projectionTextureUpDirection(value: Vector3);
  118564. private _projectionTexture;
  118565. /**
  118566. * Gets the projection texture of the light.
  118567. */
  118568. get projectionTexture(): Nullable<BaseTexture>;
  118569. /**
  118570. * Sets the projection texture of the light.
  118571. */
  118572. set projectionTexture(value: Nullable<BaseTexture>);
  118573. private _projectionTextureViewLightDirty;
  118574. private _projectionTextureProjectionLightDirty;
  118575. private _projectionTextureDirty;
  118576. private _projectionTextureViewTargetVector;
  118577. private _projectionTextureViewLightMatrix;
  118578. private _projectionTextureProjectionLightMatrix;
  118579. private _projectionTextureScalingMatrix;
  118580. /**
  118581. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  118582. * It can cast shadows.
  118583. * Documentation : https://doc.babylonjs.com/babylon101/lights
  118584. * @param name The light friendly name
  118585. * @param position The position of the spot light in the scene
  118586. * @param direction The direction of the light in the scene
  118587. * @param angle The cone angle of the light in Radians
  118588. * @param exponent The light decay speed with the distance from the emission spot
  118589. * @param scene The scene the lights belongs to
  118590. */
  118591. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  118592. /**
  118593. * Returns the string "SpotLight".
  118594. * @returns the class name
  118595. */
  118596. getClassName(): string;
  118597. /**
  118598. * Returns the integer 2.
  118599. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  118600. */
  118601. getTypeID(): number;
  118602. /**
  118603. * Overrides the direction setter to recompute the projection texture view light Matrix.
  118604. */
  118605. protected _setDirection(value: Vector3): void;
  118606. /**
  118607. * Overrides the position setter to recompute the projection texture view light Matrix.
  118608. */
  118609. protected _setPosition(value: Vector3): void;
  118610. /**
  118611. * 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.
  118612. * Returns the SpotLight.
  118613. */
  118614. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  118615. protected _computeProjectionTextureViewLightMatrix(): void;
  118616. protected _computeProjectionTextureProjectionLightMatrix(): void;
  118617. /**
  118618. * Main function for light texture projection matrix computing.
  118619. */
  118620. protected _computeProjectionTextureMatrix(): void;
  118621. protected _buildUniformLayout(): void;
  118622. private _computeAngleValues;
  118623. /**
  118624. * Sets the passed Effect "effect" with the Light textures.
  118625. * @param effect The effect to update
  118626. * @param lightIndex The index of the light in the effect to update
  118627. * @returns The light
  118628. */
  118629. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  118630. /**
  118631. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  118632. * @param effect The effect to update
  118633. * @param lightIndex The index of the light in the effect to update
  118634. * @returns The spot light
  118635. */
  118636. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  118637. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  118638. /**
  118639. * Disposes the light and the associated resources.
  118640. */
  118641. dispose(): void;
  118642. /**
  118643. * Prepares the list of defines specific to the light type.
  118644. * @param defines the list of defines
  118645. * @param lightIndex defines the index of the light for the effect
  118646. */
  118647. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  118648. }
  118649. }
  118650. declare module BABYLON {
  118651. /**
  118652. * Gizmo that enables viewing a light
  118653. */
  118654. export class LightGizmo extends Gizmo {
  118655. private _lightMesh;
  118656. private _material;
  118657. private _cachedPosition;
  118658. private _cachedForward;
  118659. private _attachedMeshParent;
  118660. /**
  118661. * Creates a LightGizmo
  118662. * @param gizmoLayer The utility layer the gizmo will be added to
  118663. */
  118664. constructor(gizmoLayer?: UtilityLayerRenderer);
  118665. private _light;
  118666. /**
  118667. * The light that the gizmo is attached to
  118668. */
  118669. set light(light: Nullable<Light>);
  118670. get light(): Nullable<Light>;
  118671. /**
  118672. * Gets the material used to render the light gizmo
  118673. */
  118674. get material(): StandardMaterial;
  118675. /**
  118676. * @hidden
  118677. * Updates the gizmo to match the attached mesh's position/rotation
  118678. */
  118679. protected _update(): void;
  118680. private static _Scale;
  118681. /**
  118682. * Creates the lines for a light mesh
  118683. */
  118684. private static _CreateLightLines;
  118685. /**
  118686. * Disposes of the light gizmo
  118687. */
  118688. dispose(): void;
  118689. private static _CreateHemisphericLightMesh;
  118690. private static _CreatePointLightMesh;
  118691. private static _CreateSpotLightMesh;
  118692. private static _CreateDirectionalLightMesh;
  118693. }
  118694. }
  118695. declare module BABYLON {
  118696. /** @hidden */
  118697. export var backgroundFragmentDeclaration: {
  118698. name: string;
  118699. shader: string;
  118700. };
  118701. }
  118702. declare module BABYLON {
  118703. /** @hidden */
  118704. export var backgroundUboDeclaration: {
  118705. name: string;
  118706. shader: string;
  118707. };
  118708. }
  118709. declare module BABYLON {
  118710. /** @hidden */
  118711. export var backgroundPixelShader: {
  118712. name: string;
  118713. shader: string;
  118714. };
  118715. }
  118716. declare module BABYLON {
  118717. /** @hidden */
  118718. export var backgroundVertexDeclaration: {
  118719. name: string;
  118720. shader: string;
  118721. };
  118722. }
  118723. declare module BABYLON {
  118724. /** @hidden */
  118725. export var backgroundVertexShader: {
  118726. name: string;
  118727. shader: string;
  118728. };
  118729. }
  118730. declare module BABYLON {
  118731. /**
  118732. * Background material used to create an efficient environement around your scene.
  118733. */
  118734. export class BackgroundMaterial extends PushMaterial {
  118735. /**
  118736. * Standard reflectance value at parallel view angle.
  118737. */
  118738. static StandardReflectance0: number;
  118739. /**
  118740. * Standard reflectance value at grazing angle.
  118741. */
  118742. static StandardReflectance90: number;
  118743. protected _primaryColor: Color3;
  118744. /**
  118745. * Key light Color (multiply against the environement texture)
  118746. */
  118747. primaryColor: Color3;
  118748. protected __perceptualColor: Nullable<Color3>;
  118749. /**
  118750. * Experimental Internal Use Only.
  118751. *
  118752. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  118753. * This acts as a helper to set the primary color to a more "human friendly" value.
  118754. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  118755. * output color as close as possible from the chosen value.
  118756. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  118757. * part of lighting setup.)
  118758. */
  118759. get _perceptualColor(): Nullable<Color3>;
  118760. set _perceptualColor(value: Nullable<Color3>);
  118761. protected _primaryColorShadowLevel: float;
  118762. /**
  118763. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  118764. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  118765. */
  118766. get primaryColorShadowLevel(): float;
  118767. set primaryColorShadowLevel(value: float);
  118768. protected _primaryColorHighlightLevel: float;
  118769. /**
  118770. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  118771. * The primary color is used at the level chosen to define what the white area would look.
  118772. */
  118773. get primaryColorHighlightLevel(): float;
  118774. set primaryColorHighlightLevel(value: float);
  118775. protected _reflectionTexture: Nullable<BaseTexture>;
  118776. /**
  118777. * Reflection Texture used in the material.
  118778. * Should be author in a specific way for the best result (refer to the documentation).
  118779. */
  118780. reflectionTexture: Nullable<BaseTexture>;
  118781. protected _reflectionBlur: float;
  118782. /**
  118783. * Reflection Texture level of blur.
  118784. *
  118785. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  118786. * texture twice.
  118787. */
  118788. reflectionBlur: float;
  118789. protected _diffuseTexture: Nullable<BaseTexture>;
  118790. /**
  118791. * Diffuse Texture used in the material.
  118792. * Should be author in a specific way for the best result (refer to the documentation).
  118793. */
  118794. diffuseTexture: Nullable<BaseTexture>;
  118795. protected _shadowLights: Nullable<IShadowLight[]>;
  118796. /**
  118797. * Specify the list of lights casting shadow on the material.
  118798. * All scene shadow lights will be included if null.
  118799. */
  118800. shadowLights: Nullable<IShadowLight[]>;
  118801. protected _shadowLevel: float;
  118802. /**
  118803. * Helps adjusting the shadow to a softer level if required.
  118804. * 0 means black shadows and 1 means no shadows.
  118805. */
  118806. shadowLevel: float;
  118807. protected _sceneCenter: Vector3;
  118808. /**
  118809. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  118810. * It is usually zero but might be interesting to modify according to your setup.
  118811. */
  118812. sceneCenter: Vector3;
  118813. protected _opacityFresnel: boolean;
  118814. /**
  118815. * This helps specifying that the material is falling off to the sky box at grazing angle.
  118816. * This helps ensuring a nice transition when the camera goes under the ground.
  118817. */
  118818. opacityFresnel: boolean;
  118819. protected _reflectionFresnel: boolean;
  118820. /**
  118821. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  118822. * This helps adding a mirror texture on the ground.
  118823. */
  118824. reflectionFresnel: boolean;
  118825. protected _reflectionFalloffDistance: number;
  118826. /**
  118827. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  118828. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  118829. */
  118830. reflectionFalloffDistance: number;
  118831. protected _reflectionAmount: number;
  118832. /**
  118833. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  118834. */
  118835. reflectionAmount: number;
  118836. protected _reflectionReflectance0: number;
  118837. /**
  118838. * This specifies the weight of the reflection at grazing angle.
  118839. */
  118840. reflectionReflectance0: number;
  118841. protected _reflectionReflectance90: number;
  118842. /**
  118843. * This specifies the weight of the reflection at a perpendicular point of view.
  118844. */
  118845. reflectionReflectance90: number;
  118846. /**
  118847. * Sets the reflection reflectance fresnel values according to the default standard
  118848. * empirically know to work well :-)
  118849. */
  118850. set reflectionStandardFresnelWeight(value: number);
  118851. protected _useRGBColor: boolean;
  118852. /**
  118853. * Helps to directly use the maps channels instead of their level.
  118854. */
  118855. useRGBColor: boolean;
  118856. protected _enableNoise: boolean;
  118857. /**
  118858. * This helps reducing the banding effect that could occur on the background.
  118859. */
  118860. enableNoise: boolean;
  118861. /**
  118862. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  118863. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  118864. * Recommended to be keep at 1.0 except for special cases.
  118865. */
  118866. get fovMultiplier(): number;
  118867. set fovMultiplier(value: number);
  118868. private _fovMultiplier;
  118869. /**
  118870. * Enable the FOV adjustment feature controlled by fovMultiplier.
  118871. */
  118872. useEquirectangularFOV: boolean;
  118873. private _maxSimultaneousLights;
  118874. /**
  118875. * Number of Simultaneous lights allowed on the material.
  118876. */
  118877. maxSimultaneousLights: int;
  118878. /**
  118879. * Default configuration related to image processing available in the Background Material.
  118880. */
  118881. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118882. /**
  118883. * Keep track of the image processing observer to allow dispose and replace.
  118884. */
  118885. private _imageProcessingObserver;
  118886. /**
  118887. * Attaches a new image processing configuration to the PBR Material.
  118888. * @param configuration (if null the scene configuration will be use)
  118889. */
  118890. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  118891. /**
  118892. * Gets the image processing configuration used either in this material.
  118893. */
  118894. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  118895. /**
  118896. * Sets the Default image processing configuration used either in the this material.
  118897. *
  118898. * If sets to null, the scene one is in use.
  118899. */
  118900. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  118901. /**
  118902. * Gets wether the color curves effect is enabled.
  118903. */
  118904. get cameraColorCurvesEnabled(): boolean;
  118905. /**
  118906. * Sets wether the color curves effect is enabled.
  118907. */
  118908. set cameraColorCurvesEnabled(value: boolean);
  118909. /**
  118910. * Gets wether the color grading effect is enabled.
  118911. */
  118912. get cameraColorGradingEnabled(): boolean;
  118913. /**
  118914. * Gets wether the color grading effect is enabled.
  118915. */
  118916. set cameraColorGradingEnabled(value: boolean);
  118917. /**
  118918. * Gets wether tonemapping is enabled or not.
  118919. */
  118920. get cameraToneMappingEnabled(): boolean;
  118921. /**
  118922. * Sets wether tonemapping is enabled or not
  118923. */
  118924. set cameraToneMappingEnabled(value: boolean);
  118925. /**
  118926. * The camera exposure used on this material.
  118927. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  118928. * This corresponds to a photographic exposure.
  118929. */
  118930. get cameraExposure(): float;
  118931. /**
  118932. * The camera exposure used on this material.
  118933. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  118934. * This corresponds to a photographic exposure.
  118935. */
  118936. set cameraExposure(value: float);
  118937. /**
  118938. * Gets The camera contrast used on this material.
  118939. */
  118940. get cameraContrast(): float;
  118941. /**
  118942. * Sets The camera contrast used on this material.
  118943. */
  118944. set cameraContrast(value: float);
  118945. /**
  118946. * Gets the Color Grading 2D Lookup Texture.
  118947. */
  118948. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  118949. /**
  118950. * Sets the Color Grading 2D Lookup Texture.
  118951. */
  118952. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  118953. /**
  118954. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  118955. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  118956. * 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;
  118957. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  118958. */
  118959. get cameraColorCurves(): Nullable<ColorCurves>;
  118960. /**
  118961. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  118962. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  118963. * 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;
  118964. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  118965. */
  118966. set cameraColorCurves(value: Nullable<ColorCurves>);
  118967. /**
  118968. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  118969. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  118970. */
  118971. switchToBGR: boolean;
  118972. private _renderTargets;
  118973. private _reflectionControls;
  118974. private _white;
  118975. private _primaryShadowColor;
  118976. private _primaryHighlightColor;
  118977. /**
  118978. * Instantiates a Background Material in the given scene
  118979. * @param name The friendly name of the material
  118980. * @param scene The scene to add the material to
  118981. */
  118982. constructor(name: string, scene: Scene);
  118983. /**
  118984. * Gets a boolean indicating that current material needs to register RTT
  118985. */
  118986. get hasRenderTargetTextures(): boolean;
  118987. /**
  118988. * The entire material has been created in order to prevent overdraw.
  118989. * @returns false
  118990. */
  118991. needAlphaTesting(): boolean;
  118992. /**
  118993. * The entire material has been created in order to prevent overdraw.
  118994. * @returns true if blending is enable
  118995. */
  118996. needAlphaBlending(): boolean;
  118997. /**
  118998. * Checks wether the material is ready to be rendered for a given mesh.
  118999. * @param mesh The mesh to render
  119000. * @param subMesh The submesh to check against
  119001. * @param useInstances Specify wether or not the material is used with instances
  119002. * @returns true if all the dependencies are ready (Textures, Effects...)
  119003. */
  119004. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  119005. /**
  119006. * Compute the primary color according to the chosen perceptual color.
  119007. */
  119008. private _computePrimaryColorFromPerceptualColor;
  119009. /**
  119010. * Compute the highlights and shadow colors according to their chosen levels.
  119011. */
  119012. private _computePrimaryColors;
  119013. /**
  119014. * Build the uniform buffer used in the material.
  119015. */
  119016. buildUniformLayout(): void;
  119017. /**
  119018. * Unbind the material.
  119019. */
  119020. unbind(): void;
  119021. /**
  119022. * Bind only the world matrix to the material.
  119023. * @param world The world matrix to bind.
  119024. */
  119025. bindOnlyWorldMatrix(world: Matrix): void;
  119026. /**
  119027. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  119028. * @param world The world matrix to bind.
  119029. * @param subMesh The submesh to bind for.
  119030. */
  119031. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  119032. /**
  119033. * Checks to see if a texture is used in the material.
  119034. * @param texture - Base texture to use.
  119035. * @returns - Boolean specifying if a texture is used in the material.
  119036. */
  119037. hasTexture(texture: BaseTexture): boolean;
  119038. /**
  119039. * Dispose the material.
  119040. * @param forceDisposeEffect Force disposal of the associated effect.
  119041. * @param forceDisposeTextures Force disposal of the associated textures.
  119042. */
  119043. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  119044. /**
  119045. * Clones the material.
  119046. * @param name The cloned name.
  119047. * @returns The cloned material.
  119048. */
  119049. clone(name: string): BackgroundMaterial;
  119050. /**
  119051. * Serializes the current material to its JSON representation.
  119052. * @returns The JSON representation.
  119053. */
  119054. serialize(): any;
  119055. /**
  119056. * Gets the class name of the material
  119057. * @returns "BackgroundMaterial"
  119058. */
  119059. getClassName(): string;
  119060. /**
  119061. * Parse a JSON input to create back a background material.
  119062. * @param source The JSON data to parse
  119063. * @param scene The scene to create the parsed material in
  119064. * @param rootUrl The root url of the assets the material depends upon
  119065. * @returns the instantiated BackgroundMaterial.
  119066. */
  119067. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  119068. }
  119069. }
  119070. declare module BABYLON {
  119071. /**
  119072. * Represents the different options available during the creation of
  119073. * a Environment helper.
  119074. *
  119075. * This can control the default ground, skybox and image processing setup of your scene.
  119076. */
  119077. export interface IEnvironmentHelperOptions {
  119078. /**
  119079. * Specifies wether or not to create a ground.
  119080. * True by default.
  119081. */
  119082. createGround: boolean;
  119083. /**
  119084. * Specifies the ground size.
  119085. * 15 by default.
  119086. */
  119087. groundSize: number;
  119088. /**
  119089. * The texture used on the ground for the main color.
  119090. * Comes from the BabylonJS CDN by default.
  119091. *
  119092. * Remarks: Can be either a texture or a url.
  119093. */
  119094. groundTexture: string | BaseTexture;
  119095. /**
  119096. * The color mixed in the ground texture by default.
  119097. * BabylonJS clearColor by default.
  119098. */
  119099. groundColor: Color3;
  119100. /**
  119101. * Specifies the ground opacity.
  119102. * 1 by default.
  119103. */
  119104. groundOpacity: number;
  119105. /**
  119106. * Enables the ground to receive shadows.
  119107. * True by default.
  119108. */
  119109. enableGroundShadow: boolean;
  119110. /**
  119111. * Helps preventing the shadow to be fully black on the ground.
  119112. * 0.5 by default.
  119113. */
  119114. groundShadowLevel: number;
  119115. /**
  119116. * Creates a mirror texture attach to the ground.
  119117. * false by default.
  119118. */
  119119. enableGroundMirror: boolean;
  119120. /**
  119121. * Specifies the ground mirror size ratio.
  119122. * 0.3 by default as the default kernel is 64.
  119123. */
  119124. groundMirrorSizeRatio: number;
  119125. /**
  119126. * Specifies the ground mirror blur kernel size.
  119127. * 64 by default.
  119128. */
  119129. groundMirrorBlurKernel: number;
  119130. /**
  119131. * Specifies the ground mirror visibility amount.
  119132. * 1 by default
  119133. */
  119134. groundMirrorAmount: number;
  119135. /**
  119136. * Specifies the ground mirror reflectance weight.
  119137. * This uses the standard weight of the background material to setup the fresnel effect
  119138. * of the mirror.
  119139. * 1 by default.
  119140. */
  119141. groundMirrorFresnelWeight: number;
  119142. /**
  119143. * Specifies the ground mirror Falloff distance.
  119144. * This can helps reducing the size of the reflection.
  119145. * 0 by Default.
  119146. */
  119147. groundMirrorFallOffDistance: number;
  119148. /**
  119149. * Specifies the ground mirror texture type.
  119150. * Unsigned Int by Default.
  119151. */
  119152. groundMirrorTextureType: number;
  119153. /**
  119154. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  119155. * the shown objects.
  119156. */
  119157. groundYBias: number;
  119158. /**
  119159. * Specifies wether or not to create a skybox.
  119160. * True by default.
  119161. */
  119162. createSkybox: boolean;
  119163. /**
  119164. * Specifies the skybox size.
  119165. * 20 by default.
  119166. */
  119167. skyboxSize: number;
  119168. /**
  119169. * The texture used on the skybox for the main color.
  119170. * Comes from the BabylonJS CDN by default.
  119171. *
  119172. * Remarks: Can be either a texture or a url.
  119173. */
  119174. skyboxTexture: string | BaseTexture;
  119175. /**
  119176. * The color mixed in the skybox texture by default.
  119177. * BabylonJS clearColor by default.
  119178. */
  119179. skyboxColor: Color3;
  119180. /**
  119181. * The background rotation around the Y axis of the scene.
  119182. * This helps aligning the key lights of your scene with the background.
  119183. * 0 by default.
  119184. */
  119185. backgroundYRotation: number;
  119186. /**
  119187. * Compute automatically the size of the elements to best fit with the scene.
  119188. */
  119189. sizeAuto: boolean;
  119190. /**
  119191. * Default position of the rootMesh if autoSize is not true.
  119192. */
  119193. rootPosition: Vector3;
  119194. /**
  119195. * Sets up the image processing in the scene.
  119196. * true by default.
  119197. */
  119198. setupImageProcessing: boolean;
  119199. /**
  119200. * The texture used as your environment texture in the scene.
  119201. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  119202. *
  119203. * Remarks: Can be either a texture or a url.
  119204. */
  119205. environmentTexture: string | BaseTexture;
  119206. /**
  119207. * The value of the exposure to apply to the scene.
  119208. * 0.6 by default if setupImageProcessing is true.
  119209. */
  119210. cameraExposure: number;
  119211. /**
  119212. * The value of the contrast to apply to the scene.
  119213. * 1.6 by default if setupImageProcessing is true.
  119214. */
  119215. cameraContrast: number;
  119216. /**
  119217. * Specifies wether or not tonemapping should be enabled in the scene.
  119218. * true by default if setupImageProcessing is true.
  119219. */
  119220. toneMappingEnabled: boolean;
  119221. }
  119222. /**
  119223. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  119224. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  119225. * It also helps with the default setup of your imageProcessing configuration.
  119226. */
  119227. export class EnvironmentHelper {
  119228. /**
  119229. * Default ground texture URL.
  119230. */
  119231. private static _groundTextureCDNUrl;
  119232. /**
  119233. * Default skybox texture URL.
  119234. */
  119235. private static _skyboxTextureCDNUrl;
  119236. /**
  119237. * Default environment texture URL.
  119238. */
  119239. private static _environmentTextureCDNUrl;
  119240. /**
  119241. * Creates the default options for the helper.
  119242. */
  119243. private static _getDefaultOptions;
  119244. private _rootMesh;
  119245. /**
  119246. * Gets the root mesh created by the helper.
  119247. */
  119248. get rootMesh(): Mesh;
  119249. private _skybox;
  119250. /**
  119251. * Gets the skybox created by the helper.
  119252. */
  119253. get skybox(): Nullable<Mesh>;
  119254. private _skyboxTexture;
  119255. /**
  119256. * Gets the skybox texture created by the helper.
  119257. */
  119258. get skyboxTexture(): Nullable<BaseTexture>;
  119259. private _skyboxMaterial;
  119260. /**
  119261. * Gets the skybox material created by the helper.
  119262. */
  119263. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  119264. private _ground;
  119265. /**
  119266. * Gets the ground mesh created by the helper.
  119267. */
  119268. get ground(): Nullable<Mesh>;
  119269. private _groundTexture;
  119270. /**
  119271. * Gets the ground texture created by the helper.
  119272. */
  119273. get groundTexture(): Nullable<BaseTexture>;
  119274. private _groundMirror;
  119275. /**
  119276. * Gets the ground mirror created by the helper.
  119277. */
  119278. get groundMirror(): Nullable<MirrorTexture>;
  119279. /**
  119280. * Gets the ground mirror render list to helps pushing the meshes
  119281. * you wish in the ground reflection.
  119282. */
  119283. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  119284. private _groundMaterial;
  119285. /**
  119286. * Gets the ground material created by the helper.
  119287. */
  119288. get groundMaterial(): Nullable<BackgroundMaterial>;
  119289. /**
  119290. * Stores the creation options.
  119291. */
  119292. private readonly _scene;
  119293. private _options;
  119294. /**
  119295. * This observable will be notified with any error during the creation of the environment,
  119296. * mainly texture creation errors.
  119297. */
  119298. onErrorObservable: Observable<{
  119299. message?: string;
  119300. exception?: any;
  119301. }>;
  119302. /**
  119303. * constructor
  119304. * @param options Defines the options we want to customize the helper
  119305. * @param scene The scene to add the material to
  119306. */
  119307. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  119308. /**
  119309. * Updates the background according to the new options
  119310. * @param options
  119311. */
  119312. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  119313. /**
  119314. * Sets the primary color of all the available elements.
  119315. * @param color the main color to affect to the ground and the background
  119316. */
  119317. setMainColor(color: Color3): void;
  119318. /**
  119319. * Setup the image processing according to the specified options.
  119320. */
  119321. private _setupImageProcessing;
  119322. /**
  119323. * Setup the environment texture according to the specified options.
  119324. */
  119325. private _setupEnvironmentTexture;
  119326. /**
  119327. * Setup the background according to the specified options.
  119328. */
  119329. private _setupBackground;
  119330. /**
  119331. * Get the scene sizes according to the setup.
  119332. */
  119333. private _getSceneSize;
  119334. /**
  119335. * Setup the ground according to the specified options.
  119336. */
  119337. private _setupGround;
  119338. /**
  119339. * Setup the ground material according to the specified options.
  119340. */
  119341. private _setupGroundMaterial;
  119342. /**
  119343. * Setup the ground diffuse texture according to the specified options.
  119344. */
  119345. private _setupGroundDiffuseTexture;
  119346. /**
  119347. * Setup the ground mirror texture according to the specified options.
  119348. */
  119349. private _setupGroundMirrorTexture;
  119350. /**
  119351. * Setup the ground to receive the mirror texture.
  119352. */
  119353. private _setupMirrorInGroundMaterial;
  119354. /**
  119355. * Setup the skybox according to the specified options.
  119356. */
  119357. private _setupSkybox;
  119358. /**
  119359. * Setup the skybox material according to the specified options.
  119360. */
  119361. private _setupSkyboxMaterial;
  119362. /**
  119363. * Setup the skybox reflection texture according to the specified options.
  119364. */
  119365. private _setupSkyboxReflectionTexture;
  119366. private _errorHandler;
  119367. /**
  119368. * Dispose all the elements created by the Helper.
  119369. */
  119370. dispose(): void;
  119371. }
  119372. }
  119373. declare module BABYLON {
  119374. /**
  119375. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  119376. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  119377. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  119378. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  119379. */
  119380. export class PhotoDome extends TransformNode {
  119381. /**
  119382. * Define the image as a Monoscopic panoramic 360 image.
  119383. */
  119384. static readonly MODE_MONOSCOPIC: number;
  119385. /**
  119386. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  119387. */
  119388. static readonly MODE_TOPBOTTOM: number;
  119389. /**
  119390. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  119391. */
  119392. static readonly MODE_SIDEBYSIDE: number;
  119393. private _useDirectMapping;
  119394. /**
  119395. * The texture being displayed on the sphere
  119396. */
  119397. protected _photoTexture: Texture;
  119398. /**
  119399. * Gets or sets the texture being displayed on the sphere
  119400. */
  119401. get photoTexture(): Texture;
  119402. set photoTexture(value: Texture);
  119403. /**
  119404. * Observable raised when an error occured while loading the 360 image
  119405. */
  119406. onLoadErrorObservable: Observable<string>;
  119407. /**
  119408. * The skybox material
  119409. */
  119410. protected _material: BackgroundMaterial;
  119411. /**
  119412. * The surface used for the skybox
  119413. */
  119414. protected _mesh: Mesh;
  119415. /**
  119416. * Gets the mesh used for the skybox.
  119417. */
  119418. get mesh(): Mesh;
  119419. /**
  119420. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  119421. * Also see the options.resolution property.
  119422. */
  119423. get fovMultiplier(): number;
  119424. set fovMultiplier(value: number);
  119425. private _imageMode;
  119426. /**
  119427. * Gets or set the current video mode for the video. It can be:
  119428. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  119429. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  119430. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  119431. */
  119432. get imageMode(): number;
  119433. set imageMode(value: number);
  119434. /**
  119435. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  119436. * @param name Element's name, child elements will append suffixes for their own names.
  119437. * @param urlsOfPhoto defines the url of the photo to display
  119438. * @param options defines an object containing optional or exposed sub element properties
  119439. * @param onError defines a callback called when an error occured while loading the texture
  119440. */
  119441. constructor(name: string, urlOfPhoto: string, options: {
  119442. resolution?: number;
  119443. size?: number;
  119444. useDirectMapping?: boolean;
  119445. faceForward?: boolean;
  119446. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  119447. private _onBeforeCameraRenderObserver;
  119448. private _changeImageMode;
  119449. /**
  119450. * Releases resources associated with this node.
  119451. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  119452. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  119453. */
  119454. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  119455. }
  119456. }
  119457. declare module BABYLON {
  119458. /**
  119459. * Class used to host RGBD texture specific utilities
  119460. */
  119461. export class RGBDTextureTools {
  119462. /**
  119463. * Expand the RGBD Texture from RGBD to Half Float if possible.
  119464. * @param texture the texture to expand.
  119465. */
  119466. static ExpandRGBDTexture(texture: Texture): void;
  119467. }
  119468. }
  119469. declare module BABYLON {
  119470. /**
  119471. * Class used to host texture specific utilities
  119472. */
  119473. export class BRDFTextureTools {
  119474. /**
  119475. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  119476. * @param scene defines the hosting scene
  119477. * @returns the environment BRDF texture
  119478. */
  119479. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  119480. private static _environmentBRDFBase64Texture;
  119481. }
  119482. }
  119483. declare module BABYLON {
  119484. /**
  119485. * @hidden
  119486. */
  119487. export interface IMaterialClearCoatDefines {
  119488. CLEARCOAT: boolean;
  119489. CLEARCOAT_DEFAULTIOR: boolean;
  119490. CLEARCOAT_TEXTURE: boolean;
  119491. CLEARCOAT_TEXTUREDIRECTUV: number;
  119492. CLEARCOAT_BUMP: boolean;
  119493. CLEARCOAT_BUMPDIRECTUV: number;
  119494. CLEARCOAT_TINT: boolean;
  119495. CLEARCOAT_TINT_TEXTURE: boolean;
  119496. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  119497. /** @hidden */
  119498. _areTexturesDirty: boolean;
  119499. }
  119500. /**
  119501. * Define the code related to the clear coat parameters of the pbr material.
  119502. */
  119503. export class PBRClearCoatConfiguration {
  119504. /**
  119505. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  119506. * The default fits with a polyurethane material.
  119507. */
  119508. private static readonly _DefaultIndexOfRefraction;
  119509. private _isEnabled;
  119510. /**
  119511. * Defines if the clear coat is enabled in the material.
  119512. */
  119513. isEnabled: boolean;
  119514. /**
  119515. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  119516. */
  119517. intensity: number;
  119518. /**
  119519. * Defines the clear coat layer roughness.
  119520. */
  119521. roughness: number;
  119522. private _indexOfRefraction;
  119523. /**
  119524. * Defines the index of refraction of the clear coat.
  119525. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  119526. * The default fits with a polyurethane material.
  119527. * Changing the default value is more performance intensive.
  119528. */
  119529. indexOfRefraction: number;
  119530. private _texture;
  119531. /**
  119532. * Stores the clear coat values in a texture.
  119533. */
  119534. texture: Nullable<BaseTexture>;
  119535. private _bumpTexture;
  119536. /**
  119537. * Define the clear coat specific bump texture.
  119538. */
  119539. bumpTexture: Nullable<BaseTexture>;
  119540. private _isTintEnabled;
  119541. /**
  119542. * Defines if the clear coat tint is enabled in the material.
  119543. */
  119544. isTintEnabled: boolean;
  119545. /**
  119546. * Defines the clear coat tint of the material.
  119547. * This is only use if tint is enabled
  119548. */
  119549. tintColor: Color3;
  119550. /**
  119551. * Defines the distance at which the tint color should be found in the
  119552. * clear coat media.
  119553. * This is only use if tint is enabled
  119554. */
  119555. tintColorAtDistance: number;
  119556. /**
  119557. * Defines the clear coat layer thickness.
  119558. * This is only use if tint is enabled
  119559. */
  119560. tintThickness: number;
  119561. private _tintTexture;
  119562. /**
  119563. * Stores the clear tint values in a texture.
  119564. * rgb is tint
  119565. * a is a thickness factor
  119566. */
  119567. tintTexture: Nullable<BaseTexture>;
  119568. /** @hidden */
  119569. private _internalMarkAllSubMeshesAsTexturesDirty;
  119570. /** @hidden */
  119571. _markAllSubMeshesAsTexturesDirty(): void;
  119572. /**
  119573. * Instantiate a new istance of clear coat configuration.
  119574. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  119575. */
  119576. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  119577. /**
  119578. * Gets wehter the submesh is ready to be used or not.
  119579. * @param defines the list of "defines" to update.
  119580. * @param scene defines the scene the material belongs to.
  119581. * @param engine defines the engine the material belongs to.
  119582. * @param disableBumpMap defines wether the material disables bump or not.
  119583. * @returns - boolean indicating that the submesh is ready or not.
  119584. */
  119585. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  119586. /**
  119587. * Checks to see if a texture is used in the material.
  119588. * @param defines the list of "defines" to update.
  119589. * @param scene defines the scene to the material belongs to.
  119590. */
  119591. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  119592. /**
  119593. * Binds the material data.
  119594. * @param uniformBuffer defines the Uniform buffer to fill in.
  119595. * @param scene defines the scene the material belongs to.
  119596. * @param engine defines the engine the material belongs to.
  119597. * @param disableBumpMap defines wether the material disables bump or not.
  119598. * @param isFrozen defines wether the material is frozen or not.
  119599. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  119600. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  119601. */
  119602. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  119603. /**
  119604. * Checks to see if a texture is used in the material.
  119605. * @param texture - Base texture to use.
  119606. * @returns - Boolean specifying if a texture is used in the material.
  119607. */
  119608. hasTexture(texture: BaseTexture): boolean;
  119609. /**
  119610. * Returns an array of the actively used textures.
  119611. * @param activeTextures Array of BaseTextures
  119612. */
  119613. getActiveTextures(activeTextures: BaseTexture[]): void;
  119614. /**
  119615. * Returns the animatable textures.
  119616. * @param animatables Array of animatable textures.
  119617. */
  119618. getAnimatables(animatables: IAnimatable[]): void;
  119619. /**
  119620. * Disposes the resources of the material.
  119621. * @param forceDisposeTextures - Forces the disposal of all textures.
  119622. */
  119623. dispose(forceDisposeTextures?: boolean): void;
  119624. /**
  119625. * Get the current class name of the texture useful for serialization or dynamic coding.
  119626. * @returns "PBRClearCoatConfiguration"
  119627. */
  119628. getClassName(): string;
  119629. /**
  119630. * Add fallbacks to the effect fallbacks list.
  119631. * @param defines defines the Base texture to use.
  119632. * @param fallbacks defines the current fallback list.
  119633. * @param currentRank defines the current fallback rank.
  119634. * @returns the new fallback rank.
  119635. */
  119636. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  119637. /**
  119638. * Add the required uniforms to the current list.
  119639. * @param uniforms defines the current uniform list.
  119640. */
  119641. static AddUniforms(uniforms: string[]): void;
  119642. /**
  119643. * Add the required samplers to the current list.
  119644. * @param samplers defines the current sampler list.
  119645. */
  119646. static AddSamplers(samplers: string[]): void;
  119647. /**
  119648. * Add the required uniforms to the current buffer.
  119649. * @param uniformBuffer defines the current uniform buffer.
  119650. */
  119651. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  119652. /**
  119653. * Makes a duplicate of the current configuration into another one.
  119654. * @param clearCoatConfiguration define the config where to copy the info
  119655. */
  119656. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  119657. /**
  119658. * Serializes this clear coat configuration.
  119659. * @returns - An object with the serialized config.
  119660. */
  119661. serialize(): any;
  119662. /**
  119663. * Parses a anisotropy Configuration from a serialized object.
  119664. * @param source - Serialized object.
  119665. * @param scene Defines the scene we are parsing for
  119666. * @param rootUrl Defines the rootUrl to load from
  119667. */
  119668. parse(source: any, scene: Scene, rootUrl: string): void;
  119669. }
  119670. }
  119671. declare module BABYLON {
  119672. /**
  119673. * @hidden
  119674. */
  119675. export interface IMaterialAnisotropicDefines {
  119676. ANISOTROPIC: boolean;
  119677. ANISOTROPIC_TEXTURE: boolean;
  119678. ANISOTROPIC_TEXTUREDIRECTUV: number;
  119679. MAINUV1: boolean;
  119680. _areTexturesDirty: boolean;
  119681. _needUVs: boolean;
  119682. }
  119683. /**
  119684. * Define the code related to the anisotropic parameters of the pbr material.
  119685. */
  119686. export class PBRAnisotropicConfiguration {
  119687. private _isEnabled;
  119688. /**
  119689. * Defines if the anisotropy is enabled in the material.
  119690. */
  119691. isEnabled: boolean;
  119692. /**
  119693. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  119694. */
  119695. intensity: number;
  119696. /**
  119697. * Defines if the effect is along the tangents, bitangents or in between.
  119698. * By default, the effect is "strectching" the highlights along the tangents.
  119699. */
  119700. direction: Vector2;
  119701. private _texture;
  119702. /**
  119703. * Stores the anisotropy values in a texture.
  119704. * rg is direction (like normal from -1 to 1)
  119705. * b is a intensity
  119706. */
  119707. texture: Nullable<BaseTexture>;
  119708. /** @hidden */
  119709. private _internalMarkAllSubMeshesAsTexturesDirty;
  119710. /** @hidden */
  119711. _markAllSubMeshesAsTexturesDirty(): void;
  119712. /**
  119713. * Instantiate a new istance of anisotropy configuration.
  119714. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  119715. */
  119716. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  119717. /**
  119718. * Specifies that the submesh is ready to be used.
  119719. * @param defines the list of "defines" to update.
  119720. * @param scene defines the scene the material belongs to.
  119721. * @returns - boolean indicating that the submesh is ready or not.
  119722. */
  119723. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  119724. /**
  119725. * Checks to see if a texture is used in the material.
  119726. * @param defines the list of "defines" to update.
  119727. * @param mesh the mesh we are preparing the defines for.
  119728. * @param scene defines the scene the material belongs to.
  119729. */
  119730. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  119731. /**
  119732. * Binds the material data.
  119733. * @param uniformBuffer defines the Uniform buffer to fill in.
  119734. * @param scene defines the scene the material belongs to.
  119735. * @param isFrozen defines wether the material is frozen or not.
  119736. */
  119737. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  119738. /**
  119739. * Checks to see if a texture is used in the material.
  119740. * @param texture - Base texture to use.
  119741. * @returns - Boolean specifying if a texture is used in the material.
  119742. */
  119743. hasTexture(texture: BaseTexture): boolean;
  119744. /**
  119745. * Returns an array of the actively used textures.
  119746. * @param activeTextures Array of BaseTextures
  119747. */
  119748. getActiveTextures(activeTextures: BaseTexture[]): void;
  119749. /**
  119750. * Returns the animatable textures.
  119751. * @param animatables Array of animatable textures.
  119752. */
  119753. getAnimatables(animatables: IAnimatable[]): void;
  119754. /**
  119755. * Disposes the resources of the material.
  119756. * @param forceDisposeTextures - Forces the disposal of all textures.
  119757. */
  119758. dispose(forceDisposeTextures?: boolean): void;
  119759. /**
  119760. * Get the current class name of the texture useful for serialization or dynamic coding.
  119761. * @returns "PBRAnisotropicConfiguration"
  119762. */
  119763. getClassName(): string;
  119764. /**
  119765. * Add fallbacks to the effect fallbacks list.
  119766. * @param defines defines the Base texture to use.
  119767. * @param fallbacks defines the current fallback list.
  119768. * @param currentRank defines the current fallback rank.
  119769. * @returns the new fallback rank.
  119770. */
  119771. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  119772. /**
  119773. * Add the required uniforms to the current list.
  119774. * @param uniforms defines the current uniform list.
  119775. */
  119776. static AddUniforms(uniforms: string[]): void;
  119777. /**
  119778. * Add the required uniforms to the current buffer.
  119779. * @param uniformBuffer defines the current uniform buffer.
  119780. */
  119781. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  119782. /**
  119783. * Add the required samplers to the current list.
  119784. * @param samplers defines the current sampler list.
  119785. */
  119786. static AddSamplers(samplers: string[]): void;
  119787. /**
  119788. * Makes a duplicate of the current configuration into another one.
  119789. * @param anisotropicConfiguration define the config where to copy the info
  119790. */
  119791. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  119792. /**
  119793. * Serializes this anisotropy configuration.
  119794. * @returns - An object with the serialized config.
  119795. */
  119796. serialize(): any;
  119797. /**
  119798. * Parses a anisotropy Configuration from a serialized object.
  119799. * @param source - Serialized object.
  119800. * @param scene Defines the scene we are parsing for
  119801. * @param rootUrl Defines the rootUrl to load from
  119802. */
  119803. parse(source: any, scene: Scene, rootUrl: string): void;
  119804. }
  119805. }
  119806. declare module BABYLON {
  119807. /**
  119808. * @hidden
  119809. */
  119810. export interface IMaterialBRDFDefines {
  119811. BRDF_V_HEIGHT_CORRELATED: boolean;
  119812. MS_BRDF_ENERGY_CONSERVATION: boolean;
  119813. SPHERICAL_HARMONICS: boolean;
  119814. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  119815. /** @hidden */
  119816. _areMiscDirty: boolean;
  119817. }
  119818. /**
  119819. * Define the code related to the BRDF parameters of the pbr material.
  119820. */
  119821. export class PBRBRDFConfiguration {
  119822. /**
  119823. * Default value used for the energy conservation.
  119824. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  119825. */
  119826. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  119827. /**
  119828. * Default value used for the Smith Visibility Height Correlated mode.
  119829. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  119830. */
  119831. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  119832. /**
  119833. * Default value used for the IBL diffuse part.
  119834. * This can help switching back to the polynomials mode globally which is a tiny bit
  119835. * less GPU intensive at the drawback of a lower quality.
  119836. */
  119837. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  119838. /**
  119839. * Default value used for activating energy conservation for the specular workflow.
  119840. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  119841. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  119842. */
  119843. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  119844. private _useEnergyConservation;
  119845. /**
  119846. * Defines if the material uses energy conservation.
  119847. */
  119848. useEnergyConservation: boolean;
  119849. private _useSmithVisibilityHeightCorrelated;
  119850. /**
  119851. * LEGACY Mode set to false
  119852. * Defines if the material uses height smith correlated visibility term.
  119853. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  119854. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  119855. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  119856. * Not relying on height correlated will also disable energy conservation.
  119857. */
  119858. useSmithVisibilityHeightCorrelated: boolean;
  119859. private _useSphericalHarmonics;
  119860. /**
  119861. * LEGACY Mode set to false
  119862. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  119863. * diffuse part of the IBL.
  119864. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  119865. * to the ground truth.
  119866. */
  119867. useSphericalHarmonics: boolean;
  119868. private _useSpecularGlossinessInputEnergyConservation;
  119869. /**
  119870. * Defines if the material uses energy conservation, when the specular workflow is active.
  119871. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  119872. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  119873. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  119874. */
  119875. useSpecularGlossinessInputEnergyConservation: boolean;
  119876. /** @hidden */
  119877. private _internalMarkAllSubMeshesAsMiscDirty;
  119878. /** @hidden */
  119879. _markAllSubMeshesAsMiscDirty(): void;
  119880. /**
  119881. * Instantiate a new istance of clear coat configuration.
  119882. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  119883. */
  119884. constructor(markAllSubMeshesAsMiscDirty: () => void);
  119885. /**
  119886. * Checks to see if a texture is used in the material.
  119887. * @param defines the list of "defines" to update.
  119888. */
  119889. prepareDefines(defines: IMaterialBRDFDefines): void;
  119890. /**
  119891. * Get the current class name of the texture useful for serialization or dynamic coding.
  119892. * @returns "PBRClearCoatConfiguration"
  119893. */
  119894. getClassName(): string;
  119895. /**
  119896. * Makes a duplicate of the current configuration into another one.
  119897. * @param brdfConfiguration define the config where to copy the info
  119898. */
  119899. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  119900. /**
  119901. * Serializes this BRDF configuration.
  119902. * @returns - An object with the serialized config.
  119903. */
  119904. serialize(): any;
  119905. /**
  119906. * Parses a anisotropy Configuration from a serialized object.
  119907. * @param source - Serialized object.
  119908. * @param scene Defines the scene we are parsing for
  119909. * @param rootUrl Defines the rootUrl to load from
  119910. */
  119911. parse(source: any, scene: Scene, rootUrl: string): void;
  119912. }
  119913. }
  119914. declare module BABYLON {
  119915. /**
  119916. * @hidden
  119917. */
  119918. export interface IMaterialSheenDefines {
  119919. SHEEN: boolean;
  119920. SHEEN_TEXTURE: boolean;
  119921. SHEEN_TEXTUREDIRECTUV: number;
  119922. SHEEN_LINKWITHALBEDO: boolean;
  119923. /** @hidden */
  119924. _areTexturesDirty: boolean;
  119925. }
  119926. /**
  119927. * Define the code related to the Sheen parameters of the pbr material.
  119928. */
  119929. export class PBRSheenConfiguration {
  119930. private _isEnabled;
  119931. /**
  119932. * Defines if the material uses sheen.
  119933. */
  119934. isEnabled: boolean;
  119935. private _linkSheenWithAlbedo;
  119936. /**
  119937. * Defines if the sheen is linked to the sheen color.
  119938. */
  119939. linkSheenWithAlbedo: boolean;
  119940. /**
  119941. * Defines the sheen intensity.
  119942. */
  119943. intensity: number;
  119944. /**
  119945. * Defines the sheen color.
  119946. */
  119947. color: Color3;
  119948. private _texture;
  119949. /**
  119950. * Stores the sheen tint values in a texture.
  119951. * rgb is tint
  119952. * a is a intensity
  119953. */
  119954. texture: Nullable<BaseTexture>;
  119955. /** @hidden */
  119956. private _internalMarkAllSubMeshesAsTexturesDirty;
  119957. /** @hidden */
  119958. _markAllSubMeshesAsTexturesDirty(): void;
  119959. /**
  119960. * Instantiate a new istance of clear coat configuration.
  119961. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  119962. */
  119963. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  119964. /**
  119965. * Specifies that the submesh is ready to be used.
  119966. * @param defines the list of "defines" to update.
  119967. * @param scene defines the scene the material belongs to.
  119968. * @returns - boolean indicating that the submesh is ready or not.
  119969. */
  119970. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  119971. /**
  119972. * Checks to see if a texture is used in the material.
  119973. * @param defines the list of "defines" to update.
  119974. * @param scene defines the scene the material belongs to.
  119975. */
  119976. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  119977. /**
  119978. * Binds the material data.
  119979. * @param uniformBuffer defines the Uniform buffer to fill in.
  119980. * @param scene defines the scene the material belongs to.
  119981. * @param isFrozen defines wether the material is frozen or not.
  119982. */
  119983. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  119984. /**
  119985. * Checks to see if a texture is used in the material.
  119986. * @param texture - Base texture to use.
  119987. * @returns - Boolean specifying if a texture is used in the material.
  119988. */
  119989. hasTexture(texture: BaseTexture): boolean;
  119990. /**
  119991. * Returns an array of the actively used textures.
  119992. * @param activeTextures Array of BaseTextures
  119993. */
  119994. getActiveTextures(activeTextures: BaseTexture[]): void;
  119995. /**
  119996. * Returns the animatable textures.
  119997. * @param animatables Array of animatable textures.
  119998. */
  119999. getAnimatables(animatables: IAnimatable[]): void;
  120000. /**
  120001. * Disposes the resources of the material.
  120002. * @param forceDisposeTextures - Forces the disposal of all textures.
  120003. */
  120004. dispose(forceDisposeTextures?: boolean): void;
  120005. /**
  120006. * Get the current class name of the texture useful for serialization or dynamic coding.
  120007. * @returns "PBRSheenConfiguration"
  120008. */
  120009. getClassName(): string;
  120010. /**
  120011. * Add fallbacks to the effect fallbacks list.
  120012. * @param defines defines the Base texture to use.
  120013. * @param fallbacks defines the current fallback list.
  120014. * @param currentRank defines the current fallback rank.
  120015. * @returns the new fallback rank.
  120016. */
  120017. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  120018. /**
  120019. * Add the required uniforms to the current list.
  120020. * @param uniforms defines the current uniform list.
  120021. */
  120022. static AddUniforms(uniforms: string[]): void;
  120023. /**
  120024. * Add the required uniforms to the current buffer.
  120025. * @param uniformBuffer defines the current uniform buffer.
  120026. */
  120027. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  120028. /**
  120029. * Add the required samplers to the current list.
  120030. * @param samplers defines the current sampler list.
  120031. */
  120032. static AddSamplers(samplers: string[]): void;
  120033. /**
  120034. * Makes a duplicate of the current configuration into another one.
  120035. * @param sheenConfiguration define the config where to copy the info
  120036. */
  120037. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  120038. /**
  120039. * Serializes this BRDF configuration.
  120040. * @returns - An object with the serialized config.
  120041. */
  120042. serialize(): any;
  120043. /**
  120044. * Parses a anisotropy Configuration from a serialized object.
  120045. * @param source - Serialized object.
  120046. * @param scene Defines the scene we are parsing for
  120047. * @param rootUrl Defines the rootUrl to load from
  120048. */
  120049. parse(source: any, scene: Scene, rootUrl: string): void;
  120050. }
  120051. }
  120052. declare module BABYLON {
  120053. /**
  120054. * @hidden
  120055. */
  120056. export interface IMaterialSubSurfaceDefines {
  120057. SUBSURFACE: boolean;
  120058. SS_REFRACTION: boolean;
  120059. SS_TRANSLUCENCY: boolean;
  120060. SS_SCATERRING: boolean;
  120061. SS_THICKNESSANDMASK_TEXTURE: boolean;
  120062. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  120063. SS_REFRACTIONMAP_3D: boolean;
  120064. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  120065. SS_LODINREFRACTIONALPHA: boolean;
  120066. SS_GAMMAREFRACTION: boolean;
  120067. SS_RGBDREFRACTION: boolean;
  120068. SS_LINEARSPECULARREFRACTION: boolean;
  120069. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  120070. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  120071. /** @hidden */
  120072. _areTexturesDirty: boolean;
  120073. }
  120074. /**
  120075. * Define the code related to the sub surface parameters of the pbr material.
  120076. */
  120077. export class PBRSubSurfaceConfiguration {
  120078. private _isRefractionEnabled;
  120079. /**
  120080. * Defines if the refraction is enabled in the material.
  120081. */
  120082. isRefractionEnabled: boolean;
  120083. private _isTranslucencyEnabled;
  120084. /**
  120085. * Defines if the translucency is enabled in the material.
  120086. */
  120087. isTranslucencyEnabled: boolean;
  120088. private _isScatteringEnabled;
  120089. /**
  120090. * Defines the refraction intensity of the material.
  120091. * The refraction when enabled replaces the Diffuse part of the material.
  120092. * The intensity helps transitionning between diffuse and refraction.
  120093. */
  120094. refractionIntensity: number;
  120095. /**
  120096. * Defines the translucency intensity of the material.
  120097. * When translucency has been enabled, this defines how much of the "translucency"
  120098. * is addded to the diffuse part of the material.
  120099. */
  120100. translucencyIntensity: number;
  120101. /**
  120102. * Defines the scattering intensity of the material.
  120103. * When scattering has been enabled, this defines how much of the "scattered light"
  120104. * is addded to the diffuse part of the material.
  120105. */
  120106. scatteringIntensity: number;
  120107. private _thicknessTexture;
  120108. /**
  120109. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  120110. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  120111. * 0 would mean minimumThickness
  120112. * 1 would mean maximumThickness
  120113. * The other channels might be use as a mask to vary the different effects intensity.
  120114. */
  120115. thicknessTexture: Nullable<BaseTexture>;
  120116. private _refractionTexture;
  120117. /**
  120118. * Defines the texture to use for refraction.
  120119. */
  120120. refractionTexture: Nullable<BaseTexture>;
  120121. private _indexOfRefraction;
  120122. /**
  120123. * Defines the index of refraction used in the material.
  120124. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  120125. */
  120126. indexOfRefraction: number;
  120127. private _invertRefractionY;
  120128. /**
  120129. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  120130. */
  120131. invertRefractionY: boolean;
  120132. private _linkRefractionWithTransparency;
  120133. /**
  120134. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  120135. * Materials half opaque for instance using refraction could benefit from this control.
  120136. */
  120137. linkRefractionWithTransparency: boolean;
  120138. /**
  120139. * Defines the minimum thickness stored in the thickness map.
  120140. * If no thickness map is defined, this value will be used to simulate thickness.
  120141. */
  120142. minimumThickness: number;
  120143. /**
  120144. * Defines the maximum thickness stored in the thickness map.
  120145. */
  120146. maximumThickness: number;
  120147. /**
  120148. * Defines the volume tint of the material.
  120149. * This is used for both translucency and scattering.
  120150. */
  120151. tintColor: Color3;
  120152. /**
  120153. * Defines the distance at which the tint color should be found in the media.
  120154. * This is used for refraction only.
  120155. */
  120156. tintColorAtDistance: number;
  120157. /**
  120158. * Defines how far each channel transmit through the media.
  120159. * It is defined as a color to simplify it selection.
  120160. */
  120161. diffusionDistance: Color3;
  120162. private _useMaskFromThicknessTexture;
  120163. /**
  120164. * Stores the intensity of the different subsurface effects in the thickness texture.
  120165. * * the green channel is the translucency intensity.
  120166. * * the blue channel is the scattering intensity.
  120167. * * the alpha channel is the refraction intensity.
  120168. */
  120169. useMaskFromThicknessTexture: boolean;
  120170. /** @hidden */
  120171. private _internalMarkAllSubMeshesAsTexturesDirty;
  120172. /** @hidden */
  120173. _markAllSubMeshesAsTexturesDirty(): void;
  120174. /**
  120175. * Instantiate a new istance of sub surface configuration.
  120176. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  120177. */
  120178. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  120179. /**
  120180. * Gets wehter the submesh is ready to be used or not.
  120181. * @param defines the list of "defines" to update.
  120182. * @param scene defines the scene the material belongs to.
  120183. * @returns - boolean indicating that the submesh is ready or not.
  120184. */
  120185. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  120186. /**
  120187. * Checks to see if a texture is used in the material.
  120188. * @param defines the list of "defines" to update.
  120189. * @param scene defines the scene to the material belongs to.
  120190. */
  120191. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  120192. /**
  120193. * Binds the material data.
  120194. * @param uniformBuffer defines the Uniform buffer to fill in.
  120195. * @param scene defines the scene the material belongs to.
  120196. * @param engine defines the engine the material belongs to.
  120197. * @param isFrozen defines wether the material is frozen or not.
  120198. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  120199. */
  120200. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  120201. /**
  120202. * Unbinds the material from the mesh.
  120203. * @param activeEffect defines the effect that should be unbound from.
  120204. * @returns true if unbound, otherwise false
  120205. */
  120206. unbind(activeEffect: Effect): boolean;
  120207. /**
  120208. * Returns the texture used for refraction or null if none is used.
  120209. * @param scene defines the scene the material belongs to.
  120210. * @returns - Refraction texture if present. If no refraction texture and refraction
  120211. * is linked with transparency, returns environment texture. Otherwise, returns null.
  120212. */
  120213. private _getRefractionTexture;
  120214. /**
  120215. * Returns true if alpha blending should be disabled.
  120216. */
  120217. get disableAlphaBlending(): boolean;
  120218. /**
  120219. * Fills the list of render target textures.
  120220. * @param renderTargets the list of render targets to update
  120221. */
  120222. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  120223. /**
  120224. * Checks to see if a texture is used in the material.
  120225. * @param texture - Base texture to use.
  120226. * @returns - Boolean specifying if a texture is used in the material.
  120227. */
  120228. hasTexture(texture: BaseTexture): boolean;
  120229. /**
  120230. * Gets a boolean indicating that current material needs to register RTT
  120231. * @returns true if this uses a render target otherwise false.
  120232. */
  120233. hasRenderTargetTextures(): boolean;
  120234. /**
  120235. * Returns an array of the actively used textures.
  120236. * @param activeTextures Array of BaseTextures
  120237. */
  120238. getActiveTextures(activeTextures: BaseTexture[]): void;
  120239. /**
  120240. * Returns the animatable textures.
  120241. * @param animatables Array of animatable textures.
  120242. */
  120243. getAnimatables(animatables: IAnimatable[]): void;
  120244. /**
  120245. * Disposes the resources of the material.
  120246. * @param forceDisposeTextures - Forces the disposal of all textures.
  120247. */
  120248. dispose(forceDisposeTextures?: boolean): void;
  120249. /**
  120250. * Get the current class name of the texture useful for serialization or dynamic coding.
  120251. * @returns "PBRSubSurfaceConfiguration"
  120252. */
  120253. getClassName(): string;
  120254. /**
  120255. * Add fallbacks to the effect fallbacks list.
  120256. * @param defines defines the Base texture to use.
  120257. * @param fallbacks defines the current fallback list.
  120258. * @param currentRank defines the current fallback rank.
  120259. * @returns the new fallback rank.
  120260. */
  120261. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  120262. /**
  120263. * Add the required uniforms to the current list.
  120264. * @param uniforms defines the current uniform list.
  120265. */
  120266. static AddUniforms(uniforms: string[]): void;
  120267. /**
  120268. * Add the required samplers to the current list.
  120269. * @param samplers defines the current sampler list.
  120270. */
  120271. static AddSamplers(samplers: string[]): void;
  120272. /**
  120273. * Add the required uniforms to the current buffer.
  120274. * @param uniformBuffer defines the current uniform buffer.
  120275. */
  120276. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  120277. /**
  120278. * Makes a duplicate of the current configuration into another one.
  120279. * @param configuration define the config where to copy the info
  120280. */
  120281. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  120282. /**
  120283. * Serializes this Sub Surface configuration.
  120284. * @returns - An object with the serialized config.
  120285. */
  120286. serialize(): any;
  120287. /**
  120288. * Parses a anisotropy Configuration from a serialized object.
  120289. * @param source - Serialized object.
  120290. * @param scene Defines the scene we are parsing for
  120291. * @param rootUrl Defines the rootUrl to load from
  120292. */
  120293. parse(source: any, scene: Scene, rootUrl: string): void;
  120294. }
  120295. }
  120296. declare module BABYLON {
  120297. /** @hidden */
  120298. export var pbrFragmentDeclaration: {
  120299. name: string;
  120300. shader: string;
  120301. };
  120302. }
  120303. declare module BABYLON {
  120304. /** @hidden */
  120305. export var pbrUboDeclaration: {
  120306. name: string;
  120307. shader: string;
  120308. };
  120309. }
  120310. declare module BABYLON {
  120311. /** @hidden */
  120312. export var pbrFragmentExtraDeclaration: {
  120313. name: string;
  120314. shader: string;
  120315. };
  120316. }
  120317. declare module BABYLON {
  120318. /** @hidden */
  120319. export var pbrFragmentSamplersDeclaration: {
  120320. name: string;
  120321. shader: string;
  120322. };
  120323. }
  120324. declare module BABYLON {
  120325. /** @hidden */
  120326. export var pbrHelperFunctions: {
  120327. name: string;
  120328. shader: string;
  120329. };
  120330. }
  120331. declare module BABYLON {
  120332. /** @hidden */
  120333. export var harmonicsFunctions: {
  120334. name: string;
  120335. shader: string;
  120336. };
  120337. }
  120338. declare module BABYLON {
  120339. /** @hidden */
  120340. export var pbrDirectLightingSetupFunctions: {
  120341. name: string;
  120342. shader: string;
  120343. };
  120344. }
  120345. declare module BABYLON {
  120346. /** @hidden */
  120347. export var pbrDirectLightingFalloffFunctions: {
  120348. name: string;
  120349. shader: string;
  120350. };
  120351. }
  120352. declare module BABYLON {
  120353. /** @hidden */
  120354. export var pbrBRDFFunctions: {
  120355. name: string;
  120356. shader: string;
  120357. };
  120358. }
  120359. declare module BABYLON {
  120360. /** @hidden */
  120361. export var pbrDirectLightingFunctions: {
  120362. name: string;
  120363. shader: string;
  120364. };
  120365. }
  120366. declare module BABYLON {
  120367. /** @hidden */
  120368. export var pbrIBLFunctions: {
  120369. name: string;
  120370. shader: string;
  120371. };
  120372. }
  120373. declare module BABYLON {
  120374. /** @hidden */
  120375. export var pbrDebug: {
  120376. name: string;
  120377. shader: string;
  120378. };
  120379. }
  120380. declare module BABYLON {
  120381. /** @hidden */
  120382. export var pbrPixelShader: {
  120383. name: string;
  120384. shader: string;
  120385. };
  120386. }
  120387. declare module BABYLON {
  120388. /** @hidden */
  120389. export var pbrVertexDeclaration: {
  120390. name: string;
  120391. shader: string;
  120392. };
  120393. }
  120394. declare module BABYLON {
  120395. /** @hidden */
  120396. export var pbrVertexShader: {
  120397. name: string;
  120398. shader: string;
  120399. };
  120400. }
  120401. declare module BABYLON {
  120402. /**
  120403. * Manages the defines for the PBR Material.
  120404. * @hidden
  120405. */
  120406. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  120407. PBR: boolean;
  120408. MAINUV1: boolean;
  120409. MAINUV2: boolean;
  120410. UV1: boolean;
  120411. UV2: boolean;
  120412. ALBEDO: boolean;
  120413. ALBEDODIRECTUV: number;
  120414. VERTEXCOLOR: boolean;
  120415. AMBIENT: boolean;
  120416. AMBIENTDIRECTUV: number;
  120417. AMBIENTINGRAYSCALE: boolean;
  120418. OPACITY: boolean;
  120419. VERTEXALPHA: boolean;
  120420. OPACITYDIRECTUV: number;
  120421. OPACITYRGB: boolean;
  120422. ALPHATEST: boolean;
  120423. DEPTHPREPASS: boolean;
  120424. ALPHABLEND: boolean;
  120425. ALPHAFROMALBEDO: boolean;
  120426. ALPHATESTVALUE: string;
  120427. SPECULAROVERALPHA: boolean;
  120428. RADIANCEOVERALPHA: boolean;
  120429. ALPHAFRESNEL: boolean;
  120430. LINEARALPHAFRESNEL: boolean;
  120431. PREMULTIPLYALPHA: boolean;
  120432. EMISSIVE: boolean;
  120433. EMISSIVEDIRECTUV: number;
  120434. REFLECTIVITY: boolean;
  120435. REFLECTIVITYDIRECTUV: number;
  120436. SPECULARTERM: boolean;
  120437. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  120438. MICROSURFACEAUTOMATIC: boolean;
  120439. LODBASEDMICROSFURACE: boolean;
  120440. MICROSURFACEMAP: boolean;
  120441. MICROSURFACEMAPDIRECTUV: number;
  120442. METALLICWORKFLOW: boolean;
  120443. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  120444. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  120445. METALLNESSSTOREINMETALMAPBLUE: boolean;
  120446. AOSTOREINMETALMAPRED: boolean;
  120447. METALLICF0FACTORFROMMETALLICMAP: boolean;
  120448. ENVIRONMENTBRDF: boolean;
  120449. ENVIRONMENTBRDF_RGBD: boolean;
  120450. NORMAL: boolean;
  120451. TANGENT: boolean;
  120452. BUMP: boolean;
  120453. BUMPDIRECTUV: number;
  120454. OBJECTSPACE_NORMALMAP: boolean;
  120455. PARALLAX: boolean;
  120456. PARALLAXOCCLUSION: boolean;
  120457. NORMALXYSCALE: boolean;
  120458. LIGHTMAP: boolean;
  120459. LIGHTMAPDIRECTUV: number;
  120460. USELIGHTMAPASSHADOWMAP: boolean;
  120461. GAMMALIGHTMAP: boolean;
  120462. RGBDLIGHTMAP: boolean;
  120463. REFLECTION: boolean;
  120464. REFLECTIONMAP_3D: boolean;
  120465. REFLECTIONMAP_SPHERICAL: boolean;
  120466. REFLECTIONMAP_PLANAR: boolean;
  120467. REFLECTIONMAP_CUBIC: boolean;
  120468. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  120469. REFLECTIONMAP_PROJECTION: boolean;
  120470. REFLECTIONMAP_SKYBOX: boolean;
  120471. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  120472. REFLECTIONMAP_EXPLICIT: boolean;
  120473. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  120474. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  120475. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  120476. INVERTCUBICMAP: boolean;
  120477. USESPHERICALFROMREFLECTIONMAP: boolean;
  120478. USEIRRADIANCEMAP: boolean;
  120479. SPHERICAL_HARMONICS: boolean;
  120480. USESPHERICALINVERTEX: boolean;
  120481. REFLECTIONMAP_OPPOSITEZ: boolean;
  120482. LODINREFLECTIONALPHA: boolean;
  120483. GAMMAREFLECTION: boolean;
  120484. RGBDREFLECTION: boolean;
  120485. LINEARSPECULARREFLECTION: boolean;
  120486. RADIANCEOCCLUSION: boolean;
  120487. HORIZONOCCLUSION: boolean;
  120488. INSTANCES: boolean;
  120489. NUM_BONE_INFLUENCERS: number;
  120490. BonesPerMesh: number;
  120491. BONETEXTURE: boolean;
  120492. NONUNIFORMSCALING: boolean;
  120493. MORPHTARGETS: boolean;
  120494. MORPHTARGETS_NORMAL: boolean;
  120495. MORPHTARGETS_TANGENT: boolean;
  120496. MORPHTARGETS_UV: boolean;
  120497. NUM_MORPH_INFLUENCERS: number;
  120498. IMAGEPROCESSING: boolean;
  120499. VIGNETTE: boolean;
  120500. VIGNETTEBLENDMODEMULTIPLY: boolean;
  120501. VIGNETTEBLENDMODEOPAQUE: boolean;
  120502. TONEMAPPING: boolean;
  120503. TONEMAPPING_ACES: boolean;
  120504. CONTRAST: boolean;
  120505. COLORCURVES: boolean;
  120506. COLORGRADING: boolean;
  120507. COLORGRADING3D: boolean;
  120508. SAMPLER3DGREENDEPTH: boolean;
  120509. SAMPLER3DBGRMAP: boolean;
  120510. IMAGEPROCESSINGPOSTPROCESS: boolean;
  120511. EXPOSURE: boolean;
  120512. MULTIVIEW: boolean;
  120513. USEPHYSICALLIGHTFALLOFF: boolean;
  120514. USEGLTFLIGHTFALLOFF: boolean;
  120515. TWOSIDEDLIGHTING: boolean;
  120516. SHADOWFLOAT: boolean;
  120517. CLIPPLANE: boolean;
  120518. CLIPPLANE2: boolean;
  120519. CLIPPLANE3: boolean;
  120520. CLIPPLANE4: boolean;
  120521. CLIPPLANE5: boolean;
  120522. CLIPPLANE6: boolean;
  120523. POINTSIZE: boolean;
  120524. FOG: boolean;
  120525. LOGARITHMICDEPTH: boolean;
  120526. FORCENORMALFORWARD: boolean;
  120527. SPECULARAA: boolean;
  120528. CLEARCOAT: boolean;
  120529. CLEARCOAT_DEFAULTIOR: boolean;
  120530. CLEARCOAT_TEXTURE: boolean;
  120531. CLEARCOAT_TEXTUREDIRECTUV: number;
  120532. CLEARCOAT_BUMP: boolean;
  120533. CLEARCOAT_BUMPDIRECTUV: number;
  120534. CLEARCOAT_TINT: boolean;
  120535. CLEARCOAT_TINT_TEXTURE: boolean;
  120536. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  120537. ANISOTROPIC: boolean;
  120538. ANISOTROPIC_TEXTURE: boolean;
  120539. ANISOTROPIC_TEXTUREDIRECTUV: number;
  120540. BRDF_V_HEIGHT_CORRELATED: boolean;
  120541. MS_BRDF_ENERGY_CONSERVATION: boolean;
  120542. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  120543. SHEEN: boolean;
  120544. SHEEN_TEXTURE: boolean;
  120545. SHEEN_TEXTUREDIRECTUV: number;
  120546. SHEEN_LINKWITHALBEDO: boolean;
  120547. SUBSURFACE: boolean;
  120548. SS_REFRACTION: boolean;
  120549. SS_TRANSLUCENCY: boolean;
  120550. SS_SCATERRING: boolean;
  120551. SS_THICKNESSANDMASK_TEXTURE: boolean;
  120552. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  120553. SS_REFRACTIONMAP_3D: boolean;
  120554. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  120555. SS_LODINREFRACTIONALPHA: boolean;
  120556. SS_GAMMAREFRACTION: boolean;
  120557. SS_RGBDREFRACTION: boolean;
  120558. SS_LINEARSPECULARREFRACTION: boolean;
  120559. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  120560. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  120561. UNLIT: boolean;
  120562. DEBUGMODE: number;
  120563. /**
  120564. * Initializes the PBR Material defines.
  120565. */
  120566. constructor();
  120567. /**
  120568. * Resets the PBR Material defines.
  120569. */
  120570. reset(): void;
  120571. }
  120572. /**
  120573. * The Physically based material base class of BJS.
  120574. *
  120575. * This offers the main features of a standard PBR material.
  120576. * For more information, please refer to the documentation :
  120577. * https://doc.babylonjs.com/how_to/physically_based_rendering
  120578. */
  120579. export abstract class PBRBaseMaterial extends PushMaterial {
  120580. /**
  120581. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  120582. */
  120583. static readonly PBRMATERIAL_OPAQUE: number;
  120584. /**
  120585. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  120586. */
  120587. static readonly PBRMATERIAL_ALPHATEST: number;
  120588. /**
  120589. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  120590. */
  120591. static readonly PBRMATERIAL_ALPHABLEND: number;
  120592. /**
  120593. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  120594. * They are also discarded below the alpha cutoff threshold to improve performances.
  120595. */
  120596. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  120597. /**
  120598. * Defines the default value of how much AO map is occluding the analytical lights
  120599. * (point spot...).
  120600. */
  120601. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  120602. /**
  120603. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  120604. */
  120605. static readonly LIGHTFALLOFF_PHYSICAL: number;
  120606. /**
  120607. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  120608. * to enhance interoperability with other engines.
  120609. */
  120610. static readonly LIGHTFALLOFF_GLTF: number;
  120611. /**
  120612. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  120613. * to enhance interoperability with other materials.
  120614. */
  120615. static readonly LIGHTFALLOFF_STANDARD: number;
  120616. /**
  120617. * Intensity of the direct lights e.g. the four lights available in your scene.
  120618. * This impacts both the direct diffuse and specular highlights.
  120619. */
  120620. protected _directIntensity: number;
  120621. /**
  120622. * Intensity of the emissive part of the material.
  120623. * This helps controlling the emissive effect without modifying the emissive color.
  120624. */
  120625. protected _emissiveIntensity: number;
  120626. /**
  120627. * Intensity of the environment e.g. how much the environment will light the object
  120628. * either through harmonics for rough material or through the refelction for shiny ones.
  120629. */
  120630. protected _environmentIntensity: number;
  120631. /**
  120632. * This is a special control allowing the reduction of the specular highlights coming from the
  120633. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  120634. */
  120635. protected _specularIntensity: number;
  120636. /**
  120637. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  120638. */
  120639. private _lightingInfos;
  120640. /**
  120641. * Debug Control allowing disabling the bump map on this material.
  120642. */
  120643. protected _disableBumpMap: boolean;
  120644. /**
  120645. * AKA Diffuse Texture in standard nomenclature.
  120646. */
  120647. protected _albedoTexture: Nullable<BaseTexture>;
  120648. /**
  120649. * AKA Occlusion Texture in other nomenclature.
  120650. */
  120651. protected _ambientTexture: Nullable<BaseTexture>;
  120652. /**
  120653. * AKA Occlusion Texture Intensity in other nomenclature.
  120654. */
  120655. protected _ambientTextureStrength: number;
  120656. /**
  120657. * Defines how much the AO map is occluding the analytical lights (point spot...).
  120658. * 1 means it completely occludes it
  120659. * 0 mean it has no impact
  120660. */
  120661. protected _ambientTextureImpactOnAnalyticalLights: number;
  120662. /**
  120663. * Stores the alpha values in a texture.
  120664. */
  120665. protected _opacityTexture: Nullable<BaseTexture>;
  120666. /**
  120667. * Stores the reflection values in a texture.
  120668. */
  120669. protected _reflectionTexture: Nullable<BaseTexture>;
  120670. /**
  120671. * Stores the emissive values in a texture.
  120672. */
  120673. protected _emissiveTexture: Nullable<BaseTexture>;
  120674. /**
  120675. * AKA Specular texture in other nomenclature.
  120676. */
  120677. protected _reflectivityTexture: Nullable<BaseTexture>;
  120678. /**
  120679. * Used to switch from specular/glossiness to metallic/roughness workflow.
  120680. */
  120681. protected _metallicTexture: Nullable<BaseTexture>;
  120682. /**
  120683. * Specifies the metallic scalar of the metallic/roughness workflow.
  120684. * Can also be used to scale the metalness values of the metallic texture.
  120685. */
  120686. protected _metallic: Nullable<number>;
  120687. /**
  120688. * Specifies the roughness scalar of the metallic/roughness workflow.
  120689. * Can also be used to scale the roughness values of the metallic texture.
  120690. */
  120691. protected _roughness: Nullable<number>;
  120692. /**
  120693. * Specifies the an F0 factor to help configuring the material F0.
  120694. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  120695. * to 0.5 the previously hard coded value stays the same.
  120696. * Can also be used to scale the F0 values of the metallic texture.
  120697. */
  120698. protected _metallicF0Factor: number;
  120699. /**
  120700. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  120701. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  120702. * your expectation as it multiplies with the texture data.
  120703. */
  120704. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  120705. /**
  120706. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  120707. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  120708. */
  120709. protected _microSurfaceTexture: Nullable<BaseTexture>;
  120710. /**
  120711. * Stores surface normal data used to displace a mesh in a texture.
  120712. */
  120713. protected _bumpTexture: Nullable<BaseTexture>;
  120714. /**
  120715. * Stores the pre-calculated light information of a mesh in a texture.
  120716. */
  120717. protected _lightmapTexture: Nullable<BaseTexture>;
  120718. /**
  120719. * The color of a material in ambient lighting.
  120720. */
  120721. protected _ambientColor: Color3;
  120722. /**
  120723. * AKA Diffuse Color in other nomenclature.
  120724. */
  120725. protected _albedoColor: Color3;
  120726. /**
  120727. * AKA Specular Color in other nomenclature.
  120728. */
  120729. protected _reflectivityColor: Color3;
  120730. /**
  120731. * The color applied when light is reflected from a material.
  120732. */
  120733. protected _reflectionColor: Color3;
  120734. /**
  120735. * The color applied when light is emitted from a material.
  120736. */
  120737. protected _emissiveColor: Color3;
  120738. /**
  120739. * AKA Glossiness in other nomenclature.
  120740. */
  120741. protected _microSurface: number;
  120742. /**
  120743. * Specifies that the material will use the light map as a show map.
  120744. */
  120745. protected _useLightmapAsShadowmap: boolean;
  120746. /**
  120747. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  120748. * makes the reflect vector face the model (under horizon).
  120749. */
  120750. protected _useHorizonOcclusion: boolean;
  120751. /**
  120752. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  120753. * too much the area relying on ambient texture to define their ambient occlusion.
  120754. */
  120755. protected _useRadianceOcclusion: boolean;
  120756. /**
  120757. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  120758. */
  120759. protected _useAlphaFromAlbedoTexture: boolean;
  120760. /**
  120761. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  120762. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  120763. */
  120764. protected _useSpecularOverAlpha: boolean;
  120765. /**
  120766. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  120767. */
  120768. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  120769. /**
  120770. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  120771. */
  120772. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  120773. /**
  120774. * Specifies if the metallic texture contains the roughness information in its green channel.
  120775. */
  120776. protected _useRoughnessFromMetallicTextureGreen: boolean;
  120777. /**
  120778. * Specifies if the metallic texture contains the metallness information in its blue channel.
  120779. */
  120780. protected _useMetallnessFromMetallicTextureBlue: boolean;
  120781. /**
  120782. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  120783. */
  120784. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  120785. /**
  120786. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  120787. */
  120788. protected _useAmbientInGrayScale: boolean;
  120789. /**
  120790. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  120791. * The material will try to infer what glossiness each pixel should be.
  120792. */
  120793. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  120794. /**
  120795. * Defines the falloff type used in this material.
  120796. * It by default is Physical.
  120797. */
  120798. protected _lightFalloff: number;
  120799. /**
  120800. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  120801. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  120802. */
  120803. protected _useRadianceOverAlpha: boolean;
  120804. /**
  120805. * Allows using an object space normal map (instead of tangent space).
  120806. */
  120807. protected _useObjectSpaceNormalMap: boolean;
  120808. /**
  120809. * Allows using the bump map in parallax mode.
  120810. */
  120811. protected _useParallax: boolean;
  120812. /**
  120813. * Allows using the bump map in parallax occlusion mode.
  120814. */
  120815. protected _useParallaxOcclusion: boolean;
  120816. /**
  120817. * Controls the scale bias of the parallax mode.
  120818. */
  120819. protected _parallaxScaleBias: number;
  120820. /**
  120821. * If sets to true, disables all the lights affecting the material.
  120822. */
  120823. protected _disableLighting: boolean;
  120824. /**
  120825. * Number of Simultaneous lights allowed on the material.
  120826. */
  120827. protected _maxSimultaneousLights: number;
  120828. /**
  120829. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  120830. */
  120831. protected _invertNormalMapX: boolean;
  120832. /**
  120833. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  120834. */
  120835. protected _invertNormalMapY: boolean;
  120836. /**
  120837. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  120838. */
  120839. protected _twoSidedLighting: boolean;
  120840. /**
  120841. * Defines the alpha limits in alpha test mode.
  120842. */
  120843. protected _alphaCutOff: number;
  120844. /**
  120845. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  120846. */
  120847. protected _forceAlphaTest: boolean;
  120848. /**
  120849. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  120850. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  120851. */
  120852. protected _useAlphaFresnel: boolean;
  120853. /**
  120854. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  120855. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  120856. */
  120857. protected _useLinearAlphaFresnel: boolean;
  120858. /**
  120859. * The transparency mode of the material.
  120860. */
  120861. protected _transparencyMode: Nullable<number>;
  120862. /**
  120863. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  120864. * from cos thetav and roughness:
  120865. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  120866. */
  120867. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  120868. /**
  120869. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  120870. */
  120871. protected _forceIrradianceInFragment: boolean;
  120872. /**
  120873. * Force normal to face away from face.
  120874. */
  120875. protected _forceNormalForward: boolean;
  120876. /**
  120877. * Enables specular anti aliasing in the PBR shader.
  120878. * It will both interacts on the Geometry for analytical and IBL lighting.
  120879. * It also prefilter the roughness map based on the bump values.
  120880. */
  120881. protected _enableSpecularAntiAliasing: boolean;
  120882. /**
  120883. * Default configuration related to image processing available in the PBR Material.
  120884. */
  120885. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  120886. /**
  120887. * Keep track of the image processing observer to allow dispose and replace.
  120888. */
  120889. private _imageProcessingObserver;
  120890. /**
  120891. * Attaches a new image processing configuration to the PBR Material.
  120892. * @param configuration
  120893. */
  120894. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  120895. /**
  120896. * Stores the available render targets.
  120897. */
  120898. private _renderTargets;
  120899. /**
  120900. * Sets the global ambient color for the material used in lighting calculations.
  120901. */
  120902. private _globalAmbientColor;
  120903. /**
  120904. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  120905. */
  120906. private _useLogarithmicDepth;
  120907. /**
  120908. * If set to true, no lighting calculations will be applied.
  120909. */
  120910. private _unlit;
  120911. private _debugMode;
  120912. /**
  120913. * @hidden
  120914. * This is reserved for the inspector.
  120915. * Defines the material debug mode.
  120916. * It helps seeing only some components of the material while troubleshooting.
  120917. */
  120918. debugMode: number;
  120919. /**
  120920. * @hidden
  120921. * This is reserved for the inspector.
  120922. * Specify from where on screen the debug mode should start.
  120923. * The value goes from -1 (full screen) to 1 (not visible)
  120924. * It helps with side by side comparison against the final render
  120925. * This defaults to -1
  120926. */
  120927. private debugLimit;
  120928. /**
  120929. * @hidden
  120930. * This is reserved for the inspector.
  120931. * As the default viewing range might not be enough (if the ambient is really small for instance)
  120932. * You can use the factor to better multiply the final value.
  120933. */
  120934. private debugFactor;
  120935. /**
  120936. * Defines the clear coat layer parameters for the material.
  120937. */
  120938. readonly clearCoat: PBRClearCoatConfiguration;
  120939. /**
  120940. * Defines the anisotropic parameters for the material.
  120941. */
  120942. readonly anisotropy: PBRAnisotropicConfiguration;
  120943. /**
  120944. * Defines the BRDF parameters for the material.
  120945. */
  120946. readonly brdf: PBRBRDFConfiguration;
  120947. /**
  120948. * Defines the Sheen parameters for the material.
  120949. */
  120950. readonly sheen: PBRSheenConfiguration;
  120951. /**
  120952. * Defines the SubSurface parameters for the material.
  120953. */
  120954. readonly subSurface: PBRSubSurfaceConfiguration;
  120955. /**
  120956. * Custom callback helping to override the default shader used in the material.
  120957. */
  120958. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  120959. protected _rebuildInParallel: boolean;
  120960. /**
  120961. * Instantiates a new PBRMaterial instance.
  120962. *
  120963. * @param name The material name
  120964. * @param scene The scene the material will be use in.
  120965. */
  120966. constructor(name: string, scene: Scene);
  120967. /**
  120968. * Gets a boolean indicating that current material needs to register RTT
  120969. */
  120970. get hasRenderTargetTextures(): boolean;
  120971. /**
  120972. * Gets the name of the material class.
  120973. */
  120974. getClassName(): string;
  120975. /**
  120976. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  120977. */
  120978. get useLogarithmicDepth(): boolean;
  120979. /**
  120980. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  120981. */
  120982. set useLogarithmicDepth(value: boolean);
  120983. /**
  120984. * Gets the current transparency mode.
  120985. */
  120986. get transparencyMode(): Nullable<number>;
  120987. /**
  120988. * Sets the transparency mode of the material.
  120989. *
  120990. * | Value | Type | Description |
  120991. * | ----- | ----------------------------------- | ----------- |
  120992. * | 0 | OPAQUE | |
  120993. * | 1 | ALPHATEST | |
  120994. * | 2 | ALPHABLEND | |
  120995. * | 3 | ALPHATESTANDBLEND | |
  120996. *
  120997. */
  120998. set transparencyMode(value: Nullable<number>);
  120999. /**
  121000. * Returns true if alpha blending should be disabled.
  121001. */
  121002. private get _disableAlphaBlending();
  121003. /**
  121004. * Specifies whether or not this material should be rendered in alpha blend mode.
  121005. */
  121006. needAlphaBlending(): boolean;
  121007. /**
  121008. * Specifies if the mesh will require alpha blending.
  121009. * @param mesh - BJS mesh.
  121010. */
  121011. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  121012. /**
  121013. * Specifies whether or not this material should be rendered in alpha test mode.
  121014. */
  121015. needAlphaTesting(): boolean;
  121016. /**
  121017. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  121018. */
  121019. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  121020. /**
  121021. * Gets the texture used for the alpha test.
  121022. */
  121023. getAlphaTestTexture(): Nullable<BaseTexture>;
  121024. /**
  121025. * Specifies that the submesh is ready to be used.
  121026. * @param mesh - BJS mesh.
  121027. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  121028. * @param useInstances - Specifies that instances should be used.
  121029. * @returns - boolean indicating that the submesh is ready or not.
  121030. */
  121031. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  121032. /**
  121033. * Specifies if the material uses metallic roughness workflow.
  121034. * @returns boolean specifiying if the material uses metallic roughness workflow.
  121035. */
  121036. isMetallicWorkflow(): boolean;
  121037. private _prepareEffect;
  121038. private _prepareDefines;
  121039. /**
  121040. * Force shader compilation
  121041. */
  121042. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  121043. /**
  121044. * Initializes the uniform buffer layout for the shader.
  121045. */
  121046. buildUniformLayout(): void;
  121047. /**
  121048. * Unbinds the material from the mesh
  121049. */
  121050. unbind(): void;
  121051. /**
  121052. * Binds the submesh data.
  121053. * @param world - The world matrix.
  121054. * @param mesh - The BJS mesh.
  121055. * @param subMesh - A submesh of the BJS mesh.
  121056. */
  121057. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  121058. /**
  121059. * Returns the animatable textures.
  121060. * @returns - Array of animatable textures.
  121061. */
  121062. getAnimatables(): IAnimatable[];
  121063. /**
  121064. * Returns the texture used for reflections.
  121065. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  121066. */
  121067. private _getReflectionTexture;
  121068. /**
  121069. * Returns an array of the actively used textures.
  121070. * @returns - Array of BaseTextures
  121071. */
  121072. getActiveTextures(): BaseTexture[];
  121073. /**
  121074. * Checks to see if a texture is used in the material.
  121075. * @param texture - Base texture to use.
  121076. * @returns - Boolean specifying if a texture is used in the material.
  121077. */
  121078. hasTexture(texture: BaseTexture): boolean;
  121079. /**
  121080. * Disposes the resources of the material.
  121081. * @param forceDisposeEffect - Forces the disposal of effects.
  121082. * @param forceDisposeTextures - Forces the disposal of all textures.
  121083. */
  121084. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  121085. }
  121086. }
  121087. declare module BABYLON {
  121088. /**
  121089. * The Physically based material of BJS.
  121090. *
  121091. * This offers the main features of a standard PBR material.
  121092. * For more information, please refer to the documentation :
  121093. * https://doc.babylonjs.com/how_to/physically_based_rendering
  121094. */
  121095. export class PBRMaterial extends PBRBaseMaterial {
  121096. /**
  121097. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  121098. */
  121099. static readonly PBRMATERIAL_OPAQUE: number;
  121100. /**
  121101. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  121102. */
  121103. static readonly PBRMATERIAL_ALPHATEST: number;
  121104. /**
  121105. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  121106. */
  121107. static readonly PBRMATERIAL_ALPHABLEND: number;
  121108. /**
  121109. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  121110. * They are also discarded below the alpha cutoff threshold to improve performances.
  121111. */
  121112. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  121113. /**
  121114. * Defines the default value of how much AO map is occluding the analytical lights
  121115. * (point spot...).
  121116. */
  121117. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  121118. /**
  121119. * Intensity of the direct lights e.g. the four lights available in your scene.
  121120. * This impacts both the direct diffuse and specular highlights.
  121121. */
  121122. directIntensity: number;
  121123. /**
  121124. * Intensity of the emissive part of the material.
  121125. * This helps controlling the emissive effect without modifying the emissive color.
  121126. */
  121127. emissiveIntensity: number;
  121128. /**
  121129. * Intensity of the environment e.g. how much the environment will light the object
  121130. * either through harmonics for rough material or through the refelction for shiny ones.
  121131. */
  121132. environmentIntensity: number;
  121133. /**
  121134. * This is a special control allowing the reduction of the specular highlights coming from the
  121135. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  121136. */
  121137. specularIntensity: number;
  121138. /**
  121139. * Debug Control allowing disabling the bump map on this material.
  121140. */
  121141. disableBumpMap: boolean;
  121142. /**
  121143. * AKA Diffuse Texture in standard nomenclature.
  121144. */
  121145. albedoTexture: BaseTexture;
  121146. /**
  121147. * AKA Occlusion Texture in other nomenclature.
  121148. */
  121149. ambientTexture: BaseTexture;
  121150. /**
  121151. * AKA Occlusion Texture Intensity in other nomenclature.
  121152. */
  121153. ambientTextureStrength: number;
  121154. /**
  121155. * Defines how much the AO map is occluding the analytical lights (point spot...).
  121156. * 1 means it completely occludes it
  121157. * 0 mean it has no impact
  121158. */
  121159. ambientTextureImpactOnAnalyticalLights: number;
  121160. /**
  121161. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  121162. */
  121163. opacityTexture: BaseTexture;
  121164. /**
  121165. * Stores the reflection values in a texture.
  121166. */
  121167. reflectionTexture: Nullable<BaseTexture>;
  121168. /**
  121169. * Stores the emissive values in a texture.
  121170. */
  121171. emissiveTexture: BaseTexture;
  121172. /**
  121173. * AKA Specular texture in other nomenclature.
  121174. */
  121175. reflectivityTexture: BaseTexture;
  121176. /**
  121177. * Used to switch from specular/glossiness to metallic/roughness workflow.
  121178. */
  121179. metallicTexture: BaseTexture;
  121180. /**
  121181. * Specifies the metallic scalar of the metallic/roughness workflow.
  121182. * Can also be used to scale the metalness values of the metallic texture.
  121183. */
  121184. metallic: Nullable<number>;
  121185. /**
  121186. * Specifies the roughness scalar of the metallic/roughness workflow.
  121187. * Can also be used to scale the roughness values of the metallic texture.
  121188. */
  121189. roughness: Nullable<number>;
  121190. /**
  121191. * Specifies the an F0 factor to help configuring the material F0.
  121192. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  121193. * to 0.5 the previously hard coded value stays the same.
  121194. * Can also be used to scale the F0 values of the metallic texture.
  121195. */
  121196. metallicF0Factor: number;
  121197. /**
  121198. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  121199. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  121200. * your expectation as it multiplies with the texture data.
  121201. */
  121202. useMetallicF0FactorFromMetallicTexture: boolean;
  121203. /**
  121204. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  121205. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  121206. */
  121207. microSurfaceTexture: BaseTexture;
  121208. /**
  121209. * Stores surface normal data used to displace a mesh in a texture.
  121210. */
  121211. bumpTexture: BaseTexture;
  121212. /**
  121213. * Stores the pre-calculated light information of a mesh in a texture.
  121214. */
  121215. lightmapTexture: BaseTexture;
  121216. /**
  121217. * Stores the refracted light information in a texture.
  121218. */
  121219. get refractionTexture(): Nullable<BaseTexture>;
  121220. set refractionTexture(value: Nullable<BaseTexture>);
  121221. /**
  121222. * The color of a material in ambient lighting.
  121223. */
  121224. ambientColor: Color3;
  121225. /**
  121226. * AKA Diffuse Color in other nomenclature.
  121227. */
  121228. albedoColor: Color3;
  121229. /**
  121230. * AKA Specular Color in other nomenclature.
  121231. */
  121232. reflectivityColor: Color3;
  121233. /**
  121234. * The color reflected from the material.
  121235. */
  121236. reflectionColor: Color3;
  121237. /**
  121238. * The color emitted from the material.
  121239. */
  121240. emissiveColor: Color3;
  121241. /**
  121242. * AKA Glossiness in other nomenclature.
  121243. */
  121244. microSurface: number;
  121245. /**
  121246. * source material index of refraction (IOR)' / 'destination material IOR.
  121247. */
  121248. get indexOfRefraction(): number;
  121249. set indexOfRefraction(value: number);
  121250. /**
  121251. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  121252. */
  121253. get invertRefractionY(): boolean;
  121254. set invertRefractionY(value: boolean);
  121255. /**
  121256. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  121257. * Materials half opaque for instance using refraction could benefit from this control.
  121258. */
  121259. get linkRefractionWithTransparency(): boolean;
  121260. set linkRefractionWithTransparency(value: boolean);
  121261. /**
  121262. * If true, the light map contains occlusion information instead of lighting info.
  121263. */
  121264. useLightmapAsShadowmap: boolean;
  121265. /**
  121266. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  121267. */
  121268. useAlphaFromAlbedoTexture: boolean;
  121269. /**
  121270. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  121271. */
  121272. forceAlphaTest: boolean;
  121273. /**
  121274. * Defines the alpha limits in alpha test mode.
  121275. */
  121276. alphaCutOff: number;
  121277. /**
  121278. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  121279. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  121280. */
  121281. useSpecularOverAlpha: boolean;
  121282. /**
  121283. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  121284. */
  121285. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  121286. /**
  121287. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  121288. */
  121289. useRoughnessFromMetallicTextureAlpha: boolean;
  121290. /**
  121291. * Specifies if the metallic texture contains the roughness information in its green channel.
  121292. */
  121293. useRoughnessFromMetallicTextureGreen: boolean;
  121294. /**
  121295. * Specifies if the metallic texture contains the metallness information in its blue channel.
  121296. */
  121297. useMetallnessFromMetallicTextureBlue: boolean;
  121298. /**
  121299. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  121300. */
  121301. useAmbientOcclusionFromMetallicTextureRed: boolean;
  121302. /**
  121303. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  121304. */
  121305. useAmbientInGrayScale: boolean;
  121306. /**
  121307. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  121308. * The material will try to infer what glossiness each pixel should be.
  121309. */
  121310. useAutoMicroSurfaceFromReflectivityMap: boolean;
  121311. /**
  121312. * BJS is using an harcoded light falloff based on a manually sets up range.
  121313. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  121314. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  121315. */
  121316. get usePhysicalLightFalloff(): boolean;
  121317. /**
  121318. * BJS is using an harcoded light falloff based on a manually sets up range.
  121319. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  121320. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  121321. */
  121322. set usePhysicalLightFalloff(value: boolean);
  121323. /**
  121324. * In order to support the falloff compatibility with gltf, a special mode has been added
  121325. * to reproduce the gltf light falloff.
  121326. */
  121327. get useGLTFLightFalloff(): boolean;
  121328. /**
  121329. * In order to support the falloff compatibility with gltf, a special mode has been added
  121330. * to reproduce the gltf light falloff.
  121331. */
  121332. set useGLTFLightFalloff(value: boolean);
  121333. /**
  121334. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  121335. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  121336. */
  121337. useRadianceOverAlpha: boolean;
  121338. /**
  121339. * Allows using an object space normal map (instead of tangent space).
  121340. */
  121341. useObjectSpaceNormalMap: boolean;
  121342. /**
  121343. * Allows using the bump map in parallax mode.
  121344. */
  121345. useParallax: boolean;
  121346. /**
  121347. * Allows using the bump map in parallax occlusion mode.
  121348. */
  121349. useParallaxOcclusion: boolean;
  121350. /**
  121351. * Controls the scale bias of the parallax mode.
  121352. */
  121353. parallaxScaleBias: number;
  121354. /**
  121355. * If sets to true, disables all the lights affecting the material.
  121356. */
  121357. disableLighting: boolean;
  121358. /**
  121359. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  121360. */
  121361. forceIrradianceInFragment: boolean;
  121362. /**
  121363. * Number of Simultaneous lights allowed on the material.
  121364. */
  121365. maxSimultaneousLights: number;
  121366. /**
  121367. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  121368. */
  121369. invertNormalMapX: boolean;
  121370. /**
  121371. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  121372. */
  121373. invertNormalMapY: boolean;
  121374. /**
  121375. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  121376. */
  121377. twoSidedLighting: boolean;
  121378. /**
  121379. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  121380. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  121381. */
  121382. useAlphaFresnel: boolean;
  121383. /**
  121384. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  121385. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  121386. */
  121387. useLinearAlphaFresnel: boolean;
  121388. /**
  121389. * Let user defines the brdf lookup texture used for IBL.
  121390. * A default 8bit version is embedded but you could point at :
  121391. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  121392. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  121393. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  121394. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  121395. */
  121396. environmentBRDFTexture: Nullable<BaseTexture>;
  121397. /**
  121398. * Force normal to face away from face.
  121399. */
  121400. forceNormalForward: boolean;
  121401. /**
  121402. * Enables specular anti aliasing in the PBR shader.
  121403. * It will both interacts on the Geometry for analytical and IBL lighting.
  121404. * It also prefilter the roughness map based on the bump values.
  121405. */
  121406. enableSpecularAntiAliasing: boolean;
  121407. /**
  121408. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  121409. * makes the reflect vector face the model (under horizon).
  121410. */
  121411. useHorizonOcclusion: boolean;
  121412. /**
  121413. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  121414. * too much the area relying on ambient texture to define their ambient occlusion.
  121415. */
  121416. useRadianceOcclusion: boolean;
  121417. /**
  121418. * If set to true, no lighting calculations will be applied.
  121419. */
  121420. unlit: boolean;
  121421. /**
  121422. * Gets the image processing configuration used either in this material.
  121423. */
  121424. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  121425. /**
  121426. * Sets the Default image processing configuration used either in the this material.
  121427. *
  121428. * If sets to null, the scene one is in use.
  121429. */
  121430. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  121431. /**
  121432. * Gets wether the color curves effect is enabled.
  121433. */
  121434. get cameraColorCurvesEnabled(): boolean;
  121435. /**
  121436. * Sets wether the color curves effect is enabled.
  121437. */
  121438. set cameraColorCurvesEnabled(value: boolean);
  121439. /**
  121440. * Gets wether the color grading effect is enabled.
  121441. */
  121442. get cameraColorGradingEnabled(): boolean;
  121443. /**
  121444. * Gets wether the color grading effect is enabled.
  121445. */
  121446. set cameraColorGradingEnabled(value: boolean);
  121447. /**
  121448. * Gets wether tonemapping is enabled or not.
  121449. */
  121450. get cameraToneMappingEnabled(): boolean;
  121451. /**
  121452. * Sets wether tonemapping is enabled or not
  121453. */
  121454. set cameraToneMappingEnabled(value: boolean);
  121455. /**
  121456. * The camera exposure used on this material.
  121457. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  121458. * This corresponds to a photographic exposure.
  121459. */
  121460. get cameraExposure(): number;
  121461. /**
  121462. * The camera exposure used on this material.
  121463. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  121464. * This corresponds to a photographic exposure.
  121465. */
  121466. set cameraExposure(value: number);
  121467. /**
  121468. * Gets The camera contrast used on this material.
  121469. */
  121470. get cameraContrast(): number;
  121471. /**
  121472. * Sets The camera contrast used on this material.
  121473. */
  121474. set cameraContrast(value: number);
  121475. /**
  121476. * Gets the Color Grading 2D Lookup Texture.
  121477. */
  121478. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  121479. /**
  121480. * Sets the Color Grading 2D Lookup Texture.
  121481. */
  121482. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  121483. /**
  121484. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  121485. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  121486. * 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;
  121487. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  121488. */
  121489. get cameraColorCurves(): Nullable<ColorCurves>;
  121490. /**
  121491. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  121492. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  121493. * 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;
  121494. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  121495. */
  121496. set cameraColorCurves(value: Nullable<ColorCurves>);
  121497. /**
  121498. * Instantiates a new PBRMaterial instance.
  121499. *
  121500. * @param name The material name
  121501. * @param scene The scene the material will be use in.
  121502. */
  121503. constructor(name: string, scene: Scene);
  121504. /**
  121505. * Returns the name of this material class.
  121506. */
  121507. getClassName(): string;
  121508. /**
  121509. * Makes a duplicate of the current material.
  121510. * @param name - name to use for the new material.
  121511. */
  121512. clone(name: string): PBRMaterial;
  121513. /**
  121514. * Serializes this PBR Material.
  121515. * @returns - An object with the serialized material.
  121516. */
  121517. serialize(): any;
  121518. /**
  121519. * Parses a PBR Material from a serialized object.
  121520. * @param source - Serialized object.
  121521. * @param scene - BJS scene instance.
  121522. * @param rootUrl - url for the scene object
  121523. * @returns - PBRMaterial
  121524. */
  121525. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  121526. }
  121527. }
  121528. declare module BABYLON {
  121529. /**
  121530. * Direct draw surface info
  121531. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  121532. */
  121533. export interface DDSInfo {
  121534. /**
  121535. * Width of the texture
  121536. */
  121537. width: number;
  121538. /**
  121539. * Width of the texture
  121540. */
  121541. height: number;
  121542. /**
  121543. * Number of Mipmaps for the texture
  121544. * @see https://en.wikipedia.org/wiki/Mipmap
  121545. */
  121546. mipmapCount: number;
  121547. /**
  121548. * If the textures format is a known fourCC format
  121549. * @see https://www.fourcc.org/
  121550. */
  121551. isFourCC: boolean;
  121552. /**
  121553. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  121554. */
  121555. isRGB: boolean;
  121556. /**
  121557. * If the texture is a lumincance format
  121558. */
  121559. isLuminance: boolean;
  121560. /**
  121561. * If this is a cube texture
  121562. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  121563. */
  121564. isCube: boolean;
  121565. /**
  121566. * If the texture is a compressed format eg. FOURCC_DXT1
  121567. */
  121568. isCompressed: boolean;
  121569. /**
  121570. * The dxgiFormat of the texture
  121571. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  121572. */
  121573. dxgiFormat: number;
  121574. /**
  121575. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  121576. */
  121577. textureType: number;
  121578. /**
  121579. * Sphericle polynomial created for the dds texture
  121580. */
  121581. sphericalPolynomial?: SphericalPolynomial;
  121582. }
  121583. /**
  121584. * Class used to provide DDS decompression tools
  121585. */
  121586. export class DDSTools {
  121587. /**
  121588. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  121589. */
  121590. static StoreLODInAlphaChannel: boolean;
  121591. /**
  121592. * Gets DDS information from an array buffer
  121593. * @param arrayBuffer defines the array buffer to read data from
  121594. * @returns the DDS information
  121595. */
  121596. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  121597. private static _FloatView;
  121598. private static _Int32View;
  121599. private static _ToHalfFloat;
  121600. private static _FromHalfFloat;
  121601. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  121602. private static _GetHalfFloatRGBAArrayBuffer;
  121603. private static _GetFloatRGBAArrayBuffer;
  121604. private static _GetFloatAsUIntRGBAArrayBuffer;
  121605. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  121606. private static _GetRGBAArrayBuffer;
  121607. private static _ExtractLongWordOrder;
  121608. private static _GetRGBArrayBuffer;
  121609. private static _GetLuminanceArrayBuffer;
  121610. /**
  121611. * Uploads DDS Levels to a Babylon Texture
  121612. * @hidden
  121613. */
  121614. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  121615. }
  121616. interface ThinEngine {
  121617. /**
  121618. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  121619. * @param rootUrl defines the url where the file to load is located
  121620. * @param scene defines the current scene
  121621. * @param lodScale defines scale to apply to the mip map selection
  121622. * @param lodOffset defines offset to apply to the mip map selection
  121623. * @param onLoad defines an optional callback raised when the texture is loaded
  121624. * @param onError defines an optional callback raised if there is an issue to load the texture
  121625. * @param format defines the format of the data
  121626. * @param forcedExtension defines the extension to use to pick the right loader
  121627. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  121628. * @returns the cube texture as an InternalTexture
  121629. */
  121630. 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;
  121631. }
  121632. }
  121633. declare module BABYLON {
  121634. /**
  121635. * Implementation of the DDS Texture Loader.
  121636. * @hidden
  121637. */
  121638. export class _DDSTextureLoader implements IInternalTextureLoader {
  121639. /**
  121640. * Defines wether the loader supports cascade loading the different faces.
  121641. */
  121642. readonly supportCascades: boolean;
  121643. /**
  121644. * This returns if the loader support the current file information.
  121645. * @param extension defines the file extension of the file being loaded
  121646. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121647. * @param fallback defines the fallback internal texture if any
  121648. * @param isBase64 defines whether the texture is encoded as a base64
  121649. * @param isBuffer defines whether the texture data are stored as a buffer
  121650. * @returns true if the loader can load the specified file
  121651. */
  121652. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121653. /**
  121654. * Transform the url before loading if required.
  121655. * @param rootUrl the url of the texture
  121656. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121657. * @returns the transformed texture
  121658. */
  121659. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121660. /**
  121661. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121662. * @param rootUrl the url of the texture
  121663. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121664. * @returns the fallback texture
  121665. */
  121666. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121667. /**
  121668. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  121669. * @param data contains the texture data
  121670. * @param texture defines the BabylonJS internal texture
  121671. * @param createPolynomials will be true if polynomials have been requested
  121672. * @param onLoad defines the callback to trigger once the texture is ready
  121673. * @param onError defines the callback to trigger in case of error
  121674. */
  121675. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121676. /**
  121677. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121678. * @param data contains the texture data
  121679. * @param texture defines the BabylonJS internal texture
  121680. * @param callback defines the method to call once ready to upload
  121681. */
  121682. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  121683. }
  121684. }
  121685. declare module BABYLON {
  121686. /**
  121687. * Implementation of the ENV Texture Loader.
  121688. * @hidden
  121689. */
  121690. export class _ENVTextureLoader implements IInternalTextureLoader {
  121691. /**
  121692. * Defines wether the loader supports cascade loading the different faces.
  121693. */
  121694. readonly supportCascades: boolean;
  121695. /**
  121696. * This returns if the loader support the current file information.
  121697. * @param extension defines the file extension of the file being loaded
  121698. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121699. * @param fallback defines the fallback internal texture if any
  121700. * @param isBase64 defines whether the texture is encoded as a base64
  121701. * @param isBuffer defines whether the texture data are stored as a buffer
  121702. * @returns true if the loader can load the specified file
  121703. */
  121704. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121705. /**
  121706. * Transform the url before loading if required.
  121707. * @param rootUrl the url of the texture
  121708. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121709. * @returns the transformed texture
  121710. */
  121711. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121712. /**
  121713. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121714. * @param rootUrl the url of the texture
  121715. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121716. * @returns the fallback texture
  121717. */
  121718. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121719. /**
  121720. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  121721. * @param data contains the texture data
  121722. * @param texture defines the BabylonJS internal texture
  121723. * @param createPolynomials will be true if polynomials have been requested
  121724. * @param onLoad defines the callback to trigger once the texture is ready
  121725. * @param onError defines the callback to trigger in case of error
  121726. */
  121727. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121728. /**
  121729. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121730. * @param data contains the texture data
  121731. * @param texture defines the BabylonJS internal texture
  121732. * @param callback defines the method to call once ready to upload
  121733. */
  121734. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  121735. }
  121736. }
  121737. declare module BABYLON {
  121738. /**
  121739. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  121740. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  121741. */
  121742. export class KhronosTextureContainer {
  121743. /** contents of the KTX container file */
  121744. arrayBuffer: any;
  121745. private static HEADER_LEN;
  121746. private static COMPRESSED_2D;
  121747. private static COMPRESSED_3D;
  121748. private static TEX_2D;
  121749. private static TEX_3D;
  121750. /**
  121751. * Gets the openGL type
  121752. */
  121753. glType: number;
  121754. /**
  121755. * Gets the openGL type size
  121756. */
  121757. glTypeSize: number;
  121758. /**
  121759. * Gets the openGL format
  121760. */
  121761. glFormat: number;
  121762. /**
  121763. * Gets the openGL internal format
  121764. */
  121765. glInternalFormat: number;
  121766. /**
  121767. * Gets the base internal format
  121768. */
  121769. glBaseInternalFormat: number;
  121770. /**
  121771. * Gets image width in pixel
  121772. */
  121773. pixelWidth: number;
  121774. /**
  121775. * Gets image height in pixel
  121776. */
  121777. pixelHeight: number;
  121778. /**
  121779. * Gets image depth in pixels
  121780. */
  121781. pixelDepth: number;
  121782. /**
  121783. * Gets the number of array elements
  121784. */
  121785. numberOfArrayElements: number;
  121786. /**
  121787. * Gets the number of faces
  121788. */
  121789. numberOfFaces: number;
  121790. /**
  121791. * Gets the number of mipmap levels
  121792. */
  121793. numberOfMipmapLevels: number;
  121794. /**
  121795. * Gets the bytes of key value data
  121796. */
  121797. bytesOfKeyValueData: number;
  121798. /**
  121799. * Gets the load type
  121800. */
  121801. loadType: number;
  121802. /**
  121803. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  121804. */
  121805. isInvalid: boolean;
  121806. /**
  121807. * Creates a new KhronosTextureContainer
  121808. * @param arrayBuffer contents of the KTX container file
  121809. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  121810. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  121811. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  121812. */
  121813. constructor(
  121814. /** contents of the KTX container file */
  121815. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  121816. /**
  121817. * Uploads KTX content to a Babylon Texture.
  121818. * It is assumed that the texture has already been created & is currently bound
  121819. * @hidden
  121820. */
  121821. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  121822. private _upload2DCompressedLevels;
  121823. }
  121824. }
  121825. declare module BABYLON {
  121826. /**
  121827. * Implementation of the KTX Texture Loader.
  121828. * @hidden
  121829. */
  121830. export class _KTXTextureLoader implements IInternalTextureLoader {
  121831. /**
  121832. * Defines wether the loader supports cascade loading the different faces.
  121833. */
  121834. readonly supportCascades: boolean;
  121835. /**
  121836. * This returns if the loader support the current file information.
  121837. * @param extension defines the file extension of the file being loaded
  121838. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121839. * @param fallback defines the fallback internal texture if any
  121840. * @param isBase64 defines whether the texture is encoded as a base64
  121841. * @param isBuffer defines whether the texture data are stored as a buffer
  121842. * @returns true if the loader can load the specified file
  121843. */
  121844. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121845. /**
  121846. * Transform the url before loading if required.
  121847. * @param rootUrl the url of the texture
  121848. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121849. * @returns the transformed texture
  121850. */
  121851. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121852. /**
  121853. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121854. * @param rootUrl the url of the texture
  121855. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121856. * @returns the fallback texture
  121857. */
  121858. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121859. /**
  121860. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  121861. * @param data contains the texture data
  121862. * @param texture defines the BabylonJS internal texture
  121863. * @param createPolynomials will be true if polynomials have been requested
  121864. * @param onLoad defines the callback to trigger once the texture is ready
  121865. * @param onError defines the callback to trigger in case of error
  121866. */
  121867. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121868. /**
  121869. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121870. * @param data contains the texture data
  121871. * @param texture defines the BabylonJS internal texture
  121872. * @param callback defines the method to call once ready to upload
  121873. */
  121874. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  121875. }
  121876. }
  121877. declare module BABYLON {
  121878. /** @hidden */
  121879. export var _forceSceneHelpersToBundle: boolean;
  121880. interface Scene {
  121881. /**
  121882. * Creates a default light for the scene.
  121883. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  121884. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  121885. */
  121886. createDefaultLight(replace?: boolean): void;
  121887. /**
  121888. * Creates a default camera for the scene.
  121889. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  121890. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  121891. * @param replace has default false, when true replaces the active camera in the scene
  121892. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  121893. */
  121894. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  121895. /**
  121896. * Creates a default camera and a default light.
  121897. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  121898. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  121899. * @param replace has the default false, when true replaces the active camera/light in the scene
  121900. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  121901. */
  121902. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  121903. /**
  121904. * Creates a new sky box
  121905. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  121906. * @param environmentTexture defines the texture to use as environment texture
  121907. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  121908. * @param scale defines the overall scale of the skybox
  121909. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  121910. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  121911. * @returns a new mesh holding the sky box
  121912. */
  121913. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  121914. /**
  121915. * Creates a new environment
  121916. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  121917. * @param options defines the options you can use to configure the environment
  121918. * @returns the new EnvironmentHelper
  121919. */
  121920. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  121921. /**
  121922. * Creates a new VREXperienceHelper
  121923. * @see http://doc.babylonjs.com/how_to/webvr_helper
  121924. * @param webVROptions defines the options used to create the new VREXperienceHelper
  121925. * @returns a new VREXperienceHelper
  121926. */
  121927. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  121928. /**
  121929. * Creates a new WebXRDefaultExperience
  121930. * @see http://doc.babylonjs.com/how_to/webxr
  121931. * @param options experience options
  121932. * @returns a promise for a new WebXRDefaultExperience
  121933. */
  121934. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  121935. }
  121936. }
  121937. declare module BABYLON {
  121938. /**
  121939. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  121940. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  121941. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  121942. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  121943. */
  121944. export class VideoDome extends TransformNode {
  121945. /**
  121946. * Define the video source as a Monoscopic panoramic 360 video.
  121947. */
  121948. static readonly MODE_MONOSCOPIC: number;
  121949. /**
  121950. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  121951. */
  121952. static readonly MODE_TOPBOTTOM: number;
  121953. /**
  121954. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  121955. */
  121956. static readonly MODE_SIDEBYSIDE: number;
  121957. private _halfDome;
  121958. private _useDirectMapping;
  121959. /**
  121960. * The video texture being displayed on the sphere
  121961. */
  121962. protected _videoTexture: VideoTexture;
  121963. /**
  121964. * Gets the video texture being displayed on the sphere
  121965. */
  121966. get videoTexture(): VideoTexture;
  121967. /**
  121968. * The skybox material
  121969. */
  121970. protected _material: BackgroundMaterial;
  121971. /**
  121972. * The surface used for the skybox
  121973. */
  121974. protected _mesh: Mesh;
  121975. /**
  121976. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  121977. */
  121978. private _halfDomeMask;
  121979. /**
  121980. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  121981. * Also see the options.resolution property.
  121982. */
  121983. get fovMultiplier(): number;
  121984. set fovMultiplier(value: number);
  121985. private _videoMode;
  121986. /**
  121987. * Gets or set the current video mode for the video. It can be:
  121988. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  121989. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  121990. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  121991. */
  121992. get videoMode(): number;
  121993. set videoMode(value: number);
  121994. /**
  121995. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  121996. *
  121997. */
  121998. get halfDome(): boolean;
  121999. /**
  122000. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  122001. */
  122002. set halfDome(enabled: boolean);
  122003. /**
  122004. * Oberserver used in Stereoscopic VR Mode.
  122005. */
  122006. private _onBeforeCameraRenderObserver;
  122007. /**
  122008. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  122009. * @param name Element's name, child elements will append suffixes for their own names.
  122010. * @param urlsOrVideo defines the url(s) or the video element to use
  122011. * @param options An object containing optional or exposed sub element properties
  122012. */
  122013. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  122014. resolution?: number;
  122015. clickToPlay?: boolean;
  122016. autoPlay?: boolean;
  122017. loop?: boolean;
  122018. size?: number;
  122019. poster?: string;
  122020. faceForward?: boolean;
  122021. useDirectMapping?: boolean;
  122022. halfDomeMode?: boolean;
  122023. }, scene: Scene);
  122024. private _changeVideoMode;
  122025. /**
  122026. * Releases resources associated with this node.
  122027. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  122028. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  122029. */
  122030. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  122031. }
  122032. }
  122033. declare module BABYLON {
  122034. /**
  122035. * This class can be used to get instrumentation data from a Babylon engine
  122036. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  122037. */
  122038. export class EngineInstrumentation implements IDisposable {
  122039. /**
  122040. * Define the instrumented engine.
  122041. */
  122042. engine: Engine;
  122043. private _captureGPUFrameTime;
  122044. private _gpuFrameTimeToken;
  122045. private _gpuFrameTime;
  122046. private _captureShaderCompilationTime;
  122047. private _shaderCompilationTime;
  122048. private _onBeginFrameObserver;
  122049. private _onEndFrameObserver;
  122050. private _onBeforeShaderCompilationObserver;
  122051. private _onAfterShaderCompilationObserver;
  122052. /**
  122053. * Gets the perf counter used for GPU frame time
  122054. */
  122055. get gpuFrameTimeCounter(): PerfCounter;
  122056. /**
  122057. * Gets the GPU frame time capture status
  122058. */
  122059. get captureGPUFrameTime(): boolean;
  122060. /**
  122061. * Enable or disable the GPU frame time capture
  122062. */
  122063. set captureGPUFrameTime(value: boolean);
  122064. /**
  122065. * Gets the perf counter used for shader compilation time
  122066. */
  122067. get shaderCompilationTimeCounter(): PerfCounter;
  122068. /**
  122069. * Gets the shader compilation time capture status
  122070. */
  122071. get captureShaderCompilationTime(): boolean;
  122072. /**
  122073. * Enable or disable the shader compilation time capture
  122074. */
  122075. set captureShaderCompilationTime(value: boolean);
  122076. /**
  122077. * Instantiates a new engine instrumentation.
  122078. * This class can be used to get instrumentation data from a Babylon engine
  122079. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  122080. * @param engine Defines the engine to instrument
  122081. */
  122082. constructor(
  122083. /**
  122084. * Define the instrumented engine.
  122085. */
  122086. engine: Engine);
  122087. /**
  122088. * Dispose and release associated resources.
  122089. */
  122090. dispose(): void;
  122091. }
  122092. }
  122093. declare module BABYLON {
  122094. /**
  122095. * This class can be used to get instrumentation data from a Babylon engine
  122096. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  122097. */
  122098. export class SceneInstrumentation implements IDisposable {
  122099. /**
  122100. * Defines the scene to instrument
  122101. */
  122102. scene: Scene;
  122103. private _captureActiveMeshesEvaluationTime;
  122104. private _activeMeshesEvaluationTime;
  122105. private _captureRenderTargetsRenderTime;
  122106. private _renderTargetsRenderTime;
  122107. private _captureFrameTime;
  122108. private _frameTime;
  122109. private _captureRenderTime;
  122110. private _renderTime;
  122111. private _captureInterFrameTime;
  122112. private _interFrameTime;
  122113. private _captureParticlesRenderTime;
  122114. private _particlesRenderTime;
  122115. private _captureSpritesRenderTime;
  122116. private _spritesRenderTime;
  122117. private _capturePhysicsTime;
  122118. private _physicsTime;
  122119. private _captureAnimationsTime;
  122120. private _animationsTime;
  122121. private _captureCameraRenderTime;
  122122. private _cameraRenderTime;
  122123. private _onBeforeActiveMeshesEvaluationObserver;
  122124. private _onAfterActiveMeshesEvaluationObserver;
  122125. private _onBeforeRenderTargetsRenderObserver;
  122126. private _onAfterRenderTargetsRenderObserver;
  122127. private _onAfterRenderObserver;
  122128. private _onBeforeDrawPhaseObserver;
  122129. private _onAfterDrawPhaseObserver;
  122130. private _onBeforeAnimationsObserver;
  122131. private _onBeforeParticlesRenderingObserver;
  122132. private _onAfterParticlesRenderingObserver;
  122133. private _onBeforeSpritesRenderingObserver;
  122134. private _onAfterSpritesRenderingObserver;
  122135. private _onBeforePhysicsObserver;
  122136. private _onAfterPhysicsObserver;
  122137. private _onAfterAnimationsObserver;
  122138. private _onBeforeCameraRenderObserver;
  122139. private _onAfterCameraRenderObserver;
  122140. /**
  122141. * Gets the perf counter used for active meshes evaluation time
  122142. */
  122143. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  122144. /**
  122145. * Gets the active meshes evaluation time capture status
  122146. */
  122147. get captureActiveMeshesEvaluationTime(): boolean;
  122148. /**
  122149. * Enable or disable the active meshes evaluation time capture
  122150. */
  122151. set captureActiveMeshesEvaluationTime(value: boolean);
  122152. /**
  122153. * Gets the perf counter used for render targets render time
  122154. */
  122155. get renderTargetsRenderTimeCounter(): PerfCounter;
  122156. /**
  122157. * Gets the render targets render time capture status
  122158. */
  122159. get captureRenderTargetsRenderTime(): boolean;
  122160. /**
  122161. * Enable or disable the render targets render time capture
  122162. */
  122163. set captureRenderTargetsRenderTime(value: boolean);
  122164. /**
  122165. * Gets the perf counter used for particles render time
  122166. */
  122167. get particlesRenderTimeCounter(): PerfCounter;
  122168. /**
  122169. * Gets the particles render time capture status
  122170. */
  122171. get captureParticlesRenderTime(): boolean;
  122172. /**
  122173. * Enable or disable the particles render time capture
  122174. */
  122175. set captureParticlesRenderTime(value: boolean);
  122176. /**
  122177. * Gets the perf counter used for sprites render time
  122178. */
  122179. get spritesRenderTimeCounter(): PerfCounter;
  122180. /**
  122181. * Gets the sprites render time capture status
  122182. */
  122183. get captureSpritesRenderTime(): boolean;
  122184. /**
  122185. * Enable or disable the sprites render time capture
  122186. */
  122187. set captureSpritesRenderTime(value: boolean);
  122188. /**
  122189. * Gets the perf counter used for physics time
  122190. */
  122191. get physicsTimeCounter(): PerfCounter;
  122192. /**
  122193. * Gets the physics time capture status
  122194. */
  122195. get capturePhysicsTime(): boolean;
  122196. /**
  122197. * Enable or disable the physics time capture
  122198. */
  122199. set capturePhysicsTime(value: boolean);
  122200. /**
  122201. * Gets the perf counter used for animations time
  122202. */
  122203. get animationsTimeCounter(): PerfCounter;
  122204. /**
  122205. * Gets the animations time capture status
  122206. */
  122207. get captureAnimationsTime(): boolean;
  122208. /**
  122209. * Enable or disable the animations time capture
  122210. */
  122211. set captureAnimationsTime(value: boolean);
  122212. /**
  122213. * Gets the perf counter used for frame time capture
  122214. */
  122215. get frameTimeCounter(): PerfCounter;
  122216. /**
  122217. * Gets the frame time capture status
  122218. */
  122219. get captureFrameTime(): boolean;
  122220. /**
  122221. * Enable or disable the frame time capture
  122222. */
  122223. set captureFrameTime(value: boolean);
  122224. /**
  122225. * Gets the perf counter used for inter-frames time capture
  122226. */
  122227. get interFrameTimeCounter(): PerfCounter;
  122228. /**
  122229. * Gets the inter-frames time capture status
  122230. */
  122231. get captureInterFrameTime(): boolean;
  122232. /**
  122233. * Enable or disable the inter-frames time capture
  122234. */
  122235. set captureInterFrameTime(value: boolean);
  122236. /**
  122237. * Gets the perf counter used for render time capture
  122238. */
  122239. get renderTimeCounter(): PerfCounter;
  122240. /**
  122241. * Gets the render time capture status
  122242. */
  122243. get captureRenderTime(): boolean;
  122244. /**
  122245. * Enable or disable the render time capture
  122246. */
  122247. set captureRenderTime(value: boolean);
  122248. /**
  122249. * Gets the perf counter used for camera render time capture
  122250. */
  122251. get cameraRenderTimeCounter(): PerfCounter;
  122252. /**
  122253. * Gets the camera render time capture status
  122254. */
  122255. get captureCameraRenderTime(): boolean;
  122256. /**
  122257. * Enable or disable the camera render time capture
  122258. */
  122259. set captureCameraRenderTime(value: boolean);
  122260. /**
  122261. * Gets the perf counter used for draw calls
  122262. */
  122263. get drawCallsCounter(): PerfCounter;
  122264. /**
  122265. * Instantiates a new scene instrumentation.
  122266. * This class can be used to get instrumentation data from a Babylon engine
  122267. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  122268. * @param scene Defines the scene to instrument
  122269. */
  122270. constructor(
  122271. /**
  122272. * Defines the scene to instrument
  122273. */
  122274. scene: Scene);
  122275. /**
  122276. * Dispose and release associated resources.
  122277. */
  122278. dispose(): void;
  122279. }
  122280. }
  122281. declare module BABYLON {
  122282. /** @hidden */
  122283. export var glowMapGenerationPixelShader: {
  122284. name: string;
  122285. shader: string;
  122286. };
  122287. }
  122288. declare module BABYLON {
  122289. /** @hidden */
  122290. export var glowMapGenerationVertexShader: {
  122291. name: string;
  122292. shader: string;
  122293. };
  122294. }
  122295. declare module BABYLON {
  122296. /**
  122297. * Effect layer options. This helps customizing the behaviour
  122298. * of the effect layer.
  122299. */
  122300. export interface IEffectLayerOptions {
  122301. /**
  122302. * Multiplication factor apply to the canvas size to compute the render target size
  122303. * used to generated the objects (the smaller the faster).
  122304. */
  122305. mainTextureRatio: number;
  122306. /**
  122307. * Enforces a fixed size texture to ensure effect stability across devices.
  122308. */
  122309. mainTextureFixedSize?: number;
  122310. /**
  122311. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  122312. */
  122313. alphaBlendingMode: number;
  122314. /**
  122315. * The camera attached to the layer.
  122316. */
  122317. camera: Nullable<Camera>;
  122318. /**
  122319. * The rendering group to draw the layer in.
  122320. */
  122321. renderingGroupId: number;
  122322. }
  122323. /**
  122324. * The effect layer Helps adding post process effect blended with the main pass.
  122325. *
  122326. * This can be for instance use to generate glow or higlight effects on the scene.
  122327. *
  122328. * The effect layer class can not be used directly and is intented to inherited from to be
  122329. * customized per effects.
  122330. */
  122331. export abstract class EffectLayer {
  122332. private _vertexBuffers;
  122333. private _indexBuffer;
  122334. private _cachedDefines;
  122335. private _effectLayerMapGenerationEffect;
  122336. private _effectLayerOptions;
  122337. private _mergeEffect;
  122338. protected _scene: Scene;
  122339. protected _engine: Engine;
  122340. protected _maxSize: number;
  122341. protected _mainTextureDesiredSize: ISize;
  122342. protected _mainTexture: RenderTargetTexture;
  122343. protected _shouldRender: boolean;
  122344. protected _postProcesses: PostProcess[];
  122345. protected _textures: BaseTexture[];
  122346. protected _emissiveTextureAndColor: {
  122347. texture: Nullable<BaseTexture>;
  122348. color: Color4;
  122349. };
  122350. /**
  122351. * The name of the layer
  122352. */
  122353. name: string;
  122354. /**
  122355. * The clear color of the texture used to generate the glow map.
  122356. */
  122357. neutralColor: Color4;
  122358. /**
  122359. * Specifies wether the highlight layer is enabled or not.
  122360. */
  122361. isEnabled: boolean;
  122362. /**
  122363. * Gets the camera attached to the layer.
  122364. */
  122365. get camera(): Nullable<Camera>;
  122366. /**
  122367. * Gets the rendering group id the layer should render in.
  122368. */
  122369. get renderingGroupId(): number;
  122370. set renderingGroupId(renderingGroupId: number);
  122371. /**
  122372. * An event triggered when the effect layer has been disposed.
  122373. */
  122374. onDisposeObservable: Observable<EffectLayer>;
  122375. /**
  122376. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  122377. */
  122378. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  122379. /**
  122380. * An event triggered when the generated texture is being merged in the scene.
  122381. */
  122382. onBeforeComposeObservable: Observable<EffectLayer>;
  122383. /**
  122384. * An event triggered when the mesh is rendered into the effect render target.
  122385. */
  122386. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  122387. /**
  122388. * An event triggered after the mesh has been rendered into the effect render target.
  122389. */
  122390. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  122391. /**
  122392. * An event triggered when the generated texture has been merged in the scene.
  122393. */
  122394. onAfterComposeObservable: Observable<EffectLayer>;
  122395. /**
  122396. * An event triggered when the efffect layer changes its size.
  122397. */
  122398. onSizeChangedObservable: Observable<EffectLayer>;
  122399. /** @hidden */
  122400. static _SceneComponentInitialization: (scene: Scene) => void;
  122401. /**
  122402. * Instantiates a new effect Layer and references it in the scene.
  122403. * @param name The name of the layer
  122404. * @param scene The scene to use the layer in
  122405. */
  122406. constructor(
  122407. /** The Friendly of the effect in the scene */
  122408. name: string, scene: Scene);
  122409. /**
  122410. * Get the effect name of the layer.
  122411. * @return The effect name
  122412. */
  122413. abstract getEffectName(): string;
  122414. /**
  122415. * Checks for the readiness of the element composing the layer.
  122416. * @param subMesh the mesh to check for
  122417. * @param useInstances specify wether or not to use instances to render the mesh
  122418. * @return true if ready otherwise, false
  122419. */
  122420. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122421. /**
  122422. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  122423. * @returns true if the effect requires stencil during the main canvas render pass.
  122424. */
  122425. abstract needStencil(): boolean;
  122426. /**
  122427. * Create the merge effect. This is the shader use to blit the information back
  122428. * to the main canvas at the end of the scene rendering.
  122429. * @returns The effect containing the shader used to merge the effect on the main canvas
  122430. */
  122431. protected abstract _createMergeEffect(): Effect;
  122432. /**
  122433. * Creates the render target textures and post processes used in the effect layer.
  122434. */
  122435. protected abstract _createTextureAndPostProcesses(): void;
  122436. /**
  122437. * Implementation specific of rendering the generating effect on the main canvas.
  122438. * @param effect The effect used to render through
  122439. */
  122440. protected abstract _internalRender(effect: Effect): void;
  122441. /**
  122442. * Sets the required values for both the emissive texture and and the main color.
  122443. */
  122444. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  122445. /**
  122446. * Free any resources and references associated to a mesh.
  122447. * Internal use
  122448. * @param mesh The mesh to free.
  122449. */
  122450. abstract _disposeMesh(mesh: Mesh): void;
  122451. /**
  122452. * Serializes this layer (Glow or Highlight for example)
  122453. * @returns a serialized layer object
  122454. */
  122455. abstract serialize?(): any;
  122456. /**
  122457. * Initializes the effect layer with the required options.
  122458. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  122459. */
  122460. protected _init(options: Partial<IEffectLayerOptions>): void;
  122461. /**
  122462. * Generates the index buffer of the full screen quad blending to the main canvas.
  122463. */
  122464. private _generateIndexBuffer;
  122465. /**
  122466. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  122467. */
  122468. private _generateVertexBuffer;
  122469. /**
  122470. * Sets the main texture desired size which is the closest power of two
  122471. * of the engine canvas size.
  122472. */
  122473. private _setMainTextureSize;
  122474. /**
  122475. * Creates the main texture for the effect layer.
  122476. */
  122477. protected _createMainTexture(): void;
  122478. /**
  122479. * Adds specific effects defines.
  122480. * @param defines The defines to add specifics to.
  122481. */
  122482. protected _addCustomEffectDefines(defines: string[]): void;
  122483. /**
  122484. * Checks for the readiness of the element composing the layer.
  122485. * @param subMesh the mesh to check for
  122486. * @param useInstances specify wether or not to use instances to render the mesh
  122487. * @param emissiveTexture the associated emissive texture used to generate the glow
  122488. * @return true if ready otherwise, false
  122489. */
  122490. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  122491. /**
  122492. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  122493. */
  122494. render(): void;
  122495. /**
  122496. * Determine if a given mesh will be used in the current effect.
  122497. * @param mesh mesh to test
  122498. * @returns true if the mesh will be used
  122499. */
  122500. hasMesh(mesh: AbstractMesh): boolean;
  122501. /**
  122502. * Returns true if the layer contains information to display, otherwise false.
  122503. * @returns true if the glow layer should be rendered
  122504. */
  122505. shouldRender(): boolean;
  122506. /**
  122507. * Returns true if the mesh should render, otherwise false.
  122508. * @param mesh The mesh to render
  122509. * @returns true if it should render otherwise false
  122510. */
  122511. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  122512. /**
  122513. * Returns true if the mesh can be rendered, otherwise false.
  122514. * @param mesh The mesh to render
  122515. * @param material The material used on the mesh
  122516. * @returns true if it can be rendered otherwise false
  122517. */
  122518. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  122519. /**
  122520. * Returns true if the mesh should render, otherwise false.
  122521. * @param mesh The mesh to render
  122522. * @returns true if it should render otherwise false
  122523. */
  122524. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  122525. /**
  122526. * Renders the submesh passed in parameter to the generation map.
  122527. */
  122528. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  122529. /**
  122530. * Defines wether the current material of the mesh should be use to render the effect.
  122531. * @param mesh defines the current mesh to render
  122532. */
  122533. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  122534. /**
  122535. * Rebuild the required buffers.
  122536. * @hidden Internal use only.
  122537. */
  122538. _rebuild(): void;
  122539. /**
  122540. * Dispose only the render target textures and post process.
  122541. */
  122542. private _disposeTextureAndPostProcesses;
  122543. /**
  122544. * Dispose the highlight layer and free resources.
  122545. */
  122546. dispose(): void;
  122547. /**
  122548. * Gets the class name of the effect layer
  122549. * @returns the string with the class name of the effect layer
  122550. */
  122551. getClassName(): string;
  122552. /**
  122553. * Creates an effect layer from parsed effect layer data
  122554. * @param parsedEffectLayer defines effect layer data
  122555. * @param scene defines the current scene
  122556. * @param rootUrl defines the root URL containing the effect layer information
  122557. * @returns a parsed effect Layer
  122558. */
  122559. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  122560. }
  122561. }
  122562. declare module BABYLON {
  122563. interface AbstractScene {
  122564. /**
  122565. * The list of effect layers (highlights/glow) added to the scene
  122566. * @see http://doc.babylonjs.com/how_to/highlight_layer
  122567. * @see http://doc.babylonjs.com/how_to/glow_layer
  122568. */
  122569. effectLayers: Array<EffectLayer>;
  122570. /**
  122571. * Removes the given effect layer from this scene.
  122572. * @param toRemove defines the effect layer to remove
  122573. * @returns the index of the removed effect layer
  122574. */
  122575. removeEffectLayer(toRemove: EffectLayer): number;
  122576. /**
  122577. * Adds the given effect layer to this scene
  122578. * @param newEffectLayer defines the effect layer to add
  122579. */
  122580. addEffectLayer(newEffectLayer: EffectLayer): void;
  122581. }
  122582. /**
  122583. * Defines the layer scene component responsible to manage any effect layers
  122584. * in a given scene.
  122585. */
  122586. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  122587. /**
  122588. * The component name helpfull to identify the component in the list of scene components.
  122589. */
  122590. readonly name: string;
  122591. /**
  122592. * The scene the component belongs to.
  122593. */
  122594. scene: Scene;
  122595. private _engine;
  122596. private _renderEffects;
  122597. private _needStencil;
  122598. private _previousStencilState;
  122599. /**
  122600. * Creates a new instance of the component for the given scene
  122601. * @param scene Defines the scene to register the component in
  122602. */
  122603. constructor(scene: Scene);
  122604. /**
  122605. * Registers the component in a given scene
  122606. */
  122607. register(): void;
  122608. /**
  122609. * Rebuilds the elements related to this component in case of
  122610. * context lost for instance.
  122611. */
  122612. rebuild(): void;
  122613. /**
  122614. * Serializes the component data to the specified json object
  122615. * @param serializationObject The object to serialize to
  122616. */
  122617. serialize(serializationObject: any): void;
  122618. /**
  122619. * Adds all the elements from the container to the scene
  122620. * @param container the container holding the elements
  122621. */
  122622. addFromContainer(container: AbstractScene): void;
  122623. /**
  122624. * Removes all the elements in the container from the scene
  122625. * @param container contains the elements to remove
  122626. * @param dispose if the removed element should be disposed (default: false)
  122627. */
  122628. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  122629. /**
  122630. * Disposes the component and the associated ressources.
  122631. */
  122632. dispose(): void;
  122633. private _isReadyForMesh;
  122634. private _renderMainTexture;
  122635. private _setStencil;
  122636. private _setStencilBack;
  122637. private _draw;
  122638. private _drawCamera;
  122639. private _drawRenderingGroup;
  122640. }
  122641. }
  122642. declare module BABYLON {
  122643. /** @hidden */
  122644. export var glowMapMergePixelShader: {
  122645. name: string;
  122646. shader: string;
  122647. };
  122648. }
  122649. declare module BABYLON {
  122650. /** @hidden */
  122651. export var glowMapMergeVertexShader: {
  122652. name: string;
  122653. shader: string;
  122654. };
  122655. }
  122656. declare module BABYLON {
  122657. interface AbstractScene {
  122658. /**
  122659. * Return a the first highlight layer of the scene with a given name.
  122660. * @param name The name of the highlight layer to look for.
  122661. * @return The highlight layer if found otherwise null.
  122662. */
  122663. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  122664. }
  122665. /**
  122666. * Glow layer options. This helps customizing the behaviour
  122667. * of the glow layer.
  122668. */
  122669. export interface IGlowLayerOptions {
  122670. /**
  122671. * Multiplication factor apply to the canvas size to compute the render target size
  122672. * used to generated the glowing objects (the smaller the faster).
  122673. */
  122674. mainTextureRatio: number;
  122675. /**
  122676. * Enforces a fixed size texture to ensure resize independant blur.
  122677. */
  122678. mainTextureFixedSize?: number;
  122679. /**
  122680. * How big is the kernel of the blur texture.
  122681. */
  122682. blurKernelSize: number;
  122683. /**
  122684. * The camera attached to the layer.
  122685. */
  122686. camera: Nullable<Camera>;
  122687. /**
  122688. * Enable MSAA by chosing the number of samples.
  122689. */
  122690. mainTextureSamples?: number;
  122691. /**
  122692. * The rendering group to draw the layer in.
  122693. */
  122694. renderingGroupId: number;
  122695. }
  122696. /**
  122697. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  122698. *
  122699. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  122700. *
  122701. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  122702. */
  122703. export class GlowLayer extends EffectLayer {
  122704. /**
  122705. * Effect Name of the layer.
  122706. */
  122707. static readonly EffectName: string;
  122708. /**
  122709. * The default blur kernel size used for the glow.
  122710. */
  122711. static DefaultBlurKernelSize: number;
  122712. /**
  122713. * The default texture size ratio used for the glow.
  122714. */
  122715. static DefaultTextureRatio: number;
  122716. /**
  122717. * Sets the kernel size of the blur.
  122718. */
  122719. set blurKernelSize(value: number);
  122720. /**
  122721. * Gets the kernel size of the blur.
  122722. */
  122723. get blurKernelSize(): number;
  122724. /**
  122725. * Sets the glow intensity.
  122726. */
  122727. set intensity(value: number);
  122728. /**
  122729. * Gets the glow intensity.
  122730. */
  122731. get intensity(): number;
  122732. private _options;
  122733. private _intensity;
  122734. private _horizontalBlurPostprocess1;
  122735. private _verticalBlurPostprocess1;
  122736. private _horizontalBlurPostprocess2;
  122737. private _verticalBlurPostprocess2;
  122738. private _blurTexture1;
  122739. private _blurTexture2;
  122740. private _postProcesses1;
  122741. private _postProcesses2;
  122742. private _includedOnlyMeshes;
  122743. private _excludedMeshes;
  122744. private _meshesUsingTheirOwnMaterials;
  122745. /**
  122746. * Callback used to let the user override the color selection on a per mesh basis
  122747. */
  122748. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  122749. /**
  122750. * Callback used to let the user override the texture selection on a per mesh basis
  122751. */
  122752. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  122753. /**
  122754. * Instantiates a new glow Layer and references it to the scene.
  122755. * @param name The name of the layer
  122756. * @param scene The scene to use the layer in
  122757. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  122758. */
  122759. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  122760. /**
  122761. * Get the effect name of the layer.
  122762. * @return The effect name
  122763. */
  122764. getEffectName(): string;
  122765. /**
  122766. * Create the merge effect. This is the shader use to blit the information back
  122767. * to the main canvas at the end of the scene rendering.
  122768. */
  122769. protected _createMergeEffect(): Effect;
  122770. /**
  122771. * Creates the render target textures and post processes used in the glow layer.
  122772. */
  122773. protected _createTextureAndPostProcesses(): void;
  122774. /**
  122775. * Checks for the readiness of the element composing the layer.
  122776. * @param subMesh the mesh to check for
  122777. * @param useInstances specify wether or not to use instances to render the mesh
  122778. * @param emissiveTexture the associated emissive texture used to generate the glow
  122779. * @return true if ready otherwise, false
  122780. */
  122781. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122782. /**
  122783. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  122784. */
  122785. needStencil(): boolean;
  122786. /**
  122787. * Returns true if the mesh can be rendered, otherwise false.
  122788. * @param mesh The mesh to render
  122789. * @param material The material used on the mesh
  122790. * @returns true if it can be rendered otherwise false
  122791. */
  122792. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  122793. /**
  122794. * Implementation specific of rendering the generating effect on the main canvas.
  122795. * @param effect The effect used to render through
  122796. */
  122797. protected _internalRender(effect: Effect): void;
  122798. /**
  122799. * Sets the required values for both the emissive texture and and the main color.
  122800. */
  122801. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  122802. /**
  122803. * Returns true if the mesh should render, otherwise false.
  122804. * @param mesh The mesh to render
  122805. * @returns true if it should render otherwise false
  122806. */
  122807. protected _shouldRenderMesh(mesh: Mesh): boolean;
  122808. /**
  122809. * Adds specific effects defines.
  122810. * @param defines The defines to add specifics to.
  122811. */
  122812. protected _addCustomEffectDefines(defines: string[]): void;
  122813. /**
  122814. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  122815. * @param mesh The mesh to exclude from the glow layer
  122816. */
  122817. addExcludedMesh(mesh: Mesh): void;
  122818. /**
  122819. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  122820. * @param mesh The mesh to remove
  122821. */
  122822. removeExcludedMesh(mesh: Mesh): void;
  122823. /**
  122824. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  122825. * @param mesh The mesh to include in the glow layer
  122826. */
  122827. addIncludedOnlyMesh(mesh: Mesh): void;
  122828. /**
  122829. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  122830. * @param mesh The mesh to remove
  122831. */
  122832. removeIncludedOnlyMesh(mesh: Mesh): void;
  122833. /**
  122834. * Determine if a given mesh will be used in the glow layer
  122835. * @param mesh The mesh to test
  122836. * @returns true if the mesh will be highlighted by the current glow layer
  122837. */
  122838. hasMesh(mesh: AbstractMesh): boolean;
  122839. /**
  122840. * Defines wether the current material of the mesh should be use to render the effect.
  122841. * @param mesh defines the current mesh to render
  122842. */
  122843. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  122844. /**
  122845. * Add a mesh to be rendered through its own material and not with emissive only.
  122846. * @param mesh The mesh for which we need to use its material
  122847. */
  122848. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  122849. /**
  122850. * Remove a mesh from being rendered through its own material and not with emissive only.
  122851. * @param mesh The mesh for which we need to not use its material
  122852. */
  122853. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  122854. /**
  122855. * Free any resources and references associated to a mesh.
  122856. * Internal use
  122857. * @param mesh The mesh to free.
  122858. * @hidden
  122859. */
  122860. _disposeMesh(mesh: Mesh): void;
  122861. /**
  122862. * Gets the class name of the effect layer
  122863. * @returns the string with the class name of the effect layer
  122864. */
  122865. getClassName(): string;
  122866. /**
  122867. * Serializes this glow layer
  122868. * @returns a serialized glow layer object
  122869. */
  122870. serialize(): any;
  122871. /**
  122872. * Creates a Glow Layer from parsed glow layer data
  122873. * @param parsedGlowLayer defines glow layer data
  122874. * @param scene defines the current scene
  122875. * @param rootUrl defines the root URL containing the glow layer information
  122876. * @returns a parsed Glow Layer
  122877. */
  122878. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  122879. }
  122880. }
  122881. declare module BABYLON {
  122882. /** @hidden */
  122883. export var glowBlurPostProcessPixelShader: {
  122884. name: string;
  122885. shader: string;
  122886. };
  122887. }
  122888. declare module BABYLON {
  122889. interface AbstractScene {
  122890. /**
  122891. * Return a the first highlight layer of the scene with a given name.
  122892. * @param name The name of the highlight layer to look for.
  122893. * @return The highlight layer if found otherwise null.
  122894. */
  122895. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  122896. }
  122897. /**
  122898. * Highlight layer options. This helps customizing the behaviour
  122899. * of the highlight layer.
  122900. */
  122901. export interface IHighlightLayerOptions {
  122902. /**
  122903. * Multiplication factor apply to the canvas size to compute the render target size
  122904. * used to generated the glowing objects (the smaller the faster).
  122905. */
  122906. mainTextureRatio: number;
  122907. /**
  122908. * Enforces a fixed size texture to ensure resize independant blur.
  122909. */
  122910. mainTextureFixedSize?: number;
  122911. /**
  122912. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  122913. * of the picture to blur (the smaller the faster).
  122914. */
  122915. blurTextureSizeRatio: number;
  122916. /**
  122917. * How big in texel of the blur texture is the vertical blur.
  122918. */
  122919. blurVerticalSize: number;
  122920. /**
  122921. * How big in texel of the blur texture is the horizontal blur.
  122922. */
  122923. blurHorizontalSize: number;
  122924. /**
  122925. * Alpha blending mode used to apply the blur. Default is combine.
  122926. */
  122927. alphaBlendingMode: number;
  122928. /**
  122929. * The camera attached to the layer.
  122930. */
  122931. camera: Nullable<Camera>;
  122932. /**
  122933. * Should we display highlight as a solid stroke?
  122934. */
  122935. isStroke?: boolean;
  122936. /**
  122937. * The rendering group to draw the layer in.
  122938. */
  122939. renderingGroupId: number;
  122940. }
  122941. /**
  122942. * The highlight layer Helps adding a glow effect around a mesh.
  122943. *
  122944. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  122945. * glowy meshes to your scene.
  122946. *
  122947. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  122948. */
  122949. export class HighlightLayer extends EffectLayer {
  122950. name: string;
  122951. /**
  122952. * Effect Name of the highlight layer.
  122953. */
  122954. static readonly EffectName: string;
  122955. /**
  122956. * The neutral color used during the preparation of the glow effect.
  122957. * This is black by default as the blend operation is a blend operation.
  122958. */
  122959. static NeutralColor: Color4;
  122960. /**
  122961. * Stencil value used for glowing meshes.
  122962. */
  122963. static GlowingMeshStencilReference: number;
  122964. /**
  122965. * Stencil value used for the other meshes in the scene.
  122966. */
  122967. static NormalMeshStencilReference: number;
  122968. /**
  122969. * Specifies whether or not the inner glow is ACTIVE in the layer.
  122970. */
  122971. innerGlow: boolean;
  122972. /**
  122973. * Specifies whether or not the outer glow is ACTIVE in the layer.
  122974. */
  122975. outerGlow: boolean;
  122976. /**
  122977. * Specifies the horizontal size of the blur.
  122978. */
  122979. set blurHorizontalSize(value: number);
  122980. /**
  122981. * Specifies the vertical size of the blur.
  122982. */
  122983. set blurVerticalSize(value: number);
  122984. /**
  122985. * Gets the horizontal size of the blur.
  122986. */
  122987. get blurHorizontalSize(): number;
  122988. /**
  122989. * Gets the vertical size of the blur.
  122990. */
  122991. get blurVerticalSize(): number;
  122992. /**
  122993. * An event triggered when the highlight layer is being blurred.
  122994. */
  122995. onBeforeBlurObservable: Observable<HighlightLayer>;
  122996. /**
  122997. * An event triggered when the highlight layer has been blurred.
  122998. */
  122999. onAfterBlurObservable: Observable<HighlightLayer>;
  123000. private _instanceGlowingMeshStencilReference;
  123001. private _options;
  123002. private _downSamplePostprocess;
  123003. private _horizontalBlurPostprocess;
  123004. private _verticalBlurPostprocess;
  123005. private _blurTexture;
  123006. private _meshes;
  123007. private _excludedMeshes;
  123008. /**
  123009. * Instantiates a new highlight Layer and references it to the scene..
  123010. * @param name The name of the layer
  123011. * @param scene The scene to use the layer in
  123012. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  123013. */
  123014. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  123015. /**
  123016. * Get the effect name of the layer.
  123017. * @return The effect name
  123018. */
  123019. getEffectName(): string;
  123020. /**
  123021. * Create the merge effect. This is the shader use to blit the information back
  123022. * to the main canvas at the end of the scene rendering.
  123023. */
  123024. protected _createMergeEffect(): Effect;
  123025. /**
  123026. * Creates the render target textures and post processes used in the highlight layer.
  123027. */
  123028. protected _createTextureAndPostProcesses(): void;
  123029. /**
  123030. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  123031. */
  123032. needStencil(): boolean;
  123033. /**
  123034. * Checks for the readiness of the element composing the layer.
  123035. * @param subMesh the mesh to check for
  123036. * @param useInstances specify wether or not to use instances to render the mesh
  123037. * @param emissiveTexture the associated emissive texture used to generate the glow
  123038. * @return true if ready otherwise, false
  123039. */
  123040. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  123041. /**
  123042. * Implementation specific of rendering the generating effect on the main canvas.
  123043. * @param effect The effect used to render through
  123044. */
  123045. protected _internalRender(effect: Effect): void;
  123046. /**
  123047. * Returns true if the layer contains information to display, otherwise false.
  123048. */
  123049. shouldRender(): boolean;
  123050. /**
  123051. * Returns true if the mesh should render, otherwise false.
  123052. * @param mesh The mesh to render
  123053. * @returns true if it should render otherwise false
  123054. */
  123055. protected _shouldRenderMesh(mesh: Mesh): boolean;
  123056. /**
  123057. * Sets the required values for both the emissive texture and and the main color.
  123058. */
  123059. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  123060. /**
  123061. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  123062. * @param mesh The mesh to exclude from the highlight layer
  123063. */
  123064. addExcludedMesh(mesh: Mesh): void;
  123065. /**
  123066. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  123067. * @param mesh The mesh to highlight
  123068. */
  123069. removeExcludedMesh(mesh: Mesh): void;
  123070. /**
  123071. * Determine if a given mesh will be highlighted by the current HighlightLayer
  123072. * @param mesh mesh to test
  123073. * @returns true if the mesh will be highlighted by the current HighlightLayer
  123074. */
  123075. hasMesh(mesh: AbstractMesh): boolean;
  123076. /**
  123077. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  123078. * @param mesh The mesh to highlight
  123079. * @param color The color of the highlight
  123080. * @param glowEmissiveOnly Extract the glow from the emissive texture
  123081. */
  123082. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  123083. /**
  123084. * Remove a mesh from the highlight layer in order to make it stop glowing.
  123085. * @param mesh The mesh to highlight
  123086. */
  123087. removeMesh(mesh: Mesh): void;
  123088. /**
  123089. * Force the stencil to the normal expected value for none glowing parts
  123090. */
  123091. private _defaultStencilReference;
  123092. /**
  123093. * Free any resources and references associated to a mesh.
  123094. * Internal use
  123095. * @param mesh The mesh to free.
  123096. * @hidden
  123097. */
  123098. _disposeMesh(mesh: Mesh): void;
  123099. /**
  123100. * Dispose the highlight layer and free resources.
  123101. */
  123102. dispose(): void;
  123103. /**
  123104. * Gets the class name of the effect layer
  123105. * @returns the string with the class name of the effect layer
  123106. */
  123107. getClassName(): string;
  123108. /**
  123109. * Serializes this Highlight layer
  123110. * @returns a serialized Highlight layer object
  123111. */
  123112. serialize(): any;
  123113. /**
  123114. * Creates a Highlight layer from parsed Highlight layer data
  123115. * @param parsedHightlightLayer defines the Highlight layer data
  123116. * @param scene defines the current scene
  123117. * @param rootUrl defines the root URL containing the Highlight layer information
  123118. * @returns a parsed Highlight layer
  123119. */
  123120. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  123121. }
  123122. }
  123123. declare module BABYLON {
  123124. interface AbstractScene {
  123125. /**
  123126. * The list of layers (background and foreground) of the scene
  123127. */
  123128. layers: Array<Layer>;
  123129. }
  123130. /**
  123131. * Defines the layer scene component responsible to manage any layers
  123132. * in a given scene.
  123133. */
  123134. export class LayerSceneComponent implements ISceneComponent {
  123135. /**
  123136. * The component name helpfull to identify the component in the list of scene components.
  123137. */
  123138. readonly name: string;
  123139. /**
  123140. * The scene the component belongs to.
  123141. */
  123142. scene: Scene;
  123143. private _engine;
  123144. /**
  123145. * Creates a new instance of the component for the given scene
  123146. * @param scene Defines the scene to register the component in
  123147. */
  123148. constructor(scene: Scene);
  123149. /**
  123150. * Registers the component in a given scene
  123151. */
  123152. register(): void;
  123153. /**
  123154. * Rebuilds the elements related to this component in case of
  123155. * context lost for instance.
  123156. */
  123157. rebuild(): void;
  123158. /**
  123159. * Disposes the component and the associated ressources.
  123160. */
  123161. dispose(): void;
  123162. private _draw;
  123163. private _drawCameraPredicate;
  123164. private _drawCameraBackground;
  123165. private _drawCameraForeground;
  123166. private _drawRenderTargetPredicate;
  123167. private _drawRenderTargetBackground;
  123168. private _drawRenderTargetForeground;
  123169. /**
  123170. * Adds all the elements from the container to the scene
  123171. * @param container the container holding the elements
  123172. */
  123173. addFromContainer(container: AbstractScene): void;
  123174. /**
  123175. * Removes all the elements in the container from the scene
  123176. * @param container contains the elements to remove
  123177. * @param dispose if the removed element should be disposed (default: false)
  123178. */
  123179. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  123180. }
  123181. }
  123182. declare module BABYLON {
  123183. /** @hidden */
  123184. export var layerPixelShader: {
  123185. name: string;
  123186. shader: string;
  123187. };
  123188. }
  123189. declare module BABYLON {
  123190. /** @hidden */
  123191. export var layerVertexShader: {
  123192. name: string;
  123193. shader: string;
  123194. };
  123195. }
  123196. declare module BABYLON {
  123197. /**
  123198. * This represents a full screen 2d layer.
  123199. * This can be useful to display a picture in the background of your scene for instance.
  123200. * @see https://www.babylonjs-playground.com/#08A2BS#1
  123201. */
  123202. export class Layer {
  123203. /**
  123204. * Define the name of the layer.
  123205. */
  123206. name: string;
  123207. /**
  123208. * Define the texture the layer should display.
  123209. */
  123210. texture: Nullable<Texture>;
  123211. /**
  123212. * Is the layer in background or foreground.
  123213. */
  123214. isBackground: boolean;
  123215. /**
  123216. * Define the color of the layer (instead of texture).
  123217. */
  123218. color: Color4;
  123219. /**
  123220. * Define the scale of the layer in order to zoom in out of the texture.
  123221. */
  123222. scale: Vector2;
  123223. /**
  123224. * Define an offset for the layer in order to shift the texture.
  123225. */
  123226. offset: Vector2;
  123227. /**
  123228. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  123229. */
  123230. alphaBlendingMode: number;
  123231. /**
  123232. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  123233. * Alpha test will not mix with the background color in case of transparency.
  123234. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  123235. */
  123236. alphaTest: boolean;
  123237. /**
  123238. * Define a mask to restrict the layer to only some of the scene cameras.
  123239. */
  123240. layerMask: number;
  123241. /**
  123242. * Define the list of render target the layer is visible into.
  123243. */
  123244. renderTargetTextures: RenderTargetTexture[];
  123245. /**
  123246. * Define if the layer is only used in renderTarget or if it also
  123247. * renders in the main frame buffer of the canvas.
  123248. */
  123249. renderOnlyInRenderTargetTextures: boolean;
  123250. private _scene;
  123251. private _vertexBuffers;
  123252. private _indexBuffer;
  123253. private _effect;
  123254. private _previousDefines;
  123255. /**
  123256. * An event triggered when the layer is disposed.
  123257. */
  123258. onDisposeObservable: Observable<Layer>;
  123259. private _onDisposeObserver;
  123260. /**
  123261. * Back compatibility with callback before the onDisposeObservable existed.
  123262. * The set callback will be triggered when the layer has been disposed.
  123263. */
  123264. set onDispose(callback: () => void);
  123265. /**
  123266. * An event triggered before rendering the scene
  123267. */
  123268. onBeforeRenderObservable: Observable<Layer>;
  123269. private _onBeforeRenderObserver;
  123270. /**
  123271. * Back compatibility with callback before the onBeforeRenderObservable existed.
  123272. * The set callback will be triggered just before rendering the layer.
  123273. */
  123274. set onBeforeRender(callback: () => void);
  123275. /**
  123276. * An event triggered after rendering the scene
  123277. */
  123278. onAfterRenderObservable: Observable<Layer>;
  123279. private _onAfterRenderObserver;
  123280. /**
  123281. * Back compatibility with callback before the onAfterRenderObservable existed.
  123282. * The set callback will be triggered just after rendering the layer.
  123283. */
  123284. set onAfterRender(callback: () => void);
  123285. /**
  123286. * Instantiates a new layer.
  123287. * This represents a full screen 2d layer.
  123288. * This can be useful to display a picture in the background of your scene for instance.
  123289. * @see https://www.babylonjs-playground.com/#08A2BS#1
  123290. * @param name Define the name of the layer in the scene
  123291. * @param imgUrl Define the url of the texture to display in the layer
  123292. * @param scene Define the scene the layer belongs to
  123293. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  123294. * @param color Defines a color for the layer
  123295. */
  123296. constructor(
  123297. /**
  123298. * Define the name of the layer.
  123299. */
  123300. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  123301. private _createIndexBuffer;
  123302. /** @hidden */
  123303. _rebuild(): void;
  123304. /**
  123305. * Renders the layer in the scene.
  123306. */
  123307. render(): void;
  123308. /**
  123309. * Disposes and releases the associated ressources.
  123310. */
  123311. dispose(): void;
  123312. }
  123313. }
  123314. declare module BABYLON {
  123315. /** @hidden */
  123316. export var lensFlarePixelShader: {
  123317. name: string;
  123318. shader: string;
  123319. };
  123320. }
  123321. declare module BABYLON {
  123322. /** @hidden */
  123323. export var lensFlareVertexShader: {
  123324. name: string;
  123325. shader: string;
  123326. };
  123327. }
  123328. declare module BABYLON {
  123329. /**
  123330. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  123331. * It is usually composed of several `lensFlare`.
  123332. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123333. */
  123334. export class LensFlareSystem {
  123335. /**
  123336. * Define the name of the lens flare system
  123337. */
  123338. name: string;
  123339. /**
  123340. * List of lens flares used in this system.
  123341. */
  123342. lensFlares: LensFlare[];
  123343. /**
  123344. * Define a limit from the border the lens flare can be visible.
  123345. */
  123346. borderLimit: number;
  123347. /**
  123348. * Define a viewport border we do not want to see the lens flare in.
  123349. */
  123350. viewportBorder: number;
  123351. /**
  123352. * Define a predicate which could limit the list of meshes able to occlude the effect.
  123353. */
  123354. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  123355. /**
  123356. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  123357. */
  123358. layerMask: number;
  123359. /**
  123360. * Define the id of the lens flare system in the scene.
  123361. * (equal to name by default)
  123362. */
  123363. id: string;
  123364. private _scene;
  123365. private _emitter;
  123366. private _vertexBuffers;
  123367. private _indexBuffer;
  123368. private _effect;
  123369. private _positionX;
  123370. private _positionY;
  123371. private _isEnabled;
  123372. /** @hidden */
  123373. static _SceneComponentInitialization: (scene: Scene) => void;
  123374. /**
  123375. * Instantiates a lens flare system.
  123376. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  123377. * It is usually composed of several `lensFlare`.
  123378. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123379. * @param name Define the name of the lens flare system in the scene
  123380. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  123381. * @param scene Define the scene the lens flare system belongs to
  123382. */
  123383. constructor(
  123384. /**
  123385. * Define the name of the lens flare system
  123386. */
  123387. name: string, emitter: any, scene: Scene);
  123388. /**
  123389. * Define if the lens flare system is enabled.
  123390. */
  123391. get isEnabled(): boolean;
  123392. set isEnabled(value: boolean);
  123393. /**
  123394. * Get the scene the effects belongs to.
  123395. * @returns the scene holding the lens flare system
  123396. */
  123397. getScene(): Scene;
  123398. /**
  123399. * Get the emitter of the lens flare system.
  123400. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  123401. * @returns the emitter of the lens flare system
  123402. */
  123403. getEmitter(): any;
  123404. /**
  123405. * Set the emitter of the lens flare system.
  123406. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  123407. * @param newEmitter Define the new emitter of the system
  123408. */
  123409. setEmitter(newEmitter: any): void;
  123410. /**
  123411. * Get the lens flare system emitter position.
  123412. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  123413. * @returns the position
  123414. */
  123415. getEmitterPosition(): Vector3;
  123416. /**
  123417. * @hidden
  123418. */
  123419. computeEffectivePosition(globalViewport: Viewport): boolean;
  123420. /** @hidden */
  123421. _isVisible(): boolean;
  123422. /**
  123423. * @hidden
  123424. */
  123425. render(): boolean;
  123426. /**
  123427. * Dispose and release the lens flare with its associated resources.
  123428. */
  123429. dispose(): void;
  123430. /**
  123431. * Parse a lens flare system from a JSON repressentation
  123432. * @param parsedLensFlareSystem Define the JSON to parse
  123433. * @param scene Define the scene the parsed system should be instantiated in
  123434. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  123435. * @returns the parsed system
  123436. */
  123437. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  123438. /**
  123439. * Serialize the current Lens Flare System into a JSON representation.
  123440. * @returns the serialized JSON
  123441. */
  123442. serialize(): any;
  123443. }
  123444. }
  123445. declare module BABYLON {
  123446. /**
  123447. * This represents one of the lens effect in a `lensFlareSystem`.
  123448. * It controls one of the indiviual texture used in the effect.
  123449. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123450. */
  123451. export class LensFlare {
  123452. /**
  123453. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  123454. */
  123455. size: number;
  123456. /**
  123457. * 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.
  123458. */
  123459. position: number;
  123460. /**
  123461. * Define the lens color.
  123462. */
  123463. color: Color3;
  123464. /**
  123465. * Define the lens texture.
  123466. */
  123467. texture: Nullable<Texture>;
  123468. /**
  123469. * Define the alpha mode to render this particular lens.
  123470. */
  123471. alphaMode: number;
  123472. private _system;
  123473. /**
  123474. * Creates a new Lens Flare.
  123475. * This represents one of the lens effect in a `lensFlareSystem`.
  123476. * It controls one of the indiviual texture used in the effect.
  123477. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123478. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  123479. * @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.
  123480. * @param color Define the lens color
  123481. * @param imgUrl Define the lens texture url
  123482. * @param system Define the `lensFlareSystem` this flare is part of
  123483. * @returns The newly created Lens Flare
  123484. */
  123485. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  123486. /**
  123487. * Instantiates a new Lens Flare.
  123488. * This represents one of the lens effect in a `lensFlareSystem`.
  123489. * It controls one of the indiviual texture used in the effect.
  123490. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123491. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  123492. * @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.
  123493. * @param color Define the lens color
  123494. * @param imgUrl Define the lens texture url
  123495. * @param system Define the `lensFlareSystem` this flare is part of
  123496. */
  123497. constructor(
  123498. /**
  123499. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  123500. */
  123501. size: number,
  123502. /**
  123503. * 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.
  123504. */
  123505. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  123506. /**
  123507. * Dispose and release the lens flare with its associated resources.
  123508. */
  123509. dispose(): void;
  123510. }
  123511. }
  123512. declare module BABYLON {
  123513. interface AbstractScene {
  123514. /**
  123515. * The list of lens flare system added to the scene
  123516. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123517. */
  123518. lensFlareSystems: Array<LensFlareSystem>;
  123519. /**
  123520. * Removes the given lens flare system from this scene.
  123521. * @param toRemove The lens flare system to remove
  123522. * @returns The index of the removed lens flare system
  123523. */
  123524. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  123525. /**
  123526. * Adds the given lens flare system to this scene
  123527. * @param newLensFlareSystem The lens flare system to add
  123528. */
  123529. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  123530. /**
  123531. * Gets a lens flare system using its name
  123532. * @param name defines the name to look for
  123533. * @returns the lens flare system or null if not found
  123534. */
  123535. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  123536. /**
  123537. * Gets a lens flare system using its id
  123538. * @param id defines the id to look for
  123539. * @returns the lens flare system or null if not found
  123540. */
  123541. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  123542. }
  123543. /**
  123544. * Defines the lens flare scene component responsible to manage any lens flares
  123545. * in a given scene.
  123546. */
  123547. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  123548. /**
  123549. * The component name helpfull to identify the component in the list of scene components.
  123550. */
  123551. readonly name: string;
  123552. /**
  123553. * The scene the component belongs to.
  123554. */
  123555. scene: Scene;
  123556. /**
  123557. * Creates a new instance of the component for the given scene
  123558. * @param scene Defines the scene to register the component in
  123559. */
  123560. constructor(scene: Scene);
  123561. /**
  123562. * Registers the component in a given scene
  123563. */
  123564. register(): void;
  123565. /**
  123566. * Rebuilds the elements related to this component in case of
  123567. * context lost for instance.
  123568. */
  123569. rebuild(): void;
  123570. /**
  123571. * Adds all the elements from the container to the scene
  123572. * @param container the container holding the elements
  123573. */
  123574. addFromContainer(container: AbstractScene): void;
  123575. /**
  123576. * Removes all the elements in the container from the scene
  123577. * @param container contains the elements to remove
  123578. * @param dispose if the removed element should be disposed (default: false)
  123579. */
  123580. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  123581. /**
  123582. * Serializes the component data to the specified json object
  123583. * @param serializationObject The object to serialize to
  123584. */
  123585. serialize(serializationObject: any): void;
  123586. /**
  123587. * Disposes the component and the associated ressources.
  123588. */
  123589. dispose(): void;
  123590. private _draw;
  123591. }
  123592. }
  123593. declare module BABYLON {
  123594. /**
  123595. * Defines the shadow generator component responsible to manage any shadow generators
  123596. * in a given scene.
  123597. */
  123598. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  123599. /**
  123600. * The component name helpfull to identify the component in the list of scene components.
  123601. */
  123602. readonly name: string;
  123603. /**
  123604. * The scene the component belongs to.
  123605. */
  123606. scene: Scene;
  123607. /**
  123608. * Creates a new instance of the component for the given scene
  123609. * @param scene Defines the scene to register the component in
  123610. */
  123611. constructor(scene: Scene);
  123612. /**
  123613. * Registers the component in a given scene
  123614. */
  123615. register(): void;
  123616. /**
  123617. * Rebuilds the elements related to this component in case of
  123618. * context lost for instance.
  123619. */
  123620. rebuild(): void;
  123621. /**
  123622. * Serializes the component data to the specified json object
  123623. * @param serializationObject The object to serialize to
  123624. */
  123625. serialize(serializationObject: any): void;
  123626. /**
  123627. * Adds all the elements from the container to the scene
  123628. * @param container the container holding the elements
  123629. */
  123630. addFromContainer(container: AbstractScene): void;
  123631. /**
  123632. * Removes all the elements in the container from the scene
  123633. * @param container contains the elements to remove
  123634. * @param dispose if the removed element should be disposed (default: false)
  123635. */
  123636. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  123637. /**
  123638. * Rebuilds the elements related to this component in case of
  123639. * context lost for instance.
  123640. */
  123641. dispose(): void;
  123642. private _gatherRenderTargets;
  123643. }
  123644. }
  123645. declare module BABYLON {
  123646. /**
  123647. * A point light is a light defined by an unique point in world space.
  123648. * The light is emitted in every direction from this point.
  123649. * A good example of a point light is a standard light bulb.
  123650. * Documentation: https://doc.babylonjs.com/babylon101/lights
  123651. */
  123652. export class PointLight extends ShadowLight {
  123653. private _shadowAngle;
  123654. /**
  123655. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  123656. * This specifies what angle the shadow will use to be created.
  123657. *
  123658. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  123659. */
  123660. get shadowAngle(): number;
  123661. /**
  123662. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  123663. * This specifies what angle the shadow will use to be created.
  123664. *
  123665. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  123666. */
  123667. set shadowAngle(value: number);
  123668. /**
  123669. * Gets the direction if it has been set.
  123670. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  123671. */
  123672. get direction(): Vector3;
  123673. /**
  123674. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  123675. */
  123676. set direction(value: Vector3);
  123677. /**
  123678. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  123679. * A PointLight emits the light in every direction.
  123680. * It can cast shadows.
  123681. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  123682. * ```javascript
  123683. * var pointLight = new PointLight("pl", camera.position, scene);
  123684. * ```
  123685. * Documentation : https://doc.babylonjs.com/babylon101/lights
  123686. * @param name The light friendly name
  123687. * @param position The position of the point light in the scene
  123688. * @param scene The scene the lights belongs to
  123689. */
  123690. constructor(name: string, position: Vector3, scene: Scene);
  123691. /**
  123692. * Returns the string "PointLight"
  123693. * @returns the class name
  123694. */
  123695. getClassName(): string;
  123696. /**
  123697. * Returns the integer 0.
  123698. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  123699. */
  123700. getTypeID(): number;
  123701. /**
  123702. * Specifies wether or not the shadowmap should be a cube texture.
  123703. * @returns true if the shadowmap needs to be a cube texture.
  123704. */
  123705. needCube(): boolean;
  123706. /**
  123707. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  123708. * @param faceIndex The index of the face we are computed the direction to generate shadow
  123709. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  123710. */
  123711. getShadowDirection(faceIndex?: number): Vector3;
  123712. /**
  123713. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  123714. * - fov = PI / 2
  123715. * - aspect ratio : 1.0
  123716. * - z-near and far equal to the active camera minZ and maxZ.
  123717. * Returns the PointLight.
  123718. */
  123719. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  123720. protected _buildUniformLayout(): void;
  123721. /**
  123722. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  123723. * @param effect The effect to update
  123724. * @param lightIndex The index of the light in the effect to update
  123725. * @returns The point light
  123726. */
  123727. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  123728. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  123729. /**
  123730. * Prepares the list of defines specific to the light type.
  123731. * @param defines the list of defines
  123732. * @param lightIndex defines the index of the light for the effect
  123733. */
  123734. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  123735. }
  123736. }
  123737. declare module BABYLON {
  123738. /**
  123739. * Header information of HDR texture files.
  123740. */
  123741. export interface HDRInfo {
  123742. /**
  123743. * The height of the texture in pixels.
  123744. */
  123745. height: number;
  123746. /**
  123747. * The width of the texture in pixels.
  123748. */
  123749. width: number;
  123750. /**
  123751. * The index of the beginning of the data in the binary file.
  123752. */
  123753. dataPosition: number;
  123754. }
  123755. /**
  123756. * This groups tools to convert HDR texture to native colors array.
  123757. */
  123758. export class HDRTools {
  123759. private static Ldexp;
  123760. private static Rgbe2float;
  123761. private static readStringLine;
  123762. /**
  123763. * Reads header information from an RGBE texture stored in a native array.
  123764. * More information on this format are available here:
  123765. * https://en.wikipedia.org/wiki/RGBE_image_format
  123766. *
  123767. * @param uint8array The binary file stored in native array.
  123768. * @return The header information.
  123769. */
  123770. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  123771. /**
  123772. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  123773. * This RGBE texture needs to store the information as a panorama.
  123774. *
  123775. * More information on this format are available here:
  123776. * https://en.wikipedia.org/wiki/RGBE_image_format
  123777. *
  123778. * @param buffer The binary file stored in an array buffer.
  123779. * @param size The expected size of the extracted cubemap.
  123780. * @return The Cube Map information.
  123781. */
  123782. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  123783. /**
  123784. * Returns the pixels data extracted from an RGBE texture.
  123785. * This pixels will be stored left to right up to down in the R G B order in one array.
  123786. *
  123787. * More information on this format are available here:
  123788. * https://en.wikipedia.org/wiki/RGBE_image_format
  123789. *
  123790. * @param uint8array The binary file stored in an array buffer.
  123791. * @param hdrInfo The header information of the file.
  123792. * @return The pixels data in RGB right to left up to down order.
  123793. */
  123794. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  123795. private static RGBE_ReadPixels_RLE;
  123796. }
  123797. }
  123798. declare module BABYLON {
  123799. /**
  123800. * This represents a texture coming from an HDR input.
  123801. *
  123802. * The only supported format is currently panorama picture stored in RGBE format.
  123803. * Example of such files can be found on HDRLib: http://hdrlib.com/
  123804. */
  123805. export class HDRCubeTexture extends BaseTexture {
  123806. private static _facesMapping;
  123807. private _generateHarmonics;
  123808. private _noMipmap;
  123809. private _textureMatrix;
  123810. private _size;
  123811. private _onLoad;
  123812. private _onError;
  123813. /**
  123814. * The texture URL.
  123815. */
  123816. url: string;
  123817. /**
  123818. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  123819. */
  123820. coordinatesMode: number;
  123821. protected _isBlocking: boolean;
  123822. /**
  123823. * Sets wether or not the texture is blocking during loading.
  123824. */
  123825. set isBlocking(value: boolean);
  123826. /**
  123827. * Gets wether or not the texture is blocking during loading.
  123828. */
  123829. get isBlocking(): boolean;
  123830. protected _rotationY: number;
  123831. /**
  123832. * Sets texture matrix rotation angle around Y axis in radians.
  123833. */
  123834. set rotationY(value: number);
  123835. /**
  123836. * Gets texture matrix rotation angle around Y axis radians.
  123837. */
  123838. get rotationY(): number;
  123839. /**
  123840. * Gets or sets the center of the bounding box associated with the cube texture
  123841. * It must define where the camera used to render the texture was set
  123842. */
  123843. boundingBoxPosition: Vector3;
  123844. private _boundingBoxSize;
  123845. /**
  123846. * Gets or sets the size of the bounding box associated with the cube texture
  123847. * When defined, the cubemap will switch to local mode
  123848. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  123849. * @example https://www.babylonjs-playground.com/#RNASML
  123850. */
  123851. set boundingBoxSize(value: Vector3);
  123852. get boundingBoxSize(): Vector3;
  123853. /**
  123854. * Instantiates an HDRTexture from the following parameters.
  123855. *
  123856. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  123857. * @param scene The scene the texture will be used in
  123858. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  123859. * @param noMipmap Forces to not generate the mipmap if true
  123860. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  123861. * @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)
  123862. * @param reserved Reserved flag for internal use.
  123863. */
  123864. 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>);
  123865. /**
  123866. * Get the current class name of the texture useful for serialization or dynamic coding.
  123867. * @returns "HDRCubeTexture"
  123868. */
  123869. getClassName(): string;
  123870. /**
  123871. * Occurs when the file is raw .hdr file.
  123872. */
  123873. private loadTexture;
  123874. clone(): HDRCubeTexture;
  123875. delayLoad(): void;
  123876. /**
  123877. * Get the texture reflection matrix used to rotate/transform the reflection.
  123878. * @returns the reflection matrix
  123879. */
  123880. getReflectionTextureMatrix(): Matrix;
  123881. /**
  123882. * Set the texture reflection matrix used to rotate/transform the reflection.
  123883. * @param value Define the reflection matrix to set
  123884. */
  123885. setReflectionTextureMatrix(value: Matrix): void;
  123886. /**
  123887. * Parses a JSON representation of an HDR Texture in order to create the texture
  123888. * @param parsedTexture Define the JSON representation
  123889. * @param scene Define the scene the texture should be created in
  123890. * @param rootUrl Define the root url in case we need to load relative dependencies
  123891. * @returns the newly created texture after parsing
  123892. */
  123893. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  123894. serialize(): any;
  123895. }
  123896. }
  123897. declare module BABYLON {
  123898. /**
  123899. * Class used to control physics engine
  123900. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  123901. */
  123902. export class PhysicsEngine implements IPhysicsEngine {
  123903. private _physicsPlugin;
  123904. /**
  123905. * Global value used to control the smallest number supported by the simulation
  123906. */
  123907. static Epsilon: number;
  123908. private _impostors;
  123909. private _joints;
  123910. private _subTimeStep;
  123911. /**
  123912. * Gets the gravity vector used by the simulation
  123913. */
  123914. gravity: Vector3;
  123915. /**
  123916. * Factory used to create the default physics plugin.
  123917. * @returns The default physics plugin
  123918. */
  123919. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  123920. /**
  123921. * Creates a new Physics Engine
  123922. * @param gravity defines the gravity vector used by the simulation
  123923. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  123924. */
  123925. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  123926. /**
  123927. * Sets the gravity vector used by the simulation
  123928. * @param gravity defines the gravity vector to use
  123929. */
  123930. setGravity(gravity: Vector3): void;
  123931. /**
  123932. * Set the time step of the physics engine.
  123933. * Default is 1/60.
  123934. * To slow it down, enter 1/600 for example.
  123935. * To speed it up, 1/30
  123936. * @param newTimeStep defines the new timestep to apply to this world.
  123937. */
  123938. setTimeStep(newTimeStep?: number): void;
  123939. /**
  123940. * Get the time step of the physics engine.
  123941. * @returns the current time step
  123942. */
  123943. getTimeStep(): number;
  123944. /**
  123945. * Set the sub time step of the physics engine.
  123946. * Default is 0 meaning there is no sub steps
  123947. * To increase physics resolution precision, set a small value (like 1 ms)
  123948. * @param subTimeStep defines the new sub timestep used for physics resolution.
  123949. */
  123950. setSubTimeStep(subTimeStep?: number): void;
  123951. /**
  123952. * Get the sub time step of the physics engine.
  123953. * @returns the current sub time step
  123954. */
  123955. getSubTimeStep(): number;
  123956. /**
  123957. * Release all resources
  123958. */
  123959. dispose(): void;
  123960. /**
  123961. * Gets the name of the current physics plugin
  123962. * @returns the name of the plugin
  123963. */
  123964. getPhysicsPluginName(): string;
  123965. /**
  123966. * Adding a new impostor for the impostor tracking.
  123967. * This will be done by the impostor itself.
  123968. * @param impostor the impostor to add
  123969. */
  123970. addImpostor(impostor: PhysicsImpostor): void;
  123971. /**
  123972. * Remove an impostor from the engine.
  123973. * This impostor and its mesh will not longer be updated by the physics engine.
  123974. * @param impostor the impostor to remove
  123975. */
  123976. removeImpostor(impostor: PhysicsImpostor): void;
  123977. /**
  123978. * Add a joint to the physics engine
  123979. * @param mainImpostor defines the main impostor to which the joint is added.
  123980. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  123981. * @param joint defines the joint that will connect both impostors.
  123982. */
  123983. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  123984. /**
  123985. * Removes a joint from the simulation
  123986. * @param mainImpostor defines the impostor used with the joint
  123987. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  123988. * @param joint defines the joint to remove
  123989. */
  123990. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  123991. /**
  123992. * Called by the scene. No need to call it.
  123993. * @param delta defines the timespam between frames
  123994. */
  123995. _step(delta: number): void;
  123996. /**
  123997. * Gets the current plugin used to run the simulation
  123998. * @returns current plugin
  123999. */
  124000. getPhysicsPlugin(): IPhysicsEnginePlugin;
  124001. /**
  124002. * Gets the list of physic impostors
  124003. * @returns an array of PhysicsImpostor
  124004. */
  124005. getImpostors(): Array<PhysicsImpostor>;
  124006. /**
  124007. * Gets the impostor for a physics enabled object
  124008. * @param object defines the object impersonated by the impostor
  124009. * @returns the PhysicsImpostor or null if not found
  124010. */
  124011. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  124012. /**
  124013. * Gets the impostor for a physics body object
  124014. * @param body defines physics body used by the impostor
  124015. * @returns the PhysicsImpostor or null if not found
  124016. */
  124017. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  124018. /**
  124019. * Does a raycast in the physics world
  124020. * @param from when should the ray start?
  124021. * @param to when should the ray end?
  124022. * @returns PhysicsRaycastResult
  124023. */
  124024. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  124025. }
  124026. }
  124027. declare module BABYLON {
  124028. /** @hidden */
  124029. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  124030. private _useDeltaForWorldStep;
  124031. world: any;
  124032. name: string;
  124033. private _physicsMaterials;
  124034. private _fixedTimeStep;
  124035. private _cannonRaycastResult;
  124036. private _raycastResult;
  124037. private _physicsBodysToRemoveAfterStep;
  124038. BJSCANNON: any;
  124039. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  124040. setGravity(gravity: Vector3): void;
  124041. setTimeStep(timeStep: number): void;
  124042. getTimeStep(): number;
  124043. executeStep(delta: number): void;
  124044. private _removeMarkedPhysicsBodiesFromWorld;
  124045. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  124046. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  124047. generatePhysicsBody(impostor: PhysicsImpostor): void;
  124048. private _processChildMeshes;
  124049. removePhysicsBody(impostor: PhysicsImpostor): void;
  124050. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  124051. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  124052. private _addMaterial;
  124053. private _checkWithEpsilon;
  124054. private _createShape;
  124055. private _createHeightmap;
  124056. private _minus90X;
  124057. private _plus90X;
  124058. private _tmpPosition;
  124059. private _tmpDeltaPosition;
  124060. private _tmpUnityRotation;
  124061. private _updatePhysicsBodyTransformation;
  124062. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  124063. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  124064. isSupported(): boolean;
  124065. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124066. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124067. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124068. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124069. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  124070. getBodyMass(impostor: PhysicsImpostor): number;
  124071. getBodyFriction(impostor: PhysicsImpostor): number;
  124072. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  124073. getBodyRestitution(impostor: PhysicsImpostor): number;
  124074. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  124075. sleepBody(impostor: PhysicsImpostor): void;
  124076. wakeUpBody(impostor: PhysicsImpostor): void;
  124077. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  124078. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  124079. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  124080. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  124081. getRadius(impostor: PhysicsImpostor): number;
  124082. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  124083. dispose(): void;
  124084. private _extendNamespace;
  124085. /**
  124086. * Does a raycast in the physics world
  124087. * @param from when should the ray start?
  124088. * @param to when should the ray end?
  124089. * @returns PhysicsRaycastResult
  124090. */
  124091. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  124092. }
  124093. }
  124094. declare module BABYLON {
  124095. /** @hidden */
  124096. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  124097. world: any;
  124098. name: string;
  124099. BJSOIMO: any;
  124100. private _raycastResult;
  124101. constructor(iterations?: number, oimoInjection?: any);
  124102. setGravity(gravity: Vector3): void;
  124103. setTimeStep(timeStep: number): void;
  124104. getTimeStep(): number;
  124105. private _tmpImpostorsArray;
  124106. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  124107. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  124108. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  124109. generatePhysicsBody(impostor: PhysicsImpostor): void;
  124110. private _tmpPositionVector;
  124111. removePhysicsBody(impostor: PhysicsImpostor): void;
  124112. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  124113. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  124114. isSupported(): boolean;
  124115. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  124116. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  124117. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124118. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124119. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124120. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124121. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  124122. getBodyMass(impostor: PhysicsImpostor): number;
  124123. getBodyFriction(impostor: PhysicsImpostor): number;
  124124. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  124125. getBodyRestitution(impostor: PhysicsImpostor): number;
  124126. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  124127. sleepBody(impostor: PhysicsImpostor): void;
  124128. wakeUpBody(impostor: PhysicsImpostor): void;
  124129. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  124130. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  124131. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  124132. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  124133. getRadius(impostor: PhysicsImpostor): number;
  124134. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  124135. dispose(): void;
  124136. /**
  124137. * Does a raycast in the physics world
  124138. * @param from when should the ray start?
  124139. * @param to when should the ray end?
  124140. * @returns PhysicsRaycastResult
  124141. */
  124142. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  124143. }
  124144. }
  124145. declare module BABYLON {
  124146. /**
  124147. * Class containing static functions to help procedurally build meshes
  124148. */
  124149. export class RibbonBuilder {
  124150. /**
  124151. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  124152. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  124153. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  124154. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  124155. * * 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
  124156. * * 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
  124157. * * 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
  124158. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124159. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124160. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124161. * * 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
  124162. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  124163. * * 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
  124164. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  124165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124166. * @param name defines the name of the mesh
  124167. * @param options defines the options used to create the mesh
  124168. * @param scene defines the hosting scene
  124169. * @returns the ribbon mesh
  124170. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  124171. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124172. */
  124173. static CreateRibbon(name: string, options: {
  124174. pathArray: Vector3[][];
  124175. closeArray?: boolean;
  124176. closePath?: boolean;
  124177. offset?: number;
  124178. updatable?: boolean;
  124179. sideOrientation?: number;
  124180. frontUVs?: Vector4;
  124181. backUVs?: Vector4;
  124182. instance?: Mesh;
  124183. invertUV?: boolean;
  124184. uvs?: Vector2[];
  124185. colors?: Color4[];
  124186. }, scene?: Nullable<Scene>): Mesh;
  124187. }
  124188. }
  124189. declare module BABYLON {
  124190. /**
  124191. * Class containing static functions to help procedurally build meshes
  124192. */
  124193. export class ShapeBuilder {
  124194. /**
  124195. * 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.
  124196. * * 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.
  124197. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  124198. * * 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.
  124199. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  124200. * * 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
  124201. * * 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
  124202. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  124203. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124204. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124205. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  124206. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124207. * @param name defines the name of the mesh
  124208. * @param options defines the options used to create the mesh
  124209. * @param scene defines the hosting scene
  124210. * @returns the extruded shape mesh
  124211. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124212. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  124213. */
  124214. static ExtrudeShape(name: string, options: {
  124215. shape: Vector3[];
  124216. path: Vector3[];
  124217. scale?: number;
  124218. rotation?: number;
  124219. cap?: number;
  124220. updatable?: boolean;
  124221. sideOrientation?: number;
  124222. frontUVs?: Vector4;
  124223. backUVs?: Vector4;
  124224. instance?: Mesh;
  124225. invertUV?: boolean;
  124226. }, scene?: Nullable<Scene>): Mesh;
  124227. /**
  124228. * Creates an custom extruded shape mesh.
  124229. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  124230. * * 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.
  124231. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  124232. * * 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
  124233. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  124234. * * 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
  124235. * * It must returns a float value that will be the scale value applied to the shape on each path point
  124236. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  124237. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  124238. * * 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
  124239. * * 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
  124240. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  124241. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124242. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124243. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124245. * @param name defines the name of the mesh
  124246. * @param options defines the options used to create the mesh
  124247. * @param scene defines the hosting scene
  124248. * @returns the custom extruded shape mesh
  124249. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  124250. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124251. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  124252. */
  124253. static ExtrudeShapeCustom(name: string, options: {
  124254. shape: Vector3[];
  124255. path: Vector3[];
  124256. scaleFunction?: any;
  124257. rotationFunction?: any;
  124258. ribbonCloseArray?: boolean;
  124259. ribbonClosePath?: boolean;
  124260. cap?: number;
  124261. updatable?: boolean;
  124262. sideOrientation?: number;
  124263. frontUVs?: Vector4;
  124264. backUVs?: Vector4;
  124265. instance?: Mesh;
  124266. invertUV?: boolean;
  124267. }, scene?: Nullable<Scene>): Mesh;
  124268. private static _ExtrudeShapeGeneric;
  124269. }
  124270. }
  124271. declare module BABYLON {
  124272. /**
  124273. * AmmoJS Physics plugin
  124274. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  124275. * @see https://github.com/kripken/ammo.js/
  124276. */
  124277. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  124278. private _useDeltaForWorldStep;
  124279. /**
  124280. * Reference to the Ammo library
  124281. */
  124282. bjsAMMO: any;
  124283. /**
  124284. * Created ammoJS world which physics bodies are added to
  124285. */
  124286. world: any;
  124287. /**
  124288. * Name of the plugin
  124289. */
  124290. name: string;
  124291. private _timeStep;
  124292. private _fixedTimeStep;
  124293. private _maxSteps;
  124294. private _tmpQuaternion;
  124295. private _tmpAmmoTransform;
  124296. private _tmpAmmoQuaternion;
  124297. private _tmpAmmoConcreteContactResultCallback;
  124298. private _collisionConfiguration;
  124299. private _dispatcher;
  124300. private _overlappingPairCache;
  124301. private _solver;
  124302. private _softBodySolver;
  124303. private _tmpAmmoVectorA;
  124304. private _tmpAmmoVectorB;
  124305. private _tmpAmmoVectorC;
  124306. private _tmpAmmoVectorD;
  124307. private _tmpContactCallbackResult;
  124308. private _tmpAmmoVectorRCA;
  124309. private _tmpAmmoVectorRCB;
  124310. private _raycastResult;
  124311. private static readonly DISABLE_COLLISION_FLAG;
  124312. private static readonly KINEMATIC_FLAG;
  124313. private static readonly DISABLE_DEACTIVATION_FLAG;
  124314. /**
  124315. * Initializes the ammoJS plugin
  124316. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  124317. * @param ammoInjection can be used to inject your own ammo reference
  124318. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  124319. */
  124320. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  124321. /**
  124322. * Sets the gravity of the physics world (m/(s^2))
  124323. * @param gravity Gravity to set
  124324. */
  124325. setGravity(gravity: Vector3): void;
  124326. /**
  124327. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  124328. * @param timeStep timestep to use in seconds
  124329. */
  124330. setTimeStep(timeStep: number): void;
  124331. /**
  124332. * 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)
  124333. * @param fixedTimeStep fixedTimeStep to use in seconds
  124334. */
  124335. setFixedTimeStep(fixedTimeStep: number): void;
  124336. /**
  124337. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  124338. * @param maxSteps the maximum number of steps by the physics engine per frame
  124339. */
  124340. setMaxSteps(maxSteps: number): void;
  124341. /**
  124342. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  124343. * @returns the current timestep in seconds
  124344. */
  124345. getTimeStep(): number;
  124346. /**
  124347. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  124348. */
  124349. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  124350. private _isImpostorInContact;
  124351. private _isImpostorPairInContact;
  124352. private _stepSimulation;
  124353. /**
  124354. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  124355. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  124356. * After the step the babylon meshes are set to the position of the physics imposters
  124357. * @param delta amount of time to step forward
  124358. * @param impostors array of imposters to update before/after the step
  124359. */
  124360. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  124361. /**
  124362. * Update babylon mesh to match physics world object
  124363. * @param impostor imposter to match
  124364. */
  124365. private _afterSoftStep;
  124366. /**
  124367. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  124368. * @param impostor imposter to match
  124369. */
  124370. private _ropeStep;
  124371. /**
  124372. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  124373. * @param impostor imposter to match
  124374. */
  124375. private _softbodyOrClothStep;
  124376. private _tmpVector;
  124377. private _tmpMatrix;
  124378. /**
  124379. * Applies an impulse on the imposter
  124380. * @param impostor imposter to apply impulse to
  124381. * @param force amount of force to be applied to the imposter
  124382. * @param contactPoint the location to apply the impulse on the imposter
  124383. */
  124384. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  124385. /**
  124386. * Applies a force on the imposter
  124387. * @param impostor imposter to apply force
  124388. * @param force amount of force to be applied to the imposter
  124389. * @param contactPoint the location to apply the force on the imposter
  124390. */
  124391. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  124392. /**
  124393. * Creates a physics body using the plugin
  124394. * @param impostor the imposter to create the physics body on
  124395. */
  124396. generatePhysicsBody(impostor: PhysicsImpostor): void;
  124397. /**
  124398. * Removes the physics body from the imposter and disposes of the body's memory
  124399. * @param impostor imposter to remove the physics body from
  124400. */
  124401. removePhysicsBody(impostor: PhysicsImpostor): void;
  124402. /**
  124403. * Generates a joint
  124404. * @param impostorJoint the imposter joint to create the joint with
  124405. */
  124406. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  124407. /**
  124408. * Removes a joint
  124409. * @param impostorJoint the imposter joint to remove the joint from
  124410. */
  124411. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  124412. private _addMeshVerts;
  124413. /**
  124414. * Initialise the soft body vertices to match its object's (mesh) vertices
  124415. * Softbody vertices (nodes) are in world space and to match this
  124416. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  124417. * @param impostor to create the softbody for
  124418. */
  124419. private _softVertexData;
  124420. /**
  124421. * Create an impostor's soft body
  124422. * @param impostor to create the softbody for
  124423. */
  124424. private _createSoftbody;
  124425. /**
  124426. * Create cloth for an impostor
  124427. * @param impostor to create the softbody for
  124428. */
  124429. private _createCloth;
  124430. /**
  124431. * Create rope for an impostor
  124432. * @param impostor to create the softbody for
  124433. */
  124434. private _createRope;
  124435. /**
  124436. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  124437. * @param impostor to create the custom physics shape for
  124438. */
  124439. private _createCustom;
  124440. private _addHullVerts;
  124441. private _createShape;
  124442. /**
  124443. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  124444. * @param impostor imposter containing the physics body and babylon object
  124445. */
  124446. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  124447. /**
  124448. * Sets the babylon object's position/rotation from the physics body's position/rotation
  124449. * @param impostor imposter containing the physics body and babylon object
  124450. * @param newPosition new position
  124451. * @param newRotation new rotation
  124452. */
  124453. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  124454. /**
  124455. * If this plugin is supported
  124456. * @returns true if its supported
  124457. */
  124458. isSupported(): boolean;
  124459. /**
  124460. * Sets the linear velocity of the physics body
  124461. * @param impostor imposter to set the velocity on
  124462. * @param velocity velocity to set
  124463. */
  124464. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124465. /**
  124466. * Sets the angular velocity of the physics body
  124467. * @param impostor imposter to set the velocity on
  124468. * @param velocity velocity to set
  124469. */
  124470. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124471. /**
  124472. * gets the linear velocity
  124473. * @param impostor imposter to get linear velocity from
  124474. * @returns linear velocity
  124475. */
  124476. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124477. /**
  124478. * gets the angular velocity
  124479. * @param impostor imposter to get angular velocity from
  124480. * @returns angular velocity
  124481. */
  124482. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124483. /**
  124484. * Sets the mass of physics body
  124485. * @param impostor imposter to set the mass on
  124486. * @param mass mass to set
  124487. */
  124488. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  124489. /**
  124490. * Gets the mass of the physics body
  124491. * @param impostor imposter to get the mass from
  124492. * @returns mass
  124493. */
  124494. getBodyMass(impostor: PhysicsImpostor): number;
  124495. /**
  124496. * Gets friction of the impostor
  124497. * @param impostor impostor to get friction from
  124498. * @returns friction value
  124499. */
  124500. getBodyFriction(impostor: PhysicsImpostor): number;
  124501. /**
  124502. * Sets friction of the impostor
  124503. * @param impostor impostor to set friction on
  124504. * @param friction friction value
  124505. */
  124506. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  124507. /**
  124508. * Gets restitution of the impostor
  124509. * @param impostor impostor to get restitution from
  124510. * @returns restitution value
  124511. */
  124512. getBodyRestitution(impostor: PhysicsImpostor): number;
  124513. /**
  124514. * Sets resitution of the impostor
  124515. * @param impostor impostor to set resitution on
  124516. * @param restitution resitution value
  124517. */
  124518. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  124519. /**
  124520. * Gets pressure inside the impostor
  124521. * @param impostor impostor to get pressure from
  124522. * @returns pressure value
  124523. */
  124524. getBodyPressure(impostor: PhysicsImpostor): number;
  124525. /**
  124526. * Sets pressure inside a soft body impostor
  124527. * Cloth and rope must remain 0 pressure
  124528. * @param impostor impostor to set pressure on
  124529. * @param pressure pressure value
  124530. */
  124531. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  124532. /**
  124533. * Gets stiffness of the impostor
  124534. * @param impostor impostor to get stiffness from
  124535. * @returns pressure value
  124536. */
  124537. getBodyStiffness(impostor: PhysicsImpostor): number;
  124538. /**
  124539. * Sets stiffness of the impostor
  124540. * @param impostor impostor to set stiffness on
  124541. * @param stiffness stiffness value from 0 to 1
  124542. */
  124543. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  124544. /**
  124545. * Gets velocityIterations of the impostor
  124546. * @param impostor impostor to get velocity iterations from
  124547. * @returns velocityIterations value
  124548. */
  124549. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  124550. /**
  124551. * Sets velocityIterations of the impostor
  124552. * @param impostor impostor to set velocity iterations on
  124553. * @param velocityIterations velocityIterations value
  124554. */
  124555. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  124556. /**
  124557. * Gets positionIterations of the impostor
  124558. * @param impostor impostor to get position iterations from
  124559. * @returns positionIterations value
  124560. */
  124561. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  124562. /**
  124563. * Sets positionIterations of the impostor
  124564. * @param impostor impostor to set position on
  124565. * @param positionIterations positionIterations value
  124566. */
  124567. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  124568. /**
  124569. * Append an anchor to a cloth object
  124570. * @param impostor is the cloth impostor to add anchor to
  124571. * @param otherImpostor is the rigid impostor to anchor to
  124572. * @param width ratio across width from 0 to 1
  124573. * @param height ratio up height from 0 to 1
  124574. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  124575. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  124576. */
  124577. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  124578. /**
  124579. * Append an hook to a rope object
  124580. * @param impostor is the rope impostor to add hook to
  124581. * @param otherImpostor is the rigid impostor to hook to
  124582. * @param length ratio along the rope from 0 to 1
  124583. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  124584. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  124585. */
  124586. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  124587. /**
  124588. * Sleeps the physics body and stops it from being active
  124589. * @param impostor impostor to sleep
  124590. */
  124591. sleepBody(impostor: PhysicsImpostor): void;
  124592. /**
  124593. * Activates the physics body
  124594. * @param impostor impostor to activate
  124595. */
  124596. wakeUpBody(impostor: PhysicsImpostor): void;
  124597. /**
  124598. * Updates the distance parameters of the joint
  124599. * @param joint joint to update
  124600. * @param maxDistance maximum distance of the joint
  124601. * @param minDistance minimum distance of the joint
  124602. */
  124603. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  124604. /**
  124605. * Sets a motor on the joint
  124606. * @param joint joint to set motor on
  124607. * @param speed speed of the motor
  124608. * @param maxForce maximum force of the motor
  124609. * @param motorIndex index of the motor
  124610. */
  124611. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  124612. /**
  124613. * Sets the motors limit
  124614. * @param joint joint to set limit on
  124615. * @param upperLimit upper limit
  124616. * @param lowerLimit lower limit
  124617. */
  124618. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  124619. /**
  124620. * Syncs the position and rotation of a mesh with the impostor
  124621. * @param mesh mesh to sync
  124622. * @param impostor impostor to update the mesh with
  124623. */
  124624. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  124625. /**
  124626. * Gets the radius of the impostor
  124627. * @param impostor impostor to get radius from
  124628. * @returns the radius
  124629. */
  124630. getRadius(impostor: PhysicsImpostor): number;
  124631. /**
  124632. * Gets the box size of the impostor
  124633. * @param impostor impostor to get box size from
  124634. * @param result the resulting box size
  124635. */
  124636. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  124637. /**
  124638. * Disposes of the impostor
  124639. */
  124640. dispose(): void;
  124641. /**
  124642. * Does a raycast in the physics world
  124643. * @param from when should the ray start?
  124644. * @param to when should the ray end?
  124645. * @returns PhysicsRaycastResult
  124646. */
  124647. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  124648. }
  124649. }
  124650. declare module BABYLON {
  124651. interface AbstractScene {
  124652. /**
  124653. * The list of reflection probes added to the scene
  124654. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  124655. */
  124656. reflectionProbes: Array<ReflectionProbe>;
  124657. /**
  124658. * Removes the given reflection probe from this scene.
  124659. * @param toRemove The reflection probe to remove
  124660. * @returns The index of the removed reflection probe
  124661. */
  124662. removeReflectionProbe(toRemove: ReflectionProbe): number;
  124663. /**
  124664. * Adds the given reflection probe to this scene.
  124665. * @param newReflectionProbe The reflection probe to add
  124666. */
  124667. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  124668. }
  124669. /**
  124670. * Class used to generate realtime reflection / refraction cube textures
  124671. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  124672. */
  124673. export class ReflectionProbe {
  124674. /** defines the name of the probe */
  124675. name: string;
  124676. private _scene;
  124677. private _renderTargetTexture;
  124678. private _projectionMatrix;
  124679. private _viewMatrix;
  124680. private _target;
  124681. private _add;
  124682. private _attachedMesh;
  124683. private _invertYAxis;
  124684. /** Gets or sets probe position (center of the cube map) */
  124685. position: Vector3;
  124686. /**
  124687. * Creates a new reflection probe
  124688. * @param name defines the name of the probe
  124689. * @param size defines the texture resolution (for each face)
  124690. * @param scene defines the hosting scene
  124691. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  124692. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  124693. */
  124694. constructor(
  124695. /** defines the name of the probe */
  124696. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  124697. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  124698. get samples(): number;
  124699. set samples(value: number);
  124700. /** Gets or sets the refresh rate to use (on every frame by default) */
  124701. get refreshRate(): number;
  124702. set refreshRate(value: number);
  124703. /**
  124704. * Gets the hosting scene
  124705. * @returns a Scene
  124706. */
  124707. getScene(): Scene;
  124708. /** Gets the internal CubeTexture used to render to */
  124709. get cubeTexture(): RenderTargetTexture;
  124710. /** Gets the list of meshes to render */
  124711. get renderList(): Nullable<AbstractMesh[]>;
  124712. /**
  124713. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  124714. * @param mesh defines the mesh to attach to
  124715. */
  124716. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  124717. /**
  124718. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  124719. * @param renderingGroupId The rendering group id corresponding to its index
  124720. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  124721. */
  124722. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  124723. /**
  124724. * Clean all associated resources
  124725. */
  124726. dispose(): void;
  124727. /**
  124728. * Converts the reflection probe information to a readable string for debug purpose.
  124729. * @param fullDetails Supports for multiple levels of logging within scene loading
  124730. * @returns the human readable reflection probe info
  124731. */
  124732. toString(fullDetails?: boolean): string;
  124733. /**
  124734. * Get the class name of the relfection probe.
  124735. * @returns "ReflectionProbe"
  124736. */
  124737. getClassName(): string;
  124738. /**
  124739. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  124740. * @returns The JSON representation of the texture
  124741. */
  124742. serialize(): any;
  124743. /**
  124744. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  124745. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  124746. * @param scene Define the scene the parsed reflection probe should be instantiated in
  124747. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  124748. * @returns The parsed reflection probe if successful
  124749. */
  124750. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  124751. }
  124752. }
  124753. declare module BABYLON {
  124754. /** @hidden */
  124755. export var _BabylonLoaderRegistered: boolean;
  124756. /**
  124757. * Helps setting up some configuration for the babylon file loader.
  124758. */
  124759. export class BabylonFileLoaderConfiguration {
  124760. /**
  124761. * The loader does not allow injecting custom physix engine into the plugins.
  124762. * Unfortunately in ES6, we need to manually inject them into the plugin.
  124763. * So you could set this variable to your engine import to make it work.
  124764. */
  124765. static LoaderInjectedPhysicsEngine: any;
  124766. }
  124767. }
  124768. declare module BABYLON {
  124769. /**
  124770. * The Physically based simple base material of BJS.
  124771. *
  124772. * This enables better naming and convention enforcements on top of the pbrMaterial.
  124773. * It is used as the base class for both the specGloss and metalRough conventions.
  124774. */
  124775. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  124776. /**
  124777. * Number of Simultaneous lights allowed on the material.
  124778. */
  124779. maxSimultaneousLights: number;
  124780. /**
  124781. * If sets to true, disables all the lights affecting the material.
  124782. */
  124783. disableLighting: boolean;
  124784. /**
  124785. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  124786. */
  124787. environmentTexture: BaseTexture;
  124788. /**
  124789. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  124790. */
  124791. invertNormalMapX: boolean;
  124792. /**
  124793. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  124794. */
  124795. invertNormalMapY: boolean;
  124796. /**
  124797. * Normal map used in the model.
  124798. */
  124799. normalTexture: BaseTexture;
  124800. /**
  124801. * Emissivie color used to self-illuminate the model.
  124802. */
  124803. emissiveColor: Color3;
  124804. /**
  124805. * Emissivie texture used to self-illuminate the model.
  124806. */
  124807. emissiveTexture: BaseTexture;
  124808. /**
  124809. * Occlusion Channel Strenght.
  124810. */
  124811. occlusionStrength: number;
  124812. /**
  124813. * Occlusion Texture of the material (adding extra occlusion effects).
  124814. */
  124815. occlusionTexture: BaseTexture;
  124816. /**
  124817. * Defines the alpha limits in alpha test mode.
  124818. */
  124819. alphaCutOff: number;
  124820. /**
  124821. * Gets the current double sided mode.
  124822. */
  124823. get doubleSided(): boolean;
  124824. /**
  124825. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124826. */
  124827. set doubleSided(value: boolean);
  124828. /**
  124829. * Stores the pre-calculated light information of a mesh in a texture.
  124830. */
  124831. lightmapTexture: BaseTexture;
  124832. /**
  124833. * If true, the light map contains occlusion information instead of lighting info.
  124834. */
  124835. useLightmapAsShadowmap: boolean;
  124836. /**
  124837. * Instantiates a new PBRMaterial instance.
  124838. *
  124839. * @param name The material name
  124840. * @param scene The scene the material will be use in.
  124841. */
  124842. constructor(name: string, scene: Scene);
  124843. getClassName(): string;
  124844. }
  124845. }
  124846. declare module BABYLON {
  124847. /**
  124848. * The PBR material of BJS following the metal roughness convention.
  124849. *
  124850. * This fits to the PBR convention in the GLTF definition:
  124851. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  124852. */
  124853. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  124854. /**
  124855. * The base color has two different interpretations depending on the value of metalness.
  124856. * When the material is a metal, the base color is the specific measured reflectance value
  124857. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  124858. * of the material.
  124859. */
  124860. baseColor: Color3;
  124861. /**
  124862. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  124863. * well as opacity information in the alpha channel.
  124864. */
  124865. baseTexture: BaseTexture;
  124866. /**
  124867. * Specifies the metallic scalar value of the material.
  124868. * Can also be used to scale the metalness values of the metallic texture.
  124869. */
  124870. metallic: number;
  124871. /**
  124872. * Specifies the roughness scalar value of the material.
  124873. * Can also be used to scale the roughness values of the metallic texture.
  124874. */
  124875. roughness: number;
  124876. /**
  124877. * Texture containing both the metallic value in the B channel and the
  124878. * roughness value in the G channel to keep better precision.
  124879. */
  124880. metallicRoughnessTexture: BaseTexture;
  124881. /**
  124882. * Instantiates a new PBRMetalRoughnessMaterial instance.
  124883. *
  124884. * @param name The material name
  124885. * @param scene The scene the material will be use in.
  124886. */
  124887. constructor(name: string, scene: Scene);
  124888. /**
  124889. * Return the currrent class name of the material.
  124890. */
  124891. getClassName(): string;
  124892. /**
  124893. * Makes a duplicate of the current material.
  124894. * @param name - name to use for the new material.
  124895. */
  124896. clone(name: string): PBRMetallicRoughnessMaterial;
  124897. /**
  124898. * Serialize the material to a parsable JSON object.
  124899. */
  124900. serialize(): any;
  124901. /**
  124902. * Parses a JSON object correponding to the serialize function.
  124903. */
  124904. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  124905. }
  124906. }
  124907. declare module BABYLON {
  124908. /**
  124909. * The PBR material of BJS following the specular glossiness convention.
  124910. *
  124911. * This fits to the PBR convention in the GLTF definition:
  124912. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  124913. */
  124914. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  124915. /**
  124916. * Specifies the diffuse color of the material.
  124917. */
  124918. diffuseColor: Color3;
  124919. /**
  124920. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  124921. * channel.
  124922. */
  124923. diffuseTexture: BaseTexture;
  124924. /**
  124925. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  124926. */
  124927. specularColor: Color3;
  124928. /**
  124929. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  124930. */
  124931. glossiness: number;
  124932. /**
  124933. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  124934. */
  124935. specularGlossinessTexture: BaseTexture;
  124936. /**
  124937. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  124938. *
  124939. * @param name The material name
  124940. * @param scene The scene the material will be use in.
  124941. */
  124942. constructor(name: string, scene: Scene);
  124943. /**
  124944. * Return the currrent class name of the material.
  124945. */
  124946. getClassName(): string;
  124947. /**
  124948. * Makes a duplicate of the current material.
  124949. * @param name - name to use for the new material.
  124950. */
  124951. clone(name: string): PBRSpecularGlossinessMaterial;
  124952. /**
  124953. * Serialize the material to a parsable JSON object.
  124954. */
  124955. serialize(): any;
  124956. /**
  124957. * Parses a JSON object correponding to the serialize function.
  124958. */
  124959. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  124960. }
  124961. }
  124962. declare module BABYLON {
  124963. /**
  124964. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  124965. * It can help converting any input color in a desired output one. This can then be used to create effects
  124966. * from sepia, black and white to sixties or futuristic rendering...
  124967. *
  124968. * The only supported format is currently 3dl.
  124969. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  124970. */
  124971. export class ColorGradingTexture extends BaseTexture {
  124972. /**
  124973. * The current texture matrix. (will always be identity in color grading texture)
  124974. */
  124975. private _textureMatrix;
  124976. /**
  124977. * The texture URL.
  124978. */
  124979. url: string;
  124980. /**
  124981. * Empty line regex stored for GC.
  124982. */
  124983. private static _noneEmptyLineRegex;
  124984. private _engine;
  124985. /**
  124986. * Instantiates a ColorGradingTexture from the following parameters.
  124987. *
  124988. * @param url The location of the color gradind data (currently only supporting 3dl)
  124989. * @param scene The scene the texture will be used in
  124990. */
  124991. constructor(url: string, scene: Scene);
  124992. /**
  124993. * Returns the texture matrix used in most of the material.
  124994. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  124995. */
  124996. getTextureMatrix(): Matrix;
  124997. /**
  124998. * Occurs when the file being loaded is a .3dl LUT file.
  124999. */
  125000. private load3dlTexture;
  125001. /**
  125002. * Starts the loading process of the texture.
  125003. */
  125004. private loadTexture;
  125005. /**
  125006. * Clones the color gradind texture.
  125007. */
  125008. clone(): ColorGradingTexture;
  125009. /**
  125010. * Called during delayed load for textures.
  125011. */
  125012. delayLoad(): void;
  125013. /**
  125014. * Parses a color grading texture serialized by Babylon.
  125015. * @param parsedTexture The texture information being parsedTexture
  125016. * @param scene The scene to load the texture in
  125017. * @param rootUrl The root url of the data assets to load
  125018. * @return A color gradind texture
  125019. */
  125020. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  125021. /**
  125022. * Serializes the LUT texture to json format.
  125023. */
  125024. serialize(): any;
  125025. }
  125026. }
  125027. declare module BABYLON {
  125028. /**
  125029. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  125030. */
  125031. export class EquiRectangularCubeTexture extends BaseTexture {
  125032. /** The six faces of the cube. */
  125033. private static _FacesMapping;
  125034. private _noMipmap;
  125035. private _onLoad;
  125036. private _onError;
  125037. /** The size of the cubemap. */
  125038. private _size;
  125039. /** The buffer of the image. */
  125040. private _buffer;
  125041. /** The width of the input image. */
  125042. private _width;
  125043. /** The height of the input image. */
  125044. private _height;
  125045. /** The URL to the image. */
  125046. url: string;
  125047. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  125048. coordinatesMode: number;
  125049. /**
  125050. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  125051. * @param url The location of the image
  125052. * @param scene The scene the texture will be used in
  125053. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  125054. * @param noMipmap Forces to not generate the mipmap if true
  125055. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  125056. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  125057. * @param onLoad — defines a callback called when texture is loaded
  125058. * @param onError — defines a callback called if there is an error
  125059. */
  125060. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  125061. /**
  125062. * Load the image data, by putting the image on a canvas and extracting its buffer.
  125063. */
  125064. private loadImage;
  125065. /**
  125066. * Convert the image buffer into a cubemap and create a CubeTexture.
  125067. */
  125068. private loadTexture;
  125069. /**
  125070. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  125071. * @param buffer The ArrayBuffer that should be converted.
  125072. * @returns The buffer as Float32Array.
  125073. */
  125074. private getFloat32ArrayFromArrayBuffer;
  125075. /**
  125076. * Get the current class name of the texture useful for serialization or dynamic coding.
  125077. * @returns "EquiRectangularCubeTexture"
  125078. */
  125079. getClassName(): string;
  125080. /**
  125081. * Create a clone of the current EquiRectangularCubeTexture and return it.
  125082. * @returns A clone of the current EquiRectangularCubeTexture.
  125083. */
  125084. clone(): EquiRectangularCubeTexture;
  125085. }
  125086. }
  125087. declare module BABYLON {
  125088. /**
  125089. * Based on jsTGALoader - Javascript loader for TGA file
  125090. * By Vincent Thibault
  125091. * @see http://blog.robrowser.com/javascript-tga-loader.html
  125092. */
  125093. export class TGATools {
  125094. private static _TYPE_INDEXED;
  125095. private static _TYPE_RGB;
  125096. private static _TYPE_GREY;
  125097. private static _TYPE_RLE_INDEXED;
  125098. private static _TYPE_RLE_RGB;
  125099. private static _TYPE_RLE_GREY;
  125100. private static _ORIGIN_MASK;
  125101. private static _ORIGIN_SHIFT;
  125102. private static _ORIGIN_BL;
  125103. private static _ORIGIN_BR;
  125104. private static _ORIGIN_UL;
  125105. private static _ORIGIN_UR;
  125106. /**
  125107. * Gets the header of a TGA file
  125108. * @param data defines the TGA data
  125109. * @returns the header
  125110. */
  125111. static GetTGAHeader(data: Uint8Array): any;
  125112. /**
  125113. * Uploads TGA content to a Babylon Texture
  125114. * @hidden
  125115. */
  125116. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  125117. /** @hidden */
  125118. 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;
  125119. /** @hidden */
  125120. 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;
  125121. /** @hidden */
  125122. 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;
  125123. /** @hidden */
  125124. 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;
  125125. /** @hidden */
  125126. 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;
  125127. /** @hidden */
  125128. 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;
  125129. }
  125130. }
  125131. declare module BABYLON {
  125132. /**
  125133. * Implementation of the TGA Texture Loader.
  125134. * @hidden
  125135. */
  125136. export class _TGATextureLoader implements IInternalTextureLoader {
  125137. /**
  125138. * Defines wether the loader supports cascade loading the different faces.
  125139. */
  125140. readonly supportCascades: boolean;
  125141. /**
  125142. * This returns if the loader support the current file information.
  125143. * @param extension defines the file extension of the file being loaded
  125144. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125145. * @param fallback defines the fallback internal texture if any
  125146. * @param isBase64 defines whether the texture is encoded as a base64
  125147. * @param isBuffer defines whether the texture data are stored as a buffer
  125148. * @returns true if the loader can load the specified file
  125149. */
  125150. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125151. /**
  125152. * Transform the url before loading if required.
  125153. * @param rootUrl the url of the texture
  125154. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125155. * @returns the transformed texture
  125156. */
  125157. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125158. /**
  125159. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125160. * @param rootUrl the url of the texture
  125161. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125162. * @returns the fallback texture
  125163. */
  125164. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125165. /**
  125166. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  125167. * @param data contains the texture data
  125168. * @param texture defines the BabylonJS internal texture
  125169. * @param createPolynomials will be true if polynomials have been requested
  125170. * @param onLoad defines the callback to trigger once the texture is ready
  125171. * @param onError defines the callback to trigger in case of error
  125172. */
  125173. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125174. /**
  125175. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125176. * @param data contains the texture data
  125177. * @param texture defines the BabylonJS internal texture
  125178. * @param callback defines the method to call once ready to upload
  125179. */
  125180. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125181. }
  125182. }
  125183. declare module BABYLON {
  125184. /**
  125185. * Info about the .basis files
  125186. */
  125187. class BasisFileInfo {
  125188. /**
  125189. * If the file has alpha
  125190. */
  125191. hasAlpha: boolean;
  125192. /**
  125193. * Info about each image of the basis file
  125194. */
  125195. images: Array<{
  125196. levels: Array<{
  125197. width: number;
  125198. height: number;
  125199. transcodedPixels: ArrayBufferView;
  125200. }>;
  125201. }>;
  125202. }
  125203. /**
  125204. * Result of transcoding a basis file
  125205. */
  125206. class TranscodeResult {
  125207. /**
  125208. * Info about the .basis file
  125209. */
  125210. fileInfo: BasisFileInfo;
  125211. /**
  125212. * Format to use when loading the file
  125213. */
  125214. format: number;
  125215. }
  125216. /**
  125217. * Configuration options for the Basis transcoder
  125218. */
  125219. export class BasisTranscodeConfiguration {
  125220. /**
  125221. * Supported compression formats used to determine the supported output format of the transcoder
  125222. */
  125223. supportedCompressionFormats?: {
  125224. /**
  125225. * etc1 compression format
  125226. */
  125227. etc1?: boolean;
  125228. /**
  125229. * s3tc compression format
  125230. */
  125231. s3tc?: boolean;
  125232. /**
  125233. * pvrtc compression format
  125234. */
  125235. pvrtc?: boolean;
  125236. /**
  125237. * etc2 compression format
  125238. */
  125239. etc2?: boolean;
  125240. };
  125241. /**
  125242. * If mipmap levels should be loaded for transcoded images (Default: true)
  125243. */
  125244. loadMipmapLevels?: boolean;
  125245. /**
  125246. * Index of a single image to load (Default: all images)
  125247. */
  125248. loadSingleImage?: number;
  125249. }
  125250. /**
  125251. * Used to load .Basis files
  125252. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  125253. */
  125254. export class BasisTools {
  125255. private static _IgnoreSupportedFormats;
  125256. /**
  125257. * URL to use when loading the basis transcoder
  125258. */
  125259. static JSModuleURL: string;
  125260. /**
  125261. * URL to use when loading the wasm module for the transcoder
  125262. */
  125263. static WasmModuleURL: string;
  125264. /**
  125265. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  125266. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  125267. * @returns internal format corresponding to the Basis format
  125268. */
  125269. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  125270. private static _WorkerPromise;
  125271. private static _Worker;
  125272. private static _actionId;
  125273. private static _CreateWorkerAsync;
  125274. /**
  125275. * Transcodes a loaded image file to compressed pixel data
  125276. * @param imageData image data to transcode
  125277. * @param config configuration options for the transcoding
  125278. * @returns a promise resulting in the transcoded image
  125279. */
  125280. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  125281. /**
  125282. * Loads a texture from the transcode result
  125283. * @param texture texture load to
  125284. * @param transcodeResult the result of transcoding the basis file to load from
  125285. */
  125286. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  125287. }
  125288. }
  125289. declare module BABYLON {
  125290. /**
  125291. * Loader for .basis file format
  125292. */
  125293. export class _BasisTextureLoader implements IInternalTextureLoader {
  125294. /**
  125295. * Defines whether the loader supports cascade loading the different faces.
  125296. */
  125297. readonly supportCascades: boolean;
  125298. /**
  125299. * This returns if the loader support the current file information.
  125300. * @param extension defines the file extension of the file being loaded
  125301. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125302. * @param fallback defines the fallback internal texture if any
  125303. * @param isBase64 defines whether the texture is encoded as a base64
  125304. * @param isBuffer defines whether the texture data are stored as a buffer
  125305. * @returns true if the loader can load the specified file
  125306. */
  125307. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125308. /**
  125309. * Transform the url before loading if required.
  125310. * @param rootUrl the url of the texture
  125311. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125312. * @returns the transformed texture
  125313. */
  125314. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125315. /**
  125316. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125317. * @param rootUrl the url of the texture
  125318. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125319. * @returns the fallback texture
  125320. */
  125321. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125322. /**
  125323. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  125324. * @param data contains the texture data
  125325. * @param texture defines the BabylonJS internal texture
  125326. * @param createPolynomials will be true if polynomials have been requested
  125327. * @param onLoad defines the callback to trigger once the texture is ready
  125328. * @param onError defines the callback to trigger in case of error
  125329. */
  125330. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125331. /**
  125332. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125333. * @param data contains the texture data
  125334. * @param texture defines the BabylonJS internal texture
  125335. * @param callback defines the method to call once ready to upload
  125336. */
  125337. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125338. }
  125339. }
  125340. declare module BABYLON {
  125341. /**
  125342. * 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.
  125343. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  125344. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  125345. */
  125346. export class CustomProceduralTexture extends ProceduralTexture {
  125347. private _animate;
  125348. private _time;
  125349. private _config;
  125350. private _texturePath;
  125351. /**
  125352. * Instantiates a new Custom Procedural Texture.
  125353. * 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.
  125354. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  125355. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  125356. * @param name Define the name of the texture
  125357. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  125358. * @param size Define the size of the texture to create
  125359. * @param scene Define the scene the texture belongs to
  125360. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  125361. * @param generateMipMaps Define if the texture should creates mip maps or not
  125362. */
  125363. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  125364. private _loadJson;
  125365. /**
  125366. * Is the texture ready to be used ? (rendered at least once)
  125367. * @returns true if ready, otherwise, false.
  125368. */
  125369. isReady(): boolean;
  125370. /**
  125371. * Render the texture to its associated render target.
  125372. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  125373. */
  125374. render(useCameraPostProcess?: boolean): void;
  125375. /**
  125376. * Update the list of dependant textures samplers in the shader.
  125377. */
  125378. updateTextures(): void;
  125379. /**
  125380. * Update the uniform values of the procedural texture in the shader.
  125381. */
  125382. updateShaderUniforms(): void;
  125383. /**
  125384. * Define if the texture animates or not.
  125385. */
  125386. get animate(): boolean;
  125387. set animate(value: boolean);
  125388. }
  125389. }
  125390. declare module BABYLON {
  125391. /** @hidden */
  125392. export var noisePixelShader: {
  125393. name: string;
  125394. shader: string;
  125395. };
  125396. }
  125397. declare module BABYLON {
  125398. /**
  125399. * Class used to generate noise procedural textures
  125400. */
  125401. export class NoiseProceduralTexture extends ProceduralTexture {
  125402. private _time;
  125403. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  125404. brightness: number;
  125405. /** Defines the number of octaves to process */
  125406. octaves: number;
  125407. /** Defines the level of persistence (0.8 by default) */
  125408. persistence: number;
  125409. /** Gets or sets animation speed factor (default is 1) */
  125410. animationSpeedFactor: number;
  125411. /**
  125412. * Creates a new NoiseProceduralTexture
  125413. * @param name defines the name fo the texture
  125414. * @param size defines the size of the texture (default is 256)
  125415. * @param scene defines the hosting scene
  125416. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  125417. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  125418. */
  125419. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  125420. private _updateShaderUniforms;
  125421. protected _getDefines(): string;
  125422. /** Generate the current state of the procedural texture */
  125423. render(useCameraPostProcess?: boolean): void;
  125424. /**
  125425. * Serializes this noise procedural texture
  125426. * @returns a serialized noise procedural texture object
  125427. */
  125428. serialize(): any;
  125429. /**
  125430. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  125431. * @param parsedTexture defines parsed texture data
  125432. * @param scene defines the current scene
  125433. * @param rootUrl defines the root URL containing noise procedural texture information
  125434. * @returns a parsed NoiseProceduralTexture
  125435. */
  125436. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  125437. }
  125438. }
  125439. declare module BABYLON {
  125440. /**
  125441. * Raw cube texture where the raw buffers are passed in
  125442. */
  125443. export class RawCubeTexture extends CubeTexture {
  125444. /**
  125445. * Creates a cube texture where the raw buffers are passed in.
  125446. * @param scene defines the scene the texture is attached to
  125447. * @param data defines the array of data to use to create each face
  125448. * @param size defines the size of the textures
  125449. * @param format defines the format of the data
  125450. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  125451. * @param generateMipMaps defines if the engine should generate the mip levels
  125452. * @param invertY defines if data must be stored with Y axis inverted
  125453. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  125454. * @param compression defines the compression used (null by default)
  125455. */
  125456. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  125457. /**
  125458. * Updates the raw cube texture.
  125459. * @param data defines the data to store
  125460. * @param format defines the data format
  125461. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  125462. * @param invertY defines if data must be stored with Y axis inverted
  125463. * @param compression defines the compression used (null by default)
  125464. * @param level defines which level of the texture to update
  125465. */
  125466. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  125467. /**
  125468. * Updates a raw cube texture with RGBD encoded data.
  125469. * @param data defines the array of data [mipmap][face] to use to create each face
  125470. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  125471. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  125472. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  125473. * @returns a promsie that resolves when the operation is complete
  125474. */
  125475. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  125476. /**
  125477. * Clones the raw cube texture.
  125478. * @return a new cube texture
  125479. */
  125480. clone(): CubeTexture;
  125481. /** @hidden */
  125482. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  125483. }
  125484. }
  125485. declare module BABYLON {
  125486. /**
  125487. * Class used to store 3D textures containing user data
  125488. */
  125489. export class RawTexture3D extends Texture {
  125490. /** Gets or sets the texture format to use */
  125491. format: number;
  125492. private _engine;
  125493. /**
  125494. * Create a new RawTexture3D
  125495. * @param data defines the data of the texture
  125496. * @param width defines the width of the texture
  125497. * @param height defines the height of the texture
  125498. * @param depth defines the depth of the texture
  125499. * @param format defines the texture format to use
  125500. * @param scene defines the hosting scene
  125501. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  125502. * @param invertY defines if texture must be stored with Y axis inverted
  125503. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  125504. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  125505. */
  125506. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  125507. /** Gets or sets the texture format to use */
  125508. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  125509. /**
  125510. * Update the texture with new data
  125511. * @param data defines the data to store in the texture
  125512. */
  125513. update(data: ArrayBufferView): void;
  125514. }
  125515. }
  125516. declare module BABYLON {
  125517. /**
  125518. * Class used to store 2D array textures containing user data
  125519. */
  125520. export class RawTexture2DArray extends Texture {
  125521. /** Gets or sets the texture format to use */
  125522. format: number;
  125523. private _engine;
  125524. /**
  125525. * Create a new RawTexture2DArray
  125526. * @param data defines the data of the texture
  125527. * @param width defines the width of the texture
  125528. * @param height defines the height of the texture
  125529. * @param depth defines the number of layers of the texture
  125530. * @param format defines the texture format to use
  125531. * @param scene defines the hosting scene
  125532. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  125533. * @param invertY defines if texture must be stored with Y axis inverted
  125534. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  125535. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  125536. */
  125537. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  125538. /** Gets or sets the texture format to use */
  125539. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  125540. /**
  125541. * Update the texture with new data
  125542. * @param data defines the data to store in the texture
  125543. */
  125544. update(data: ArrayBufferView): void;
  125545. }
  125546. }
  125547. declare module BABYLON {
  125548. /**
  125549. * Creates a refraction texture used by refraction channel of the standard material.
  125550. * It is like a mirror but to see through a material.
  125551. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  125552. */
  125553. export class RefractionTexture extends RenderTargetTexture {
  125554. /**
  125555. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  125556. * 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.
  125557. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  125558. */
  125559. refractionPlane: Plane;
  125560. /**
  125561. * Define how deep under the surface we should see.
  125562. */
  125563. depth: number;
  125564. /**
  125565. * Creates a refraction texture used by refraction channel of the standard material.
  125566. * It is like a mirror but to see through a material.
  125567. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  125568. * @param name Define the texture name
  125569. * @param size Define the size of the underlying texture
  125570. * @param scene Define the scene the refraction belongs to
  125571. * @param generateMipMaps Define if we need to generate mips level for the refraction
  125572. */
  125573. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  125574. /**
  125575. * Clone the refraction texture.
  125576. * @returns the cloned texture
  125577. */
  125578. clone(): RefractionTexture;
  125579. /**
  125580. * Serialize the texture to a JSON representation you could use in Parse later on
  125581. * @returns the serialized JSON representation
  125582. */
  125583. serialize(): any;
  125584. }
  125585. }
  125586. declare module BABYLON {
  125587. /**
  125588. * Defines the options related to the creation of an HtmlElementTexture
  125589. */
  125590. export interface IHtmlElementTextureOptions {
  125591. /**
  125592. * Defines wether mip maps should be created or not.
  125593. */
  125594. generateMipMaps?: boolean;
  125595. /**
  125596. * Defines the sampling mode of the texture.
  125597. */
  125598. samplingMode?: number;
  125599. /**
  125600. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  125601. */
  125602. engine: Nullable<ThinEngine>;
  125603. /**
  125604. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  125605. */
  125606. scene: Nullable<Scene>;
  125607. }
  125608. /**
  125609. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  125610. * To be as efficient as possible depending on your constraints nothing aside the first upload
  125611. * is automatically managed.
  125612. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  125613. * in your application.
  125614. *
  125615. * As the update is not automatic, you need to call them manually.
  125616. */
  125617. export class HtmlElementTexture extends BaseTexture {
  125618. /**
  125619. * The texture URL.
  125620. */
  125621. element: HTMLVideoElement | HTMLCanvasElement;
  125622. private static readonly DefaultOptions;
  125623. private _textureMatrix;
  125624. private _engine;
  125625. private _isVideo;
  125626. private _generateMipMaps;
  125627. private _samplingMode;
  125628. /**
  125629. * Instantiates a HtmlElementTexture from the following parameters.
  125630. *
  125631. * @param name Defines the name of the texture
  125632. * @param element Defines the video or canvas the texture is filled with
  125633. * @param options Defines the other none mandatory texture creation options
  125634. */
  125635. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  125636. private _createInternalTexture;
  125637. /**
  125638. * Returns the texture matrix used in most of the material.
  125639. */
  125640. getTextureMatrix(): Matrix;
  125641. /**
  125642. * Updates the content of the texture.
  125643. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  125644. */
  125645. update(invertY?: Nullable<boolean>): void;
  125646. }
  125647. }
  125648. declare module BABYLON {
  125649. /**
  125650. * Enum used to define the target of a block
  125651. */
  125652. export enum NodeMaterialBlockTargets {
  125653. /** Vertex shader */
  125654. Vertex = 1,
  125655. /** Fragment shader */
  125656. Fragment = 2,
  125657. /** Neutral */
  125658. Neutral = 4,
  125659. /** Vertex and Fragment */
  125660. VertexAndFragment = 3
  125661. }
  125662. }
  125663. declare module BABYLON {
  125664. /**
  125665. * Defines the kind of connection point for node based material
  125666. */
  125667. export enum NodeMaterialBlockConnectionPointTypes {
  125668. /** Float */
  125669. Float = 1,
  125670. /** Int */
  125671. Int = 2,
  125672. /** Vector2 */
  125673. Vector2 = 4,
  125674. /** Vector3 */
  125675. Vector3 = 8,
  125676. /** Vector4 */
  125677. Vector4 = 16,
  125678. /** Color3 */
  125679. Color3 = 32,
  125680. /** Color4 */
  125681. Color4 = 64,
  125682. /** Matrix */
  125683. Matrix = 128,
  125684. /** Detect type based on connection */
  125685. AutoDetect = 1024,
  125686. /** Output type that will be defined by input type */
  125687. BasedOnInput = 2048
  125688. }
  125689. }
  125690. declare module BABYLON {
  125691. /**
  125692. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  125693. */
  125694. export enum NodeMaterialBlockConnectionPointMode {
  125695. /** Value is an uniform */
  125696. Uniform = 0,
  125697. /** Value is a mesh attribute */
  125698. Attribute = 1,
  125699. /** Value is a varying between vertex and fragment shaders */
  125700. Varying = 2,
  125701. /** Mode is undefined */
  125702. Undefined = 3
  125703. }
  125704. }
  125705. declare module BABYLON {
  125706. /**
  125707. * Enum used to define system values e.g. values automatically provided by the system
  125708. */
  125709. export enum NodeMaterialSystemValues {
  125710. /** World */
  125711. World = 1,
  125712. /** View */
  125713. View = 2,
  125714. /** Projection */
  125715. Projection = 3,
  125716. /** ViewProjection */
  125717. ViewProjection = 4,
  125718. /** WorldView */
  125719. WorldView = 5,
  125720. /** WorldViewProjection */
  125721. WorldViewProjection = 6,
  125722. /** CameraPosition */
  125723. CameraPosition = 7,
  125724. /** Fog Color */
  125725. FogColor = 8,
  125726. /** Delta time */
  125727. DeltaTime = 9
  125728. }
  125729. }
  125730. declare module BABYLON {
  125731. /**
  125732. * Root class for all node material optimizers
  125733. */
  125734. export class NodeMaterialOptimizer {
  125735. /**
  125736. * Function used to optimize a NodeMaterial graph
  125737. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  125738. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  125739. */
  125740. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  125741. }
  125742. }
  125743. declare module BABYLON {
  125744. /**
  125745. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  125746. */
  125747. export class TransformBlock extends NodeMaterialBlock {
  125748. /**
  125749. * Defines the value to use to complement W value to transform it to a Vector4
  125750. */
  125751. complementW: number;
  125752. /**
  125753. * Defines the value to use to complement z value to transform it to a Vector4
  125754. */
  125755. complementZ: number;
  125756. /**
  125757. * Creates a new TransformBlock
  125758. * @param name defines the block name
  125759. */
  125760. constructor(name: string);
  125761. /**
  125762. * Gets the current class name
  125763. * @returns the class name
  125764. */
  125765. getClassName(): string;
  125766. /**
  125767. * Gets the vector input
  125768. */
  125769. get vector(): NodeMaterialConnectionPoint;
  125770. /**
  125771. * Gets the output component
  125772. */
  125773. get output(): NodeMaterialConnectionPoint;
  125774. /**
  125775. * Gets the matrix transform input
  125776. */
  125777. get transform(): NodeMaterialConnectionPoint;
  125778. protected _buildBlock(state: NodeMaterialBuildState): this;
  125779. serialize(): any;
  125780. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125781. protected _dumpPropertiesCode(): string;
  125782. }
  125783. }
  125784. declare module BABYLON {
  125785. /**
  125786. * Block used to output the vertex position
  125787. */
  125788. export class VertexOutputBlock extends NodeMaterialBlock {
  125789. /**
  125790. * Creates a new VertexOutputBlock
  125791. * @param name defines the block name
  125792. */
  125793. constructor(name: string);
  125794. /**
  125795. * Gets the current class name
  125796. * @returns the class name
  125797. */
  125798. getClassName(): string;
  125799. /**
  125800. * Gets the vector input component
  125801. */
  125802. get vector(): NodeMaterialConnectionPoint;
  125803. protected _buildBlock(state: NodeMaterialBuildState): this;
  125804. }
  125805. }
  125806. declare module BABYLON {
  125807. /**
  125808. * Block used to output the final color
  125809. */
  125810. export class FragmentOutputBlock extends NodeMaterialBlock {
  125811. /**
  125812. * Create a new FragmentOutputBlock
  125813. * @param name defines the block name
  125814. */
  125815. constructor(name: string);
  125816. /**
  125817. * Gets the current class name
  125818. * @returns the class name
  125819. */
  125820. getClassName(): string;
  125821. /**
  125822. * Gets the rgba input component
  125823. */
  125824. get rgba(): NodeMaterialConnectionPoint;
  125825. /**
  125826. * Gets the rgb input component
  125827. */
  125828. get rgb(): NodeMaterialConnectionPoint;
  125829. /**
  125830. * Gets the a input component
  125831. */
  125832. get a(): NodeMaterialConnectionPoint;
  125833. protected _buildBlock(state: NodeMaterialBuildState): this;
  125834. }
  125835. }
  125836. declare module BABYLON {
  125837. /**
  125838. * Block used to read a reflection texture from a sampler
  125839. */
  125840. export class ReflectionTextureBlock extends NodeMaterialBlock {
  125841. private _define3DName;
  125842. private _defineCubicName;
  125843. private _defineExplicitName;
  125844. private _defineProjectionName;
  125845. private _defineLocalCubicName;
  125846. private _defineSphericalName;
  125847. private _definePlanarName;
  125848. private _defineEquirectangularName;
  125849. private _defineMirroredEquirectangularFixedName;
  125850. private _defineEquirectangularFixedName;
  125851. private _defineSkyboxName;
  125852. private _cubeSamplerName;
  125853. private _2DSamplerName;
  125854. private _positionUVWName;
  125855. private _directionWName;
  125856. private _reflectionCoordsName;
  125857. private _reflection2DCoordsName;
  125858. private _reflectionColorName;
  125859. private _reflectionMatrixName;
  125860. /**
  125861. * Gets or sets the texture associated with the node
  125862. */
  125863. texture: Nullable<BaseTexture>;
  125864. /**
  125865. * Create a new TextureBlock
  125866. * @param name defines the block name
  125867. */
  125868. constructor(name: string);
  125869. /**
  125870. * Gets the current class name
  125871. * @returns the class name
  125872. */
  125873. getClassName(): string;
  125874. /**
  125875. * Gets the world position input component
  125876. */
  125877. get position(): NodeMaterialConnectionPoint;
  125878. /**
  125879. * Gets the world position input component
  125880. */
  125881. get worldPosition(): NodeMaterialConnectionPoint;
  125882. /**
  125883. * Gets the world normal input component
  125884. */
  125885. get worldNormal(): NodeMaterialConnectionPoint;
  125886. /**
  125887. * Gets the world input component
  125888. */
  125889. get world(): NodeMaterialConnectionPoint;
  125890. /**
  125891. * Gets the camera (or eye) position component
  125892. */
  125893. get cameraPosition(): NodeMaterialConnectionPoint;
  125894. /**
  125895. * Gets the view input component
  125896. */
  125897. get view(): NodeMaterialConnectionPoint;
  125898. /**
  125899. * Gets the rgb output component
  125900. */
  125901. get rgb(): NodeMaterialConnectionPoint;
  125902. /**
  125903. * Gets the r output component
  125904. */
  125905. get r(): NodeMaterialConnectionPoint;
  125906. /**
  125907. * Gets the g output component
  125908. */
  125909. get g(): NodeMaterialConnectionPoint;
  125910. /**
  125911. * Gets the b output component
  125912. */
  125913. get b(): NodeMaterialConnectionPoint;
  125914. autoConfigure(material: NodeMaterial): void;
  125915. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  125916. isReady(): boolean;
  125917. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  125918. private _injectVertexCode;
  125919. private _writeOutput;
  125920. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125921. protected _dumpPropertiesCode(): string;
  125922. serialize(): any;
  125923. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125924. }
  125925. }
  125926. declare module BABYLON {
  125927. /**
  125928. * Interface used to configure the node material editor
  125929. */
  125930. export interface INodeMaterialEditorOptions {
  125931. /** Define the URl to load node editor script */
  125932. editorURL?: string;
  125933. }
  125934. /** @hidden */
  125935. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  125936. /** BONES */
  125937. NUM_BONE_INFLUENCERS: number;
  125938. BonesPerMesh: number;
  125939. BONETEXTURE: boolean;
  125940. /** MORPH TARGETS */
  125941. MORPHTARGETS: boolean;
  125942. MORPHTARGETS_NORMAL: boolean;
  125943. MORPHTARGETS_TANGENT: boolean;
  125944. MORPHTARGETS_UV: boolean;
  125945. NUM_MORPH_INFLUENCERS: number;
  125946. /** IMAGE PROCESSING */
  125947. IMAGEPROCESSING: boolean;
  125948. VIGNETTE: boolean;
  125949. VIGNETTEBLENDMODEMULTIPLY: boolean;
  125950. VIGNETTEBLENDMODEOPAQUE: boolean;
  125951. TONEMAPPING: boolean;
  125952. TONEMAPPING_ACES: boolean;
  125953. CONTRAST: boolean;
  125954. EXPOSURE: boolean;
  125955. COLORCURVES: boolean;
  125956. COLORGRADING: boolean;
  125957. COLORGRADING3D: boolean;
  125958. SAMPLER3DGREENDEPTH: boolean;
  125959. SAMPLER3DBGRMAP: boolean;
  125960. IMAGEPROCESSINGPOSTPROCESS: boolean;
  125961. /** MISC. */
  125962. BUMPDIRECTUV: number;
  125963. constructor();
  125964. setValue(name: string, value: boolean): void;
  125965. }
  125966. /**
  125967. * Class used to configure NodeMaterial
  125968. */
  125969. export interface INodeMaterialOptions {
  125970. /**
  125971. * Defines if blocks should emit comments
  125972. */
  125973. emitComments: boolean;
  125974. }
  125975. /**
  125976. * Class used to create a node based material built by assembling shader blocks
  125977. */
  125978. export class NodeMaterial extends PushMaterial {
  125979. private static _BuildIdGenerator;
  125980. private _options;
  125981. private _vertexCompilationState;
  125982. private _fragmentCompilationState;
  125983. private _sharedData;
  125984. private _buildId;
  125985. private _buildWasSuccessful;
  125986. private _cachedWorldViewMatrix;
  125987. private _cachedWorldViewProjectionMatrix;
  125988. private _optimizers;
  125989. private _animationFrame;
  125990. /** Define the URl to load node editor script */
  125991. static EditorURL: string;
  125992. private BJSNODEMATERIALEDITOR;
  125993. /** Get the inspector from bundle or global */
  125994. private _getGlobalNodeMaterialEditor;
  125995. /**
  125996. * Gets or sets data used by visual editor
  125997. * @see https://nme.babylonjs.com
  125998. */
  125999. editorData: any;
  126000. /**
  126001. * 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)
  126002. */
  126003. ignoreAlpha: boolean;
  126004. /**
  126005. * Defines the maximum number of lights that can be used in the material
  126006. */
  126007. maxSimultaneousLights: number;
  126008. /**
  126009. * Observable raised when the material is built
  126010. */
  126011. onBuildObservable: Observable<NodeMaterial>;
  126012. /**
  126013. * Gets or sets the root nodes of the material vertex shader
  126014. */
  126015. _vertexOutputNodes: NodeMaterialBlock[];
  126016. /**
  126017. * Gets or sets the root nodes of the material fragment (pixel) shader
  126018. */
  126019. _fragmentOutputNodes: NodeMaterialBlock[];
  126020. /** Gets or sets options to control the node material overall behavior */
  126021. get options(): INodeMaterialOptions;
  126022. set options(options: INodeMaterialOptions);
  126023. /**
  126024. * Default configuration related to image processing available in the standard Material.
  126025. */
  126026. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  126027. /**
  126028. * Gets the image processing configuration used either in this material.
  126029. */
  126030. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  126031. /**
  126032. * Sets the Default image processing configuration used either in the this material.
  126033. *
  126034. * If sets to null, the scene one is in use.
  126035. */
  126036. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  126037. /**
  126038. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  126039. */
  126040. attachedBlocks: NodeMaterialBlock[];
  126041. /**
  126042. * Create a new node based material
  126043. * @param name defines the material name
  126044. * @param scene defines the hosting scene
  126045. * @param options defines creation option
  126046. */
  126047. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  126048. /**
  126049. * Gets the current class name of the material e.g. "NodeMaterial"
  126050. * @returns the class name
  126051. */
  126052. getClassName(): string;
  126053. /**
  126054. * Keep track of the image processing observer to allow dispose and replace.
  126055. */
  126056. private _imageProcessingObserver;
  126057. /**
  126058. * Attaches a new image processing configuration to the Standard Material.
  126059. * @param configuration
  126060. */
  126061. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  126062. /**
  126063. * Get a block by its name
  126064. * @param name defines the name of the block to retrieve
  126065. * @returns the required block or null if not found
  126066. */
  126067. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  126068. /**
  126069. * Get a block by its name
  126070. * @param predicate defines the predicate used to find the good candidate
  126071. * @returns the required block or null if not found
  126072. */
  126073. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  126074. /**
  126075. * Get an input block by its name
  126076. * @param predicate defines the predicate used to find the good candidate
  126077. * @returns the required input block or null if not found
  126078. */
  126079. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  126080. /**
  126081. * Gets the list of input blocks attached to this material
  126082. * @returns an array of InputBlocks
  126083. */
  126084. getInputBlocks(): InputBlock[];
  126085. /**
  126086. * Adds a new optimizer to the list of optimizers
  126087. * @param optimizer defines the optimizers to add
  126088. * @returns the current material
  126089. */
  126090. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  126091. /**
  126092. * Remove an optimizer from the list of optimizers
  126093. * @param optimizer defines the optimizers to remove
  126094. * @returns the current material
  126095. */
  126096. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  126097. /**
  126098. * Add a new block to the list of output nodes
  126099. * @param node defines the node to add
  126100. * @returns the current material
  126101. */
  126102. addOutputNode(node: NodeMaterialBlock): this;
  126103. /**
  126104. * Remove a block from the list of root nodes
  126105. * @param node defines the node to remove
  126106. * @returns the current material
  126107. */
  126108. removeOutputNode(node: NodeMaterialBlock): this;
  126109. private _addVertexOutputNode;
  126110. private _removeVertexOutputNode;
  126111. private _addFragmentOutputNode;
  126112. private _removeFragmentOutputNode;
  126113. /**
  126114. * Specifies if the material will require alpha blending
  126115. * @returns a boolean specifying if alpha blending is needed
  126116. */
  126117. needAlphaBlending(): boolean;
  126118. /**
  126119. * Specifies if this material should be rendered in alpha test mode
  126120. * @returns a boolean specifying if an alpha test is needed.
  126121. */
  126122. needAlphaTesting(): boolean;
  126123. private _initializeBlock;
  126124. private _resetDualBlocks;
  126125. /**
  126126. * Remove a block from the current node material
  126127. * @param block defines the block to remove
  126128. */
  126129. removeBlock(block: NodeMaterialBlock): void;
  126130. /**
  126131. * Build the material and generates the inner effect
  126132. * @param verbose defines if the build should log activity
  126133. */
  126134. build(verbose?: boolean): void;
  126135. /**
  126136. * Runs an otpimization phase to try to improve the shader code
  126137. */
  126138. optimize(): void;
  126139. private _prepareDefinesForAttributes;
  126140. /**
  126141. * Get if the submesh is ready to be used and all its information available.
  126142. * Child classes can use it to update shaders
  126143. * @param mesh defines the mesh to check
  126144. * @param subMesh defines which submesh to check
  126145. * @param useInstances specifies that instances should be used
  126146. * @returns a boolean indicating that the submesh is ready or not
  126147. */
  126148. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  126149. /**
  126150. * Get a string representing the shaders built by the current node graph
  126151. */
  126152. get compiledShaders(): string;
  126153. /**
  126154. * Binds the world matrix to the material
  126155. * @param world defines the world transformation matrix
  126156. */
  126157. bindOnlyWorldMatrix(world: Matrix): void;
  126158. /**
  126159. * Binds the submesh to this material by preparing the effect and shader to draw
  126160. * @param world defines the world transformation matrix
  126161. * @param mesh defines the mesh containing the submesh
  126162. * @param subMesh defines the submesh to bind the material to
  126163. */
  126164. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  126165. /**
  126166. * Gets the active textures from the material
  126167. * @returns an array of textures
  126168. */
  126169. getActiveTextures(): BaseTexture[];
  126170. /**
  126171. * Gets the list of texture blocks
  126172. * @returns an array of texture blocks
  126173. */
  126174. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  126175. /**
  126176. * Specifies if the material uses a texture
  126177. * @param texture defines the texture to check against the material
  126178. * @returns a boolean specifying if the material uses the texture
  126179. */
  126180. hasTexture(texture: BaseTexture): boolean;
  126181. /**
  126182. * Disposes the material
  126183. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  126184. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  126185. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  126186. */
  126187. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  126188. /** Creates the node editor window. */
  126189. private _createNodeEditor;
  126190. /**
  126191. * Launch the node material editor
  126192. * @param config Define the configuration of the editor
  126193. * @return a promise fulfilled when the node editor is visible
  126194. */
  126195. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  126196. /**
  126197. * Clear the current material
  126198. */
  126199. clear(): void;
  126200. /**
  126201. * Clear the current material and set it to a default state
  126202. */
  126203. setToDefault(): void;
  126204. /**
  126205. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  126206. * @param url defines the url to load from
  126207. * @returns a promise that will fullfil when the material is fully loaded
  126208. */
  126209. loadAsync(url: string): Promise<void>;
  126210. private _gatherBlocks;
  126211. /**
  126212. * Generate a string containing the code declaration required to create an equivalent of this material
  126213. * @returns a string
  126214. */
  126215. generateCode(): string;
  126216. /**
  126217. * Serializes this material in a JSON representation
  126218. * @returns the serialized material object
  126219. */
  126220. serialize(): any;
  126221. private _restoreConnections;
  126222. /**
  126223. * Clear the current graph and load a new one from a serialization object
  126224. * @param source defines the JSON representation of the material
  126225. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  126226. */
  126227. loadFromSerialization(source: any, rootUrl?: string): void;
  126228. /**
  126229. * Creates a node material from parsed material data
  126230. * @param source defines the JSON representation of the material
  126231. * @param scene defines the hosting scene
  126232. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  126233. * @returns a new node material
  126234. */
  126235. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  126236. /**
  126237. * Creates a new node material set to default basic configuration
  126238. * @param name defines the name of the material
  126239. * @param scene defines the hosting scene
  126240. * @returns a new NodeMaterial
  126241. */
  126242. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  126243. }
  126244. }
  126245. declare module BABYLON {
  126246. /**
  126247. * Block used to read a texture from a sampler
  126248. */
  126249. export class TextureBlock extends NodeMaterialBlock {
  126250. private _defineName;
  126251. private _linearDefineName;
  126252. private _tempTextureRead;
  126253. private _samplerName;
  126254. private _transformedUVName;
  126255. private _textureTransformName;
  126256. private _textureInfoName;
  126257. private _mainUVName;
  126258. private _mainUVDefineName;
  126259. /**
  126260. * Gets or sets the texture associated with the node
  126261. */
  126262. texture: Nullable<Texture>;
  126263. /**
  126264. * Create a new TextureBlock
  126265. * @param name defines the block name
  126266. */
  126267. constructor(name: string);
  126268. /**
  126269. * Gets the current class name
  126270. * @returns the class name
  126271. */
  126272. getClassName(): string;
  126273. /**
  126274. * Gets the uv input component
  126275. */
  126276. get uv(): NodeMaterialConnectionPoint;
  126277. /**
  126278. * Gets the rgba output component
  126279. */
  126280. get rgba(): NodeMaterialConnectionPoint;
  126281. /**
  126282. * Gets the rgb output component
  126283. */
  126284. get rgb(): NodeMaterialConnectionPoint;
  126285. /**
  126286. * Gets the r output component
  126287. */
  126288. get r(): NodeMaterialConnectionPoint;
  126289. /**
  126290. * Gets the g output component
  126291. */
  126292. get g(): NodeMaterialConnectionPoint;
  126293. /**
  126294. * Gets the b output component
  126295. */
  126296. get b(): NodeMaterialConnectionPoint;
  126297. /**
  126298. * Gets the a output component
  126299. */
  126300. get a(): NodeMaterialConnectionPoint;
  126301. get target(): NodeMaterialBlockTargets;
  126302. autoConfigure(material: NodeMaterial): void;
  126303. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  126304. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  126305. private _getTextureBase;
  126306. isReady(): boolean;
  126307. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  126308. private get _isMixed();
  126309. private _injectVertexCode;
  126310. private _writeTextureRead;
  126311. private _writeOutput;
  126312. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  126313. protected _dumpPropertiesCode(): string;
  126314. serialize(): any;
  126315. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126316. }
  126317. }
  126318. declare module BABYLON {
  126319. /**
  126320. * Class used to store shared data between 2 NodeMaterialBuildState
  126321. */
  126322. export class NodeMaterialBuildStateSharedData {
  126323. /**
  126324. * Gets the list of emitted varyings
  126325. */
  126326. temps: string[];
  126327. /**
  126328. * Gets the list of emitted varyings
  126329. */
  126330. varyings: string[];
  126331. /**
  126332. * Gets the varying declaration string
  126333. */
  126334. varyingDeclaration: string;
  126335. /**
  126336. * Input blocks
  126337. */
  126338. inputBlocks: InputBlock[];
  126339. /**
  126340. * Input blocks
  126341. */
  126342. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  126343. /**
  126344. * Bindable blocks (Blocks that need to set data to the effect)
  126345. */
  126346. bindableBlocks: NodeMaterialBlock[];
  126347. /**
  126348. * List of blocks that can provide a compilation fallback
  126349. */
  126350. blocksWithFallbacks: NodeMaterialBlock[];
  126351. /**
  126352. * List of blocks that can provide a define update
  126353. */
  126354. blocksWithDefines: NodeMaterialBlock[];
  126355. /**
  126356. * List of blocks that can provide a repeatable content
  126357. */
  126358. repeatableContentBlocks: NodeMaterialBlock[];
  126359. /**
  126360. * List of blocks that can provide a dynamic list of uniforms
  126361. */
  126362. dynamicUniformBlocks: NodeMaterialBlock[];
  126363. /**
  126364. * List of blocks that can block the isReady function for the material
  126365. */
  126366. blockingBlocks: NodeMaterialBlock[];
  126367. /**
  126368. * Gets the list of animated inputs
  126369. */
  126370. animatedInputs: InputBlock[];
  126371. /**
  126372. * Build Id used to avoid multiple recompilations
  126373. */
  126374. buildId: number;
  126375. /** List of emitted variables */
  126376. variableNames: {
  126377. [key: string]: number;
  126378. };
  126379. /** List of emitted defines */
  126380. defineNames: {
  126381. [key: string]: number;
  126382. };
  126383. /** Should emit comments? */
  126384. emitComments: boolean;
  126385. /** Emit build activity */
  126386. verbose: boolean;
  126387. /** Gets or sets the hosting scene */
  126388. scene: Scene;
  126389. /**
  126390. * Gets the compilation hints emitted at compilation time
  126391. */
  126392. hints: {
  126393. needWorldViewMatrix: boolean;
  126394. needWorldViewProjectionMatrix: boolean;
  126395. needAlphaBlending: boolean;
  126396. needAlphaTesting: boolean;
  126397. };
  126398. /**
  126399. * List of compilation checks
  126400. */
  126401. checks: {
  126402. emitVertex: boolean;
  126403. emitFragment: boolean;
  126404. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  126405. };
  126406. /** Creates a new shared data */
  126407. constructor();
  126408. /**
  126409. * Emits console errors and exceptions if there is a failing check
  126410. */
  126411. emitErrors(): void;
  126412. }
  126413. }
  126414. declare module BABYLON {
  126415. /**
  126416. * Class used to store node based material build state
  126417. */
  126418. export class NodeMaterialBuildState {
  126419. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  126420. supportUniformBuffers: boolean;
  126421. /**
  126422. * Gets the list of emitted attributes
  126423. */
  126424. attributes: string[];
  126425. /**
  126426. * Gets the list of emitted uniforms
  126427. */
  126428. uniforms: string[];
  126429. /**
  126430. * Gets the list of emitted constants
  126431. */
  126432. constants: string[];
  126433. /**
  126434. * Gets the list of emitted samplers
  126435. */
  126436. samplers: string[];
  126437. /**
  126438. * Gets the list of emitted functions
  126439. */
  126440. functions: {
  126441. [key: string]: string;
  126442. };
  126443. /**
  126444. * Gets the list of emitted extensions
  126445. */
  126446. extensions: {
  126447. [key: string]: string;
  126448. };
  126449. /**
  126450. * Gets the target of the compilation state
  126451. */
  126452. target: NodeMaterialBlockTargets;
  126453. /**
  126454. * Gets the list of emitted counters
  126455. */
  126456. counters: {
  126457. [key: string]: number;
  126458. };
  126459. /**
  126460. * Shared data between multiple NodeMaterialBuildState instances
  126461. */
  126462. sharedData: NodeMaterialBuildStateSharedData;
  126463. /** @hidden */
  126464. _vertexState: NodeMaterialBuildState;
  126465. /** @hidden */
  126466. _attributeDeclaration: string;
  126467. /** @hidden */
  126468. _uniformDeclaration: string;
  126469. /** @hidden */
  126470. _constantDeclaration: string;
  126471. /** @hidden */
  126472. _samplerDeclaration: string;
  126473. /** @hidden */
  126474. _varyingTransfer: string;
  126475. private _repeatableContentAnchorIndex;
  126476. /** @hidden */
  126477. _builtCompilationString: string;
  126478. /**
  126479. * Gets the emitted compilation strings
  126480. */
  126481. compilationString: string;
  126482. /**
  126483. * Finalize the compilation strings
  126484. * @param state defines the current compilation state
  126485. */
  126486. finalize(state: NodeMaterialBuildState): void;
  126487. /** @hidden */
  126488. get _repeatableContentAnchor(): string;
  126489. /** @hidden */
  126490. _getFreeVariableName(prefix: string): string;
  126491. /** @hidden */
  126492. _getFreeDefineName(prefix: string): string;
  126493. /** @hidden */
  126494. _excludeVariableName(name: string): void;
  126495. /** @hidden */
  126496. _emit2DSampler(name: string): void;
  126497. /** @hidden */
  126498. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  126499. /** @hidden */
  126500. _emitExtension(name: string, extension: string): void;
  126501. /** @hidden */
  126502. _emitFunction(name: string, code: string, comments: string): void;
  126503. /** @hidden */
  126504. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  126505. replaceStrings?: {
  126506. search: RegExp;
  126507. replace: string;
  126508. }[];
  126509. repeatKey?: string;
  126510. }): string;
  126511. /** @hidden */
  126512. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  126513. repeatKey?: string;
  126514. removeAttributes?: boolean;
  126515. removeUniforms?: boolean;
  126516. removeVaryings?: boolean;
  126517. removeIfDef?: boolean;
  126518. replaceStrings?: {
  126519. search: RegExp;
  126520. replace: string;
  126521. }[];
  126522. }, storeKey?: string): void;
  126523. /** @hidden */
  126524. _registerTempVariable(name: string): boolean;
  126525. /** @hidden */
  126526. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  126527. /** @hidden */
  126528. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  126529. /** @hidden */
  126530. _emitFloat(value: number): string;
  126531. }
  126532. }
  126533. declare module BABYLON {
  126534. /**
  126535. * Defines a block that can be used inside a node based material
  126536. */
  126537. export class NodeMaterialBlock {
  126538. private _buildId;
  126539. private _buildTarget;
  126540. private _target;
  126541. private _isFinalMerger;
  126542. private _isInput;
  126543. protected _isUnique: boolean;
  126544. /** @hidden */
  126545. _codeVariableName: string;
  126546. /** @hidden */
  126547. _inputs: NodeMaterialConnectionPoint[];
  126548. /** @hidden */
  126549. _outputs: NodeMaterialConnectionPoint[];
  126550. /** @hidden */
  126551. _preparationId: number;
  126552. /**
  126553. * Gets or sets the name of the block
  126554. */
  126555. name: string;
  126556. /**
  126557. * Gets or sets the unique id of the node
  126558. */
  126559. uniqueId: number;
  126560. /**
  126561. * Gets or sets the comments associated with this block
  126562. */
  126563. comments: string;
  126564. /**
  126565. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  126566. */
  126567. get isUnique(): boolean;
  126568. /**
  126569. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  126570. */
  126571. get isFinalMerger(): boolean;
  126572. /**
  126573. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  126574. */
  126575. get isInput(): boolean;
  126576. /**
  126577. * Gets or sets the build Id
  126578. */
  126579. get buildId(): number;
  126580. set buildId(value: number);
  126581. /**
  126582. * Gets or sets the target of the block
  126583. */
  126584. get target(): NodeMaterialBlockTargets;
  126585. set target(value: NodeMaterialBlockTargets);
  126586. /**
  126587. * Gets the list of input points
  126588. */
  126589. get inputs(): NodeMaterialConnectionPoint[];
  126590. /** Gets the list of output points */
  126591. get outputs(): NodeMaterialConnectionPoint[];
  126592. /**
  126593. * Find an input by its name
  126594. * @param name defines the name of the input to look for
  126595. * @returns the input or null if not found
  126596. */
  126597. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  126598. /**
  126599. * Find an output by its name
  126600. * @param name defines the name of the outputto look for
  126601. * @returns the output or null if not found
  126602. */
  126603. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  126604. /**
  126605. * Creates a new NodeMaterialBlock
  126606. * @param name defines the block name
  126607. * @param target defines the target of that block (Vertex by default)
  126608. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  126609. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  126610. */
  126611. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  126612. /**
  126613. * Initialize the block and prepare the context for build
  126614. * @param state defines the state that will be used for the build
  126615. */
  126616. initialize(state: NodeMaterialBuildState): void;
  126617. /**
  126618. * Bind data to effect. Will only be called for blocks with isBindable === true
  126619. * @param effect defines the effect to bind data to
  126620. * @param nodeMaterial defines the hosting NodeMaterial
  126621. * @param mesh defines the mesh that will be rendered
  126622. */
  126623. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  126624. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  126625. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  126626. protected _writeFloat(value: number): string;
  126627. /**
  126628. * Gets the current class name e.g. "NodeMaterialBlock"
  126629. * @returns the class name
  126630. */
  126631. getClassName(): string;
  126632. /**
  126633. * Register a new input. Must be called inside a block constructor
  126634. * @param name defines the connection point name
  126635. * @param type defines the connection point type
  126636. * @param isOptional defines a boolean indicating that this input can be omitted
  126637. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  126638. * @returns the current block
  126639. */
  126640. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  126641. /**
  126642. * Register a new output. Must be called inside a block constructor
  126643. * @param name defines the connection point name
  126644. * @param type defines the connection point type
  126645. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  126646. * @returns the current block
  126647. */
  126648. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  126649. /**
  126650. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  126651. * @param forOutput defines an optional connection point to check compatibility with
  126652. * @returns the first available input or null
  126653. */
  126654. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  126655. /**
  126656. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  126657. * @param forBlock defines an optional block to check compatibility with
  126658. * @returns the first available input or null
  126659. */
  126660. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  126661. /**
  126662. * Gets the sibling of the given output
  126663. * @param current defines the current output
  126664. * @returns the next output in the list or null
  126665. */
  126666. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  126667. /**
  126668. * Connect current block with another block
  126669. * @param other defines the block to connect with
  126670. * @param options define the various options to help pick the right connections
  126671. * @returns the current block
  126672. */
  126673. connectTo(other: NodeMaterialBlock, options?: {
  126674. input?: string;
  126675. output?: string;
  126676. outputSwizzle?: string;
  126677. }): this | undefined;
  126678. protected _buildBlock(state: NodeMaterialBuildState): void;
  126679. /**
  126680. * Add uniforms, samplers and uniform buffers at compilation time
  126681. * @param state defines the state to update
  126682. * @param nodeMaterial defines the node material requesting the update
  126683. * @param defines defines the material defines to update
  126684. * @param uniformBuffers defines the list of uniform buffer names
  126685. */
  126686. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  126687. /**
  126688. * Add potential fallbacks if shader compilation fails
  126689. * @param mesh defines the mesh to be rendered
  126690. * @param fallbacks defines the current prioritized list of fallbacks
  126691. */
  126692. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  126693. /**
  126694. * Initialize defines for shader compilation
  126695. * @param mesh defines the mesh to be rendered
  126696. * @param nodeMaterial defines the node material requesting the update
  126697. * @param defines defines the material defines to update
  126698. * @param useInstances specifies that instances should be used
  126699. */
  126700. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  126701. /**
  126702. * Update defines for shader compilation
  126703. * @param mesh defines the mesh to be rendered
  126704. * @param nodeMaterial defines the node material requesting the update
  126705. * @param defines defines the material defines to update
  126706. * @param useInstances specifies that instances should be used
  126707. */
  126708. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  126709. /**
  126710. * Lets the block try to connect some inputs automatically
  126711. * @param material defines the hosting NodeMaterial
  126712. */
  126713. autoConfigure(material: NodeMaterial): void;
  126714. /**
  126715. * Function called when a block is declared as repeatable content generator
  126716. * @param vertexShaderState defines the current compilation state for the vertex shader
  126717. * @param fragmentShaderState defines the current compilation state for the fragment shader
  126718. * @param mesh defines the mesh to be rendered
  126719. * @param defines defines the material defines to update
  126720. */
  126721. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  126722. /**
  126723. * Checks if the block is ready
  126724. * @param mesh defines the mesh to be rendered
  126725. * @param nodeMaterial defines the node material requesting the update
  126726. * @param defines defines the material defines to update
  126727. * @param useInstances specifies that instances should be used
  126728. * @returns true if the block is ready
  126729. */
  126730. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  126731. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  126732. private _processBuild;
  126733. /**
  126734. * Compile the current node and generate the shader code
  126735. * @param state defines the current compilation state (uniforms, samplers, current string)
  126736. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  126737. * @returns true if already built
  126738. */
  126739. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  126740. protected _inputRename(name: string): string;
  126741. protected _outputRename(name: string): string;
  126742. protected _dumpPropertiesCode(): string;
  126743. /** @hidden */
  126744. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  126745. /** @hidden */
  126746. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  126747. /**
  126748. * Clone the current block to a new identical block
  126749. * @param scene defines the hosting scene
  126750. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  126751. * @returns a copy of the current block
  126752. */
  126753. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  126754. /**
  126755. * Serializes this block in a JSON representation
  126756. * @returns the serialized block object
  126757. */
  126758. serialize(): any;
  126759. /** @hidden */
  126760. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126761. /**
  126762. * Release resources
  126763. */
  126764. dispose(): void;
  126765. }
  126766. }
  126767. declare module BABYLON {
  126768. /**
  126769. * Enum defining the type of animations supported by InputBlock
  126770. */
  126771. export enum AnimatedInputBlockTypes {
  126772. /** No animation */
  126773. None = 0,
  126774. /** Time based animation. Will only work for floats */
  126775. Time = 1
  126776. }
  126777. }
  126778. declare module BABYLON {
  126779. /**
  126780. * Block used to expose an input value
  126781. */
  126782. export class InputBlock extends NodeMaterialBlock {
  126783. private _mode;
  126784. private _associatedVariableName;
  126785. private _storedValue;
  126786. private _valueCallback;
  126787. private _type;
  126788. private _animationType;
  126789. /** Gets or set a value used to limit the range of float values */
  126790. min: number;
  126791. /** Gets or set a value used to limit the range of float values */
  126792. max: number;
  126793. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  126794. matrixMode: number;
  126795. /** @hidden */
  126796. _systemValue: Nullable<NodeMaterialSystemValues>;
  126797. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  126798. visibleInInspector: boolean;
  126799. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  126800. isConstant: boolean;
  126801. /** Gets or sets the group to use to display this block in the Inspector */
  126802. groupInInspector: string;
  126803. /**
  126804. * Gets or sets the connection point type (default is float)
  126805. */
  126806. get type(): NodeMaterialBlockConnectionPointTypes;
  126807. /**
  126808. * Creates a new InputBlock
  126809. * @param name defines the block name
  126810. * @param target defines the target of that block (Vertex by default)
  126811. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  126812. */
  126813. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  126814. /**
  126815. * Gets the output component
  126816. */
  126817. get output(): NodeMaterialConnectionPoint;
  126818. /**
  126819. * Set the source of this connection point to a vertex attribute
  126820. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  126821. * @returns the current connection point
  126822. */
  126823. setAsAttribute(attributeName?: string): InputBlock;
  126824. /**
  126825. * Set the source of this connection point to a system value
  126826. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  126827. * @returns the current connection point
  126828. */
  126829. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  126830. /**
  126831. * Gets or sets the value of that point.
  126832. * Please note that this value will be ignored if valueCallback is defined
  126833. */
  126834. get value(): any;
  126835. set value(value: any);
  126836. /**
  126837. * Gets or sets a callback used to get the value of that point.
  126838. * Please note that setting this value will force the connection point to ignore the value property
  126839. */
  126840. get valueCallback(): () => any;
  126841. set valueCallback(value: () => any);
  126842. /**
  126843. * Gets or sets the associated variable name in the shader
  126844. */
  126845. get associatedVariableName(): string;
  126846. set associatedVariableName(value: string);
  126847. /** Gets or sets the type of animation applied to the input */
  126848. get animationType(): AnimatedInputBlockTypes;
  126849. set animationType(value: AnimatedInputBlockTypes);
  126850. /**
  126851. * Gets a boolean indicating that this connection point not defined yet
  126852. */
  126853. get isUndefined(): boolean;
  126854. /**
  126855. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  126856. * In this case the connection point name must be the name of the uniform to use.
  126857. * Can only be set on inputs
  126858. */
  126859. get isUniform(): boolean;
  126860. set isUniform(value: boolean);
  126861. /**
  126862. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  126863. * In this case the connection point name must be the name of the attribute to use
  126864. * Can only be set on inputs
  126865. */
  126866. get isAttribute(): boolean;
  126867. set isAttribute(value: boolean);
  126868. /**
  126869. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  126870. * Can only be set on exit points
  126871. */
  126872. get isVarying(): boolean;
  126873. set isVarying(value: boolean);
  126874. /**
  126875. * Gets a boolean indicating that the current connection point is a system value
  126876. */
  126877. get isSystemValue(): boolean;
  126878. /**
  126879. * Gets or sets the current well known value or null if not defined as a system value
  126880. */
  126881. get systemValue(): Nullable<NodeMaterialSystemValues>;
  126882. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  126883. /**
  126884. * Gets the current class name
  126885. * @returns the class name
  126886. */
  126887. getClassName(): string;
  126888. /**
  126889. * Animate the input if animationType !== None
  126890. * @param scene defines the rendering scene
  126891. */
  126892. animate(scene: Scene): void;
  126893. private _emitDefine;
  126894. initialize(state: NodeMaterialBuildState): void;
  126895. /**
  126896. * Set the input block to its default value (based on its type)
  126897. */
  126898. setDefaultValue(): void;
  126899. private _emitConstant;
  126900. private _emit;
  126901. /** @hidden */
  126902. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  126903. /** @hidden */
  126904. _transmit(effect: Effect, scene: Scene): void;
  126905. protected _buildBlock(state: NodeMaterialBuildState): void;
  126906. protected _dumpPropertiesCode(): string;
  126907. serialize(): any;
  126908. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126909. }
  126910. }
  126911. declare module BABYLON {
  126912. /**
  126913. * Enum used to define the compatibility state between two connection points
  126914. */
  126915. export enum NodeMaterialConnectionPointCompatibilityStates {
  126916. /** Points are compatibles */
  126917. Compatible = 0,
  126918. /** Points are incompatible because of their types */
  126919. TypeIncompatible = 1,
  126920. /** Points are incompatible because of their targets (vertex vs fragment) */
  126921. TargetIncompatible = 2
  126922. }
  126923. /**
  126924. * Defines the direction of a connection point
  126925. */
  126926. export enum NodeMaterialConnectionPointDirection {
  126927. /** Input */
  126928. Input = 0,
  126929. /** Output */
  126930. Output = 1
  126931. }
  126932. /**
  126933. * Defines a connection point for a block
  126934. */
  126935. export class NodeMaterialConnectionPoint {
  126936. /** @hidden */
  126937. _ownerBlock: NodeMaterialBlock;
  126938. /** @hidden */
  126939. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  126940. private _endpoints;
  126941. private _associatedVariableName;
  126942. private _direction;
  126943. /** @hidden */
  126944. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  126945. /** @hidden */
  126946. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  126947. private _type;
  126948. /** @hidden */
  126949. _enforceAssociatedVariableName: boolean;
  126950. /** Gets the direction of the point */
  126951. get direction(): NodeMaterialConnectionPointDirection;
  126952. /**
  126953. * Gets or sets the additional types supported by this connection point
  126954. */
  126955. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  126956. /**
  126957. * Gets or sets the additional types excluded by this connection point
  126958. */
  126959. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  126960. /**
  126961. * Observable triggered when this point is connected
  126962. */
  126963. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  126964. /**
  126965. * Gets or sets the associated variable name in the shader
  126966. */
  126967. get associatedVariableName(): string;
  126968. set associatedVariableName(value: string);
  126969. /**
  126970. * Gets or sets the connection point type (default is float)
  126971. */
  126972. get type(): NodeMaterialBlockConnectionPointTypes;
  126973. set type(value: NodeMaterialBlockConnectionPointTypes);
  126974. /**
  126975. * Gets or sets the connection point name
  126976. */
  126977. name: string;
  126978. /**
  126979. * Gets or sets a boolean indicating that this connection point can be omitted
  126980. */
  126981. isOptional: boolean;
  126982. /**
  126983. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  126984. */
  126985. define: string;
  126986. /** @hidden */
  126987. _prioritizeVertex: boolean;
  126988. private _target;
  126989. /** Gets or sets the target of that connection point */
  126990. get target(): NodeMaterialBlockTargets;
  126991. set target(value: NodeMaterialBlockTargets);
  126992. /**
  126993. * Gets a boolean indicating that the current point is connected
  126994. */
  126995. get isConnected(): boolean;
  126996. /**
  126997. * Gets a boolean indicating that the current point is connected to an input block
  126998. */
  126999. get isConnectedToInputBlock(): boolean;
  127000. /**
  127001. * Gets a the connected input block (if any)
  127002. */
  127003. get connectInputBlock(): Nullable<InputBlock>;
  127004. /** Get the other side of the connection (if any) */
  127005. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  127006. /** Get the block that owns this connection point */
  127007. get ownerBlock(): NodeMaterialBlock;
  127008. /** Get the block connected on the other side of this connection (if any) */
  127009. get sourceBlock(): Nullable<NodeMaterialBlock>;
  127010. /** Get the block connected on the endpoints of this connection (if any) */
  127011. get connectedBlocks(): Array<NodeMaterialBlock>;
  127012. /** Gets the list of connected endpoints */
  127013. get endpoints(): NodeMaterialConnectionPoint[];
  127014. /** Gets a boolean indicating if that output point is connected to at least one input */
  127015. get hasEndpoints(): boolean;
  127016. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  127017. get isConnectedInVertexShader(): boolean;
  127018. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  127019. get isConnectedInFragmentShader(): boolean;
  127020. /**
  127021. * Creates a new connection point
  127022. * @param name defines the connection point name
  127023. * @param ownerBlock defines the block hosting this connection point
  127024. * @param direction defines the direction of the connection point
  127025. */
  127026. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  127027. /**
  127028. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  127029. * @returns the class name
  127030. */
  127031. getClassName(): string;
  127032. /**
  127033. * Gets a boolean indicating if the current point can be connected to another point
  127034. * @param connectionPoint defines the other connection point
  127035. * @returns a boolean
  127036. */
  127037. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  127038. /**
  127039. * Gets a number indicating if the current point can be connected to another point
  127040. * @param connectionPoint defines the other connection point
  127041. * @returns a number defining the compatibility state
  127042. */
  127043. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  127044. /**
  127045. * Connect this point to another connection point
  127046. * @param connectionPoint defines the other connection point
  127047. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  127048. * @returns the current connection point
  127049. */
  127050. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  127051. /**
  127052. * Disconnect this point from one of his endpoint
  127053. * @param endpoint defines the other connection point
  127054. * @returns the current connection point
  127055. */
  127056. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  127057. /**
  127058. * Serializes this point in a JSON representation
  127059. * @returns the serialized point object
  127060. */
  127061. serialize(): any;
  127062. /**
  127063. * Release resources
  127064. */
  127065. dispose(): void;
  127066. }
  127067. }
  127068. declare module BABYLON {
  127069. /**
  127070. * Block used to add support for vertex skinning (bones)
  127071. */
  127072. export class BonesBlock extends NodeMaterialBlock {
  127073. /**
  127074. * Creates a new BonesBlock
  127075. * @param name defines the block name
  127076. */
  127077. constructor(name: string);
  127078. /**
  127079. * Initialize the block and prepare the context for build
  127080. * @param state defines the state that will be used for the build
  127081. */
  127082. initialize(state: NodeMaterialBuildState): void;
  127083. /**
  127084. * Gets the current class name
  127085. * @returns the class name
  127086. */
  127087. getClassName(): string;
  127088. /**
  127089. * Gets the matrix indices input component
  127090. */
  127091. get matricesIndices(): NodeMaterialConnectionPoint;
  127092. /**
  127093. * Gets the matrix weights input component
  127094. */
  127095. get matricesWeights(): NodeMaterialConnectionPoint;
  127096. /**
  127097. * Gets the extra matrix indices input component
  127098. */
  127099. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  127100. /**
  127101. * Gets the extra matrix weights input component
  127102. */
  127103. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  127104. /**
  127105. * Gets the world input component
  127106. */
  127107. get world(): NodeMaterialConnectionPoint;
  127108. /**
  127109. * Gets the output component
  127110. */
  127111. get output(): NodeMaterialConnectionPoint;
  127112. autoConfigure(material: NodeMaterial): void;
  127113. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  127114. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127115. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127116. protected _buildBlock(state: NodeMaterialBuildState): this;
  127117. }
  127118. }
  127119. declare module BABYLON {
  127120. /**
  127121. * Block used to add support for instances
  127122. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  127123. */
  127124. export class InstancesBlock extends NodeMaterialBlock {
  127125. /**
  127126. * Creates a new InstancesBlock
  127127. * @param name defines the block name
  127128. */
  127129. constructor(name: string);
  127130. /**
  127131. * Gets the current class name
  127132. * @returns the class name
  127133. */
  127134. getClassName(): string;
  127135. /**
  127136. * Gets the first world row input component
  127137. */
  127138. get world0(): NodeMaterialConnectionPoint;
  127139. /**
  127140. * Gets the second world row input component
  127141. */
  127142. get world1(): NodeMaterialConnectionPoint;
  127143. /**
  127144. * Gets the third world row input component
  127145. */
  127146. get world2(): NodeMaterialConnectionPoint;
  127147. /**
  127148. * Gets the forth world row input component
  127149. */
  127150. get world3(): NodeMaterialConnectionPoint;
  127151. /**
  127152. * Gets the world input component
  127153. */
  127154. get world(): NodeMaterialConnectionPoint;
  127155. /**
  127156. * Gets the output component
  127157. */
  127158. get output(): NodeMaterialConnectionPoint;
  127159. autoConfigure(material: NodeMaterial): void;
  127160. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  127161. protected _buildBlock(state: NodeMaterialBuildState): this;
  127162. }
  127163. }
  127164. declare module BABYLON {
  127165. /**
  127166. * Block used to add morph targets support to vertex shader
  127167. */
  127168. export class MorphTargetsBlock extends NodeMaterialBlock {
  127169. private _repeatableContentAnchor;
  127170. private _repeatebleContentGenerated;
  127171. /**
  127172. * Create a new MorphTargetsBlock
  127173. * @param name defines the block name
  127174. */
  127175. constructor(name: string);
  127176. /**
  127177. * Gets the current class name
  127178. * @returns the class name
  127179. */
  127180. getClassName(): string;
  127181. /**
  127182. * Gets the position input component
  127183. */
  127184. get position(): NodeMaterialConnectionPoint;
  127185. /**
  127186. * Gets the normal input component
  127187. */
  127188. get normal(): NodeMaterialConnectionPoint;
  127189. /**
  127190. * Gets the tangent input component
  127191. */
  127192. get tangent(): NodeMaterialConnectionPoint;
  127193. /**
  127194. * Gets the tangent input component
  127195. */
  127196. get uv(): NodeMaterialConnectionPoint;
  127197. /**
  127198. * Gets the position output component
  127199. */
  127200. get positionOutput(): NodeMaterialConnectionPoint;
  127201. /**
  127202. * Gets the normal output component
  127203. */
  127204. get normalOutput(): NodeMaterialConnectionPoint;
  127205. /**
  127206. * Gets the tangent output component
  127207. */
  127208. get tangentOutput(): NodeMaterialConnectionPoint;
  127209. /**
  127210. * Gets the tangent output component
  127211. */
  127212. get uvOutput(): NodeMaterialConnectionPoint;
  127213. initialize(state: NodeMaterialBuildState): void;
  127214. autoConfigure(material: NodeMaterial): void;
  127215. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127216. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127217. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  127218. protected _buildBlock(state: NodeMaterialBuildState): this;
  127219. }
  127220. }
  127221. declare module BABYLON {
  127222. /**
  127223. * Block used to get data information from a light
  127224. */
  127225. export class LightInformationBlock extends NodeMaterialBlock {
  127226. private _lightDataUniformName;
  127227. private _lightColorUniformName;
  127228. private _lightTypeDefineName;
  127229. /**
  127230. * Gets or sets the light associated with this block
  127231. */
  127232. light: Nullable<Light>;
  127233. /**
  127234. * Creates a new LightInformationBlock
  127235. * @param name defines the block name
  127236. */
  127237. constructor(name: string);
  127238. /**
  127239. * Gets the current class name
  127240. * @returns the class name
  127241. */
  127242. getClassName(): string;
  127243. /**
  127244. * Gets the world position input component
  127245. */
  127246. get worldPosition(): NodeMaterialConnectionPoint;
  127247. /**
  127248. * Gets the direction output component
  127249. */
  127250. get direction(): NodeMaterialConnectionPoint;
  127251. /**
  127252. * Gets the direction output component
  127253. */
  127254. get color(): NodeMaterialConnectionPoint;
  127255. /**
  127256. * Gets the direction output component
  127257. */
  127258. get intensity(): NodeMaterialConnectionPoint;
  127259. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127260. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127261. protected _buildBlock(state: NodeMaterialBuildState): this;
  127262. serialize(): any;
  127263. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127264. }
  127265. }
  127266. declare module BABYLON {
  127267. /**
  127268. * Block used to add image processing support to fragment shader
  127269. */
  127270. export class ImageProcessingBlock extends NodeMaterialBlock {
  127271. /**
  127272. * Create a new ImageProcessingBlock
  127273. * @param name defines the block name
  127274. */
  127275. constructor(name: string);
  127276. /**
  127277. * Gets the current class name
  127278. * @returns the class name
  127279. */
  127280. getClassName(): string;
  127281. /**
  127282. * Gets the color input component
  127283. */
  127284. get color(): NodeMaterialConnectionPoint;
  127285. /**
  127286. * Gets the output component
  127287. */
  127288. get output(): NodeMaterialConnectionPoint;
  127289. /**
  127290. * Initialize the block and prepare the context for build
  127291. * @param state defines the state that will be used for the build
  127292. */
  127293. initialize(state: NodeMaterialBuildState): void;
  127294. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  127295. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127296. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127297. protected _buildBlock(state: NodeMaterialBuildState): this;
  127298. }
  127299. }
  127300. declare module BABYLON {
  127301. /**
  127302. * Block used to pertub normals based on a normal map
  127303. */
  127304. export class PerturbNormalBlock extends NodeMaterialBlock {
  127305. private _tangentSpaceParameterName;
  127306. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  127307. invertX: boolean;
  127308. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  127309. invertY: boolean;
  127310. /**
  127311. * Create a new PerturbNormalBlock
  127312. * @param name defines the block name
  127313. */
  127314. constructor(name: string);
  127315. /**
  127316. * Gets the current class name
  127317. * @returns the class name
  127318. */
  127319. getClassName(): string;
  127320. /**
  127321. * Gets the world position input component
  127322. */
  127323. get worldPosition(): NodeMaterialConnectionPoint;
  127324. /**
  127325. * Gets the world normal input component
  127326. */
  127327. get worldNormal(): NodeMaterialConnectionPoint;
  127328. /**
  127329. * Gets the uv input component
  127330. */
  127331. get uv(): NodeMaterialConnectionPoint;
  127332. /**
  127333. * Gets the normal map color input component
  127334. */
  127335. get normalMapColor(): NodeMaterialConnectionPoint;
  127336. /**
  127337. * Gets the strength input component
  127338. */
  127339. get strength(): NodeMaterialConnectionPoint;
  127340. /**
  127341. * Gets the output component
  127342. */
  127343. get output(): NodeMaterialConnectionPoint;
  127344. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127345. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127346. autoConfigure(material: NodeMaterial): void;
  127347. protected _buildBlock(state: NodeMaterialBuildState): this;
  127348. protected _dumpPropertiesCode(): string;
  127349. serialize(): any;
  127350. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127351. }
  127352. }
  127353. declare module BABYLON {
  127354. /**
  127355. * Block used to discard a pixel if a value is smaller than a cutoff
  127356. */
  127357. export class DiscardBlock extends NodeMaterialBlock {
  127358. /**
  127359. * Create a new DiscardBlock
  127360. * @param name defines the block name
  127361. */
  127362. constructor(name: string);
  127363. /**
  127364. * Gets the current class name
  127365. * @returns the class name
  127366. */
  127367. getClassName(): string;
  127368. /**
  127369. * Gets the color input component
  127370. */
  127371. get value(): NodeMaterialConnectionPoint;
  127372. /**
  127373. * Gets the cutoff input component
  127374. */
  127375. get cutoff(): NodeMaterialConnectionPoint;
  127376. protected _buildBlock(state: NodeMaterialBuildState): this;
  127377. }
  127378. }
  127379. declare module BABYLON {
  127380. /**
  127381. * Block used to test if the fragment shader is front facing
  127382. */
  127383. export class FrontFacingBlock extends NodeMaterialBlock {
  127384. /**
  127385. * Creates a new FrontFacingBlock
  127386. * @param name defines the block name
  127387. */
  127388. constructor(name: string);
  127389. /**
  127390. * Gets the current class name
  127391. * @returns the class name
  127392. */
  127393. getClassName(): string;
  127394. /**
  127395. * Gets the output component
  127396. */
  127397. get output(): NodeMaterialConnectionPoint;
  127398. protected _buildBlock(state: NodeMaterialBuildState): this;
  127399. }
  127400. }
  127401. declare module BABYLON {
  127402. /**
  127403. * Block used to get the derivative value on x and y of a given input
  127404. */
  127405. export class DerivativeBlock extends NodeMaterialBlock {
  127406. /**
  127407. * Create a new DerivativeBlock
  127408. * @param name defines the block name
  127409. */
  127410. constructor(name: string);
  127411. /**
  127412. * Gets the current class name
  127413. * @returns the class name
  127414. */
  127415. getClassName(): string;
  127416. /**
  127417. * Gets the input component
  127418. */
  127419. get input(): NodeMaterialConnectionPoint;
  127420. /**
  127421. * Gets the derivative output on x
  127422. */
  127423. get dx(): NodeMaterialConnectionPoint;
  127424. /**
  127425. * Gets the derivative output on y
  127426. */
  127427. get dy(): NodeMaterialConnectionPoint;
  127428. protected _buildBlock(state: NodeMaterialBuildState): this;
  127429. }
  127430. }
  127431. declare module BABYLON {
  127432. /**
  127433. * Block used to add support for scene fog
  127434. */
  127435. export class FogBlock extends NodeMaterialBlock {
  127436. private _fogDistanceName;
  127437. private _fogParameters;
  127438. /**
  127439. * Create a new FogBlock
  127440. * @param name defines the block name
  127441. */
  127442. constructor(name: string);
  127443. /**
  127444. * Gets the current class name
  127445. * @returns the class name
  127446. */
  127447. getClassName(): string;
  127448. /**
  127449. * Gets the world position input component
  127450. */
  127451. get worldPosition(): NodeMaterialConnectionPoint;
  127452. /**
  127453. * Gets the view input component
  127454. */
  127455. get view(): NodeMaterialConnectionPoint;
  127456. /**
  127457. * Gets the color input component
  127458. */
  127459. get input(): NodeMaterialConnectionPoint;
  127460. /**
  127461. * Gets the fog color input component
  127462. */
  127463. get fogColor(): NodeMaterialConnectionPoint;
  127464. /**
  127465. * Gets the output component
  127466. */
  127467. get output(): NodeMaterialConnectionPoint;
  127468. autoConfigure(material: NodeMaterial): void;
  127469. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127470. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127471. protected _buildBlock(state: NodeMaterialBuildState): this;
  127472. }
  127473. }
  127474. declare module BABYLON {
  127475. /**
  127476. * Block used to add light in the fragment shader
  127477. */
  127478. export class LightBlock extends NodeMaterialBlock {
  127479. private _lightId;
  127480. /**
  127481. * Gets or sets the light associated with this block
  127482. */
  127483. light: Nullable<Light>;
  127484. /**
  127485. * Create a new LightBlock
  127486. * @param name defines the block name
  127487. */
  127488. constructor(name: string);
  127489. /**
  127490. * Gets the current class name
  127491. * @returns the class name
  127492. */
  127493. getClassName(): string;
  127494. /**
  127495. * Gets the world position input component
  127496. */
  127497. get worldPosition(): NodeMaterialConnectionPoint;
  127498. /**
  127499. * Gets the world normal input component
  127500. */
  127501. get worldNormal(): NodeMaterialConnectionPoint;
  127502. /**
  127503. * Gets the camera (or eye) position component
  127504. */
  127505. get cameraPosition(): NodeMaterialConnectionPoint;
  127506. /**
  127507. * Gets the glossiness component
  127508. */
  127509. get glossiness(): NodeMaterialConnectionPoint;
  127510. /**
  127511. * Gets the glossinness power component
  127512. */
  127513. get glossPower(): NodeMaterialConnectionPoint;
  127514. /**
  127515. * Gets the diffuse color component
  127516. */
  127517. get diffuseColor(): NodeMaterialConnectionPoint;
  127518. /**
  127519. * Gets the specular color component
  127520. */
  127521. get specularColor(): NodeMaterialConnectionPoint;
  127522. /**
  127523. * Gets the diffuse output component
  127524. */
  127525. get diffuseOutput(): NodeMaterialConnectionPoint;
  127526. /**
  127527. * Gets the specular output component
  127528. */
  127529. get specularOutput(): NodeMaterialConnectionPoint;
  127530. /**
  127531. * Gets the shadow output component
  127532. */
  127533. get shadow(): NodeMaterialConnectionPoint;
  127534. autoConfigure(material: NodeMaterial): void;
  127535. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127536. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  127537. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127538. private _injectVertexCode;
  127539. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  127540. serialize(): any;
  127541. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127542. }
  127543. }
  127544. declare module BABYLON {
  127545. /**
  127546. * Block used to multiply 2 values
  127547. */
  127548. export class MultiplyBlock extends NodeMaterialBlock {
  127549. /**
  127550. * Creates a new MultiplyBlock
  127551. * @param name defines the block name
  127552. */
  127553. constructor(name: string);
  127554. /**
  127555. * Gets the current class name
  127556. * @returns the class name
  127557. */
  127558. getClassName(): string;
  127559. /**
  127560. * Gets the left operand input component
  127561. */
  127562. get left(): NodeMaterialConnectionPoint;
  127563. /**
  127564. * Gets the right operand input component
  127565. */
  127566. get right(): NodeMaterialConnectionPoint;
  127567. /**
  127568. * Gets the output component
  127569. */
  127570. get output(): NodeMaterialConnectionPoint;
  127571. protected _buildBlock(state: NodeMaterialBuildState): this;
  127572. }
  127573. }
  127574. declare module BABYLON {
  127575. /**
  127576. * Block used to add 2 vectors
  127577. */
  127578. export class AddBlock extends NodeMaterialBlock {
  127579. /**
  127580. * Creates a new AddBlock
  127581. * @param name defines the block name
  127582. */
  127583. constructor(name: string);
  127584. /**
  127585. * Gets the current class name
  127586. * @returns the class name
  127587. */
  127588. getClassName(): string;
  127589. /**
  127590. * Gets the left operand input component
  127591. */
  127592. get left(): NodeMaterialConnectionPoint;
  127593. /**
  127594. * Gets the right operand input component
  127595. */
  127596. get right(): NodeMaterialConnectionPoint;
  127597. /**
  127598. * Gets the output component
  127599. */
  127600. get output(): NodeMaterialConnectionPoint;
  127601. protected _buildBlock(state: NodeMaterialBuildState): this;
  127602. }
  127603. }
  127604. declare module BABYLON {
  127605. /**
  127606. * Block used to scale a vector by a float
  127607. */
  127608. export class ScaleBlock extends NodeMaterialBlock {
  127609. /**
  127610. * Creates a new ScaleBlock
  127611. * @param name defines the block name
  127612. */
  127613. constructor(name: string);
  127614. /**
  127615. * Gets the current class name
  127616. * @returns the class name
  127617. */
  127618. getClassName(): string;
  127619. /**
  127620. * Gets the input component
  127621. */
  127622. get input(): NodeMaterialConnectionPoint;
  127623. /**
  127624. * Gets the factor input component
  127625. */
  127626. get factor(): NodeMaterialConnectionPoint;
  127627. /**
  127628. * Gets the output component
  127629. */
  127630. get output(): NodeMaterialConnectionPoint;
  127631. protected _buildBlock(state: NodeMaterialBuildState): this;
  127632. }
  127633. }
  127634. declare module BABYLON {
  127635. /**
  127636. * Block used to clamp a float
  127637. */
  127638. export class ClampBlock extends NodeMaterialBlock {
  127639. /** Gets or sets the minimum range */
  127640. minimum: number;
  127641. /** Gets or sets the maximum range */
  127642. maximum: number;
  127643. /**
  127644. * Creates a new ClampBlock
  127645. * @param name defines the block name
  127646. */
  127647. constructor(name: string);
  127648. /**
  127649. * Gets the current class name
  127650. * @returns the class name
  127651. */
  127652. getClassName(): string;
  127653. /**
  127654. * Gets the value input component
  127655. */
  127656. get value(): NodeMaterialConnectionPoint;
  127657. /**
  127658. * Gets the output component
  127659. */
  127660. get output(): NodeMaterialConnectionPoint;
  127661. protected _buildBlock(state: NodeMaterialBuildState): this;
  127662. protected _dumpPropertiesCode(): string;
  127663. serialize(): any;
  127664. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127665. }
  127666. }
  127667. declare module BABYLON {
  127668. /**
  127669. * Block used to apply a cross product between 2 vectors
  127670. */
  127671. export class CrossBlock extends NodeMaterialBlock {
  127672. /**
  127673. * Creates a new CrossBlock
  127674. * @param name defines the block name
  127675. */
  127676. constructor(name: string);
  127677. /**
  127678. * Gets the current class name
  127679. * @returns the class name
  127680. */
  127681. getClassName(): string;
  127682. /**
  127683. * Gets the left operand input component
  127684. */
  127685. get left(): NodeMaterialConnectionPoint;
  127686. /**
  127687. * Gets the right operand input component
  127688. */
  127689. get right(): NodeMaterialConnectionPoint;
  127690. /**
  127691. * Gets the output component
  127692. */
  127693. get output(): NodeMaterialConnectionPoint;
  127694. protected _buildBlock(state: NodeMaterialBuildState): this;
  127695. }
  127696. }
  127697. declare module BABYLON {
  127698. /**
  127699. * Block used to apply a dot product between 2 vectors
  127700. */
  127701. export class DotBlock extends NodeMaterialBlock {
  127702. /**
  127703. * Creates a new DotBlock
  127704. * @param name defines the block name
  127705. */
  127706. constructor(name: string);
  127707. /**
  127708. * Gets the current class name
  127709. * @returns the class name
  127710. */
  127711. getClassName(): string;
  127712. /**
  127713. * Gets the left operand input component
  127714. */
  127715. get left(): NodeMaterialConnectionPoint;
  127716. /**
  127717. * Gets the right operand input component
  127718. */
  127719. get right(): NodeMaterialConnectionPoint;
  127720. /**
  127721. * Gets the output component
  127722. */
  127723. get output(): NodeMaterialConnectionPoint;
  127724. protected _buildBlock(state: NodeMaterialBuildState): this;
  127725. }
  127726. }
  127727. declare module BABYLON {
  127728. /**
  127729. * Block used to remap a float from a range to a new one
  127730. */
  127731. export class RemapBlock extends NodeMaterialBlock {
  127732. /**
  127733. * Gets or sets the source range
  127734. */
  127735. sourceRange: Vector2;
  127736. /**
  127737. * Gets or sets the target range
  127738. */
  127739. targetRange: Vector2;
  127740. /**
  127741. * Creates a new RemapBlock
  127742. * @param name defines the block name
  127743. */
  127744. constructor(name: string);
  127745. /**
  127746. * Gets the current class name
  127747. * @returns the class name
  127748. */
  127749. getClassName(): string;
  127750. /**
  127751. * Gets the input component
  127752. */
  127753. get input(): NodeMaterialConnectionPoint;
  127754. /**
  127755. * Gets the source min input component
  127756. */
  127757. get sourceMin(): NodeMaterialConnectionPoint;
  127758. /**
  127759. * Gets the source max input component
  127760. */
  127761. get sourceMax(): NodeMaterialConnectionPoint;
  127762. /**
  127763. * Gets the target min input component
  127764. */
  127765. get targetMin(): NodeMaterialConnectionPoint;
  127766. /**
  127767. * Gets the target max input component
  127768. */
  127769. get targetMax(): NodeMaterialConnectionPoint;
  127770. /**
  127771. * Gets the output component
  127772. */
  127773. get output(): NodeMaterialConnectionPoint;
  127774. protected _buildBlock(state: NodeMaterialBuildState): this;
  127775. protected _dumpPropertiesCode(): string;
  127776. serialize(): any;
  127777. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127778. }
  127779. }
  127780. declare module BABYLON {
  127781. /**
  127782. * Block used to normalize a vector
  127783. */
  127784. export class NormalizeBlock extends NodeMaterialBlock {
  127785. /**
  127786. * Creates a new NormalizeBlock
  127787. * @param name defines the block name
  127788. */
  127789. constructor(name: string);
  127790. /**
  127791. * Gets the current class name
  127792. * @returns the class name
  127793. */
  127794. getClassName(): string;
  127795. /**
  127796. * Gets the input component
  127797. */
  127798. get input(): NodeMaterialConnectionPoint;
  127799. /**
  127800. * Gets the output component
  127801. */
  127802. get output(): NodeMaterialConnectionPoint;
  127803. protected _buildBlock(state: NodeMaterialBuildState): this;
  127804. }
  127805. }
  127806. declare module BABYLON {
  127807. /**
  127808. * Operations supported by the Trigonometry block
  127809. */
  127810. export enum TrigonometryBlockOperations {
  127811. /** Cos */
  127812. Cos = 0,
  127813. /** Sin */
  127814. Sin = 1,
  127815. /** Abs */
  127816. Abs = 2,
  127817. /** Exp */
  127818. Exp = 3,
  127819. /** Exp2 */
  127820. Exp2 = 4,
  127821. /** Round */
  127822. Round = 5,
  127823. /** Floor */
  127824. Floor = 6,
  127825. /** Ceiling */
  127826. Ceiling = 7,
  127827. /** Square root */
  127828. Sqrt = 8,
  127829. /** Log */
  127830. Log = 9,
  127831. /** Tangent */
  127832. Tan = 10,
  127833. /** Arc tangent */
  127834. ArcTan = 11,
  127835. /** Arc cosinus */
  127836. ArcCos = 12,
  127837. /** Arc sinus */
  127838. ArcSin = 13,
  127839. /** Fraction */
  127840. Fract = 14,
  127841. /** Sign */
  127842. Sign = 15,
  127843. /** To radians (from degrees) */
  127844. Radians = 16,
  127845. /** To degrees (from radians) */
  127846. Degrees = 17
  127847. }
  127848. /**
  127849. * Block used to apply trigonometry operation to floats
  127850. */
  127851. export class TrigonometryBlock extends NodeMaterialBlock {
  127852. /**
  127853. * Gets or sets the operation applied by the block
  127854. */
  127855. operation: TrigonometryBlockOperations;
  127856. /**
  127857. * Creates a new TrigonometryBlock
  127858. * @param name defines the block name
  127859. */
  127860. constructor(name: string);
  127861. /**
  127862. * Gets the current class name
  127863. * @returns the class name
  127864. */
  127865. getClassName(): string;
  127866. /**
  127867. * Gets the input component
  127868. */
  127869. get input(): NodeMaterialConnectionPoint;
  127870. /**
  127871. * Gets the output component
  127872. */
  127873. get output(): NodeMaterialConnectionPoint;
  127874. protected _buildBlock(state: NodeMaterialBuildState): this;
  127875. serialize(): any;
  127876. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127877. protected _dumpPropertiesCode(): string;
  127878. }
  127879. }
  127880. declare module BABYLON {
  127881. /**
  127882. * Block used to create a Color3/4 out of individual inputs (one for each component)
  127883. */
  127884. export class ColorMergerBlock extends NodeMaterialBlock {
  127885. /**
  127886. * Create a new ColorMergerBlock
  127887. * @param name defines the block name
  127888. */
  127889. constructor(name: string);
  127890. /**
  127891. * Gets the current class name
  127892. * @returns the class name
  127893. */
  127894. getClassName(): string;
  127895. /**
  127896. * Gets the rgb component (input)
  127897. */
  127898. get rgbIn(): NodeMaterialConnectionPoint;
  127899. /**
  127900. * Gets the r component (input)
  127901. */
  127902. get r(): NodeMaterialConnectionPoint;
  127903. /**
  127904. * Gets the g component (input)
  127905. */
  127906. get g(): NodeMaterialConnectionPoint;
  127907. /**
  127908. * Gets the b component (input)
  127909. */
  127910. get b(): NodeMaterialConnectionPoint;
  127911. /**
  127912. * Gets the a component (input)
  127913. */
  127914. get a(): NodeMaterialConnectionPoint;
  127915. /**
  127916. * Gets the rgba component (output)
  127917. */
  127918. get rgba(): NodeMaterialConnectionPoint;
  127919. /**
  127920. * Gets the rgb component (output)
  127921. */
  127922. get rgbOut(): NodeMaterialConnectionPoint;
  127923. /**
  127924. * Gets the rgb component (output)
  127925. * @deprecated Please use rgbOut instead.
  127926. */
  127927. get rgb(): NodeMaterialConnectionPoint;
  127928. protected _buildBlock(state: NodeMaterialBuildState): this;
  127929. }
  127930. }
  127931. declare module BABYLON {
  127932. /**
  127933. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  127934. */
  127935. export class VectorMergerBlock extends NodeMaterialBlock {
  127936. /**
  127937. * Create a new VectorMergerBlock
  127938. * @param name defines the block name
  127939. */
  127940. constructor(name: string);
  127941. /**
  127942. * Gets the current class name
  127943. * @returns the class name
  127944. */
  127945. getClassName(): string;
  127946. /**
  127947. * Gets the xyz component (input)
  127948. */
  127949. get xyzIn(): NodeMaterialConnectionPoint;
  127950. /**
  127951. * Gets the xy component (input)
  127952. */
  127953. get xyIn(): NodeMaterialConnectionPoint;
  127954. /**
  127955. * Gets the x component (input)
  127956. */
  127957. get x(): NodeMaterialConnectionPoint;
  127958. /**
  127959. * Gets the y component (input)
  127960. */
  127961. get y(): NodeMaterialConnectionPoint;
  127962. /**
  127963. * Gets the z component (input)
  127964. */
  127965. get z(): NodeMaterialConnectionPoint;
  127966. /**
  127967. * Gets the w component (input)
  127968. */
  127969. get w(): NodeMaterialConnectionPoint;
  127970. /**
  127971. * Gets the xyzw component (output)
  127972. */
  127973. get xyzw(): NodeMaterialConnectionPoint;
  127974. /**
  127975. * Gets the xyz component (output)
  127976. */
  127977. get xyzOut(): NodeMaterialConnectionPoint;
  127978. /**
  127979. * Gets the xy component (output)
  127980. */
  127981. get xyOut(): NodeMaterialConnectionPoint;
  127982. /**
  127983. * Gets the xy component (output)
  127984. * @deprecated Please use xyOut instead.
  127985. */
  127986. get xy(): NodeMaterialConnectionPoint;
  127987. /**
  127988. * Gets the xyz component (output)
  127989. * @deprecated Please use xyzOut instead.
  127990. */
  127991. get xyz(): NodeMaterialConnectionPoint;
  127992. protected _buildBlock(state: NodeMaterialBuildState): this;
  127993. }
  127994. }
  127995. declare module BABYLON {
  127996. /**
  127997. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  127998. */
  127999. export class ColorSplitterBlock extends NodeMaterialBlock {
  128000. /**
  128001. * Create a new ColorSplitterBlock
  128002. * @param name defines the block name
  128003. */
  128004. constructor(name: string);
  128005. /**
  128006. * Gets the current class name
  128007. * @returns the class name
  128008. */
  128009. getClassName(): string;
  128010. /**
  128011. * Gets the rgba component (input)
  128012. */
  128013. get rgba(): NodeMaterialConnectionPoint;
  128014. /**
  128015. * Gets the rgb component (input)
  128016. */
  128017. get rgbIn(): NodeMaterialConnectionPoint;
  128018. /**
  128019. * Gets the rgb component (output)
  128020. */
  128021. get rgbOut(): NodeMaterialConnectionPoint;
  128022. /**
  128023. * Gets the r component (output)
  128024. */
  128025. get r(): NodeMaterialConnectionPoint;
  128026. /**
  128027. * Gets the g component (output)
  128028. */
  128029. get g(): NodeMaterialConnectionPoint;
  128030. /**
  128031. * Gets the b component (output)
  128032. */
  128033. get b(): NodeMaterialConnectionPoint;
  128034. /**
  128035. * Gets the a component (output)
  128036. */
  128037. get a(): NodeMaterialConnectionPoint;
  128038. protected _inputRename(name: string): string;
  128039. protected _outputRename(name: string): string;
  128040. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  128041. }
  128042. }
  128043. declare module BABYLON {
  128044. /**
  128045. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  128046. */
  128047. export class VectorSplitterBlock extends NodeMaterialBlock {
  128048. /**
  128049. * Create a new VectorSplitterBlock
  128050. * @param name defines the block name
  128051. */
  128052. constructor(name: string);
  128053. /**
  128054. * Gets the current class name
  128055. * @returns the class name
  128056. */
  128057. getClassName(): string;
  128058. /**
  128059. * Gets the xyzw component (input)
  128060. */
  128061. get xyzw(): NodeMaterialConnectionPoint;
  128062. /**
  128063. * Gets the xyz component (input)
  128064. */
  128065. get xyzIn(): NodeMaterialConnectionPoint;
  128066. /**
  128067. * Gets the xy component (input)
  128068. */
  128069. get xyIn(): NodeMaterialConnectionPoint;
  128070. /**
  128071. * Gets the xyz component (output)
  128072. */
  128073. get xyzOut(): NodeMaterialConnectionPoint;
  128074. /**
  128075. * Gets the xy component (output)
  128076. */
  128077. get xyOut(): NodeMaterialConnectionPoint;
  128078. /**
  128079. * Gets the x component (output)
  128080. */
  128081. get x(): NodeMaterialConnectionPoint;
  128082. /**
  128083. * Gets the y component (output)
  128084. */
  128085. get y(): NodeMaterialConnectionPoint;
  128086. /**
  128087. * Gets the z component (output)
  128088. */
  128089. get z(): NodeMaterialConnectionPoint;
  128090. /**
  128091. * Gets the w component (output)
  128092. */
  128093. get w(): NodeMaterialConnectionPoint;
  128094. protected _inputRename(name: string): string;
  128095. protected _outputRename(name: string): string;
  128096. protected _buildBlock(state: NodeMaterialBuildState): this;
  128097. }
  128098. }
  128099. declare module BABYLON {
  128100. /**
  128101. * Block used to lerp between 2 values
  128102. */
  128103. export class LerpBlock extends NodeMaterialBlock {
  128104. /**
  128105. * Creates a new LerpBlock
  128106. * @param name defines the block name
  128107. */
  128108. constructor(name: string);
  128109. /**
  128110. * Gets the current class name
  128111. * @returns the class name
  128112. */
  128113. getClassName(): string;
  128114. /**
  128115. * Gets the left operand input component
  128116. */
  128117. get left(): NodeMaterialConnectionPoint;
  128118. /**
  128119. * Gets the right operand input component
  128120. */
  128121. get right(): NodeMaterialConnectionPoint;
  128122. /**
  128123. * Gets the gradient operand input component
  128124. */
  128125. get gradient(): NodeMaterialConnectionPoint;
  128126. /**
  128127. * Gets the output component
  128128. */
  128129. get output(): NodeMaterialConnectionPoint;
  128130. protected _buildBlock(state: NodeMaterialBuildState): this;
  128131. }
  128132. }
  128133. declare module BABYLON {
  128134. /**
  128135. * Block used to divide 2 vectors
  128136. */
  128137. export class DivideBlock extends NodeMaterialBlock {
  128138. /**
  128139. * Creates a new DivideBlock
  128140. * @param name defines the block name
  128141. */
  128142. constructor(name: string);
  128143. /**
  128144. * Gets the current class name
  128145. * @returns the class name
  128146. */
  128147. getClassName(): string;
  128148. /**
  128149. * Gets the left operand input component
  128150. */
  128151. get left(): NodeMaterialConnectionPoint;
  128152. /**
  128153. * Gets the right operand input component
  128154. */
  128155. get right(): NodeMaterialConnectionPoint;
  128156. /**
  128157. * Gets the output component
  128158. */
  128159. get output(): NodeMaterialConnectionPoint;
  128160. protected _buildBlock(state: NodeMaterialBuildState): this;
  128161. }
  128162. }
  128163. declare module BABYLON {
  128164. /**
  128165. * Block used to subtract 2 vectors
  128166. */
  128167. export class SubtractBlock extends NodeMaterialBlock {
  128168. /**
  128169. * Creates a new SubtractBlock
  128170. * @param name defines the block name
  128171. */
  128172. constructor(name: string);
  128173. /**
  128174. * Gets the current class name
  128175. * @returns the class name
  128176. */
  128177. getClassName(): string;
  128178. /**
  128179. * Gets the left operand input component
  128180. */
  128181. get left(): NodeMaterialConnectionPoint;
  128182. /**
  128183. * Gets the right operand input component
  128184. */
  128185. get right(): NodeMaterialConnectionPoint;
  128186. /**
  128187. * Gets the output component
  128188. */
  128189. get output(): NodeMaterialConnectionPoint;
  128190. protected _buildBlock(state: NodeMaterialBuildState): this;
  128191. }
  128192. }
  128193. declare module BABYLON {
  128194. /**
  128195. * Block used to step a value
  128196. */
  128197. export class StepBlock extends NodeMaterialBlock {
  128198. /**
  128199. * Creates a new StepBlock
  128200. * @param name defines the block name
  128201. */
  128202. constructor(name: string);
  128203. /**
  128204. * Gets the current class name
  128205. * @returns the class name
  128206. */
  128207. getClassName(): string;
  128208. /**
  128209. * Gets the value operand input component
  128210. */
  128211. get value(): NodeMaterialConnectionPoint;
  128212. /**
  128213. * Gets the edge operand input component
  128214. */
  128215. get edge(): NodeMaterialConnectionPoint;
  128216. /**
  128217. * Gets the output component
  128218. */
  128219. get output(): NodeMaterialConnectionPoint;
  128220. protected _buildBlock(state: NodeMaterialBuildState): this;
  128221. }
  128222. }
  128223. declare module BABYLON {
  128224. /**
  128225. * Block used to get the opposite (1 - x) of a value
  128226. */
  128227. export class OneMinusBlock extends NodeMaterialBlock {
  128228. /**
  128229. * Creates a new OneMinusBlock
  128230. * @param name defines the block name
  128231. */
  128232. constructor(name: string);
  128233. /**
  128234. * Gets the current class name
  128235. * @returns the class name
  128236. */
  128237. getClassName(): string;
  128238. /**
  128239. * Gets the input component
  128240. */
  128241. get input(): NodeMaterialConnectionPoint;
  128242. /**
  128243. * Gets the output component
  128244. */
  128245. get output(): NodeMaterialConnectionPoint;
  128246. protected _buildBlock(state: NodeMaterialBuildState): this;
  128247. }
  128248. }
  128249. declare module BABYLON {
  128250. /**
  128251. * Block used to get the view direction
  128252. */
  128253. export class ViewDirectionBlock extends NodeMaterialBlock {
  128254. /**
  128255. * Creates a new ViewDirectionBlock
  128256. * @param name defines the block name
  128257. */
  128258. constructor(name: string);
  128259. /**
  128260. * Gets the current class name
  128261. * @returns the class name
  128262. */
  128263. getClassName(): string;
  128264. /**
  128265. * Gets the world position component
  128266. */
  128267. get worldPosition(): NodeMaterialConnectionPoint;
  128268. /**
  128269. * Gets the camera position component
  128270. */
  128271. get cameraPosition(): NodeMaterialConnectionPoint;
  128272. /**
  128273. * Gets the output component
  128274. */
  128275. get output(): NodeMaterialConnectionPoint;
  128276. autoConfigure(material: NodeMaterial): void;
  128277. protected _buildBlock(state: NodeMaterialBuildState): this;
  128278. }
  128279. }
  128280. declare module BABYLON {
  128281. /**
  128282. * Block used to compute fresnel value
  128283. */
  128284. export class FresnelBlock extends NodeMaterialBlock {
  128285. /**
  128286. * Create a new FresnelBlock
  128287. * @param name defines the block name
  128288. */
  128289. constructor(name: string);
  128290. /**
  128291. * Gets the current class name
  128292. * @returns the class name
  128293. */
  128294. getClassName(): string;
  128295. /**
  128296. * Gets the world normal input component
  128297. */
  128298. get worldNormal(): NodeMaterialConnectionPoint;
  128299. /**
  128300. * Gets the view direction input component
  128301. */
  128302. get viewDirection(): NodeMaterialConnectionPoint;
  128303. /**
  128304. * Gets the bias input component
  128305. */
  128306. get bias(): NodeMaterialConnectionPoint;
  128307. /**
  128308. * Gets the camera (or eye) position component
  128309. */
  128310. get power(): NodeMaterialConnectionPoint;
  128311. /**
  128312. * Gets the fresnel output component
  128313. */
  128314. get fresnel(): NodeMaterialConnectionPoint;
  128315. autoConfigure(material: NodeMaterial): void;
  128316. protected _buildBlock(state: NodeMaterialBuildState): this;
  128317. }
  128318. }
  128319. declare module BABYLON {
  128320. /**
  128321. * Block used to get the max of 2 values
  128322. */
  128323. export class MaxBlock extends NodeMaterialBlock {
  128324. /**
  128325. * Creates a new MaxBlock
  128326. * @param name defines the block name
  128327. */
  128328. constructor(name: string);
  128329. /**
  128330. * Gets the current class name
  128331. * @returns the class name
  128332. */
  128333. getClassName(): string;
  128334. /**
  128335. * Gets the left operand input component
  128336. */
  128337. get left(): NodeMaterialConnectionPoint;
  128338. /**
  128339. * Gets the right operand input component
  128340. */
  128341. get right(): NodeMaterialConnectionPoint;
  128342. /**
  128343. * Gets the output component
  128344. */
  128345. get output(): NodeMaterialConnectionPoint;
  128346. protected _buildBlock(state: NodeMaterialBuildState): this;
  128347. }
  128348. }
  128349. declare module BABYLON {
  128350. /**
  128351. * Block used to get the min of 2 values
  128352. */
  128353. export class MinBlock extends NodeMaterialBlock {
  128354. /**
  128355. * Creates a new MinBlock
  128356. * @param name defines the block name
  128357. */
  128358. constructor(name: string);
  128359. /**
  128360. * Gets the current class name
  128361. * @returns the class name
  128362. */
  128363. getClassName(): string;
  128364. /**
  128365. * Gets the left operand input component
  128366. */
  128367. get left(): NodeMaterialConnectionPoint;
  128368. /**
  128369. * Gets the right operand input component
  128370. */
  128371. get right(): NodeMaterialConnectionPoint;
  128372. /**
  128373. * Gets the output component
  128374. */
  128375. get output(): NodeMaterialConnectionPoint;
  128376. protected _buildBlock(state: NodeMaterialBuildState): this;
  128377. }
  128378. }
  128379. declare module BABYLON {
  128380. /**
  128381. * Block used to get the distance between 2 values
  128382. */
  128383. export class DistanceBlock extends NodeMaterialBlock {
  128384. /**
  128385. * Creates a new DistanceBlock
  128386. * @param name defines the block name
  128387. */
  128388. constructor(name: string);
  128389. /**
  128390. * Gets the current class name
  128391. * @returns the class name
  128392. */
  128393. getClassName(): string;
  128394. /**
  128395. * Gets the left operand input component
  128396. */
  128397. get left(): NodeMaterialConnectionPoint;
  128398. /**
  128399. * Gets the right operand input component
  128400. */
  128401. get right(): NodeMaterialConnectionPoint;
  128402. /**
  128403. * Gets the output component
  128404. */
  128405. get output(): NodeMaterialConnectionPoint;
  128406. protected _buildBlock(state: NodeMaterialBuildState): this;
  128407. }
  128408. }
  128409. declare module BABYLON {
  128410. /**
  128411. * Block used to get the length of a vector
  128412. */
  128413. export class LengthBlock extends NodeMaterialBlock {
  128414. /**
  128415. * Creates a new LengthBlock
  128416. * @param name defines the block name
  128417. */
  128418. constructor(name: string);
  128419. /**
  128420. * Gets the current class name
  128421. * @returns the class name
  128422. */
  128423. getClassName(): string;
  128424. /**
  128425. * Gets the value input component
  128426. */
  128427. get value(): NodeMaterialConnectionPoint;
  128428. /**
  128429. * Gets the output component
  128430. */
  128431. get output(): NodeMaterialConnectionPoint;
  128432. protected _buildBlock(state: NodeMaterialBuildState): this;
  128433. }
  128434. }
  128435. declare module BABYLON {
  128436. /**
  128437. * Block used to get negative version of a value (i.e. x * -1)
  128438. */
  128439. export class NegateBlock extends NodeMaterialBlock {
  128440. /**
  128441. * Creates a new NegateBlock
  128442. * @param name defines the block name
  128443. */
  128444. constructor(name: string);
  128445. /**
  128446. * Gets the current class name
  128447. * @returns the class name
  128448. */
  128449. getClassName(): string;
  128450. /**
  128451. * Gets the value input component
  128452. */
  128453. get value(): NodeMaterialConnectionPoint;
  128454. /**
  128455. * Gets the output component
  128456. */
  128457. get output(): NodeMaterialConnectionPoint;
  128458. protected _buildBlock(state: NodeMaterialBuildState): this;
  128459. }
  128460. }
  128461. declare module BABYLON {
  128462. /**
  128463. * Block used to get the value of the first parameter raised to the power of the second
  128464. */
  128465. export class PowBlock extends NodeMaterialBlock {
  128466. /**
  128467. * Creates a new PowBlock
  128468. * @param name defines the block name
  128469. */
  128470. constructor(name: string);
  128471. /**
  128472. * Gets the current class name
  128473. * @returns the class name
  128474. */
  128475. getClassName(): string;
  128476. /**
  128477. * Gets the value operand input component
  128478. */
  128479. get value(): NodeMaterialConnectionPoint;
  128480. /**
  128481. * Gets the power operand input component
  128482. */
  128483. get power(): NodeMaterialConnectionPoint;
  128484. /**
  128485. * Gets the output component
  128486. */
  128487. get output(): NodeMaterialConnectionPoint;
  128488. protected _buildBlock(state: NodeMaterialBuildState): this;
  128489. }
  128490. }
  128491. declare module BABYLON {
  128492. /**
  128493. * Block used to get a random number
  128494. */
  128495. export class RandomNumberBlock extends NodeMaterialBlock {
  128496. /**
  128497. * Creates a new RandomNumberBlock
  128498. * @param name defines the block name
  128499. */
  128500. constructor(name: string);
  128501. /**
  128502. * Gets the current class name
  128503. * @returns the class name
  128504. */
  128505. getClassName(): string;
  128506. /**
  128507. * Gets the seed input component
  128508. */
  128509. get seed(): NodeMaterialConnectionPoint;
  128510. /**
  128511. * Gets the output component
  128512. */
  128513. get output(): NodeMaterialConnectionPoint;
  128514. protected _buildBlock(state: NodeMaterialBuildState): this;
  128515. }
  128516. }
  128517. declare module BABYLON {
  128518. /**
  128519. * Block used to compute arc tangent of 2 values
  128520. */
  128521. export class ArcTan2Block extends NodeMaterialBlock {
  128522. /**
  128523. * Creates a new ArcTan2Block
  128524. * @param name defines the block name
  128525. */
  128526. constructor(name: string);
  128527. /**
  128528. * Gets the current class name
  128529. * @returns the class name
  128530. */
  128531. getClassName(): string;
  128532. /**
  128533. * Gets the x operand input component
  128534. */
  128535. get x(): NodeMaterialConnectionPoint;
  128536. /**
  128537. * Gets the y operand input component
  128538. */
  128539. get y(): NodeMaterialConnectionPoint;
  128540. /**
  128541. * Gets the output component
  128542. */
  128543. get output(): NodeMaterialConnectionPoint;
  128544. protected _buildBlock(state: NodeMaterialBuildState): this;
  128545. }
  128546. }
  128547. declare module BABYLON {
  128548. /**
  128549. * Block used to smooth step a value
  128550. */
  128551. export class SmoothStepBlock extends NodeMaterialBlock {
  128552. /**
  128553. * Creates a new SmoothStepBlock
  128554. * @param name defines the block name
  128555. */
  128556. constructor(name: string);
  128557. /**
  128558. * Gets the current class name
  128559. * @returns the class name
  128560. */
  128561. getClassName(): string;
  128562. /**
  128563. * Gets the value operand input component
  128564. */
  128565. get value(): NodeMaterialConnectionPoint;
  128566. /**
  128567. * Gets the first edge operand input component
  128568. */
  128569. get edge0(): NodeMaterialConnectionPoint;
  128570. /**
  128571. * Gets the second edge operand input component
  128572. */
  128573. get edge1(): NodeMaterialConnectionPoint;
  128574. /**
  128575. * Gets the output component
  128576. */
  128577. get output(): NodeMaterialConnectionPoint;
  128578. protected _buildBlock(state: NodeMaterialBuildState): this;
  128579. }
  128580. }
  128581. declare module BABYLON {
  128582. /**
  128583. * Block used to get the reciprocal (1 / x) of a value
  128584. */
  128585. export class ReciprocalBlock extends NodeMaterialBlock {
  128586. /**
  128587. * Creates a new ReciprocalBlock
  128588. * @param name defines the block name
  128589. */
  128590. constructor(name: string);
  128591. /**
  128592. * Gets the current class name
  128593. * @returns the class name
  128594. */
  128595. getClassName(): string;
  128596. /**
  128597. * Gets the input component
  128598. */
  128599. get input(): NodeMaterialConnectionPoint;
  128600. /**
  128601. * Gets the output component
  128602. */
  128603. get output(): NodeMaterialConnectionPoint;
  128604. protected _buildBlock(state: NodeMaterialBuildState): this;
  128605. }
  128606. }
  128607. declare module BABYLON {
  128608. /**
  128609. * Block used to replace a color by another one
  128610. */
  128611. export class ReplaceColorBlock extends NodeMaterialBlock {
  128612. /**
  128613. * Creates a new ReplaceColorBlock
  128614. * @param name defines the block name
  128615. */
  128616. constructor(name: string);
  128617. /**
  128618. * Gets the current class name
  128619. * @returns the class name
  128620. */
  128621. getClassName(): string;
  128622. /**
  128623. * Gets the value input component
  128624. */
  128625. get value(): NodeMaterialConnectionPoint;
  128626. /**
  128627. * Gets the reference input component
  128628. */
  128629. get reference(): NodeMaterialConnectionPoint;
  128630. /**
  128631. * Gets the distance input component
  128632. */
  128633. get distance(): NodeMaterialConnectionPoint;
  128634. /**
  128635. * Gets the replacement input component
  128636. */
  128637. get replacement(): NodeMaterialConnectionPoint;
  128638. /**
  128639. * Gets the output component
  128640. */
  128641. get output(): NodeMaterialConnectionPoint;
  128642. protected _buildBlock(state: NodeMaterialBuildState): this;
  128643. }
  128644. }
  128645. declare module BABYLON {
  128646. /**
  128647. * Block used to posterize a value
  128648. * @see https://en.wikipedia.org/wiki/Posterization
  128649. */
  128650. export class PosterizeBlock extends NodeMaterialBlock {
  128651. /**
  128652. * Creates a new PosterizeBlock
  128653. * @param name defines the block name
  128654. */
  128655. constructor(name: string);
  128656. /**
  128657. * Gets the current class name
  128658. * @returns the class name
  128659. */
  128660. getClassName(): string;
  128661. /**
  128662. * Gets the value input component
  128663. */
  128664. get value(): NodeMaterialConnectionPoint;
  128665. /**
  128666. * Gets the steps input component
  128667. */
  128668. get steps(): NodeMaterialConnectionPoint;
  128669. /**
  128670. * Gets the output component
  128671. */
  128672. get output(): NodeMaterialConnectionPoint;
  128673. protected _buildBlock(state: NodeMaterialBuildState): this;
  128674. }
  128675. }
  128676. declare module BABYLON {
  128677. /**
  128678. * Operations supported by the Wave block
  128679. */
  128680. export enum WaveBlockKind {
  128681. /** SawTooth */
  128682. SawTooth = 0,
  128683. /** Square */
  128684. Square = 1,
  128685. /** Triangle */
  128686. Triangle = 2
  128687. }
  128688. /**
  128689. * Block used to apply wave operation to floats
  128690. */
  128691. export class WaveBlock extends NodeMaterialBlock {
  128692. /**
  128693. * Gets or sets the kibnd of wave to be applied by the block
  128694. */
  128695. kind: WaveBlockKind;
  128696. /**
  128697. * Creates a new WaveBlock
  128698. * @param name defines the block name
  128699. */
  128700. constructor(name: string);
  128701. /**
  128702. * Gets the current class name
  128703. * @returns the class name
  128704. */
  128705. getClassName(): string;
  128706. /**
  128707. * Gets the input component
  128708. */
  128709. get input(): NodeMaterialConnectionPoint;
  128710. /**
  128711. * Gets the output component
  128712. */
  128713. get output(): NodeMaterialConnectionPoint;
  128714. protected _buildBlock(state: NodeMaterialBuildState): this;
  128715. serialize(): any;
  128716. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128717. }
  128718. }
  128719. declare module BABYLON {
  128720. /**
  128721. * Class used to store a color step for the GradientBlock
  128722. */
  128723. export class GradientBlockColorStep {
  128724. /**
  128725. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  128726. */
  128727. step: number;
  128728. /**
  128729. * Gets or sets the color associated with this step
  128730. */
  128731. color: Color3;
  128732. /**
  128733. * Creates a new GradientBlockColorStep
  128734. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  128735. * @param color defines the color associated with this step
  128736. */
  128737. constructor(
  128738. /**
  128739. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  128740. */
  128741. step: number,
  128742. /**
  128743. * Gets or sets the color associated with this step
  128744. */
  128745. color: Color3);
  128746. }
  128747. /**
  128748. * Block used to return a color from a gradient based on an input value between 0 and 1
  128749. */
  128750. export class GradientBlock extends NodeMaterialBlock {
  128751. /**
  128752. * Gets or sets the list of color steps
  128753. */
  128754. colorSteps: GradientBlockColorStep[];
  128755. /**
  128756. * Creates a new GradientBlock
  128757. * @param name defines the block name
  128758. */
  128759. constructor(name: string);
  128760. /**
  128761. * Gets the current class name
  128762. * @returns the class name
  128763. */
  128764. getClassName(): string;
  128765. /**
  128766. * Gets the gradient input component
  128767. */
  128768. get gradient(): NodeMaterialConnectionPoint;
  128769. /**
  128770. * Gets the output component
  128771. */
  128772. get output(): NodeMaterialConnectionPoint;
  128773. private _writeColorConstant;
  128774. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  128775. serialize(): any;
  128776. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128777. protected _dumpPropertiesCode(): string;
  128778. }
  128779. }
  128780. declare module BABYLON {
  128781. /**
  128782. * Block used to normalize lerp between 2 values
  128783. */
  128784. export class NLerpBlock extends NodeMaterialBlock {
  128785. /**
  128786. * Creates a new NLerpBlock
  128787. * @param name defines the block name
  128788. */
  128789. constructor(name: string);
  128790. /**
  128791. * Gets the current class name
  128792. * @returns the class name
  128793. */
  128794. getClassName(): string;
  128795. /**
  128796. * Gets the left operand input component
  128797. */
  128798. get left(): NodeMaterialConnectionPoint;
  128799. /**
  128800. * Gets the right operand input component
  128801. */
  128802. get right(): NodeMaterialConnectionPoint;
  128803. /**
  128804. * Gets the gradient operand input component
  128805. */
  128806. get gradient(): NodeMaterialConnectionPoint;
  128807. /**
  128808. * Gets the output component
  128809. */
  128810. get output(): NodeMaterialConnectionPoint;
  128811. protected _buildBlock(state: NodeMaterialBuildState): this;
  128812. }
  128813. }
  128814. declare module BABYLON {
  128815. /**
  128816. * block used to Generate a Worley Noise 3D Noise Pattern
  128817. */
  128818. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  128819. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  128820. manhattanDistance: boolean;
  128821. /**
  128822. * Creates a new WorleyNoise3DBlock
  128823. * @param name defines the block name
  128824. */
  128825. constructor(name: string);
  128826. /**
  128827. * Gets the current class name
  128828. * @returns the class name
  128829. */
  128830. getClassName(): string;
  128831. /**
  128832. * Gets the seed input component
  128833. */
  128834. get seed(): NodeMaterialConnectionPoint;
  128835. /**
  128836. * Gets the jitter input component
  128837. */
  128838. get jitter(): NodeMaterialConnectionPoint;
  128839. /**
  128840. * Gets the output component
  128841. */
  128842. get output(): NodeMaterialConnectionPoint;
  128843. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  128844. /**
  128845. * Exposes the properties to the UI?
  128846. */
  128847. protected _dumpPropertiesCode(): string;
  128848. /**
  128849. * Exposes the properties to the Seralize?
  128850. */
  128851. serialize(): any;
  128852. /**
  128853. * Exposes the properties to the deseralize?
  128854. */
  128855. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128856. }
  128857. }
  128858. declare module BABYLON {
  128859. /**
  128860. * block used to Generate a Simplex Perlin 3d Noise Pattern
  128861. */
  128862. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  128863. /**
  128864. * Creates a new SimplexPerlin3DBlock
  128865. * @param name defines the block name
  128866. */
  128867. constructor(name: string);
  128868. /**
  128869. * Gets the current class name
  128870. * @returns the class name
  128871. */
  128872. getClassName(): string;
  128873. /**
  128874. * Gets the seed operand input component
  128875. */
  128876. get seed(): NodeMaterialConnectionPoint;
  128877. /**
  128878. * Gets the output component
  128879. */
  128880. get output(): NodeMaterialConnectionPoint;
  128881. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  128882. }
  128883. }
  128884. declare module BABYLON {
  128885. /**
  128886. * Block used to blend normals
  128887. */
  128888. export class NormalBlendBlock extends NodeMaterialBlock {
  128889. /**
  128890. * Creates a new NormalBlendBlock
  128891. * @param name defines the block name
  128892. */
  128893. constructor(name: string);
  128894. /**
  128895. * Gets the current class name
  128896. * @returns the class name
  128897. */
  128898. getClassName(): string;
  128899. /**
  128900. * Gets the first input component
  128901. */
  128902. get normalMap0(): NodeMaterialConnectionPoint;
  128903. /**
  128904. * Gets the second input component
  128905. */
  128906. get normalMap1(): NodeMaterialConnectionPoint;
  128907. /**
  128908. * Gets the output component
  128909. */
  128910. get output(): NodeMaterialConnectionPoint;
  128911. protected _buildBlock(state: NodeMaterialBuildState): this;
  128912. }
  128913. }
  128914. declare module BABYLON {
  128915. /**
  128916. * Block used to rotate a 2d vector by a given angle
  128917. */
  128918. export class Rotate2dBlock extends NodeMaterialBlock {
  128919. /**
  128920. * Creates a new Rotate2dBlock
  128921. * @param name defines the block name
  128922. */
  128923. constructor(name: string);
  128924. /**
  128925. * Gets the current class name
  128926. * @returns the class name
  128927. */
  128928. getClassName(): string;
  128929. /**
  128930. * Gets the input vector
  128931. */
  128932. get input(): NodeMaterialConnectionPoint;
  128933. /**
  128934. * Gets the input angle
  128935. */
  128936. get angle(): NodeMaterialConnectionPoint;
  128937. /**
  128938. * Gets the output component
  128939. */
  128940. get output(): NodeMaterialConnectionPoint;
  128941. autoConfigure(material: NodeMaterial): void;
  128942. protected _buildBlock(state: NodeMaterialBuildState): this;
  128943. }
  128944. }
  128945. declare module BABYLON {
  128946. /**
  128947. * Block used to get the reflected vector from a direction and a normal
  128948. */
  128949. export class ReflectBlock extends NodeMaterialBlock {
  128950. /**
  128951. * Creates a new ReflectBlock
  128952. * @param name defines the block name
  128953. */
  128954. constructor(name: string);
  128955. /**
  128956. * Gets the current class name
  128957. * @returns the class name
  128958. */
  128959. getClassName(): string;
  128960. /**
  128961. * Gets the incident component
  128962. */
  128963. get incident(): NodeMaterialConnectionPoint;
  128964. /**
  128965. * Gets the normal component
  128966. */
  128967. get normal(): NodeMaterialConnectionPoint;
  128968. /**
  128969. * Gets the output component
  128970. */
  128971. get output(): NodeMaterialConnectionPoint;
  128972. protected _buildBlock(state: NodeMaterialBuildState): this;
  128973. }
  128974. }
  128975. declare module BABYLON {
  128976. /**
  128977. * Block used to get the refracted vector from a direction and a normal
  128978. */
  128979. export class RefractBlock extends NodeMaterialBlock {
  128980. /**
  128981. * Creates a new RefractBlock
  128982. * @param name defines the block name
  128983. */
  128984. constructor(name: string);
  128985. /**
  128986. * Gets the current class name
  128987. * @returns the class name
  128988. */
  128989. getClassName(): string;
  128990. /**
  128991. * Gets the incident component
  128992. */
  128993. get incident(): NodeMaterialConnectionPoint;
  128994. /**
  128995. * Gets the normal component
  128996. */
  128997. get normal(): NodeMaterialConnectionPoint;
  128998. /**
  128999. * Gets the index of refraction component
  129000. */
  129001. get ior(): NodeMaterialConnectionPoint;
  129002. /**
  129003. * Gets the output component
  129004. */
  129005. get output(): NodeMaterialConnectionPoint;
  129006. protected _buildBlock(state: NodeMaterialBuildState): this;
  129007. }
  129008. }
  129009. declare module BABYLON {
  129010. /**
  129011. * Block used to desaturate a color
  129012. */
  129013. export class DesaturateBlock extends NodeMaterialBlock {
  129014. /**
  129015. * Creates a new DesaturateBlock
  129016. * @param name defines the block name
  129017. */
  129018. constructor(name: string);
  129019. /**
  129020. * Gets the current class name
  129021. * @returns the class name
  129022. */
  129023. getClassName(): string;
  129024. /**
  129025. * Gets the color operand input component
  129026. */
  129027. get color(): NodeMaterialConnectionPoint;
  129028. /**
  129029. * Gets the level operand input component
  129030. */
  129031. get level(): NodeMaterialConnectionPoint;
  129032. /**
  129033. * Gets the output component
  129034. */
  129035. get output(): NodeMaterialConnectionPoint;
  129036. protected _buildBlock(state: NodeMaterialBuildState): this;
  129037. }
  129038. }
  129039. declare module BABYLON {
  129040. /**
  129041. * Effect Render Options
  129042. */
  129043. export interface IEffectRendererOptions {
  129044. /**
  129045. * Defines the vertices positions.
  129046. */
  129047. positions?: number[];
  129048. /**
  129049. * Defines the indices.
  129050. */
  129051. indices?: number[];
  129052. }
  129053. /**
  129054. * Helper class to render one or more effects
  129055. */
  129056. export class EffectRenderer {
  129057. private engine;
  129058. private static _DefaultOptions;
  129059. private _vertexBuffers;
  129060. private _indexBuffer;
  129061. private _ringBufferIndex;
  129062. private _ringScreenBuffer;
  129063. private _fullscreenViewport;
  129064. private _getNextFrameBuffer;
  129065. /**
  129066. * Creates an effect renderer
  129067. * @param engine the engine to use for rendering
  129068. * @param options defines the options of the effect renderer
  129069. */
  129070. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  129071. /**
  129072. * Sets the current viewport in normalized coordinates 0-1
  129073. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  129074. */
  129075. setViewport(viewport?: Viewport): void;
  129076. /**
  129077. * Binds the embedded attributes buffer to the effect.
  129078. * @param effect Defines the effect to bind the attributes for
  129079. */
  129080. bindBuffers(effect: Effect): void;
  129081. /**
  129082. * Sets the current effect wrapper to use during draw.
  129083. * The effect needs to be ready before calling this api.
  129084. * This also sets the default full screen position attribute.
  129085. * @param effectWrapper Defines the effect to draw with
  129086. */
  129087. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  129088. /**
  129089. * Draws a full screen quad.
  129090. */
  129091. draw(): void;
  129092. /**
  129093. * renders one or more effects to a specified texture
  129094. * @param effectWrappers list of effects to renderer
  129095. * @param outputTexture texture to draw to, if null it will render to the screen
  129096. */
  129097. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  129098. /**
  129099. * Disposes of the effect renderer
  129100. */
  129101. dispose(): void;
  129102. }
  129103. /**
  129104. * Options to create an EffectWrapper
  129105. */
  129106. interface EffectWrapperCreationOptions {
  129107. /**
  129108. * Engine to use to create the effect
  129109. */
  129110. engine: ThinEngine;
  129111. /**
  129112. * Fragment shader for the effect
  129113. */
  129114. fragmentShader: string;
  129115. /**
  129116. * Vertex shader for the effect
  129117. */
  129118. vertexShader?: string;
  129119. /**
  129120. * Attributes to use in the shader
  129121. */
  129122. attributeNames?: Array<string>;
  129123. /**
  129124. * Uniforms to use in the shader
  129125. */
  129126. uniformNames?: Array<string>;
  129127. /**
  129128. * Texture sampler names to use in the shader
  129129. */
  129130. samplerNames?: Array<string>;
  129131. /**
  129132. * The friendly name of the effect displayed in Spector.
  129133. */
  129134. name?: string;
  129135. }
  129136. /**
  129137. * Wraps an effect to be used for rendering
  129138. */
  129139. export class EffectWrapper {
  129140. /**
  129141. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  129142. */
  129143. onApplyObservable: Observable<{}>;
  129144. /**
  129145. * The underlying effect
  129146. */
  129147. effect: Effect;
  129148. /**
  129149. * Creates an effect to be renderer
  129150. * @param creationOptions options to create the effect
  129151. */
  129152. constructor(creationOptions: EffectWrapperCreationOptions);
  129153. /**
  129154. * Disposes of the effect wrapper
  129155. */
  129156. dispose(): void;
  129157. }
  129158. }
  129159. declare module BABYLON {
  129160. /**
  129161. * Helper class to push actions to a pool of workers.
  129162. */
  129163. export class WorkerPool implements IDisposable {
  129164. private _workerInfos;
  129165. private _pendingActions;
  129166. /**
  129167. * Constructor
  129168. * @param workers Array of workers to use for actions
  129169. */
  129170. constructor(workers: Array<Worker>);
  129171. /**
  129172. * Terminates all workers and clears any pending actions.
  129173. */
  129174. dispose(): void;
  129175. /**
  129176. * Pushes an action to the worker pool. If all the workers are active, the action will be
  129177. * pended until a worker has completed its action.
  129178. * @param action The action to perform. Call onComplete when the action is complete.
  129179. */
  129180. push(action: (worker: Worker, onComplete: () => void) => void): void;
  129181. private _execute;
  129182. }
  129183. }
  129184. declare module BABYLON {
  129185. /**
  129186. * Configuration for Draco compression
  129187. */
  129188. export interface IDracoCompressionConfiguration {
  129189. /**
  129190. * Configuration for the decoder.
  129191. */
  129192. decoder: {
  129193. /**
  129194. * The url to the WebAssembly module.
  129195. */
  129196. wasmUrl?: string;
  129197. /**
  129198. * The url to the WebAssembly binary.
  129199. */
  129200. wasmBinaryUrl?: string;
  129201. /**
  129202. * The url to the fallback JavaScript module.
  129203. */
  129204. fallbackUrl?: string;
  129205. };
  129206. }
  129207. /**
  129208. * Draco compression (https://google.github.io/draco/)
  129209. *
  129210. * This class wraps the Draco module.
  129211. *
  129212. * **Encoder**
  129213. *
  129214. * The encoder is not currently implemented.
  129215. *
  129216. * **Decoder**
  129217. *
  129218. * 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.
  129219. *
  129220. * To update the configuration, use the following code:
  129221. * ```javascript
  129222. * DracoCompression.Configuration = {
  129223. * decoder: {
  129224. * wasmUrl: "<url to the WebAssembly library>",
  129225. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  129226. * fallbackUrl: "<url to the fallback JavaScript library>",
  129227. * }
  129228. * };
  129229. * ```
  129230. *
  129231. * 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.
  129232. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  129233. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  129234. *
  129235. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  129236. * ```javascript
  129237. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  129238. * ```
  129239. *
  129240. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  129241. */
  129242. export class DracoCompression implements IDisposable {
  129243. private _workerPoolPromise?;
  129244. private _decoderModulePromise?;
  129245. /**
  129246. * The configuration. Defaults to the following urls:
  129247. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  129248. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  129249. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  129250. */
  129251. static Configuration: IDracoCompressionConfiguration;
  129252. /**
  129253. * Returns true if the decoder configuration is available.
  129254. */
  129255. static get DecoderAvailable(): boolean;
  129256. /**
  129257. * Default number of workers to create when creating the draco compression object.
  129258. */
  129259. static DefaultNumWorkers: number;
  129260. private static GetDefaultNumWorkers;
  129261. private static _Default;
  129262. /**
  129263. * Default instance for the draco compression object.
  129264. */
  129265. static get Default(): DracoCompression;
  129266. /**
  129267. * Constructor
  129268. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  129269. */
  129270. constructor(numWorkers?: number);
  129271. /**
  129272. * Stop all async operations and release resources.
  129273. */
  129274. dispose(): void;
  129275. /**
  129276. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  129277. * @returns a promise that resolves when ready
  129278. */
  129279. whenReadyAsync(): Promise<void>;
  129280. /**
  129281. * Decode Draco compressed mesh data to vertex data.
  129282. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  129283. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  129284. * @returns A promise that resolves with the decoded vertex data
  129285. */
  129286. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  129287. [kind: string]: number;
  129288. }): Promise<VertexData>;
  129289. }
  129290. }
  129291. declare module BABYLON {
  129292. /**
  129293. * Class for building Constructive Solid Geometry
  129294. */
  129295. export class CSG {
  129296. private polygons;
  129297. /**
  129298. * The world matrix
  129299. */
  129300. matrix: Matrix;
  129301. /**
  129302. * Stores the position
  129303. */
  129304. position: Vector3;
  129305. /**
  129306. * Stores the rotation
  129307. */
  129308. rotation: Vector3;
  129309. /**
  129310. * Stores the rotation quaternion
  129311. */
  129312. rotationQuaternion: Nullable<Quaternion>;
  129313. /**
  129314. * Stores the scaling vector
  129315. */
  129316. scaling: Vector3;
  129317. /**
  129318. * Convert the Mesh to CSG
  129319. * @param mesh The Mesh to convert to CSG
  129320. * @returns A new CSG from the Mesh
  129321. */
  129322. static FromMesh(mesh: Mesh): CSG;
  129323. /**
  129324. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  129325. * @param polygons Polygons used to construct a CSG solid
  129326. */
  129327. private static FromPolygons;
  129328. /**
  129329. * Clones, or makes a deep copy, of the CSG
  129330. * @returns A new CSG
  129331. */
  129332. clone(): CSG;
  129333. /**
  129334. * Unions this CSG with another CSG
  129335. * @param csg The CSG to union against this CSG
  129336. * @returns The unioned CSG
  129337. */
  129338. union(csg: CSG): CSG;
  129339. /**
  129340. * Unions this CSG with another CSG in place
  129341. * @param csg The CSG to union against this CSG
  129342. */
  129343. unionInPlace(csg: CSG): void;
  129344. /**
  129345. * Subtracts this CSG with another CSG
  129346. * @param csg The CSG to subtract against this CSG
  129347. * @returns A new CSG
  129348. */
  129349. subtract(csg: CSG): CSG;
  129350. /**
  129351. * Subtracts this CSG with another CSG in place
  129352. * @param csg The CSG to subtact against this CSG
  129353. */
  129354. subtractInPlace(csg: CSG): void;
  129355. /**
  129356. * Intersect this CSG with another CSG
  129357. * @param csg The CSG to intersect against this CSG
  129358. * @returns A new CSG
  129359. */
  129360. intersect(csg: CSG): CSG;
  129361. /**
  129362. * Intersects this CSG with another CSG in place
  129363. * @param csg The CSG to intersect against this CSG
  129364. */
  129365. intersectInPlace(csg: CSG): void;
  129366. /**
  129367. * Return a new CSG solid with solid and empty space switched. This solid is
  129368. * not modified.
  129369. * @returns A new CSG solid with solid and empty space switched
  129370. */
  129371. inverse(): CSG;
  129372. /**
  129373. * Inverses the CSG in place
  129374. */
  129375. inverseInPlace(): void;
  129376. /**
  129377. * This is used to keep meshes transformations so they can be restored
  129378. * when we build back a Babylon Mesh
  129379. * NB : All CSG operations are performed in world coordinates
  129380. * @param csg The CSG to copy the transform attributes from
  129381. * @returns This CSG
  129382. */
  129383. copyTransformAttributes(csg: CSG): CSG;
  129384. /**
  129385. * Build Raw mesh from CSG
  129386. * Coordinates here are in world space
  129387. * @param name The name of the mesh geometry
  129388. * @param scene The Scene
  129389. * @param keepSubMeshes Specifies if the submeshes should be kept
  129390. * @returns A new Mesh
  129391. */
  129392. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  129393. /**
  129394. * Build Mesh from CSG taking material and transforms into account
  129395. * @param name The name of the Mesh
  129396. * @param material The material of the Mesh
  129397. * @param scene The Scene
  129398. * @param keepSubMeshes Specifies if submeshes should be kept
  129399. * @returns The new Mesh
  129400. */
  129401. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  129402. }
  129403. }
  129404. declare module BABYLON {
  129405. /**
  129406. * Class used to create a trail following a mesh
  129407. */
  129408. export class TrailMesh extends Mesh {
  129409. private _generator;
  129410. private _autoStart;
  129411. private _running;
  129412. private _diameter;
  129413. private _length;
  129414. private _sectionPolygonPointsCount;
  129415. private _sectionVectors;
  129416. private _sectionNormalVectors;
  129417. private _beforeRenderObserver;
  129418. /**
  129419. * @constructor
  129420. * @param name The value used by scene.getMeshByName() to do a lookup.
  129421. * @param generator The mesh to generate a trail.
  129422. * @param scene The scene to add this mesh to.
  129423. * @param diameter Diameter of trailing mesh. Default is 1.
  129424. * @param length Length of trailing mesh. Default is 60.
  129425. * @param autoStart Automatically start trailing mesh. Default true.
  129426. */
  129427. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  129428. /**
  129429. * "TrailMesh"
  129430. * @returns "TrailMesh"
  129431. */
  129432. getClassName(): string;
  129433. private _createMesh;
  129434. /**
  129435. * Start trailing mesh.
  129436. */
  129437. start(): void;
  129438. /**
  129439. * Stop trailing mesh.
  129440. */
  129441. stop(): void;
  129442. /**
  129443. * Update trailing mesh geometry.
  129444. */
  129445. update(): void;
  129446. /**
  129447. * Returns a new TrailMesh object.
  129448. * @param name is a string, the name given to the new mesh
  129449. * @param newGenerator use new generator object for cloned trail mesh
  129450. * @returns a new mesh
  129451. */
  129452. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  129453. /**
  129454. * Serializes this trail mesh
  129455. * @param serializationObject object to write serialization to
  129456. */
  129457. serialize(serializationObject: any): void;
  129458. /**
  129459. * Parses a serialized trail mesh
  129460. * @param parsedMesh the serialized mesh
  129461. * @param scene the scene to create the trail mesh in
  129462. * @returns the created trail mesh
  129463. */
  129464. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  129465. }
  129466. }
  129467. declare module BABYLON {
  129468. /**
  129469. * Class containing static functions to help procedurally build meshes
  129470. */
  129471. export class TiledBoxBuilder {
  129472. /**
  129473. * Creates a box mesh
  129474. * 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)
  129475. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  129476. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129477. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129479. * @param name defines the name of the mesh
  129480. * @param options defines the options used to create the mesh
  129481. * @param scene defines the hosting scene
  129482. * @returns the box mesh
  129483. */
  129484. static CreateTiledBox(name: string, options: {
  129485. pattern?: number;
  129486. width?: number;
  129487. height?: number;
  129488. depth?: number;
  129489. tileSize?: number;
  129490. tileWidth?: number;
  129491. tileHeight?: number;
  129492. alignHorizontal?: number;
  129493. alignVertical?: number;
  129494. faceUV?: Vector4[];
  129495. faceColors?: Color4[];
  129496. sideOrientation?: number;
  129497. updatable?: boolean;
  129498. }, scene?: Nullable<Scene>): Mesh;
  129499. }
  129500. }
  129501. declare module BABYLON {
  129502. /**
  129503. * Class containing static functions to help procedurally build meshes
  129504. */
  129505. export class TorusKnotBuilder {
  129506. /**
  129507. * Creates a torus knot mesh
  129508. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  129509. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  129510. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  129511. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  129512. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129513. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129515. * @param name defines the name of the mesh
  129516. * @param options defines the options used to create the mesh
  129517. * @param scene defines the hosting scene
  129518. * @returns the torus knot mesh
  129519. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  129520. */
  129521. static CreateTorusKnot(name: string, options: {
  129522. radius?: number;
  129523. tube?: number;
  129524. radialSegments?: number;
  129525. tubularSegments?: number;
  129526. p?: number;
  129527. q?: number;
  129528. updatable?: boolean;
  129529. sideOrientation?: number;
  129530. frontUVs?: Vector4;
  129531. backUVs?: Vector4;
  129532. }, scene: any): Mesh;
  129533. }
  129534. }
  129535. declare module BABYLON {
  129536. /**
  129537. * Polygon
  129538. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  129539. */
  129540. export class Polygon {
  129541. /**
  129542. * Creates a rectangle
  129543. * @param xmin bottom X coord
  129544. * @param ymin bottom Y coord
  129545. * @param xmax top X coord
  129546. * @param ymax top Y coord
  129547. * @returns points that make the resulting rectation
  129548. */
  129549. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  129550. /**
  129551. * Creates a circle
  129552. * @param radius radius of circle
  129553. * @param cx scale in x
  129554. * @param cy scale in y
  129555. * @param numberOfSides number of sides that make up the circle
  129556. * @returns points that make the resulting circle
  129557. */
  129558. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  129559. /**
  129560. * Creates a polygon from input string
  129561. * @param input Input polygon data
  129562. * @returns the parsed points
  129563. */
  129564. static Parse(input: string): Vector2[];
  129565. /**
  129566. * Starts building a polygon from x and y coordinates
  129567. * @param x x coordinate
  129568. * @param y y coordinate
  129569. * @returns the started path2
  129570. */
  129571. static StartingAt(x: number, y: number): Path2;
  129572. }
  129573. /**
  129574. * Builds a polygon
  129575. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  129576. */
  129577. export class PolygonMeshBuilder {
  129578. private _points;
  129579. private _outlinepoints;
  129580. private _holes;
  129581. private _name;
  129582. private _scene;
  129583. private _epoints;
  129584. private _eholes;
  129585. private _addToepoint;
  129586. /**
  129587. * Babylon reference to the earcut plugin.
  129588. */
  129589. bjsEarcut: any;
  129590. /**
  129591. * Creates a PolygonMeshBuilder
  129592. * @param name name of the builder
  129593. * @param contours Path of the polygon
  129594. * @param scene scene to add to when creating the mesh
  129595. * @param earcutInjection can be used to inject your own earcut reference
  129596. */
  129597. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  129598. /**
  129599. * Adds a whole within the polygon
  129600. * @param hole Array of points defining the hole
  129601. * @returns this
  129602. */
  129603. addHole(hole: Vector2[]): PolygonMeshBuilder;
  129604. /**
  129605. * Creates the polygon
  129606. * @param updatable If the mesh should be updatable
  129607. * @param depth The depth of the mesh created
  129608. * @returns the created mesh
  129609. */
  129610. build(updatable?: boolean, depth?: number): Mesh;
  129611. /**
  129612. * Creates the polygon
  129613. * @param depth The depth of the mesh created
  129614. * @returns the created VertexData
  129615. */
  129616. buildVertexData(depth?: number): VertexData;
  129617. /**
  129618. * Adds a side to the polygon
  129619. * @param positions points that make the polygon
  129620. * @param normals normals of the polygon
  129621. * @param uvs uvs of the polygon
  129622. * @param indices indices of the polygon
  129623. * @param bounds bounds of the polygon
  129624. * @param points points of the polygon
  129625. * @param depth depth of the polygon
  129626. * @param flip flip of the polygon
  129627. */
  129628. private addSide;
  129629. }
  129630. }
  129631. declare module BABYLON {
  129632. /**
  129633. * Class containing static functions to help procedurally build meshes
  129634. */
  129635. export class PolygonBuilder {
  129636. /**
  129637. * Creates a polygon mesh
  129638. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  129639. * * 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
  129640. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  129641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129642. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  129643. * * Remember you can only change the shape positions, not their number when updating a polygon
  129644. * @param name defines the name of the mesh
  129645. * @param options defines the options used to create the mesh
  129646. * @param scene defines the hosting scene
  129647. * @param earcutInjection can be used to inject your own earcut reference
  129648. * @returns the polygon mesh
  129649. */
  129650. static CreatePolygon(name: string, options: {
  129651. shape: Vector3[];
  129652. holes?: Vector3[][];
  129653. depth?: number;
  129654. faceUV?: Vector4[];
  129655. faceColors?: Color4[];
  129656. updatable?: boolean;
  129657. sideOrientation?: number;
  129658. frontUVs?: Vector4;
  129659. backUVs?: Vector4;
  129660. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  129661. /**
  129662. * Creates an extruded polygon mesh, with depth in the Y direction.
  129663. * * 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)
  129664. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  129665. * @param name defines the name of the mesh
  129666. * @param options defines the options used to create the mesh
  129667. * @param scene defines the hosting scene
  129668. * @param earcutInjection can be used to inject your own earcut reference
  129669. * @returns the polygon mesh
  129670. */
  129671. static ExtrudePolygon(name: string, options: {
  129672. shape: Vector3[];
  129673. holes?: Vector3[][];
  129674. depth?: number;
  129675. faceUV?: Vector4[];
  129676. faceColors?: Color4[];
  129677. updatable?: boolean;
  129678. sideOrientation?: number;
  129679. frontUVs?: Vector4;
  129680. backUVs?: Vector4;
  129681. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  129682. }
  129683. }
  129684. declare module BABYLON {
  129685. /**
  129686. * Class containing static functions to help procedurally build meshes
  129687. */
  129688. export class LatheBuilder {
  129689. /**
  129690. * Creates lathe mesh.
  129691. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  129692. * * 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
  129693. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  129694. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  129695. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  129696. * * 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
  129697. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  129698. * * 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
  129699. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129700. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129701. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129703. * @param name defines the name of the mesh
  129704. * @param options defines the options used to create the mesh
  129705. * @param scene defines the hosting scene
  129706. * @returns the lathe mesh
  129707. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  129708. */
  129709. static CreateLathe(name: string, options: {
  129710. shape: Vector3[];
  129711. radius?: number;
  129712. tessellation?: number;
  129713. clip?: number;
  129714. arc?: number;
  129715. closed?: boolean;
  129716. updatable?: boolean;
  129717. sideOrientation?: number;
  129718. frontUVs?: Vector4;
  129719. backUVs?: Vector4;
  129720. cap?: number;
  129721. invertUV?: boolean;
  129722. }, scene?: Nullable<Scene>): Mesh;
  129723. }
  129724. }
  129725. declare module BABYLON {
  129726. /**
  129727. * Class containing static functions to help procedurally build meshes
  129728. */
  129729. export class TiledPlaneBuilder {
  129730. /**
  129731. * Creates a tiled plane mesh
  129732. * * The parameter `pattern` will, depending on value, do nothing or
  129733. * * * flip (reflect about central vertical) alternate tiles across and up
  129734. * * * flip every tile on alternate rows
  129735. * * * rotate (180 degs) alternate tiles across and up
  129736. * * * rotate every tile on alternate rows
  129737. * * * flip and rotate alternate tiles across and up
  129738. * * * flip and rotate every tile on alternate rows
  129739. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  129740. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  129741. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129742. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  129743. * * 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)
  129744. * * 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)
  129745. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  129746. * @param name defines the name of the mesh
  129747. * @param options defines the options used to create the mesh
  129748. * @param scene defines the hosting scene
  129749. * @returns the box mesh
  129750. */
  129751. static CreateTiledPlane(name: string, options: {
  129752. pattern?: number;
  129753. tileSize?: number;
  129754. tileWidth?: number;
  129755. tileHeight?: number;
  129756. size?: number;
  129757. width?: number;
  129758. height?: number;
  129759. alignHorizontal?: number;
  129760. alignVertical?: number;
  129761. sideOrientation?: number;
  129762. frontUVs?: Vector4;
  129763. backUVs?: Vector4;
  129764. updatable?: boolean;
  129765. }, scene?: Nullable<Scene>): Mesh;
  129766. }
  129767. }
  129768. declare module BABYLON {
  129769. /**
  129770. * Class containing static functions to help procedurally build meshes
  129771. */
  129772. export class TubeBuilder {
  129773. /**
  129774. * Creates a tube mesh.
  129775. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  129776. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  129777. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  129778. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  129779. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  129780. * * 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)
  129781. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  129782. * * 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
  129783. * * 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
  129784. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129785. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129786. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129788. * @param name defines the name of the mesh
  129789. * @param options defines the options used to create the mesh
  129790. * @param scene defines the hosting scene
  129791. * @returns the tube mesh
  129792. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129793. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  129794. */
  129795. static CreateTube(name: string, options: {
  129796. path: Vector3[];
  129797. radius?: number;
  129798. tessellation?: number;
  129799. radiusFunction?: {
  129800. (i: number, distance: number): number;
  129801. };
  129802. cap?: number;
  129803. arc?: number;
  129804. updatable?: boolean;
  129805. sideOrientation?: number;
  129806. frontUVs?: Vector4;
  129807. backUVs?: Vector4;
  129808. instance?: Mesh;
  129809. invertUV?: boolean;
  129810. }, scene?: Nullable<Scene>): Mesh;
  129811. }
  129812. }
  129813. declare module BABYLON {
  129814. /**
  129815. * Class containing static functions to help procedurally build meshes
  129816. */
  129817. export class IcoSphereBuilder {
  129818. /**
  129819. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  129820. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  129821. * * 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`)
  129822. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  129823. * * 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
  129824. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129825. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129827. * @param name defines the name of the mesh
  129828. * @param options defines the options used to create the mesh
  129829. * @param scene defines the hosting scene
  129830. * @returns the icosahedron mesh
  129831. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  129832. */
  129833. static CreateIcoSphere(name: string, options: {
  129834. radius?: number;
  129835. radiusX?: number;
  129836. radiusY?: number;
  129837. radiusZ?: number;
  129838. flat?: boolean;
  129839. subdivisions?: number;
  129840. sideOrientation?: number;
  129841. frontUVs?: Vector4;
  129842. backUVs?: Vector4;
  129843. updatable?: boolean;
  129844. }, scene?: Nullable<Scene>): Mesh;
  129845. }
  129846. }
  129847. declare module BABYLON {
  129848. /**
  129849. * Class containing static functions to help procedurally build meshes
  129850. */
  129851. export class DecalBuilder {
  129852. /**
  129853. * Creates a decal mesh.
  129854. * 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
  129855. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  129856. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  129857. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  129858. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  129859. * @param name defines the name of the mesh
  129860. * @param sourceMesh defines the mesh where the decal must be applied
  129861. * @param options defines the options used to create the mesh
  129862. * @param scene defines the hosting scene
  129863. * @returns the decal mesh
  129864. * @see https://doc.babylonjs.com/how_to/decals
  129865. */
  129866. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  129867. position?: Vector3;
  129868. normal?: Vector3;
  129869. size?: Vector3;
  129870. angle?: number;
  129871. }): Mesh;
  129872. }
  129873. }
  129874. declare module BABYLON {
  129875. /**
  129876. * Class containing static functions to help procedurally build meshes
  129877. */
  129878. export class MeshBuilder {
  129879. /**
  129880. * Creates a box mesh
  129881. * * The parameter `size` sets the size (float) of each box side (default 1)
  129882. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  129883. * * 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)
  129884. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  129885. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129886. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129888. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  129889. * @param name defines the name of the mesh
  129890. * @param options defines the options used to create the mesh
  129891. * @param scene defines the hosting scene
  129892. * @returns the box mesh
  129893. */
  129894. static CreateBox(name: string, options: {
  129895. size?: number;
  129896. width?: number;
  129897. height?: number;
  129898. depth?: number;
  129899. faceUV?: Vector4[];
  129900. faceColors?: Color4[];
  129901. sideOrientation?: number;
  129902. frontUVs?: Vector4;
  129903. backUVs?: Vector4;
  129904. updatable?: boolean;
  129905. }, scene?: Nullable<Scene>): Mesh;
  129906. /**
  129907. * Creates a tiled box mesh
  129908. * * faceTiles sets the pattern, tile size and number of tiles for a face
  129909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129910. * @param name defines the name of the mesh
  129911. * @param options defines the options used to create the mesh
  129912. * @param scene defines the hosting scene
  129913. * @returns the tiled box mesh
  129914. */
  129915. static CreateTiledBox(name: string, options: {
  129916. pattern?: number;
  129917. size?: number;
  129918. width?: number;
  129919. height?: number;
  129920. depth: number;
  129921. tileSize?: number;
  129922. tileWidth?: number;
  129923. tileHeight?: number;
  129924. faceUV?: Vector4[];
  129925. faceColors?: Color4[];
  129926. alignHorizontal?: number;
  129927. alignVertical?: number;
  129928. sideOrientation?: number;
  129929. updatable?: boolean;
  129930. }, scene?: Nullable<Scene>): Mesh;
  129931. /**
  129932. * Creates a sphere mesh
  129933. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  129934. * * 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`)
  129935. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  129936. * * 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
  129937. * * 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)
  129938. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129939. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129941. * @param name defines the name of the mesh
  129942. * @param options defines the options used to create the mesh
  129943. * @param scene defines the hosting scene
  129944. * @returns the sphere mesh
  129945. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  129946. */
  129947. static CreateSphere(name: string, options: {
  129948. segments?: number;
  129949. diameter?: number;
  129950. diameterX?: number;
  129951. diameterY?: number;
  129952. diameterZ?: number;
  129953. arc?: number;
  129954. slice?: number;
  129955. sideOrientation?: number;
  129956. frontUVs?: Vector4;
  129957. backUVs?: Vector4;
  129958. updatable?: boolean;
  129959. }, scene?: Nullable<Scene>): Mesh;
  129960. /**
  129961. * Creates a plane polygonal mesh. By default, this is a disc
  129962. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  129963. * * 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
  129964. * * 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
  129965. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129966. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129967. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129968. * @param name defines the name of the mesh
  129969. * @param options defines the options used to create the mesh
  129970. * @param scene defines the hosting scene
  129971. * @returns the plane polygonal mesh
  129972. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  129973. */
  129974. static CreateDisc(name: string, options: {
  129975. radius?: number;
  129976. tessellation?: number;
  129977. arc?: number;
  129978. updatable?: boolean;
  129979. sideOrientation?: number;
  129980. frontUVs?: Vector4;
  129981. backUVs?: Vector4;
  129982. }, scene?: Nullable<Scene>): Mesh;
  129983. /**
  129984. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  129985. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  129986. * * 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`)
  129987. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  129988. * * 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
  129989. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129990. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129992. * @param name defines the name of the mesh
  129993. * @param options defines the options used to create the mesh
  129994. * @param scene defines the hosting scene
  129995. * @returns the icosahedron mesh
  129996. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  129997. */
  129998. static CreateIcoSphere(name: string, options: {
  129999. radius?: number;
  130000. radiusX?: number;
  130001. radiusY?: number;
  130002. radiusZ?: number;
  130003. flat?: boolean;
  130004. subdivisions?: number;
  130005. sideOrientation?: number;
  130006. frontUVs?: Vector4;
  130007. backUVs?: Vector4;
  130008. updatable?: boolean;
  130009. }, scene?: Nullable<Scene>): Mesh;
  130010. /**
  130011. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  130012. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  130013. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  130014. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  130015. * * 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
  130016. * * 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
  130017. * * 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
  130018. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130019. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130020. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130021. * * 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
  130022. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  130023. * * 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
  130024. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  130025. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130026. * @param name defines the name of the mesh
  130027. * @param options defines the options used to create the mesh
  130028. * @param scene defines the hosting scene
  130029. * @returns the ribbon mesh
  130030. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  130031. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130032. */
  130033. static CreateRibbon(name: string, options: {
  130034. pathArray: Vector3[][];
  130035. closeArray?: boolean;
  130036. closePath?: boolean;
  130037. offset?: number;
  130038. updatable?: boolean;
  130039. sideOrientation?: number;
  130040. frontUVs?: Vector4;
  130041. backUVs?: Vector4;
  130042. instance?: Mesh;
  130043. invertUV?: boolean;
  130044. uvs?: Vector2[];
  130045. colors?: Color4[];
  130046. }, scene?: Nullable<Scene>): Mesh;
  130047. /**
  130048. * Creates a cylinder or a cone mesh
  130049. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  130050. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  130051. * * 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.
  130052. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  130053. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  130054. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  130055. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  130056. * * 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).
  130057. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  130058. * * 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).
  130059. * * 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
  130060. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  130061. * * 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
  130062. * * 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.
  130063. * * If `enclose` is false, a ring surface is one element.
  130064. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  130065. * * 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
  130066. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130067. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130069. * @param name defines the name of the mesh
  130070. * @param options defines the options used to create the mesh
  130071. * @param scene defines the hosting scene
  130072. * @returns the cylinder mesh
  130073. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  130074. */
  130075. static CreateCylinder(name: string, options: {
  130076. height?: number;
  130077. diameterTop?: number;
  130078. diameterBottom?: number;
  130079. diameter?: number;
  130080. tessellation?: number;
  130081. subdivisions?: number;
  130082. arc?: number;
  130083. faceColors?: Color4[];
  130084. faceUV?: Vector4[];
  130085. updatable?: boolean;
  130086. hasRings?: boolean;
  130087. enclose?: boolean;
  130088. cap?: number;
  130089. sideOrientation?: number;
  130090. frontUVs?: Vector4;
  130091. backUVs?: Vector4;
  130092. }, scene?: Nullable<Scene>): Mesh;
  130093. /**
  130094. * Creates a torus mesh
  130095. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  130096. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  130097. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  130098. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130099. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130101. * @param name defines the name of the mesh
  130102. * @param options defines the options used to create the mesh
  130103. * @param scene defines the hosting scene
  130104. * @returns the torus mesh
  130105. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  130106. */
  130107. static CreateTorus(name: string, options: {
  130108. diameter?: number;
  130109. thickness?: number;
  130110. tessellation?: number;
  130111. updatable?: boolean;
  130112. sideOrientation?: number;
  130113. frontUVs?: Vector4;
  130114. backUVs?: Vector4;
  130115. }, scene?: Nullable<Scene>): Mesh;
  130116. /**
  130117. * Creates a torus knot mesh
  130118. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  130119. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  130120. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  130121. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  130122. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130123. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130124. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130125. * @param name defines the name of the mesh
  130126. * @param options defines the options used to create the mesh
  130127. * @param scene defines the hosting scene
  130128. * @returns the torus knot mesh
  130129. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  130130. */
  130131. static CreateTorusKnot(name: string, options: {
  130132. radius?: number;
  130133. tube?: number;
  130134. radialSegments?: number;
  130135. tubularSegments?: number;
  130136. p?: number;
  130137. q?: number;
  130138. updatable?: boolean;
  130139. sideOrientation?: number;
  130140. frontUVs?: Vector4;
  130141. backUVs?: Vector4;
  130142. }, scene?: Nullable<Scene>): Mesh;
  130143. /**
  130144. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  130145. * * 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
  130146. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  130147. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  130148. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  130149. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  130150. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  130151. * * 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
  130152. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  130153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130154. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  130155. * @param name defines the name of the new line system
  130156. * @param options defines the options used to create the line system
  130157. * @param scene defines the hosting scene
  130158. * @returns a new line system mesh
  130159. */
  130160. static CreateLineSystem(name: string, options: {
  130161. lines: Vector3[][];
  130162. updatable?: boolean;
  130163. instance?: Nullable<LinesMesh>;
  130164. colors?: Nullable<Color4[][]>;
  130165. useVertexAlpha?: boolean;
  130166. }, scene: Nullable<Scene>): LinesMesh;
  130167. /**
  130168. * Creates a line mesh
  130169. * 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
  130170. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  130171. * * The parameter `points` is an array successive Vector3
  130172. * * 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
  130173. * * The optional parameter `colors` is an array of successive Color4, one per line point
  130174. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  130175. * * When updating an instance, remember that only point positions can change, not the number of points
  130176. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130177. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  130178. * @param name defines the name of the new line system
  130179. * @param options defines the options used to create the line system
  130180. * @param scene defines the hosting scene
  130181. * @returns a new line mesh
  130182. */
  130183. static CreateLines(name: string, options: {
  130184. points: Vector3[];
  130185. updatable?: boolean;
  130186. instance?: Nullable<LinesMesh>;
  130187. colors?: Color4[];
  130188. useVertexAlpha?: boolean;
  130189. }, scene?: Nullable<Scene>): LinesMesh;
  130190. /**
  130191. * Creates a dashed line mesh
  130192. * * 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
  130193. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  130194. * * The parameter `points` is an array successive Vector3
  130195. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  130196. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  130197. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  130198. * * 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
  130199. * * When updating an instance, remember that only point positions can change, not the number of points
  130200. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130201. * @param name defines the name of the mesh
  130202. * @param options defines the options used to create the mesh
  130203. * @param scene defines the hosting scene
  130204. * @returns the dashed line mesh
  130205. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  130206. */
  130207. static CreateDashedLines(name: string, options: {
  130208. points: Vector3[];
  130209. dashSize?: number;
  130210. gapSize?: number;
  130211. dashNb?: number;
  130212. updatable?: boolean;
  130213. instance?: LinesMesh;
  130214. }, scene?: Nullable<Scene>): LinesMesh;
  130215. /**
  130216. * 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.
  130217. * * 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.
  130218. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  130219. * * 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.
  130220. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  130221. * * 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
  130222. * * 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
  130223. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  130224. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130225. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130226. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  130227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130228. * @param name defines the name of the mesh
  130229. * @param options defines the options used to create the mesh
  130230. * @param scene defines the hosting scene
  130231. * @returns the extruded shape mesh
  130232. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130233. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  130234. */
  130235. static ExtrudeShape(name: string, options: {
  130236. shape: Vector3[];
  130237. path: Vector3[];
  130238. scale?: number;
  130239. rotation?: number;
  130240. cap?: number;
  130241. updatable?: boolean;
  130242. sideOrientation?: number;
  130243. frontUVs?: Vector4;
  130244. backUVs?: Vector4;
  130245. instance?: Mesh;
  130246. invertUV?: boolean;
  130247. }, scene?: Nullable<Scene>): Mesh;
  130248. /**
  130249. * Creates an custom extruded shape mesh.
  130250. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  130251. * * 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.
  130252. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  130253. * * 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
  130254. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  130255. * * 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
  130256. * * It must returns a float value that will be the scale value applied to the shape on each path point
  130257. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  130258. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  130259. * * 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
  130260. * * 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
  130261. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  130262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130263. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130264. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130266. * @param name defines the name of the mesh
  130267. * @param options defines the options used to create the mesh
  130268. * @param scene defines the hosting scene
  130269. * @returns the custom extruded shape mesh
  130270. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  130271. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130272. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  130273. */
  130274. static ExtrudeShapeCustom(name: string, options: {
  130275. shape: Vector3[];
  130276. path: Vector3[];
  130277. scaleFunction?: any;
  130278. rotationFunction?: any;
  130279. ribbonCloseArray?: boolean;
  130280. ribbonClosePath?: boolean;
  130281. cap?: number;
  130282. updatable?: boolean;
  130283. sideOrientation?: number;
  130284. frontUVs?: Vector4;
  130285. backUVs?: Vector4;
  130286. instance?: Mesh;
  130287. invertUV?: boolean;
  130288. }, scene?: Nullable<Scene>): Mesh;
  130289. /**
  130290. * Creates lathe mesh.
  130291. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  130292. * * 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
  130293. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  130294. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  130295. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  130296. * * 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
  130297. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  130298. * * 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
  130299. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130300. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130301. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130303. * @param name defines the name of the mesh
  130304. * @param options defines the options used to create the mesh
  130305. * @param scene defines the hosting scene
  130306. * @returns the lathe mesh
  130307. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  130308. */
  130309. static CreateLathe(name: string, options: {
  130310. shape: Vector3[];
  130311. radius?: number;
  130312. tessellation?: number;
  130313. clip?: number;
  130314. arc?: number;
  130315. closed?: boolean;
  130316. updatable?: boolean;
  130317. sideOrientation?: number;
  130318. frontUVs?: Vector4;
  130319. backUVs?: Vector4;
  130320. cap?: number;
  130321. invertUV?: boolean;
  130322. }, scene?: Nullable<Scene>): Mesh;
  130323. /**
  130324. * Creates a tiled plane mesh
  130325. * * You can set a limited pattern arrangement with the tiles
  130326. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130327. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130329. * @param name defines the name of the mesh
  130330. * @param options defines the options used to create the mesh
  130331. * @param scene defines the hosting scene
  130332. * @returns the plane mesh
  130333. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  130334. */
  130335. static CreateTiledPlane(name: string, options: {
  130336. pattern?: number;
  130337. tileSize?: number;
  130338. tileWidth?: number;
  130339. tileHeight?: number;
  130340. size?: number;
  130341. width?: number;
  130342. height?: number;
  130343. alignHorizontal?: number;
  130344. alignVertical?: number;
  130345. sideOrientation?: number;
  130346. frontUVs?: Vector4;
  130347. backUVs?: Vector4;
  130348. updatable?: boolean;
  130349. }, scene?: Nullable<Scene>): Mesh;
  130350. /**
  130351. * Creates a plane mesh
  130352. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  130353. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  130354. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  130355. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130356. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130358. * @param name defines the name of the mesh
  130359. * @param options defines the options used to create the mesh
  130360. * @param scene defines the hosting scene
  130361. * @returns the plane mesh
  130362. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  130363. */
  130364. static CreatePlane(name: string, options: {
  130365. size?: number;
  130366. width?: number;
  130367. height?: number;
  130368. sideOrientation?: number;
  130369. frontUVs?: Vector4;
  130370. backUVs?: Vector4;
  130371. updatable?: boolean;
  130372. sourcePlane?: Plane;
  130373. }, scene?: Nullable<Scene>): Mesh;
  130374. /**
  130375. * Creates a ground mesh
  130376. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  130377. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  130378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130379. * @param name defines the name of the mesh
  130380. * @param options defines the options used to create the mesh
  130381. * @param scene defines the hosting scene
  130382. * @returns the ground mesh
  130383. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  130384. */
  130385. static CreateGround(name: string, options: {
  130386. width?: number;
  130387. height?: number;
  130388. subdivisions?: number;
  130389. subdivisionsX?: number;
  130390. subdivisionsY?: number;
  130391. updatable?: boolean;
  130392. }, scene?: Nullable<Scene>): Mesh;
  130393. /**
  130394. * Creates a tiled ground mesh
  130395. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  130396. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  130397. * * 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
  130398. * * 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
  130399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130400. * @param name defines the name of the mesh
  130401. * @param options defines the options used to create the mesh
  130402. * @param scene defines the hosting scene
  130403. * @returns the tiled ground mesh
  130404. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  130405. */
  130406. static CreateTiledGround(name: string, options: {
  130407. xmin: number;
  130408. zmin: number;
  130409. xmax: number;
  130410. zmax: number;
  130411. subdivisions?: {
  130412. w: number;
  130413. h: number;
  130414. };
  130415. precision?: {
  130416. w: number;
  130417. h: number;
  130418. };
  130419. updatable?: boolean;
  130420. }, scene?: Nullable<Scene>): Mesh;
  130421. /**
  130422. * Creates a ground mesh from a height map
  130423. * * The parameter `url` sets the URL of the height map image resource.
  130424. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  130425. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  130426. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  130427. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  130428. * * 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.
  130429. * * 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).
  130430. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  130431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130432. * @param name defines the name of the mesh
  130433. * @param url defines the url to the height map
  130434. * @param options defines the options used to create the mesh
  130435. * @param scene defines the hosting scene
  130436. * @returns the ground mesh
  130437. * @see https://doc.babylonjs.com/babylon101/height_map
  130438. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  130439. */
  130440. static CreateGroundFromHeightMap(name: string, url: string, options: {
  130441. width?: number;
  130442. height?: number;
  130443. subdivisions?: number;
  130444. minHeight?: number;
  130445. maxHeight?: number;
  130446. colorFilter?: Color3;
  130447. alphaFilter?: number;
  130448. updatable?: boolean;
  130449. onReady?: (mesh: GroundMesh) => void;
  130450. }, scene?: Nullable<Scene>): GroundMesh;
  130451. /**
  130452. * Creates a polygon mesh
  130453. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  130454. * * 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
  130455. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  130456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130457. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  130458. * * Remember you can only change the shape positions, not their number when updating a polygon
  130459. * @param name defines the name of the mesh
  130460. * @param options defines the options used to create the mesh
  130461. * @param scene defines the hosting scene
  130462. * @param earcutInjection can be used to inject your own earcut reference
  130463. * @returns the polygon mesh
  130464. */
  130465. static CreatePolygon(name: string, options: {
  130466. shape: Vector3[];
  130467. holes?: Vector3[][];
  130468. depth?: number;
  130469. faceUV?: Vector4[];
  130470. faceColors?: Color4[];
  130471. updatable?: boolean;
  130472. sideOrientation?: number;
  130473. frontUVs?: Vector4;
  130474. backUVs?: Vector4;
  130475. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  130476. /**
  130477. * Creates an extruded polygon mesh, with depth in the Y direction.
  130478. * * 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)
  130479. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  130480. * @param name defines the name of the mesh
  130481. * @param options defines the options used to create the mesh
  130482. * @param scene defines the hosting scene
  130483. * @param earcutInjection can be used to inject your own earcut reference
  130484. * @returns the polygon mesh
  130485. */
  130486. static ExtrudePolygon(name: string, options: {
  130487. shape: Vector3[];
  130488. holes?: Vector3[][];
  130489. depth?: number;
  130490. faceUV?: Vector4[];
  130491. faceColors?: Color4[];
  130492. updatable?: boolean;
  130493. sideOrientation?: number;
  130494. frontUVs?: Vector4;
  130495. backUVs?: Vector4;
  130496. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  130497. /**
  130498. * Creates a tube mesh.
  130499. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  130500. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  130501. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  130502. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  130503. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  130504. * * 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)
  130505. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  130506. * * 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
  130507. * * 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
  130508. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130509. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130510. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130512. * @param name defines the name of the mesh
  130513. * @param options defines the options used to create the mesh
  130514. * @param scene defines the hosting scene
  130515. * @returns the tube mesh
  130516. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130517. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  130518. */
  130519. static CreateTube(name: string, options: {
  130520. path: Vector3[];
  130521. radius?: number;
  130522. tessellation?: number;
  130523. radiusFunction?: {
  130524. (i: number, distance: number): number;
  130525. };
  130526. cap?: number;
  130527. arc?: number;
  130528. updatable?: boolean;
  130529. sideOrientation?: number;
  130530. frontUVs?: Vector4;
  130531. backUVs?: Vector4;
  130532. instance?: Mesh;
  130533. invertUV?: boolean;
  130534. }, scene?: Nullable<Scene>): Mesh;
  130535. /**
  130536. * Creates a polyhedron mesh
  130537. * * 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
  130538. * * The parameter `size` (positive float, default 1) sets the polygon size
  130539. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  130540. * * 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`
  130541. * * 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
  130542. * * 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)`)
  130543. * * 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
  130544. * * 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
  130545. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130546. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130548. * @param name defines the name of the mesh
  130549. * @param options defines the options used to create the mesh
  130550. * @param scene defines the hosting scene
  130551. * @returns the polyhedron mesh
  130552. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  130553. */
  130554. static CreatePolyhedron(name: string, options: {
  130555. type?: number;
  130556. size?: number;
  130557. sizeX?: number;
  130558. sizeY?: number;
  130559. sizeZ?: number;
  130560. custom?: any;
  130561. faceUV?: Vector4[];
  130562. faceColors?: Color4[];
  130563. flat?: boolean;
  130564. updatable?: boolean;
  130565. sideOrientation?: number;
  130566. frontUVs?: Vector4;
  130567. backUVs?: Vector4;
  130568. }, scene?: Nullable<Scene>): Mesh;
  130569. /**
  130570. * Creates a decal mesh.
  130571. * 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
  130572. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  130573. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  130574. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  130575. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  130576. * @param name defines the name of the mesh
  130577. * @param sourceMesh defines the mesh where the decal must be applied
  130578. * @param options defines the options used to create the mesh
  130579. * @param scene defines the hosting scene
  130580. * @returns the decal mesh
  130581. * @see https://doc.babylonjs.com/how_to/decals
  130582. */
  130583. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  130584. position?: Vector3;
  130585. normal?: Vector3;
  130586. size?: Vector3;
  130587. angle?: number;
  130588. }): Mesh;
  130589. }
  130590. }
  130591. declare module BABYLON {
  130592. /**
  130593. * A simplifier interface for future simplification implementations
  130594. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130595. */
  130596. export interface ISimplifier {
  130597. /**
  130598. * Simplification of a given mesh according to the given settings.
  130599. * Since this requires computation, it is assumed that the function runs async.
  130600. * @param settings The settings of the simplification, including quality and distance
  130601. * @param successCallback A callback that will be called after the mesh was simplified.
  130602. * @param errorCallback in case of an error, this callback will be called. optional.
  130603. */
  130604. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  130605. }
  130606. /**
  130607. * Expected simplification settings.
  130608. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  130609. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130610. */
  130611. export interface ISimplificationSettings {
  130612. /**
  130613. * Gets or sets the expected quality
  130614. */
  130615. quality: number;
  130616. /**
  130617. * Gets or sets the distance when this optimized version should be used
  130618. */
  130619. distance: number;
  130620. /**
  130621. * Gets an already optimized mesh
  130622. */
  130623. optimizeMesh?: boolean;
  130624. }
  130625. /**
  130626. * Class used to specify simplification options
  130627. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130628. */
  130629. export class SimplificationSettings implements ISimplificationSettings {
  130630. /** expected quality */
  130631. quality: number;
  130632. /** distance when this optimized version should be used */
  130633. distance: number;
  130634. /** already optimized mesh */
  130635. optimizeMesh?: boolean | undefined;
  130636. /**
  130637. * Creates a SimplificationSettings
  130638. * @param quality expected quality
  130639. * @param distance distance when this optimized version should be used
  130640. * @param optimizeMesh already optimized mesh
  130641. */
  130642. constructor(
  130643. /** expected quality */
  130644. quality: number,
  130645. /** distance when this optimized version should be used */
  130646. distance: number,
  130647. /** already optimized mesh */
  130648. optimizeMesh?: boolean | undefined);
  130649. }
  130650. /**
  130651. * Interface used to define a simplification task
  130652. */
  130653. export interface ISimplificationTask {
  130654. /**
  130655. * Array of settings
  130656. */
  130657. settings: Array<ISimplificationSettings>;
  130658. /**
  130659. * Simplification type
  130660. */
  130661. simplificationType: SimplificationType;
  130662. /**
  130663. * Mesh to simplify
  130664. */
  130665. mesh: Mesh;
  130666. /**
  130667. * Callback called on success
  130668. */
  130669. successCallback?: () => void;
  130670. /**
  130671. * Defines if parallel processing can be used
  130672. */
  130673. parallelProcessing: boolean;
  130674. }
  130675. /**
  130676. * Queue used to order the simplification tasks
  130677. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130678. */
  130679. export class SimplificationQueue {
  130680. private _simplificationArray;
  130681. /**
  130682. * Gets a boolean indicating that the process is still running
  130683. */
  130684. running: boolean;
  130685. /**
  130686. * Creates a new queue
  130687. */
  130688. constructor();
  130689. /**
  130690. * Adds a new simplification task
  130691. * @param task defines a task to add
  130692. */
  130693. addTask(task: ISimplificationTask): void;
  130694. /**
  130695. * Execute next task
  130696. */
  130697. executeNext(): void;
  130698. /**
  130699. * Execute a simplification task
  130700. * @param task defines the task to run
  130701. */
  130702. runSimplification(task: ISimplificationTask): void;
  130703. private getSimplifier;
  130704. }
  130705. /**
  130706. * The implemented types of simplification
  130707. * At the moment only Quadratic Error Decimation is implemented
  130708. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130709. */
  130710. export enum SimplificationType {
  130711. /** Quadratic error decimation */
  130712. QUADRATIC = 0
  130713. }
  130714. }
  130715. declare module BABYLON {
  130716. interface Scene {
  130717. /** @hidden (Backing field) */
  130718. _simplificationQueue: SimplificationQueue;
  130719. /**
  130720. * Gets or sets the simplification queue attached to the scene
  130721. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130722. */
  130723. simplificationQueue: SimplificationQueue;
  130724. }
  130725. interface Mesh {
  130726. /**
  130727. * Simplify the mesh according to the given array of settings.
  130728. * Function will return immediately and will simplify async
  130729. * @param settings a collection of simplification settings
  130730. * @param parallelProcessing should all levels calculate parallel or one after the other
  130731. * @param simplificationType the type of simplification to run
  130732. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  130733. * @returns the current mesh
  130734. */
  130735. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  130736. }
  130737. /**
  130738. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  130739. * created in a scene
  130740. */
  130741. export class SimplicationQueueSceneComponent implements ISceneComponent {
  130742. /**
  130743. * The component name helpfull to identify the component in the list of scene components.
  130744. */
  130745. readonly name: string;
  130746. /**
  130747. * The scene the component belongs to.
  130748. */
  130749. scene: Scene;
  130750. /**
  130751. * Creates a new instance of the component for the given scene
  130752. * @param scene Defines the scene to register the component in
  130753. */
  130754. constructor(scene: Scene);
  130755. /**
  130756. * Registers the component in a given scene
  130757. */
  130758. register(): void;
  130759. /**
  130760. * Rebuilds the elements related to this component in case of
  130761. * context lost for instance.
  130762. */
  130763. rebuild(): void;
  130764. /**
  130765. * Disposes the component and the associated ressources
  130766. */
  130767. dispose(): void;
  130768. private _beforeCameraUpdate;
  130769. }
  130770. }
  130771. declare module BABYLON {
  130772. /**
  130773. * Navigation plugin interface to add navigation constrained by a navigation mesh
  130774. */
  130775. export interface INavigationEnginePlugin {
  130776. /**
  130777. * plugin name
  130778. */
  130779. name: string;
  130780. /**
  130781. * Creates a navigation mesh
  130782. * @param meshes array of all the geometry used to compute the navigatio mesh
  130783. * @param parameters bunch of parameters used to filter geometry
  130784. */
  130785. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  130786. /**
  130787. * Create a navigation mesh debug mesh
  130788. * @param scene is where the mesh will be added
  130789. * @returns debug display mesh
  130790. */
  130791. createDebugNavMesh(scene: Scene): Mesh;
  130792. /**
  130793. * Get a navigation mesh constrained position, closest to the parameter position
  130794. * @param position world position
  130795. * @returns the closest point to position constrained by the navigation mesh
  130796. */
  130797. getClosestPoint(position: Vector3): Vector3;
  130798. /**
  130799. * Get a navigation mesh constrained position, within a particular radius
  130800. * @param position world position
  130801. * @param maxRadius the maximum distance to the constrained world position
  130802. * @returns the closest point to position constrained by the navigation mesh
  130803. */
  130804. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  130805. /**
  130806. * Compute the final position from a segment made of destination-position
  130807. * @param position world position
  130808. * @param destination world position
  130809. * @returns the resulting point along the navmesh
  130810. */
  130811. moveAlong(position: Vector3, destination: Vector3): Vector3;
  130812. /**
  130813. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  130814. * @param start world position
  130815. * @param end world position
  130816. * @returns array containing world position composing the path
  130817. */
  130818. computePath(start: Vector3, end: Vector3): Vector3[];
  130819. /**
  130820. * If this plugin is supported
  130821. * @returns true if plugin is supported
  130822. */
  130823. isSupported(): boolean;
  130824. /**
  130825. * Create a new Crowd so you can add agents
  130826. * @param maxAgents the maximum agent count in the crowd
  130827. * @param maxAgentRadius the maximum radius an agent can have
  130828. * @param scene to attach the crowd to
  130829. * @returns the crowd you can add agents to
  130830. */
  130831. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  130832. /**
  130833. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  130834. * The queries will try to find a solution within those bounds
  130835. * default is (1,1,1)
  130836. * @param extent x,y,z value that define the extent around the queries point of reference
  130837. */
  130838. setDefaultQueryExtent(extent: Vector3): void;
  130839. /**
  130840. * Get the Bounding box extent specified by setDefaultQueryExtent
  130841. * @returns the box extent values
  130842. */
  130843. getDefaultQueryExtent(): Vector3;
  130844. /**
  130845. * Release all resources
  130846. */
  130847. dispose(): void;
  130848. }
  130849. /**
  130850. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  130851. */
  130852. export interface ICrowd {
  130853. /**
  130854. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  130855. * You can attach anything to that node. The node position is updated in the scene update tick.
  130856. * @param pos world position that will be constrained by the navigation mesh
  130857. * @param parameters agent parameters
  130858. * @param transform hooked to the agent that will be update by the scene
  130859. * @returns agent index
  130860. */
  130861. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  130862. /**
  130863. * Returns the agent position in world space
  130864. * @param index agent index returned by addAgent
  130865. * @returns world space position
  130866. */
  130867. getAgentPosition(index: number): Vector3;
  130868. /**
  130869. * Gets the agent velocity in world space
  130870. * @param index agent index returned by addAgent
  130871. * @returns world space velocity
  130872. */
  130873. getAgentVelocity(index: number): Vector3;
  130874. /**
  130875. * remove a particular agent previously created
  130876. * @param index agent index returned by addAgent
  130877. */
  130878. removeAgent(index: number): void;
  130879. /**
  130880. * get the list of all agents attached to this crowd
  130881. * @returns list of agent indices
  130882. */
  130883. getAgents(): number[];
  130884. /**
  130885. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  130886. * @param deltaTime in seconds
  130887. */
  130888. update(deltaTime: number): void;
  130889. /**
  130890. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  130891. * @param index agent index returned by addAgent
  130892. * @param destination targeted world position
  130893. */
  130894. agentGoto(index: number, destination: Vector3): void;
  130895. /**
  130896. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  130897. * The queries will try to find a solution within those bounds
  130898. * default is (1,1,1)
  130899. * @param extent x,y,z value that define the extent around the queries point of reference
  130900. */
  130901. setDefaultQueryExtent(extent: Vector3): void;
  130902. /**
  130903. * Get the Bounding box extent specified by setDefaultQueryExtent
  130904. * @returns the box extent values
  130905. */
  130906. getDefaultQueryExtent(): Vector3;
  130907. /**
  130908. * Release all resources
  130909. */
  130910. dispose(): void;
  130911. }
  130912. /**
  130913. * Configures an agent
  130914. */
  130915. export interface IAgentParameters {
  130916. /**
  130917. * Agent radius. [Limit: >= 0]
  130918. */
  130919. radius: number;
  130920. /**
  130921. * Agent height. [Limit: > 0]
  130922. */
  130923. height: number;
  130924. /**
  130925. * Maximum allowed acceleration. [Limit: >= 0]
  130926. */
  130927. maxAcceleration: number;
  130928. /**
  130929. * Maximum allowed speed. [Limit: >= 0]
  130930. */
  130931. maxSpeed: number;
  130932. /**
  130933. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  130934. */
  130935. collisionQueryRange: number;
  130936. /**
  130937. * The path visibility optimization range. [Limit: > 0]
  130938. */
  130939. pathOptimizationRange: number;
  130940. /**
  130941. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  130942. */
  130943. separationWeight: number;
  130944. }
  130945. /**
  130946. * Configures the navigation mesh creation
  130947. */
  130948. export interface INavMeshParameters {
  130949. /**
  130950. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  130951. */
  130952. cs: number;
  130953. /**
  130954. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  130955. */
  130956. ch: number;
  130957. /**
  130958. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  130959. */
  130960. walkableSlopeAngle: number;
  130961. /**
  130962. * Minimum floor to 'ceiling' height that will still allow the floor area to
  130963. * be considered walkable. [Limit: >= 3] [Units: vx]
  130964. */
  130965. walkableHeight: number;
  130966. /**
  130967. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  130968. */
  130969. walkableClimb: number;
  130970. /**
  130971. * The distance to erode/shrink the walkable area of the heightfield away from
  130972. * obstructions. [Limit: >=0] [Units: vx]
  130973. */
  130974. walkableRadius: number;
  130975. /**
  130976. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  130977. */
  130978. maxEdgeLen: number;
  130979. /**
  130980. * The maximum distance a simplfied contour's border edges should deviate
  130981. * the original raw contour. [Limit: >=0] [Units: vx]
  130982. */
  130983. maxSimplificationError: number;
  130984. /**
  130985. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  130986. */
  130987. minRegionArea: number;
  130988. /**
  130989. * Any regions with a span count smaller than this value will, if possible,
  130990. * be merged with larger regions. [Limit: >=0] [Units: vx]
  130991. */
  130992. mergeRegionArea: number;
  130993. /**
  130994. * The maximum number of vertices allowed for polygons generated during the
  130995. * contour to polygon conversion process. [Limit: >= 3]
  130996. */
  130997. maxVertsPerPoly: number;
  130998. /**
  130999. * Sets the sampling distance to use when generating the detail mesh.
  131000. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  131001. */
  131002. detailSampleDist: number;
  131003. /**
  131004. * The maximum distance the detail mesh surface should deviate from heightfield
  131005. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  131006. */
  131007. detailSampleMaxError: number;
  131008. }
  131009. }
  131010. declare module BABYLON {
  131011. /**
  131012. * RecastJS navigation plugin
  131013. */
  131014. export class RecastJSPlugin implements INavigationEnginePlugin {
  131015. /**
  131016. * Reference to the Recast library
  131017. */
  131018. bjsRECAST: any;
  131019. /**
  131020. * plugin name
  131021. */
  131022. name: string;
  131023. /**
  131024. * the first navmesh created. We might extend this to support multiple navmeshes
  131025. */
  131026. navMesh: any;
  131027. /**
  131028. * Initializes the recastJS plugin
  131029. * @param recastInjection can be used to inject your own recast reference
  131030. */
  131031. constructor(recastInjection?: any);
  131032. /**
  131033. * Creates a navigation mesh
  131034. * @param meshes array of all the geometry used to compute the navigatio mesh
  131035. * @param parameters bunch of parameters used to filter geometry
  131036. */
  131037. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  131038. /**
  131039. * Create a navigation mesh debug mesh
  131040. * @param scene is where the mesh will be added
  131041. * @returns debug display mesh
  131042. */
  131043. createDebugNavMesh(scene: Scene): Mesh;
  131044. /**
  131045. * Get a navigation mesh constrained position, closest to the parameter position
  131046. * @param position world position
  131047. * @returns the closest point to position constrained by the navigation mesh
  131048. */
  131049. getClosestPoint(position: Vector3): Vector3;
  131050. /**
  131051. * Get a navigation mesh constrained position, within a particular radius
  131052. * @param position world position
  131053. * @param maxRadius the maximum distance to the constrained world position
  131054. * @returns the closest point to position constrained by the navigation mesh
  131055. */
  131056. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  131057. /**
  131058. * Compute the final position from a segment made of destination-position
  131059. * @param position world position
  131060. * @param destination world position
  131061. * @returns the resulting point along the navmesh
  131062. */
  131063. moveAlong(position: Vector3, destination: Vector3): Vector3;
  131064. /**
  131065. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  131066. * @param start world position
  131067. * @param end world position
  131068. * @returns array containing world position composing the path
  131069. */
  131070. computePath(start: Vector3, end: Vector3): Vector3[];
  131071. /**
  131072. * Create a new Crowd so you can add agents
  131073. * @param maxAgents the maximum agent count in the crowd
  131074. * @param maxAgentRadius the maximum radius an agent can have
  131075. * @param scene to attach the crowd to
  131076. * @returns the crowd you can add agents to
  131077. */
  131078. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  131079. /**
  131080. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  131081. * The queries will try to find a solution within those bounds
  131082. * default is (1,1,1)
  131083. * @param extent x,y,z value that define the extent around the queries point of reference
  131084. */
  131085. setDefaultQueryExtent(extent: Vector3): void;
  131086. /**
  131087. * Get the Bounding box extent specified by setDefaultQueryExtent
  131088. * @returns the box extent values
  131089. */
  131090. getDefaultQueryExtent(): Vector3;
  131091. /**
  131092. * Disposes
  131093. */
  131094. dispose(): void;
  131095. /**
  131096. * If this plugin is supported
  131097. * @returns true if plugin is supported
  131098. */
  131099. isSupported(): boolean;
  131100. }
  131101. /**
  131102. * Recast detour crowd implementation
  131103. */
  131104. export class RecastJSCrowd implements ICrowd {
  131105. /**
  131106. * Recast/detour plugin
  131107. */
  131108. bjsRECASTPlugin: RecastJSPlugin;
  131109. /**
  131110. * Link to the detour crowd
  131111. */
  131112. recastCrowd: any;
  131113. /**
  131114. * One transform per agent
  131115. */
  131116. transforms: TransformNode[];
  131117. /**
  131118. * All agents created
  131119. */
  131120. agents: number[];
  131121. /**
  131122. * Link to the scene is kept to unregister the crowd from the scene
  131123. */
  131124. private _scene;
  131125. /**
  131126. * Observer for crowd updates
  131127. */
  131128. private _onBeforeAnimationsObserver;
  131129. /**
  131130. * Constructor
  131131. * @param plugin recastJS plugin
  131132. * @param maxAgents the maximum agent count in the crowd
  131133. * @param maxAgentRadius the maximum radius an agent can have
  131134. * @param scene to attach the crowd to
  131135. * @returns the crowd you can add agents to
  131136. */
  131137. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  131138. /**
  131139. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  131140. * You can attach anything to that node. The node position is updated in the scene update tick.
  131141. * @param pos world position that will be constrained by the navigation mesh
  131142. * @param parameters agent parameters
  131143. * @param transform hooked to the agent that will be update by the scene
  131144. * @returns agent index
  131145. */
  131146. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  131147. /**
  131148. * Returns the agent position in world space
  131149. * @param index agent index returned by addAgent
  131150. * @returns world space position
  131151. */
  131152. getAgentPosition(index: number): Vector3;
  131153. /**
  131154. * Returns the agent velocity in world space
  131155. * @param index agent index returned by addAgent
  131156. * @returns world space velocity
  131157. */
  131158. getAgentVelocity(index: number): Vector3;
  131159. /**
  131160. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  131161. * @param index agent index returned by addAgent
  131162. * @param destination targeted world position
  131163. */
  131164. agentGoto(index: number, destination: Vector3): void;
  131165. /**
  131166. * remove a particular agent previously created
  131167. * @param index agent index returned by addAgent
  131168. */
  131169. removeAgent(index: number): void;
  131170. /**
  131171. * get the list of all agents attached to this crowd
  131172. * @returns list of agent indices
  131173. */
  131174. getAgents(): number[];
  131175. /**
  131176. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  131177. * @param deltaTime in seconds
  131178. */
  131179. update(deltaTime: number): void;
  131180. /**
  131181. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  131182. * The queries will try to find a solution within those bounds
  131183. * default is (1,1,1)
  131184. * @param extent x,y,z value that define the extent around the queries point of reference
  131185. */
  131186. setDefaultQueryExtent(extent: Vector3): void;
  131187. /**
  131188. * Get the Bounding box extent specified by setDefaultQueryExtent
  131189. * @returns the box extent values
  131190. */
  131191. getDefaultQueryExtent(): Vector3;
  131192. /**
  131193. * Release all resources
  131194. */
  131195. dispose(): void;
  131196. }
  131197. }
  131198. declare module BABYLON {
  131199. /**
  131200. * Class used to enable access to IndexedDB
  131201. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  131202. */
  131203. export class Database implements IOfflineProvider {
  131204. private _callbackManifestChecked;
  131205. private _currentSceneUrl;
  131206. private _db;
  131207. private _enableSceneOffline;
  131208. private _enableTexturesOffline;
  131209. private _manifestVersionFound;
  131210. private _mustUpdateRessources;
  131211. private _hasReachedQuota;
  131212. private _isSupported;
  131213. private _idbFactory;
  131214. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  131215. private static IsUASupportingBlobStorage;
  131216. /**
  131217. * Gets a boolean indicating if Database storate is enabled (off by default)
  131218. */
  131219. static IDBStorageEnabled: boolean;
  131220. /**
  131221. * Gets a boolean indicating if scene must be saved in the database
  131222. */
  131223. get enableSceneOffline(): boolean;
  131224. /**
  131225. * Gets a boolean indicating if textures must be saved in the database
  131226. */
  131227. get enableTexturesOffline(): boolean;
  131228. /**
  131229. * Creates a new Database
  131230. * @param urlToScene defines the url to load the scene
  131231. * @param callbackManifestChecked defines the callback to use when manifest is checked
  131232. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  131233. */
  131234. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  131235. private static _ParseURL;
  131236. private static _ReturnFullUrlLocation;
  131237. private _checkManifestFile;
  131238. /**
  131239. * Open the database and make it available
  131240. * @param successCallback defines the callback to call on success
  131241. * @param errorCallback defines the callback to call on error
  131242. */
  131243. open(successCallback: () => void, errorCallback: () => void): void;
  131244. /**
  131245. * Loads an image from the database
  131246. * @param url defines the url to load from
  131247. * @param image defines the target DOM image
  131248. */
  131249. loadImage(url: string, image: HTMLImageElement): void;
  131250. private _loadImageFromDBAsync;
  131251. private _saveImageIntoDBAsync;
  131252. private _checkVersionFromDB;
  131253. private _loadVersionFromDBAsync;
  131254. private _saveVersionIntoDBAsync;
  131255. /**
  131256. * Loads a file from database
  131257. * @param url defines the URL to load from
  131258. * @param sceneLoaded defines a callback to call on success
  131259. * @param progressCallBack defines a callback to call when progress changed
  131260. * @param errorCallback defines a callback to call on error
  131261. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  131262. */
  131263. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  131264. private _loadFileAsync;
  131265. private _saveFileAsync;
  131266. /**
  131267. * Validates if xhr data is correct
  131268. * @param xhr defines the request to validate
  131269. * @param dataType defines the expected data type
  131270. * @returns true if data is correct
  131271. */
  131272. private static _ValidateXHRData;
  131273. }
  131274. }
  131275. declare module BABYLON {
  131276. /** @hidden */
  131277. export var gpuUpdateParticlesPixelShader: {
  131278. name: string;
  131279. shader: string;
  131280. };
  131281. }
  131282. declare module BABYLON {
  131283. /** @hidden */
  131284. export var gpuUpdateParticlesVertexShader: {
  131285. name: string;
  131286. shader: string;
  131287. };
  131288. }
  131289. declare module BABYLON {
  131290. /** @hidden */
  131291. export var clipPlaneFragmentDeclaration2: {
  131292. name: string;
  131293. shader: string;
  131294. };
  131295. }
  131296. declare module BABYLON {
  131297. /** @hidden */
  131298. export var gpuRenderParticlesPixelShader: {
  131299. name: string;
  131300. shader: string;
  131301. };
  131302. }
  131303. declare module BABYLON {
  131304. /** @hidden */
  131305. export var clipPlaneVertexDeclaration2: {
  131306. name: string;
  131307. shader: string;
  131308. };
  131309. }
  131310. declare module BABYLON {
  131311. /** @hidden */
  131312. export var gpuRenderParticlesVertexShader: {
  131313. name: string;
  131314. shader: string;
  131315. };
  131316. }
  131317. declare module BABYLON {
  131318. /**
  131319. * This represents a GPU particle system in Babylon
  131320. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  131321. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  131322. */
  131323. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  131324. /**
  131325. * The layer mask we are rendering the particles through.
  131326. */
  131327. layerMask: number;
  131328. private _capacity;
  131329. private _activeCount;
  131330. private _currentActiveCount;
  131331. private _accumulatedCount;
  131332. private _renderEffect;
  131333. private _updateEffect;
  131334. private _buffer0;
  131335. private _buffer1;
  131336. private _spriteBuffer;
  131337. private _updateVAO;
  131338. private _renderVAO;
  131339. private _targetIndex;
  131340. private _sourceBuffer;
  131341. private _targetBuffer;
  131342. private _engine;
  131343. private _currentRenderId;
  131344. private _started;
  131345. private _stopped;
  131346. private _timeDelta;
  131347. private _randomTexture;
  131348. private _randomTexture2;
  131349. private _attributesStrideSize;
  131350. private _updateEffectOptions;
  131351. private _randomTextureSize;
  131352. private _actualFrame;
  131353. private readonly _rawTextureWidth;
  131354. /**
  131355. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  131356. */
  131357. static get IsSupported(): boolean;
  131358. /**
  131359. * An event triggered when the system is disposed.
  131360. */
  131361. onDisposeObservable: Observable<GPUParticleSystem>;
  131362. /**
  131363. * Gets the maximum number of particles active at the same time.
  131364. * @returns The max number of active particles.
  131365. */
  131366. getCapacity(): number;
  131367. /**
  131368. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  131369. * to override the particles.
  131370. */
  131371. forceDepthWrite: boolean;
  131372. /**
  131373. * Gets or set the number of active particles
  131374. */
  131375. get activeParticleCount(): number;
  131376. set activeParticleCount(value: number);
  131377. private _preWarmDone;
  131378. /**
  131379. * Is this system ready to be used/rendered
  131380. * @return true if the system is ready
  131381. */
  131382. isReady(): boolean;
  131383. /**
  131384. * Gets if the system has been started. (Note: this will still be true after stop is called)
  131385. * @returns True if it has been started, otherwise false.
  131386. */
  131387. isStarted(): boolean;
  131388. /**
  131389. * Starts the particle system and begins to emit
  131390. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  131391. */
  131392. start(delay?: number): void;
  131393. /**
  131394. * Stops the particle system.
  131395. */
  131396. stop(): void;
  131397. /**
  131398. * Remove all active particles
  131399. */
  131400. reset(): void;
  131401. /**
  131402. * Returns the string "GPUParticleSystem"
  131403. * @returns a string containing the class name
  131404. */
  131405. getClassName(): string;
  131406. private _colorGradientsTexture;
  131407. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  131408. /**
  131409. * Adds a new color gradient
  131410. * @param gradient defines the gradient to use (between 0 and 1)
  131411. * @param color1 defines the color to affect to the specified gradient
  131412. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  131413. * @returns the current particle system
  131414. */
  131415. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  131416. /**
  131417. * Remove a specific color gradient
  131418. * @param gradient defines the gradient to remove
  131419. * @returns the current particle system
  131420. */
  131421. removeColorGradient(gradient: number): GPUParticleSystem;
  131422. private _angularSpeedGradientsTexture;
  131423. private _sizeGradientsTexture;
  131424. private _velocityGradientsTexture;
  131425. private _limitVelocityGradientsTexture;
  131426. private _dragGradientsTexture;
  131427. private _addFactorGradient;
  131428. /**
  131429. * Adds a new size gradient
  131430. * @param gradient defines the gradient to use (between 0 and 1)
  131431. * @param factor defines the size factor to affect to the specified gradient
  131432. * @returns the current particle system
  131433. */
  131434. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  131435. /**
  131436. * Remove a specific size gradient
  131437. * @param gradient defines the gradient to remove
  131438. * @returns the current particle system
  131439. */
  131440. removeSizeGradient(gradient: number): GPUParticleSystem;
  131441. /**
  131442. * Adds a new angular speed gradient
  131443. * @param gradient defines the gradient to use (between 0 and 1)
  131444. * @param factor defines the angular speed to affect to the specified gradient
  131445. * @returns the current particle system
  131446. */
  131447. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  131448. /**
  131449. * Remove a specific angular speed gradient
  131450. * @param gradient defines the gradient to remove
  131451. * @returns the current particle system
  131452. */
  131453. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  131454. /**
  131455. * Adds a new velocity gradient
  131456. * @param gradient defines the gradient to use (between 0 and 1)
  131457. * @param factor defines the velocity to affect to the specified gradient
  131458. * @returns the current particle system
  131459. */
  131460. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  131461. /**
  131462. * Remove a specific velocity gradient
  131463. * @param gradient defines the gradient to remove
  131464. * @returns the current particle system
  131465. */
  131466. removeVelocityGradient(gradient: number): GPUParticleSystem;
  131467. /**
  131468. * Adds a new limit velocity gradient
  131469. * @param gradient defines the gradient to use (between 0 and 1)
  131470. * @param factor defines the limit velocity value to affect to the specified gradient
  131471. * @returns the current particle system
  131472. */
  131473. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  131474. /**
  131475. * Remove a specific limit velocity gradient
  131476. * @param gradient defines the gradient to remove
  131477. * @returns the current particle system
  131478. */
  131479. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  131480. /**
  131481. * Adds a new drag gradient
  131482. * @param gradient defines the gradient to use (between 0 and 1)
  131483. * @param factor defines the drag value to affect to the specified gradient
  131484. * @returns the current particle system
  131485. */
  131486. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  131487. /**
  131488. * Remove a specific drag gradient
  131489. * @param gradient defines the gradient to remove
  131490. * @returns the current particle system
  131491. */
  131492. removeDragGradient(gradient: number): GPUParticleSystem;
  131493. /**
  131494. * Not supported by GPUParticleSystem
  131495. * @param gradient defines the gradient to use (between 0 and 1)
  131496. * @param factor defines the emit rate value to affect to the specified gradient
  131497. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  131498. * @returns the current particle system
  131499. */
  131500. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  131501. /**
  131502. * Not supported by GPUParticleSystem
  131503. * @param gradient defines the gradient to remove
  131504. * @returns the current particle system
  131505. */
  131506. removeEmitRateGradient(gradient: number): IParticleSystem;
  131507. /**
  131508. * Not supported by GPUParticleSystem
  131509. * @param gradient defines the gradient to use (between 0 and 1)
  131510. * @param factor defines the start size value to affect to the specified gradient
  131511. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  131512. * @returns the current particle system
  131513. */
  131514. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  131515. /**
  131516. * Not supported by GPUParticleSystem
  131517. * @param gradient defines the gradient to remove
  131518. * @returns the current particle system
  131519. */
  131520. removeStartSizeGradient(gradient: number): IParticleSystem;
  131521. /**
  131522. * Not supported by GPUParticleSystem
  131523. * @param gradient defines the gradient to use (between 0 and 1)
  131524. * @param min defines the color remap minimal range
  131525. * @param max defines the color remap maximal range
  131526. * @returns the current particle system
  131527. */
  131528. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  131529. /**
  131530. * Not supported by GPUParticleSystem
  131531. * @param gradient defines the gradient to remove
  131532. * @returns the current particle system
  131533. */
  131534. removeColorRemapGradient(): IParticleSystem;
  131535. /**
  131536. * Not supported by GPUParticleSystem
  131537. * @param gradient defines the gradient to use (between 0 and 1)
  131538. * @param min defines the alpha remap minimal range
  131539. * @param max defines the alpha remap maximal range
  131540. * @returns the current particle system
  131541. */
  131542. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  131543. /**
  131544. * Not supported by GPUParticleSystem
  131545. * @param gradient defines the gradient to remove
  131546. * @returns the current particle system
  131547. */
  131548. removeAlphaRemapGradient(): IParticleSystem;
  131549. /**
  131550. * Not supported by GPUParticleSystem
  131551. * @param gradient defines the gradient to use (between 0 and 1)
  131552. * @param color defines the color to affect to the specified gradient
  131553. * @returns the current particle system
  131554. */
  131555. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  131556. /**
  131557. * Not supported by GPUParticleSystem
  131558. * @param gradient defines the gradient to remove
  131559. * @returns the current particle system
  131560. */
  131561. removeRampGradient(): IParticleSystem;
  131562. /**
  131563. * Not supported by GPUParticleSystem
  131564. * @returns the list of ramp gradients
  131565. */
  131566. getRampGradients(): Nullable<Array<Color3Gradient>>;
  131567. /**
  131568. * Not supported by GPUParticleSystem
  131569. * Gets or sets a boolean indicating that ramp gradients must be used
  131570. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  131571. */
  131572. get useRampGradients(): boolean;
  131573. set useRampGradients(value: boolean);
  131574. /**
  131575. * Not supported by GPUParticleSystem
  131576. * @param gradient defines the gradient to use (between 0 and 1)
  131577. * @param factor defines the life time factor to affect to the specified gradient
  131578. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  131579. * @returns the current particle system
  131580. */
  131581. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  131582. /**
  131583. * Not supported by GPUParticleSystem
  131584. * @param gradient defines the gradient to remove
  131585. * @returns the current particle system
  131586. */
  131587. removeLifeTimeGradient(gradient: number): IParticleSystem;
  131588. /**
  131589. * Instantiates a GPU particle system.
  131590. * 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.
  131591. * @param name The name of the particle system
  131592. * @param options The options used to create the system
  131593. * @param scene The scene the particle system belongs to
  131594. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  131595. */
  131596. constructor(name: string, options: Partial<{
  131597. capacity: number;
  131598. randomTextureSize: number;
  131599. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  131600. protected _reset(): void;
  131601. private _createUpdateVAO;
  131602. private _createRenderVAO;
  131603. private _initialize;
  131604. /** @hidden */
  131605. _recreateUpdateEffect(): void;
  131606. /** @hidden */
  131607. _recreateRenderEffect(): void;
  131608. /**
  131609. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  131610. * @param preWarm defines if we are in the pre-warmimg phase
  131611. */
  131612. animate(preWarm?: boolean): void;
  131613. private _createFactorGradientTexture;
  131614. private _createSizeGradientTexture;
  131615. private _createAngularSpeedGradientTexture;
  131616. private _createVelocityGradientTexture;
  131617. private _createLimitVelocityGradientTexture;
  131618. private _createDragGradientTexture;
  131619. private _createColorGradientTexture;
  131620. /**
  131621. * Renders the particle system in its current state
  131622. * @param preWarm defines if the system should only update the particles but not render them
  131623. * @returns the current number of particles
  131624. */
  131625. render(preWarm?: boolean): number;
  131626. /**
  131627. * Rebuilds the particle system
  131628. */
  131629. rebuild(): void;
  131630. private _releaseBuffers;
  131631. private _releaseVAOs;
  131632. /**
  131633. * Disposes the particle system and free the associated resources
  131634. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  131635. */
  131636. dispose(disposeTexture?: boolean): void;
  131637. /**
  131638. * Clones the particle system.
  131639. * @param name The name of the cloned object
  131640. * @param newEmitter The new emitter to use
  131641. * @returns the cloned particle system
  131642. */
  131643. clone(name: string, newEmitter: any): GPUParticleSystem;
  131644. /**
  131645. * Serializes the particle system to a JSON object.
  131646. * @returns the JSON object
  131647. */
  131648. serialize(): any;
  131649. /**
  131650. * Parses a JSON object to create a GPU particle system.
  131651. * @param parsedParticleSystem The JSON object to parse
  131652. * @param scene The scene to create the particle system in
  131653. * @param rootUrl The root url to use to load external dependencies like texture
  131654. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  131655. * @returns the parsed GPU particle system
  131656. */
  131657. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  131658. }
  131659. }
  131660. declare module BABYLON {
  131661. /**
  131662. * Represents a set of particle systems working together to create a specific effect
  131663. */
  131664. export class ParticleSystemSet implements IDisposable {
  131665. /**
  131666. * Gets or sets base Assets URL
  131667. */
  131668. static BaseAssetsUrl: string;
  131669. private _emitterCreationOptions;
  131670. private _emitterNode;
  131671. /**
  131672. * Gets the particle system list
  131673. */
  131674. systems: IParticleSystem[];
  131675. /**
  131676. * Gets the emitter node used with this set
  131677. */
  131678. get emitterNode(): Nullable<TransformNode>;
  131679. /**
  131680. * Creates a new emitter mesh as a sphere
  131681. * @param options defines the options used to create the sphere
  131682. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  131683. * @param scene defines the hosting scene
  131684. */
  131685. setEmitterAsSphere(options: {
  131686. diameter: number;
  131687. segments: number;
  131688. color: Color3;
  131689. }, renderingGroupId: number, scene: Scene): void;
  131690. /**
  131691. * Starts all particle systems of the set
  131692. * @param emitter defines an optional mesh to use as emitter for the particle systems
  131693. */
  131694. start(emitter?: AbstractMesh): void;
  131695. /**
  131696. * Release all associated resources
  131697. */
  131698. dispose(): void;
  131699. /**
  131700. * Serialize the set into a JSON compatible object
  131701. * @returns a JSON compatible representation of the set
  131702. */
  131703. serialize(): any;
  131704. /**
  131705. * Parse a new ParticleSystemSet from a serialized source
  131706. * @param data defines a JSON compatible representation of the set
  131707. * @param scene defines the hosting scene
  131708. * @param gpu defines if we want GPU particles or CPU particles
  131709. * @returns a new ParticleSystemSet
  131710. */
  131711. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  131712. }
  131713. }
  131714. declare module BABYLON {
  131715. /**
  131716. * This class is made for on one-liner static method to help creating particle system set.
  131717. */
  131718. export class ParticleHelper {
  131719. /**
  131720. * Gets or sets base Assets URL
  131721. */
  131722. static BaseAssetsUrl: string;
  131723. /**
  131724. * Create a default particle system that you can tweak
  131725. * @param emitter defines the emitter to use
  131726. * @param capacity defines the system capacity (default is 500 particles)
  131727. * @param scene defines the hosting scene
  131728. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  131729. * @returns the new Particle system
  131730. */
  131731. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  131732. /**
  131733. * This is the main static method (one-liner) of this helper to create different particle systems
  131734. * @param type This string represents the type to the particle system to create
  131735. * @param scene The scene where the particle system should live
  131736. * @param gpu If the system will use gpu
  131737. * @returns the ParticleSystemSet created
  131738. */
  131739. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  131740. /**
  131741. * Static function used to export a particle system to a ParticleSystemSet variable.
  131742. * Please note that the emitter shape is not exported
  131743. * @param systems defines the particle systems to export
  131744. * @returns the created particle system set
  131745. */
  131746. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  131747. }
  131748. }
  131749. declare module BABYLON {
  131750. interface Engine {
  131751. /**
  131752. * Create an effect to use with particle systems.
  131753. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  131754. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  131755. * @param uniformsNames defines a list of attribute names
  131756. * @param samplers defines an array of string used to represent textures
  131757. * @param defines defines the string containing the defines to use to compile the shaders
  131758. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  131759. * @param onCompiled defines a function to call when the effect creation is successful
  131760. * @param onError defines a function to call when the effect creation has failed
  131761. * @returns the new Effect
  131762. */
  131763. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  131764. }
  131765. interface Mesh {
  131766. /**
  131767. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  131768. * @returns an array of IParticleSystem
  131769. */
  131770. getEmittedParticleSystems(): IParticleSystem[];
  131771. /**
  131772. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  131773. * @returns an array of IParticleSystem
  131774. */
  131775. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  131776. }
  131777. /**
  131778. * @hidden
  131779. */
  131780. export var _IDoNeedToBeInTheBuild: number;
  131781. }
  131782. declare module BABYLON {
  131783. /** Defines the 4 color options */
  131784. export enum PointColor {
  131785. /** color value */
  131786. Color = 2,
  131787. /** uv value */
  131788. UV = 1,
  131789. /** random value */
  131790. Random = 0,
  131791. /** stated value */
  131792. Stated = 3
  131793. }
  131794. /**
  131795. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  131796. * 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.
  131797. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  131798. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  131799. *
  131800. * Full documentation here : TO BE ENTERED
  131801. */
  131802. export class PointsCloudSystem implements IDisposable {
  131803. /**
  131804. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  131805. * Example : var p = SPS.particles[i];
  131806. */
  131807. particles: CloudPoint[];
  131808. /**
  131809. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  131810. */
  131811. nbParticles: number;
  131812. /**
  131813. * This a counter for your own usage. It's not set by any SPS functions.
  131814. */
  131815. counter: number;
  131816. /**
  131817. * The PCS name. This name is also given to the underlying mesh.
  131818. */
  131819. name: string;
  131820. /**
  131821. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  131822. */
  131823. mesh: Mesh;
  131824. /**
  131825. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  131826. * Please read :
  131827. */
  131828. vars: any;
  131829. /**
  131830. * @hidden
  131831. */
  131832. _size: number;
  131833. private _scene;
  131834. private _promises;
  131835. private _positions;
  131836. private _indices;
  131837. private _normals;
  131838. private _colors;
  131839. private _uvs;
  131840. private _indices32;
  131841. private _positions32;
  131842. private _colors32;
  131843. private _uvs32;
  131844. private _updatable;
  131845. private _isVisibilityBoxLocked;
  131846. private _alwaysVisible;
  131847. private _groups;
  131848. private _groupCounter;
  131849. private _computeParticleColor;
  131850. private _computeParticleTexture;
  131851. private _computeParticleRotation;
  131852. private _computeBoundingBox;
  131853. private _isReady;
  131854. /**
  131855. * Creates a PCS (Points Cloud System) object
  131856. * @param name (String) is the PCS name, this will be the underlying mesh name
  131857. * @param pointSize (number) is the size for each point
  131858. * @param scene (Scene) is the scene in which the PCS is added
  131859. * @param options defines the options of the PCS e.g.
  131860. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  131861. */
  131862. constructor(name: string, pointSize: number, scene: Scene, options?: {
  131863. updatable?: boolean;
  131864. });
  131865. /**
  131866. * Builds the PCS underlying mesh. Returns a standard Mesh.
  131867. * If no points were added to the PCS, the returned mesh is just a single point.
  131868. * @returns a promise for the created mesh
  131869. */
  131870. buildMeshAsync(): Promise<Mesh>;
  131871. /**
  131872. * @hidden
  131873. */
  131874. private _buildMesh;
  131875. private _addParticle;
  131876. private _randomUnitVector;
  131877. private _getColorIndicesForCoord;
  131878. private _setPointsColorOrUV;
  131879. private _colorFromTexture;
  131880. private _calculateDensity;
  131881. /**
  131882. * Adds points to the PCS in random positions within a unit sphere
  131883. * @param nb (positive integer) the number of particles to be created from this model
  131884. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  131885. * @returns the number of groups in the system
  131886. */
  131887. addPoints(nb: number, pointFunction?: any): number;
  131888. /**
  131889. * Adds points to the PCS from the surface of the model shape
  131890. * @param mesh is any Mesh object that will be used as a surface model for the points
  131891. * @param nb (positive integer) the number of particles to be created from this model
  131892. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  131893. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  131894. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  131895. * @returns the number of groups in the system
  131896. */
  131897. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  131898. /**
  131899. * Adds points to the PCS inside the model shape
  131900. * @param mesh is any Mesh object that will be used as a surface model for the points
  131901. * @param nb (positive integer) the number of particles to be created from this model
  131902. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  131903. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  131904. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  131905. * @returns the number of groups in the system
  131906. */
  131907. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  131908. /**
  131909. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  131910. * This method calls `updateParticle()` for each particle of the SPS.
  131911. * For an animated SPS, it is usually called within the render loop.
  131912. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  131913. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  131914. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  131915. * @returns the PCS.
  131916. */
  131917. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  131918. /**
  131919. * Disposes the PCS.
  131920. */
  131921. dispose(): void;
  131922. /**
  131923. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  131924. * doc :
  131925. * @returns the PCS.
  131926. */
  131927. refreshVisibleSize(): PointsCloudSystem;
  131928. /**
  131929. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  131930. * @param size the size (float) of the visibility box
  131931. * note : this doesn't lock the PCS mesh bounding box.
  131932. * doc :
  131933. */
  131934. setVisibilityBox(size: number): void;
  131935. /**
  131936. * Gets whether the PCS is always visible or not
  131937. * doc :
  131938. */
  131939. get isAlwaysVisible(): boolean;
  131940. /**
  131941. * Sets the PCS as always visible or not
  131942. * doc :
  131943. */
  131944. set isAlwaysVisible(val: boolean);
  131945. /**
  131946. * Tells to `setParticles()` to compute the particle rotations or not
  131947. * Default value : false. The PCS is faster when it's set to false
  131948. * Note : particle rotations are only applied to parent particles
  131949. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  131950. */
  131951. set computeParticleRotation(val: boolean);
  131952. /**
  131953. * Tells to `setParticles()` to compute the particle colors or not.
  131954. * Default value : true. The PCS is faster when it's set to false.
  131955. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  131956. */
  131957. set computeParticleColor(val: boolean);
  131958. set computeParticleTexture(val: boolean);
  131959. /**
  131960. * Gets if `setParticles()` computes the particle colors or not.
  131961. * Default value : false. The PCS is faster when it's set to false.
  131962. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  131963. */
  131964. get computeParticleColor(): boolean;
  131965. /**
  131966. * Gets if `setParticles()` computes the particle textures or not.
  131967. * Default value : false. The PCS is faster when it's set to false.
  131968. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  131969. */
  131970. get computeParticleTexture(): boolean;
  131971. /**
  131972. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  131973. */
  131974. set computeBoundingBox(val: boolean);
  131975. /**
  131976. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  131977. */
  131978. get computeBoundingBox(): boolean;
  131979. /**
  131980. * This function does nothing. It may be overwritten to set all the particle first values.
  131981. * The PCS doesn't call this function, you may have to call it by your own.
  131982. * doc :
  131983. */
  131984. initParticles(): void;
  131985. /**
  131986. * This function does nothing. It may be overwritten to recycle a particle
  131987. * The PCS doesn't call this function, you can to call it
  131988. * doc :
  131989. * @param particle The particle to recycle
  131990. * @returns the recycled particle
  131991. */
  131992. recycleParticle(particle: CloudPoint): CloudPoint;
  131993. /**
  131994. * Updates a particle : this function should be overwritten by the user.
  131995. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  131996. * doc :
  131997. * @example : just set a particle position or velocity and recycle conditions
  131998. * @param particle The particle to update
  131999. * @returns the updated particle
  132000. */
  132001. updateParticle(particle: CloudPoint): CloudPoint;
  132002. /**
  132003. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  132004. * This does nothing and may be overwritten by the user.
  132005. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  132006. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  132007. * @param update the boolean update value actually passed to setParticles()
  132008. */
  132009. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  132010. /**
  132011. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  132012. * This will be passed three parameters.
  132013. * This does nothing and may be overwritten by the user.
  132014. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  132015. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  132016. * @param update the boolean update value actually passed to setParticles()
  132017. */
  132018. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  132019. }
  132020. }
  132021. declare module BABYLON {
  132022. /**
  132023. * Represents one particle of a points cloud system.
  132024. */
  132025. export class CloudPoint {
  132026. /**
  132027. * particle global index
  132028. */
  132029. idx: number;
  132030. /**
  132031. * The color of the particle
  132032. */
  132033. color: Nullable<Color4>;
  132034. /**
  132035. * The world space position of the particle.
  132036. */
  132037. position: Vector3;
  132038. /**
  132039. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  132040. */
  132041. rotation: Vector3;
  132042. /**
  132043. * The world space rotation quaternion of the particle.
  132044. */
  132045. rotationQuaternion: Nullable<Quaternion>;
  132046. /**
  132047. * The uv of the particle.
  132048. */
  132049. uv: Nullable<Vector2>;
  132050. /**
  132051. * The current speed of the particle.
  132052. */
  132053. velocity: Vector3;
  132054. /**
  132055. * The pivot point in the particle local space.
  132056. */
  132057. pivot: Vector3;
  132058. /**
  132059. * Must the particle be translated from its pivot point in its local space ?
  132060. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  132061. * Default : false
  132062. */
  132063. translateFromPivot: boolean;
  132064. /**
  132065. * Index of this particle in the global "positions" array (Internal use)
  132066. * @hidden
  132067. */
  132068. _pos: number;
  132069. /**
  132070. * @hidden Index of this particle in the global "indices" array (Internal use)
  132071. */
  132072. _ind: number;
  132073. /**
  132074. * Group this particle belongs to
  132075. */
  132076. _group: PointsGroup;
  132077. /**
  132078. * Group id of this particle
  132079. */
  132080. groupId: number;
  132081. /**
  132082. * Index of the particle in its group id (Internal use)
  132083. */
  132084. idxInGroup: number;
  132085. /**
  132086. * @hidden Particle BoundingInfo object (Internal use)
  132087. */
  132088. _boundingInfo: BoundingInfo;
  132089. /**
  132090. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  132091. */
  132092. _pcs: PointsCloudSystem;
  132093. /**
  132094. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  132095. */
  132096. _stillInvisible: boolean;
  132097. /**
  132098. * @hidden Last computed particle rotation matrix
  132099. */
  132100. _rotationMatrix: number[];
  132101. /**
  132102. * Parent particle Id, if any.
  132103. * Default null.
  132104. */
  132105. parentId: Nullable<number>;
  132106. /**
  132107. * @hidden Internal global position in the PCS.
  132108. */
  132109. _globalPosition: Vector3;
  132110. /**
  132111. * Creates a Point Cloud object.
  132112. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  132113. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  132114. * @param group (PointsGroup) is the group the particle belongs to
  132115. * @param groupId (integer) is the group identifier in the PCS.
  132116. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  132117. * @param pcs defines the PCS it is associated to
  132118. */
  132119. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  132120. /**
  132121. * get point size
  132122. */
  132123. get size(): Vector3;
  132124. /**
  132125. * Set point size
  132126. */
  132127. set size(scale: Vector3);
  132128. /**
  132129. * Legacy support, changed quaternion to rotationQuaternion
  132130. */
  132131. get quaternion(): Nullable<Quaternion>;
  132132. /**
  132133. * Legacy support, changed quaternion to rotationQuaternion
  132134. */
  132135. set quaternion(q: Nullable<Quaternion>);
  132136. /**
  132137. * Returns a boolean. True if the particle intersects a mesh, else false
  132138. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  132139. * @param target is the object (point or mesh) what the intersection is computed against
  132140. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  132141. * @returns true if it intersects
  132142. */
  132143. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  132144. /**
  132145. * get the rotation matrix of the particle
  132146. * @hidden
  132147. */
  132148. getRotationMatrix(m: Matrix): void;
  132149. }
  132150. /**
  132151. * Represents a group of points in a points cloud system
  132152. * * PCS internal tool, don't use it manually.
  132153. */
  132154. export class PointsGroup {
  132155. /**
  132156. * The group id
  132157. * @hidden
  132158. */
  132159. groupID: number;
  132160. /**
  132161. * image data for group (internal use)
  132162. * @hidden
  132163. */
  132164. _groupImageData: Nullable<ArrayBufferView>;
  132165. /**
  132166. * Image Width (internal use)
  132167. * @hidden
  132168. */
  132169. _groupImgWidth: number;
  132170. /**
  132171. * Image Height (internal use)
  132172. * @hidden
  132173. */
  132174. _groupImgHeight: number;
  132175. /**
  132176. * Custom position function (internal use)
  132177. * @hidden
  132178. */
  132179. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  132180. /**
  132181. * density per facet for surface points
  132182. * @hidden
  132183. */
  132184. _groupDensity: number[];
  132185. /**
  132186. * Only when points are colored by texture carries pointer to texture list array
  132187. * @hidden
  132188. */
  132189. _textureNb: number;
  132190. /**
  132191. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  132192. * PCS internal tool, don't use it manually.
  132193. * @hidden
  132194. */
  132195. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  132196. }
  132197. }
  132198. declare module BABYLON {
  132199. interface Scene {
  132200. /** @hidden (Backing field) */
  132201. _physicsEngine: Nullable<IPhysicsEngine>;
  132202. /** @hidden */
  132203. _physicsTimeAccumulator: number;
  132204. /**
  132205. * Gets the current physics engine
  132206. * @returns a IPhysicsEngine or null if none attached
  132207. */
  132208. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  132209. /**
  132210. * Enables physics to the current scene
  132211. * @param gravity defines the scene's gravity for the physics engine
  132212. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  132213. * @return a boolean indicating if the physics engine was initialized
  132214. */
  132215. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  132216. /**
  132217. * Disables and disposes the physics engine associated with the scene
  132218. */
  132219. disablePhysicsEngine(): void;
  132220. /**
  132221. * Gets a boolean indicating if there is an active physics engine
  132222. * @returns a boolean indicating if there is an active physics engine
  132223. */
  132224. isPhysicsEnabled(): boolean;
  132225. /**
  132226. * Deletes a physics compound impostor
  132227. * @param compound defines the compound to delete
  132228. */
  132229. deleteCompoundImpostor(compound: any): void;
  132230. /**
  132231. * An event triggered when physic simulation is about to be run
  132232. */
  132233. onBeforePhysicsObservable: Observable<Scene>;
  132234. /**
  132235. * An event triggered when physic simulation has been done
  132236. */
  132237. onAfterPhysicsObservable: Observable<Scene>;
  132238. }
  132239. interface AbstractMesh {
  132240. /** @hidden */
  132241. _physicsImpostor: Nullable<PhysicsImpostor>;
  132242. /**
  132243. * Gets or sets impostor used for physic simulation
  132244. * @see http://doc.babylonjs.com/features/physics_engine
  132245. */
  132246. physicsImpostor: Nullable<PhysicsImpostor>;
  132247. /**
  132248. * Gets the current physics impostor
  132249. * @see http://doc.babylonjs.com/features/physics_engine
  132250. * @returns a physics impostor or null
  132251. */
  132252. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  132253. /** Apply a physic impulse to the mesh
  132254. * @param force defines the force to apply
  132255. * @param contactPoint defines where to apply the force
  132256. * @returns the current mesh
  132257. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  132258. */
  132259. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  132260. /**
  132261. * Creates a physic joint between two meshes
  132262. * @param otherMesh defines the other mesh to use
  132263. * @param pivot1 defines the pivot to use on this mesh
  132264. * @param pivot2 defines the pivot to use on the other mesh
  132265. * @param options defines additional options (can be plugin dependent)
  132266. * @returns the current mesh
  132267. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  132268. */
  132269. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  132270. /** @hidden */
  132271. _disposePhysicsObserver: Nullable<Observer<Node>>;
  132272. }
  132273. /**
  132274. * Defines the physics engine scene component responsible to manage a physics engine
  132275. */
  132276. export class PhysicsEngineSceneComponent implements ISceneComponent {
  132277. /**
  132278. * The component name helpful to identify the component in the list of scene components.
  132279. */
  132280. readonly name: string;
  132281. /**
  132282. * The scene the component belongs to.
  132283. */
  132284. scene: Scene;
  132285. /**
  132286. * Creates a new instance of the component for the given scene
  132287. * @param scene Defines the scene to register the component in
  132288. */
  132289. constructor(scene: Scene);
  132290. /**
  132291. * Registers the component in a given scene
  132292. */
  132293. register(): void;
  132294. /**
  132295. * Rebuilds the elements related to this component in case of
  132296. * context lost for instance.
  132297. */
  132298. rebuild(): void;
  132299. /**
  132300. * Disposes the component and the associated ressources
  132301. */
  132302. dispose(): void;
  132303. }
  132304. }
  132305. declare module BABYLON {
  132306. /**
  132307. * A helper for physics simulations
  132308. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132309. */
  132310. export class PhysicsHelper {
  132311. private _scene;
  132312. private _physicsEngine;
  132313. /**
  132314. * Initializes the Physics helper
  132315. * @param scene Babylon.js scene
  132316. */
  132317. constructor(scene: Scene);
  132318. /**
  132319. * Applies a radial explosion impulse
  132320. * @param origin the origin of the explosion
  132321. * @param radiusOrEventOptions the radius or the options of radial explosion
  132322. * @param strength the explosion strength
  132323. * @param falloff possible options: Constant & Linear. Defaults to Constant
  132324. * @returns A physics radial explosion event, or null
  132325. */
  132326. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  132327. /**
  132328. * Applies a radial explosion force
  132329. * @param origin the origin of the explosion
  132330. * @param radiusOrEventOptions the radius or the options of radial explosion
  132331. * @param strength the explosion strength
  132332. * @param falloff possible options: Constant & Linear. Defaults to Constant
  132333. * @returns A physics radial explosion event, or null
  132334. */
  132335. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  132336. /**
  132337. * Creates a gravitational field
  132338. * @param origin the origin of the explosion
  132339. * @param radiusOrEventOptions the radius or the options of radial explosion
  132340. * @param strength the explosion strength
  132341. * @param falloff possible options: Constant & Linear. Defaults to Constant
  132342. * @returns A physics gravitational field event, or null
  132343. */
  132344. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  132345. /**
  132346. * Creates a physics updraft event
  132347. * @param origin the origin of the updraft
  132348. * @param radiusOrEventOptions the radius or the options of the updraft
  132349. * @param strength the strength of the updraft
  132350. * @param height the height of the updraft
  132351. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  132352. * @returns A physics updraft event, or null
  132353. */
  132354. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  132355. /**
  132356. * Creates a physics vortex event
  132357. * @param origin the of the vortex
  132358. * @param radiusOrEventOptions the radius or the options of the vortex
  132359. * @param strength the strength of the vortex
  132360. * @param height the height of the vortex
  132361. * @returns a Physics vortex event, or null
  132362. * A physics vortex event or null
  132363. */
  132364. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  132365. }
  132366. /**
  132367. * Represents a physics radial explosion event
  132368. */
  132369. class PhysicsRadialExplosionEvent {
  132370. private _scene;
  132371. private _options;
  132372. private _sphere;
  132373. private _dataFetched;
  132374. /**
  132375. * Initializes a radial explosioin event
  132376. * @param _scene BabylonJS scene
  132377. * @param _options The options for the vortex event
  132378. */
  132379. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  132380. /**
  132381. * Returns the data related to the radial explosion event (sphere).
  132382. * @returns The radial explosion event data
  132383. */
  132384. getData(): PhysicsRadialExplosionEventData;
  132385. /**
  132386. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  132387. * @param impostor A physics imposter
  132388. * @param origin the origin of the explosion
  132389. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  132390. */
  132391. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  132392. /**
  132393. * Triggers affecterd impostors callbacks
  132394. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  132395. */
  132396. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  132397. /**
  132398. * Disposes the sphere.
  132399. * @param force Specifies if the sphere should be disposed by force
  132400. */
  132401. dispose(force?: boolean): void;
  132402. /*** Helpers ***/
  132403. private _prepareSphere;
  132404. private _intersectsWithSphere;
  132405. }
  132406. /**
  132407. * Represents a gravitational field event
  132408. */
  132409. class PhysicsGravitationalFieldEvent {
  132410. private _physicsHelper;
  132411. private _scene;
  132412. private _origin;
  132413. private _options;
  132414. private _tickCallback;
  132415. private _sphere;
  132416. private _dataFetched;
  132417. /**
  132418. * Initializes the physics gravitational field event
  132419. * @param _physicsHelper A physics helper
  132420. * @param _scene BabylonJS scene
  132421. * @param _origin The origin position of the gravitational field event
  132422. * @param _options The options for the vortex event
  132423. */
  132424. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  132425. /**
  132426. * Returns the data related to the gravitational field event (sphere).
  132427. * @returns A gravitational field event
  132428. */
  132429. getData(): PhysicsGravitationalFieldEventData;
  132430. /**
  132431. * Enables the gravitational field.
  132432. */
  132433. enable(): void;
  132434. /**
  132435. * Disables the gravitational field.
  132436. */
  132437. disable(): void;
  132438. /**
  132439. * Disposes the sphere.
  132440. * @param force The force to dispose from the gravitational field event
  132441. */
  132442. dispose(force?: boolean): void;
  132443. private _tick;
  132444. }
  132445. /**
  132446. * Represents a physics updraft event
  132447. */
  132448. class PhysicsUpdraftEvent {
  132449. private _scene;
  132450. private _origin;
  132451. private _options;
  132452. private _physicsEngine;
  132453. private _originTop;
  132454. private _originDirection;
  132455. private _tickCallback;
  132456. private _cylinder;
  132457. private _cylinderPosition;
  132458. private _dataFetched;
  132459. /**
  132460. * Initializes the physics updraft event
  132461. * @param _scene BabylonJS scene
  132462. * @param _origin The origin position of the updraft
  132463. * @param _options The options for the updraft event
  132464. */
  132465. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  132466. /**
  132467. * Returns the data related to the updraft event (cylinder).
  132468. * @returns A physics updraft event
  132469. */
  132470. getData(): PhysicsUpdraftEventData;
  132471. /**
  132472. * Enables the updraft.
  132473. */
  132474. enable(): void;
  132475. /**
  132476. * Disables the updraft.
  132477. */
  132478. disable(): void;
  132479. /**
  132480. * Disposes the cylinder.
  132481. * @param force Specifies if the updraft should be disposed by force
  132482. */
  132483. dispose(force?: boolean): void;
  132484. private getImpostorHitData;
  132485. private _tick;
  132486. /*** Helpers ***/
  132487. private _prepareCylinder;
  132488. private _intersectsWithCylinder;
  132489. }
  132490. /**
  132491. * Represents a physics vortex event
  132492. */
  132493. class PhysicsVortexEvent {
  132494. private _scene;
  132495. private _origin;
  132496. private _options;
  132497. private _physicsEngine;
  132498. private _originTop;
  132499. private _tickCallback;
  132500. private _cylinder;
  132501. private _cylinderPosition;
  132502. private _dataFetched;
  132503. /**
  132504. * Initializes the physics vortex event
  132505. * @param _scene The BabylonJS scene
  132506. * @param _origin The origin position of the vortex
  132507. * @param _options The options for the vortex event
  132508. */
  132509. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  132510. /**
  132511. * Returns the data related to the vortex event (cylinder).
  132512. * @returns The physics vortex event data
  132513. */
  132514. getData(): PhysicsVortexEventData;
  132515. /**
  132516. * Enables the vortex.
  132517. */
  132518. enable(): void;
  132519. /**
  132520. * Disables the cortex.
  132521. */
  132522. disable(): void;
  132523. /**
  132524. * Disposes the sphere.
  132525. * @param force
  132526. */
  132527. dispose(force?: boolean): void;
  132528. private getImpostorHitData;
  132529. private _tick;
  132530. /*** Helpers ***/
  132531. private _prepareCylinder;
  132532. private _intersectsWithCylinder;
  132533. }
  132534. /**
  132535. * Options fot the radial explosion event
  132536. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132537. */
  132538. export class PhysicsRadialExplosionEventOptions {
  132539. /**
  132540. * The radius of the sphere for the radial explosion.
  132541. */
  132542. radius: number;
  132543. /**
  132544. * The strenth of the explosion.
  132545. */
  132546. strength: number;
  132547. /**
  132548. * The strenght of the force in correspondence to the distance of the affected object
  132549. */
  132550. falloff: PhysicsRadialImpulseFalloff;
  132551. /**
  132552. * Sphere options for the radial explosion.
  132553. */
  132554. sphere: {
  132555. segments: number;
  132556. diameter: number;
  132557. };
  132558. /**
  132559. * Sphere options for the radial explosion.
  132560. */
  132561. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  132562. }
  132563. /**
  132564. * Options fot the updraft event
  132565. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132566. */
  132567. export class PhysicsUpdraftEventOptions {
  132568. /**
  132569. * The radius of the cylinder for the vortex
  132570. */
  132571. radius: number;
  132572. /**
  132573. * The strenth of the updraft.
  132574. */
  132575. strength: number;
  132576. /**
  132577. * The height of the cylinder for the updraft.
  132578. */
  132579. height: number;
  132580. /**
  132581. * The mode for the the updraft.
  132582. */
  132583. updraftMode: PhysicsUpdraftMode;
  132584. }
  132585. /**
  132586. * Options fot the vortex event
  132587. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132588. */
  132589. export class PhysicsVortexEventOptions {
  132590. /**
  132591. * The radius of the cylinder for the vortex
  132592. */
  132593. radius: number;
  132594. /**
  132595. * The strenth of the vortex.
  132596. */
  132597. strength: number;
  132598. /**
  132599. * The height of the cylinder for the vortex.
  132600. */
  132601. height: number;
  132602. /**
  132603. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  132604. */
  132605. centripetalForceThreshold: number;
  132606. /**
  132607. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  132608. */
  132609. centripetalForceMultiplier: number;
  132610. /**
  132611. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  132612. */
  132613. centrifugalForceMultiplier: number;
  132614. /**
  132615. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  132616. */
  132617. updraftForceMultiplier: number;
  132618. }
  132619. /**
  132620. * The strenght of the force in correspondence to the distance of the affected object
  132621. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132622. */
  132623. export enum PhysicsRadialImpulseFalloff {
  132624. /** Defines that impulse is constant in strength across it's whole radius */
  132625. Constant = 0,
  132626. /** Defines that impulse gets weaker if it's further from the origin */
  132627. Linear = 1
  132628. }
  132629. /**
  132630. * The strength of the force in correspondence to the distance of the affected object
  132631. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132632. */
  132633. export enum PhysicsUpdraftMode {
  132634. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  132635. Center = 0,
  132636. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  132637. Perpendicular = 1
  132638. }
  132639. /**
  132640. * Interface for a physics hit data
  132641. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132642. */
  132643. export interface PhysicsHitData {
  132644. /**
  132645. * The force applied at the contact point
  132646. */
  132647. force: Vector3;
  132648. /**
  132649. * The contact point
  132650. */
  132651. contactPoint: Vector3;
  132652. /**
  132653. * The distance from the origin to the contact point
  132654. */
  132655. distanceFromOrigin: number;
  132656. }
  132657. /**
  132658. * Interface for radial explosion event data
  132659. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132660. */
  132661. export interface PhysicsRadialExplosionEventData {
  132662. /**
  132663. * A sphere used for the radial explosion event
  132664. */
  132665. sphere: Mesh;
  132666. }
  132667. /**
  132668. * Interface for gravitational field event data
  132669. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132670. */
  132671. export interface PhysicsGravitationalFieldEventData {
  132672. /**
  132673. * A sphere mesh used for the gravitational field event
  132674. */
  132675. sphere: Mesh;
  132676. }
  132677. /**
  132678. * Interface for updraft event data
  132679. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132680. */
  132681. export interface PhysicsUpdraftEventData {
  132682. /**
  132683. * A cylinder used for the updraft event
  132684. */
  132685. cylinder: Mesh;
  132686. }
  132687. /**
  132688. * Interface for vortex event data
  132689. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132690. */
  132691. export interface PhysicsVortexEventData {
  132692. /**
  132693. * A cylinder used for the vortex event
  132694. */
  132695. cylinder: Mesh;
  132696. }
  132697. /**
  132698. * Interface for an affected physics impostor
  132699. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132700. */
  132701. export interface PhysicsAffectedImpostorWithData {
  132702. /**
  132703. * The impostor affected by the effect
  132704. */
  132705. impostor: PhysicsImpostor;
  132706. /**
  132707. * The data about the hit/horce from the explosion
  132708. */
  132709. hitData: PhysicsHitData;
  132710. }
  132711. }
  132712. declare module BABYLON {
  132713. /** @hidden */
  132714. export var blackAndWhitePixelShader: {
  132715. name: string;
  132716. shader: string;
  132717. };
  132718. }
  132719. declare module BABYLON {
  132720. /**
  132721. * Post process used to render in black and white
  132722. */
  132723. export class BlackAndWhitePostProcess extends PostProcess {
  132724. /**
  132725. * Linear about to convert he result to black and white (default: 1)
  132726. */
  132727. degree: number;
  132728. /**
  132729. * Creates a black and white post process
  132730. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  132731. * @param name The name of the effect.
  132732. * @param options The required width/height ratio to downsize to before computing the render pass.
  132733. * @param camera The camera to apply the render pass to.
  132734. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132735. * @param engine The engine which the post process will be applied. (default: current engine)
  132736. * @param reusable If the post process can be reused on the same frame. (default: false)
  132737. */
  132738. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  132739. }
  132740. }
  132741. declare module BABYLON {
  132742. /**
  132743. * This represents a set of one or more post processes in Babylon.
  132744. * A post process can be used to apply a shader to a texture after it is rendered.
  132745. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  132746. */
  132747. export class PostProcessRenderEffect {
  132748. private _postProcesses;
  132749. private _getPostProcesses;
  132750. private _singleInstance;
  132751. private _cameras;
  132752. private _indicesForCamera;
  132753. /**
  132754. * Name of the effect
  132755. * @hidden
  132756. */
  132757. _name: string;
  132758. /**
  132759. * Instantiates a post process render effect.
  132760. * A post process can be used to apply a shader to a texture after it is rendered.
  132761. * @param engine The engine the effect is tied to
  132762. * @param name The name of the effect
  132763. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  132764. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  132765. */
  132766. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  132767. /**
  132768. * Checks if all the post processes in the effect are supported.
  132769. */
  132770. get isSupported(): boolean;
  132771. /**
  132772. * Updates the current state of the effect
  132773. * @hidden
  132774. */
  132775. _update(): void;
  132776. /**
  132777. * Attaches the effect on cameras
  132778. * @param cameras The camera to attach to.
  132779. * @hidden
  132780. */
  132781. _attachCameras(cameras: Camera): void;
  132782. /**
  132783. * Attaches the effect on cameras
  132784. * @param cameras The camera to attach to.
  132785. * @hidden
  132786. */
  132787. _attachCameras(cameras: Camera[]): void;
  132788. /**
  132789. * Detaches the effect on cameras
  132790. * @param cameras The camera to detatch from.
  132791. * @hidden
  132792. */
  132793. _detachCameras(cameras: Camera): void;
  132794. /**
  132795. * Detatches the effect on cameras
  132796. * @param cameras The camera to detatch from.
  132797. * @hidden
  132798. */
  132799. _detachCameras(cameras: Camera[]): void;
  132800. /**
  132801. * Enables the effect on given cameras
  132802. * @param cameras The camera to enable.
  132803. * @hidden
  132804. */
  132805. _enable(cameras: Camera): void;
  132806. /**
  132807. * Enables the effect on given cameras
  132808. * @param cameras The camera to enable.
  132809. * @hidden
  132810. */
  132811. _enable(cameras: Nullable<Camera[]>): void;
  132812. /**
  132813. * Disables the effect on the given cameras
  132814. * @param cameras The camera to disable.
  132815. * @hidden
  132816. */
  132817. _disable(cameras: Camera): void;
  132818. /**
  132819. * Disables the effect on the given cameras
  132820. * @param cameras The camera to disable.
  132821. * @hidden
  132822. */
  132823. _disable(cameras: Nullable<Camera[]>): void;
  132824. /**
  132825. * Gets a list of the post processes contained in the effect.
  132826. * @param camera The camera to get the post processes on.
  132827. * @returns The list of the post processes in the effect.
  132828. */
  132829. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  132830. }
  132831. }
  132832. declare module BABYLON {
  132833. /** @hidden */
  132834. export var extractHighlightsPixelShader: {
  132835. name: string;
  132836. shader: string;
  132837. };
  132838. }
  132839. declare module BABYLON {
  132840. /**
  132841. * 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.
  132842. */
  132843. export class ExtractHighlightsPostProcess extends PostProcess {
  132844. /**
  132845. * The luminance threshold, pixels below this value will be set to black.
  132846. */
  132847. threshold: number;
  132848. /** @hidden */
  132849. _exposure: number;
  132850. /**
  132851. * Post process which has the input texture to be used when performing highlight extraction
  132852. * @hidden
  132853. */
  132854. _inputPostProcess: Nullable<PostProcess>;
  132855. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  132856. }
  132857. }
  132858. declare module BABYLON {
  132859. /** @hidden */
  132860. export var bloomMergePixelShader: {
  132861. name: string;
  132862. shader: string;
  132863. };
  132864. }
  132865. declare module BABYLON {
  132866. /**
  132867. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  132868. */
  132869. export class BloomMergePostProcess extends PostProcess {
  132870. /** Weight of the bloom to be added to the original input. */
  132871. weight: number;
  132872. /**
  132873. * Creates a new instance of @see BloomMergePostProcess
  132874. * @param name The name of the effect.
  132875. * @param originalFromInput Post process which's input will be used for the merge.
  132876. * @param blurred Blurred highlights post process which's output will be used.
  132877. * @param weight Weight of the bloom to be added to the original input.
  132878. * @param options The required width/height ratio to downsize to before computing the render pass.
  132879. * @param camera The camera to apply the render pass to.
  132880. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132881. * @param engine The engine which the post process will be applied. (default: current engine)
  132882. * @param reusable If the post process can be reused on the same frame. (default: false)
  132883. * @param textureType Type of textures used when performing the post process. (default: 0)
  132884. * @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)
  132885. */
  132886. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  132887. /** Weight of the bloom to be added to the original input. */
  132888. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  132889. }
  132890. }
  132891. declare module BABYLON {
  132892. /**
  132893. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  132894. */
  132895. export class BloomEffect extends PostProcessRenderEffect {
  132896. private bloomScale;
  132897. /**
  132898. * @hidden Internal
  132899. */
  132900. _effects: Array<PostProcess>;
  132901. /**
  132902. * @hidden Internal
  132903. */
  132904. _downscale: ExtractHighlightsPostProcess;
  132905. private _blurX;
  132906. private _blurY;
  132907. private _merge;
  132908. /**
  132909. * The luminance threshold to find bright areas of the image to bloom.
  132910. */
  132911. get threshold(): number;
  132912. set threshold(value: number);
  132913. /**
  132914. * The strength of the bloom.
  132915. */
  132916. get weight(): number;
  132917. set weight(value: number);
  132918. /**
  132919. * Specifies the size of the bloom blur kernel, relative to the final output size
  132920. */
  132921. get kernel(): number;
  132922. set kernel(value: number);
  132923. /**
  132924. * Creates a new instance of @see BloomEffect
  132925. * @param scene The scene the effect belongs to.
  132926. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  132927. * @param bloomKernel The size of the kernel to be used when applying the blur.
  132928. * @param bloomWeight The the strength of bloom.
  132929. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  132930. * @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)
  132931. */
  132932. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  132933. /**
  132934. * Disposes each of the internal effects for a given camera.
  132935. * @param camera The camera to dispose the effect on.
  132936. */
  132937. disposeEffects(camera: Camera): void;
  132938. /**
  132939. * @hidden Internal
  132940. */
  132941. _updateEffects(): void;
  132942. /**
  132943. * Internal
  132944. * @returns if all the contained post processes are ready.
  132945. * @hidden
  132946. */
  132947. _isReady(): boolean;
  132948. }
  132949. }
  132950. declare module BABYLON {
  132951. /** @hidden */
  132952. export var chromaticAberrationPixelShader: {
  132953. name: string;
  132954. shader: string;
  132955. };
  132956. }
  132957. declare module BABYLON {
  132958. /**
  132959. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  132960. */
  132961. export class ChromaticAberrationPostProcess extends PostProcess {
  132962. /**
  132963. * The amount of seperation of rgb channels (default: 30)
  132964. */
  132965. aberrationAmount: number;
  132966. /**
  132967. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  132968. */
  132969. radialIntensity: number;
  132970. /**
  132971. * 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))
  132972. */
  132973. direction: Vector2;
  132974. /**
  132975. * 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))
  132976. */
  132977. centerPosition: Vector2;
  132978. /**
  132979. * Creates a new instance ChromaticAberrationPostProcess
  132980. * @param name The name of the effect.
  132981. * @param screenWidth The width of the screen to apply the effect on.
  132982. * @param screenHeight The height of the screen to apply the effect on.
  132983. * @param options The required width/height ratio to downsize to before computing the render pass.
  132984. * @param camera The camera to apply the render pass to.
  132985. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132986. * @param engine The engine which the post process will be applied. (default: current engine)
  132987. * @param reusable If the post process can be reused on the same frame. (default: false)
  132988. * @param textureType Type of textures used when performing the post process. (default: 0)
  132989. * @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)
  132990. */
  132991. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  132992. }
  132993. }
  132994. declare module BABYLON {
  132995. /** @hidden */
  132996. export var circleOfConfusionPixelShader: {
  132997. name: string;
  132998. shader: string;
  132999. };
  133000. }
  133001. declare module BABYLON {
  133002. /**
  133003. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  133004. */
  133005. export class CircleOfConfusionPostProcess extends PostProcess {
  133006. /**
  133007. * 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.
  133008. */
  133009. lensSize: number;
  133010. /**
  133011. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  133012. */
  133013. fStop: number;
  133014. /**
  133015. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  133016. */
  133017. focusDistance: number;
  133018. /**
  133019. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  133020. */
  133021. focalLength: number;
  133022. private _depthTexture;
  133023. /**
  133024. * Creates a new instance CircleOfConfusionPostProcess
  133025. * @param name The name of the effect.
  133026. * @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.
  133027. * @param options The required width/height ratio to downsize to before computing the render pass.
  133028. * @param camera The camera to apply the render pass to.
  133029. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133030. * @param engine The engine which the post process will be applied. (default: current engine)
  133031. * @param reusable If the post process can be reused on the same frame. (default: false)
  133032. * @param textureType Type of textures used when performing the post process. (default: 0)
  133033. * @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)
  133034. */
  133035. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  133036. /**
  133037. * 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.
  133038. */
  133039. set depthTexture(value: RenderTargetTexture);
  133040. }
  133041. }
  133042. declare module BABYLON {
  133043. /** @hidden */
  133044. export var colorCorrectionPixelShader: {
  133045. name: string;
  133046. shader: string;
  133047. };
  133048. }
  133049. declare module BABYLON {
  133050. /**
  133051. *
  133052. * This post-process allows the modification of rendered colors by using
  133053. * a 'look-up table' (LUT). This effect is also called Color Grading.
  133054. *
  133055. * The object needs to be provided an url to a texture containing the color
  133056. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  133057. * Use an image editing software to tweak the LUT to match your needs.
  133058. *
  133059. * For an example of a color LUT, see here:
  133060. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  133061. * For explanations on color grading, see here:
  133062. * @see http://udn.epicgames.com/Three/ColorGrading.html
  133063. *
  133064. */
  133065. export class ColorCorrectionPostProcess extends PostProcess {
  133066. private _colorTableTexture;
  133067. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  133068. }
  133069. }
  133070. declare module BABYLON {
  133071. /** @hidden */
  133072. export var convolutionPixelShader: {
  133073. name: string;
  133074. shader: string;
  133075. };
  133076. }
  133077. declare module BABYLON {
  133078. /**
  133079. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  133080. * input texture to perform effects such as edge detection or sharpening
  133081. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  133082. */
  133083. export class ConvolutionPostProcess extends PostProcess {
  133084. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  133085. kernel: number[];
  133086. /**
  133087. * Creates a new instance ConvolutionPostProcess
  133088. * @param name The name of the effect.
  133089. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  133090. * @param options The required width/height ratio to downsize to before computing the render pass.
  133091. * @param camera The camera to apply the render pass to.
  133092. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133093. * @param engine The engine which the post process will be applied. (default: current engine)
  133094. * @param reusable If the post process can be reused on the same frame. (default: false)
  133095. * @param textureType Type of textures used when performing the post process. (default: 0)
  133096. */
  133097. constructor(name: string,
  133098. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  133099. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  133100. /**
  133101. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  133102. */
  133103. static EdgeDetect0Kernel: number[];
  133104. /**
  133105. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  133106. */
  133107. static EdgeDetect1Kernel: number[];
  133108. /**
  133109. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  133110. */
  133111. static EdgeDetect2Kernel: number[];
  133112. /**
  133113. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  133114. */
  133115. static SharpenKernel: number[];
  133116. /**
  133117. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  133118. */
  133119. static EmbossKernel: number[];
  133120. /**
  133121. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  133122. */
  133123. static GaussianKernel: number[];
  133124. }
  133125. }
  133126. declare module BABYLON {
  133127. /**
  133128. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  133129. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  133130. * based on samples that have a large difference in distance than the center pixel.
  133131. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  133132. */
  133133. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  133134. direction: Vector2;
  133135. /**
  133136. * Creates a new instance CircleOfConfusionPostProcess
  133137. * @param name The name of the effect.
  133138. * @param scene The scene the effect belongs to.
  133139. * @param direction The direction the blur should be applied.
  133140. * @param kernel The size of the kernel used to blur.
  133141. * @param options The required width/height ratio to downsize to before computing the render pass.
  133142. * @param camera The camera to apply the render pass to.
  133143. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  133144. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  133145. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133146. * @param engine The engine which the post process will be applied. (default: current engine)
  133147. * @param reusable If the post process can be reused on the same frame. (default: false)
  133148. * @param textureType Type of textures used when performing the post process. (default: 0)
  133149. * @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)
  133150. */
  133151. 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);
  133152. }
  133153. }
  133154. declare module BABYLON {
  133155. /** @hidden */
  133156. export var depthOfFieldMergePixelShader: {
  133157. name: string;
  133158. shader: string;
  133159. };
  133160. }
  133161. declare module BABYLON {
  133162. /**
  133163. * Options to be set when merging outputs from the default pipeline.
  133164. */
  133165. export class DepthOfFieldMergePostProcessOptions {
  133166. /**
  133167. * The original image to merge on top of
  133168. */
  133169. originalFromInput: PostProcess;
  133170. /**
  133171. * Parameters to perform the merge of the depth of field effect
  133172. */
  133173. depthOfField?: {
  133174. circleOfConfusion: PostProcess;
  133175. blurSteps: Array<PostProcess>;
  133176. };
  133177. /**
  133178. * Parameters to perform the merge of bloom effect
  133179. */
  133180. bloom?: {
  133181. blurred: PostProcess;
  133182. weight: number;
  133183. };
  133184. }
  133185. /**
  133186. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  133187. */
  133188. export class DepthOfFieldMergePostProcess extends PostProcess {
  133189. private blurSteps;
  133190. /**
  133191. * Creates a new instance of DepthOfFieldMergePostProcess
  133192. * @param name The name of the effect.
  133193. * @param originalFromInput Post process which's input will be used for the merge.
  133194. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  133195. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  133196. * @param options The required width/height ratio to downsize to before computing the render pass.
  133197. * @param camera The camera to apply the render pass to.
  133198. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133199. * @param engine The engine which the post process will be applied. (default: current engine)
  133200. * @param reusable If the post process can be reused on the same frame. (default: false)
  133201. * @param textureType Type of textures used when performing the post process. (default: 0)
  133202. * @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)
  133203. */
  133204. 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);
  133205. /**
  133206. * Updates the effect with the current post process compile time values and recompiles the shader.
  133207. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  133208. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  133209. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  133210. * @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
  133211. * @param onCompiled Called when the shader has been compiled.
  133212. * @param onError Called if there is an error when compiling a shader.
  133213. */
  133214. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  133215. }
  133216. }
  133217. declare module BABYLON {
  133218. /**
  133219. * Specifies the level of max blur that should be applied when using the depth of field effect
  133220. */
  133221. export enum DepthOfFieldEffectBlurLevel {
  133222. /**
  133223. * Subtle blur
  133224. */
  133225. Low = 0,
  133226. /**
  133227. * Medium blur
  133228. */
  133229. Medium = 1,
  133230. /**
  133231. * Large blur
  133232. */
  133233. High = 2
  133234. }
  133235. /**
  133236. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  133237. */
  133238. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  133239. private _circleOfConfusion;
  133240. /**
  133241. * @hidden Internal, blurs from high to low
  133242. */
  133243. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  133244. private _depthOfFieldBlurY;
  133245. private _dofMerge;
  133246. /**
  133247. * @hidden Internal post processes in depth of field effect
  133248. */
  133249. _effects: Array<PostProcess>;
  133250. /**
  133251. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  133252. */
  133253. set focalLength(value: number);
  133254. get focalLength(): number;
  133255. /**
  133256. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  133257. */
  133258. set fStop(value: number);
  133259. get fStop(): number;
  133260. /**
  133261. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  133262. */
  133263. set focusDistance(value: number);
  133264. get focusDistance(): number;
  133265. /**
  133266. * 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.
  133267. */
  133268. set lensSize(value: number);
  133269. get lensSize(): number;
  133270. /**
  133271. * Creates a new instance DepthOfFieldEffect
  133272. * @param scene The scene the effect belongs to.
  133273. * @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.
  133274. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  133275. * @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)
  133276. */
  133277. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  133278. /**
  133279. * Get the current class name of the current effet
  133280. * @returns "DepthOfFieldEffect"
  133281. */
  133282. getClassName(): string;
  133283. /**
  133284. * 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.
  133285. */
  133286. set depthTexture(value: RenderTargetTexture);
  133287. /**
  133288. * Disposes each of the internal effects for a given camera.
  133289. * @param camera The camera to dispose the effect on.
  133290. */
  133291. disposeEffects(camera: Camera): void;
  133292. /**
  133293. * @hidden Internal
  133294. */
  133295. _updateEffects(): void;
  133296. /**
  133297. * Internal
  133298. * @returns if all the contained post processes are ready.
  133299. * @hidden
  133300. */
  133301. _isReady(): boolean;
  133302. }
  133303. }
  133304. declare module BABYLON {
  133305. /** @hidden */
  133306. export var displayPassPixelShader: {
  133307. name: string;
  133308. shader: string;
  133309. };
  133310. }
  133311. declare module BABYLON {
  133312. /**
  133313. * DisplayPassPostProcess which produces an output the same as it's input
  133314. */
  133315. export class DisplayPassPostProcess extends PostProcess {
  133316. /**
  133317. * Creates the DisplayPassPostProcess
  133318. * @param name The name of the effect.
  133319. * @param options The required width/height ratio to downsize to before computing the render pass.
  133320. * @param camera The camera to apply the render pass to.
  133321. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133322. * @param engine The engine which the post process will be applied. (default: current engine)
  133323. * @param reusable If the post process can be reused on the same frame. (default: false)
  133324. */
  133325. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  133326. }
  133327. }
  133328. declare module BABYLON {
  133329. /** @hidden */
  133330. export var filterPixelShader: {
  133331. name: string;
  133332. shader: string;
  133333. };
  133334. }
  133335. declare module BABYLON {
  133336. /**
  133337. * Applies a kernel filter to the image
  133338. */
  133339. export class FilterPostProcess extends PostProcess {
  133340. /** The matrix to be applied to the image */
  133341. kernelMatrix: Matrix;
  133342. /**
  133343. *
  133344. * @param name The name of the effect.
  133345. * @param kernelMatrix The matrix to be applied to the image
  133346. * @param options The required width/height ratio to downsize to before computing the render pass.
  133347. * @param camera The camera to apply the render pass to.
  133348. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133349. * @param engine The engine which the post process will be applied. (default: current engine)
  133350. * @param reusable If the post process can be reused on the same frame. (default: false)
  133351. */
  133352. constructor(name: string,
  133353. /** The matrix to be applied to the image */
  133354. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  133355. }
  133356. }
  133357. declare module BABYLON {
  133358. /** @hidden */
  133359. export var fxaaPixelShader: {
  133360. name: string;
  133361. shader: string;
  133362. };
  133363. }
  133364. declare module BABYLON {
  133365. /** @hidden */
  133366. export var fxaaVertexShader: {
  133367. name: string;
  133368. shader: string;
  133369. };
  133370. }
  133371. declare module BABYLON {
  133372. /**
  133373. * Fxaa post process
  133374. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  133375. */
  133376. export class FxaaPostProcess extends PostProcess {
  133377. /** @hidden */
  133378. texelWidth: number;
  133379. /** @hidden */
  133380. texelHeight: number;
  133381. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  133382. private _getDefines;
  133383. }
  133384. }
  133385. declare module BABYLON {
  133386. /** @hidden */
  133387. export var grainPixelShader: {
  133388. name: string;
  133389. shader: string;
  133390. };
  133391. }
  133392. declare module BABYLON {
  133393. /**
  133394. * The GrainPostProcess adds noise to the image at mid luminance levels
  133395. */
  133396. export class GrainPostProcess extends PostProcess {
  133397. /**
  133398. * The intensity of the grain added (default: 30)
  133399. */
  133400. intensity: number;
  133401. /**
  133402. * If the grain should be randomized on every frame
  133403. */
  133404. animated: boolean;
  133405. /**
  133406. * Creates a new instance of @see GrainPostProcess
  133407. * @param name The name of the effect.
  133408. * @param options The required width/height ratio to downsize to before computing the render pass.
  133409. * @param camera The camera to apply the render pass to.
  133410. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133411. * @param engine The engine which the post process will be applied. (default: current engine)
  133412. * @param reusable If the post process can be reused on the same frame. (default: false)
  133413. * @param textureType Type of textures used when performing the post process. (default: 0)
  133414. * @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)
  133415. */
  133416. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  133417. }
  133418. }
  133419. declare module BABYLON {
  133420. /** @hidden */
  133421. export var highlightsPixelShader: {
  133422. name: string;
  133423. shader: string;
  133424. };
  133425. }
  133426. declare module BABYLON {
  133427. /**
  133428. * Extracts highlights from the image
  133429. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  133430. */
  133431. export class HighlightsPostProcess extends PostProcess {
  133432. /**
  133433. * Extracts highlights from the image
  133434. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  133435. * @param name The name of the effect.
  133436. * @param options The required width/height ratio to downsize to before computing the render pass.
  133437. * @param camera The camera to apply the render pass to.
  133438. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133439. * @param engine The engine which the post process will be applied. (default: current engine)
  133440. * @param reusable If the post process can be reused on the same frame. (default: false)
  133441. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  133442. */
  133443. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  133444. }
  133445. }
  133446. declare module BABYLON {
  133447. /** @hidden */
  133448. export var mrtFragmentDeclaration: {
  133449. name: string;
  133450. shader: string;
  133451. };
  133452. }
  133453. declare module BABYLON {
  133454. /** @hidden */
  133455. export var geometryPixelShader: {
  133456. name: string;
  133457. shader: string;
  133458. };
  133459. }
  133460. declare module BABYLON {
  133461. /** @hidden */
  133462. export var geometryVertexShader: {
  133463. name: string;
  133464. shader: string;
  133465. };
  133466. }
  133467. declare module BABYLON {
  133468. /** @hidden */
  133469. interface ISavedTransformationMatrix {
  133470. world: Matrix;
  133471. viewProjection: Matrix;
  133472. }
  133473. /**
  133474. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  133475. */
  133476. export class GeometryBufferRenderer {
  133477. /**
  133478. * Constant used to retrieve the position texture index in the G-Buffer textures array
  133479. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  133480. */
  133481. static readonly POSITION_TEXTURE_TYPE: number;
  133482. /**
  133483. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  133484. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  133485. */
  133486. static readonly VELOCITY_TEXTURE_TYPE: number;
  133487. /**
  133488. * Dictionary used to store the previous transformation matrices of each rendered mesh
  133489. * in order to compute objects velocities when enableVelocity is set to "true"
  133490. * @hidden
  133491. */
  133492. _previousTransformationMatrices: {
  133493. [index: number]: ISavedTransformationMatrix;
  133494. };
  133495. /**
  133496. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  133497. * in order to compute objects velocities when enableVelocity is set to "true"
  133498. * @hidden
  133499. */
  133500. _previousBonesTransformationMatrices: {
  133501. [index: number]: Float32Array;
  133502. };
  133503. /**
  133504. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  133505. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  133506. */
  133507. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  133508. private _scene;
  133509. private _multiRenderTarget;
  133510. private _ratio;
  133511. private _enablePosition;
  133512. private _enableVelocity;
  133513. private _positionIndex;
  133514. private _velocityIndex;
  133515. protected _effect: Effect;
  133516. protected _cachedDefines: string;
  133517. /**
  133518. * Set the render list (meshes to be rendered) used in the G buffer.
  133519. */
  133520. set renderList(meshes: Mesh[]);
  133521. /**
  133522. * Gets wether or not G buffer are supported by the running hardware.
  133523. * This requires draw buffer supports
  133524. */
  133525. get isSupported(): boolean;
  133526. /**
  133527. * Returns the index of the given texture type in the G-Buffer textures array
  133528. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  133529. * @returns the index of the given texture type in the G-Buffer textures array
  133530. */
  133531. getTextureIndex(textureType: number): number;
  133532. /**
  133533. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  133534. */
  133535. get enablePosition(): boolean;
  133536. /**
  133537. * Sets whether or not objects positions are enabled for the G buffer.
  133538. */
  133539. set enablePosition(enable: boolean);
  133540. /**
  133541. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  133542. */
  133543. get enableVelocity(): boolean;
  133544. /**
  133545. * Sets wether or not objects velocities are enabled for the G buffer.
  133546. */
  133547. set enableVelocity(enable: boolean);
  133548. /**
  133549. * Gets the scene associated with the buffer.
  133550. */
  133551. get scene(): Scene;
  133552. /**
  133553. * Gets the ratio used by the buffer during its creation.
  133554. * How big is the buffer related to the main canvas.
  133555. */
  133556. get ratio(): number;
  133557. /** @hidden */
  133558. static _SceneComponentInitialization: (scene: Scene) => void;
  133559. /**
  133560. * Creates a new G Buffer for the scene
  133561. * @param scene The scene the buffer belongs to
  133562. * @param ratio How big is the buffer related to the main canvas.
  133563. */
  133564. constructor(scene: Scene, ratio?: number);
  133565. /**
  133566. * Checks wether everything is ready to render a submesh to the G buffer.
  133567. * @param subMesh the submesh to check readiness for
  133568. * @param useInstances is the mesh drawn using instance or not
  133569. * @returns true if ready otherwise false
  133570. */
  133571. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  133572. /**
  133573. * Gets the current underlying G Buffer.
  133574. * @returns the buffer
  133575. */
  133576. getGBuffer(): MultiRenderTarget;
  133577. /**
  133578. * Gets the number of samples used to render the buffer (anti aliasing).
  133579. */
  133580. get samples(): number;
  133581. /**
  133582. * Sets the number of samples used to render the buffer (anti aliasing).
  133583. */
  133584. set samples(value: number);
  133585. /**
  133586. * Disposes the renderer and frees up associated resources.
  133587. */
  133588. dispose(): void;
  133589. protected _createRenderTargets(): void;
  133590. private _copyBonesTransformationMatrices;
  133591. }
  133592. }
  133593. declare module BABYLON {
  133594. interface Scene {
  133595. /** @hidden (Backing field) */
  133596. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  133597. /**
  133598. * Gets or Sets the current geometry buffer associated to the scene.
  133599. */
  133600. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  133601. /**
  133602. * Enables a GeometryBufferRender and associates it with the scene
  133603. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  133604. * @returns the GeometryBufferRenderer
  133605. */
  133606. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  133607. /**
  133608. * Disables the GeometryBufferRender associated with the scene
  133609. */
  133610. disableGeometryBufferRenderer(): void;
  133611. }
  133612. /**
  133613. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  133614. * in several rendering techniques.
  133615. */
  133616. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  133617. /**
  133618. * The component name helpful to identify the component in the list of scene components.
  133619. */
  133620. readonly name: string;
  133621. /**
  133622. * The scene the component belongs to.
  133623. */
  133624. scene: Scene;
  133625. /**
  133626. * Creates a new instance of the component for the given scene
  133627. * @param scene Defines the scene to register the component in
  133628. */
  133629. constructor(scene: Scene);
  133630. /**
  133631. * Registers the component in a given scene
  133632. */
  133633. register(): void;
  133634. /**
  133635. * Rebuilds the elements related to this component in case of
  133636. * context lost for instance.
  133637. */
  133638. rebuild(): void;
  133639. /**
  133640. * Disposes the component and the associated ressources
  133641. */
  133642. dispose(): void;
  133643. private _gatherRenderTargets;
  133644. }
  133645. }
  133646. declare module BABYLON {
  133647. /** @hidden */
  133648. export var motionBlurPixelShader: {
  133649. name: string;
  133650. shader: string;
  133651. };
  133652. }
  133653. declare module BABYLON {
  133654. /**
  133655. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  133656. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  133657. * As an example, all you have to do is to create the post-process:
  133658. * var mb = new BABYLON.MotionBlurPostProcess(
  133659. * 'mb', // The name of the effect.
  133660. * scene, // The scene containing the objects to blur according to their velocity.
  133661. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  133662. * camera // The camera to apply the render pass to.
  133663. * );
  133664. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  133665. */
  133666. export class MotionBlurPostProcess extends PostProcess {
  133667. /**
  133668. * Defines how much the image is blurred by the movement. Default value is equal to 1
  133669. */
  133670. motionStrength: number;
  133671. /**
  133672. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  133673. */
  133674. get motionBlurSamples(): number;
  133675. /**
  133676. * Sets the number of iterations to be used for motion blur quality
  133677. */
  133678. set motionBlurSamples(samples: number);
  133679. private _motionBlurSamples;
  133680. private _geometryBufferRenderer;
  133681. /**
  133682. * Creates a new instance MotionBlurPostProcess
  133683. * @param name The name of the effect.
  133684. * @param scene The scene containing the objects to blur according to their velocity.
  133685. * @param options The required width/height ratio to downsize to before computing the render pass.
  133686. * @param camera The camera to apply the render pass to.
  133687. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133688. * @param engine The engine which the post process will be applied. (default: current engine)
  133689. * @param reusable If the post process can be reused on the same frame. (default: false)
  133690. * @param textureType Type of textures used when performing the post process. (default: 0)
  133691. * @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)
  133692. */
  133693. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  133694. /**
  133695. * Excludes the given skinned mesh from computing bones velocities.
  133696. * 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.
  133697. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  133698. */
  133699. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  133700. /**
  133701. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  133702. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  133703. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  133704. */
  133705. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  133706. /**
  133707. * Disposes the post process.
  133708. * @param camera The camera to dispose the post process on.
  133709. */
  133710. dispose(camera?: Camera): void;
  133711. }
  133712. }
  133713. declare module BABYLON {
  133714. /** @hidden */
  133715. export var refractionPixelShader: {
  133716. name: string;
  133717. shader: string;
  133718. };
  133719. }
  133720. declare module BABYLON {
  133721. /**
  133722. * Post process which applies a refractin texture
  133723. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  133724. */
  133725. export class RefractionPostProcess extends PostProcess {
  133726. /** the base color of the refraction (used to taint the rendering) */
  133727. color: Color3;
  133728. /** simulated refraction depth */
  133729. depth: number;
  133730. /** the coefficient of the base color (0 to remove base color tainting) */
  133731. colorLevel: number;
  133732. private _refTexture;
  133733. private _ownRefractionTexture;
  133734. /**
  133735. * Gets or sets the refraction texture
  133736. * Please note that you are responsible for disposing the texture if you set it manually
  133737. */
  133738. get refractionTexture(): Texture;
  133739. set refractionTexture(value: Texture);
  133740. /**
  133741. * Initializes the RefractionPostProcess
  133742. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  133743. * @param name The name of the effect.
  133744. * @param refractionTextureUrl Url of the refraction texture to use
  133745. * @param color the base color of the refraction (used to taint the rendering)
  133746. * @param depth simulated refraction depth
  133747. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  133748. * @param camera The camera to apply the render pass to.
  133749. * @param options The required width/height ratio to downsize to before computing the render pass.
  133750. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133751. * @param engine The engine which the post process will be applied. (default: current engine)
  133752. * @param reusable If the post process can be reused on the same frame. (default: false)
  133753. */
  133754. constructor(name: string, refractionTextureUrl: string,
  133755. /** the base color of the refraction (used to taint the rendering) */
  133756. color: Color3,
  133757. /** simulated refraction depth */
  133758. depth: number,
  133759. /** the coefficient of the base color (0 to remove base color tainting) */
  133760. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  133761. /**
  133762. * Disposes of the post process
  133763. * @param camera Camera to dispose post process on
  133764. */
  133765. dispose(camera: Camera): void;
  133766. }
  133767. }
  133768. declare module BABYLON {
  133769. /** @hidden */
  133770. export var sharpenPixelShader: {
  133771. name: string;
  133772. shader: string;
  133773. };
  133774. }
  133775. declare module BABYLON {
  133776. /**
  133777. * The SharpenPostProcess applies a sharpen kernel to every pixel
  133778. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  133779. */
  133780. export class SharpenPostProcess extends PostProcess {
  133781. /**
  133782. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  133783. */
  133784. colorAmount: number;
  133785. /**
  133786. * How much sharpness should be applied (default: 0.3)
  133787. */
  133788. edgeAmount: number;
  133789. /**
  133790. * Creates a new instance ConvolutionPostProcess
  133791. * @param name The name of the effect.
  133792. * @param options The required width/height ratio to downsize to before computing the render pass.
  133793. * @param camera The camera to apply the render pass to.
  133794. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133795. * @param engine The engine which the post process will be applied. (default: current engine)
  133796. * @param reusable If the post process can be reused on the same frame. (default: false)
  133797. * @param textureType Type of textures used when performing the post process. (default: 0)
  133798. * @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)
  133799. */
  133800. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  133801. }
  133802. }
  133803. declare module BABYLON {
  133804. /**
  133805. * PostProcessRenderPipeline
  133806. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  133807. */
  133808. export class PostProcessRenderPipeline {
  133809. private engine;
  133810. private _renderEffects;
  133811. private _renderEffectsForIsolatedPass;
  133812. /**
  133813. * List of inspectable custom properties (used by the Inspector)
  133814. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  133815. */
  133816. inspectableCustomProperties: IInspectable[];
  133817. /**
  133818. * @hidden
  133819. */
  133820. protected _cameras: Camera[];
  133821. /** @hidden */
  133822. _name: string;
  133823. /**
  133824. * Gets pipeline name
  133825. */
  133826. get name(): string;
  133827. /** Gets the list of attached cameras */
  133828. get cameras(): Camera[];
  133829. /**
  133830. * Initializes a PostProcessRenderPipeline
  133831. * @param engine engine to add the pipeline to
  133832. * @param name name of the pipeline
  133833. */
  133834. constructor(engine: Engine, name: string);
  133835. /**
  133836. * Gets the class name
  133837. * @returns "PostProcessRenderPipeline"
  133838. */
  133839. getClassName(): string;
  133840. /**
  133841. * If all the render effects in the pipeline are supported
  133842. */
  133843. get isSupported(): boolean;
  133844. /**
  133845. * Adds an effect to the pipeline
  133846. * @param renderEffect the effect to add
  133847. */
  133848. addEffect(renderEffect: PostProcessRenderEffect): void;
  133849. /** @hidden */
  133850. _rebuild(): void;
  133851. /** @hidden */
  133852. _enableEffect(renderEffectName: string, cameras: Camera): void;
  133853. /** @hidden */
  133854. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  133855. /** @hidden */
  133856. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  133857. /** @hidden */
  133858. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  133859. /** @hidden */
  133860. _attachCameras(cameras: Camera, unique: boolean): void;
  133861. /** @hidden */
  133862. _attachCameras(cameras: Camera[], unique: boolean): void;
  133863. /** @hidden */
  133864. _detachCameras(cameras: Camera): void;
  133865. /** @hidden */
  133866. _detachCameras(cameras: Nullable<Camera[]>): void;
  133867. /** @hidden */
  133868. _update(): void;
  133869. /** @hidden */
  133870. _reset(): void;
  133871. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  133872. /**
  133873. * Disposes of the pipeline
  133874. */
  133875. dispose(): void;
  133876. }
  133877. }
  133878. declare module BABYLON {
  133879. /**
  133880. * PostProcessRenderPipelineManager class
  133881. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  133882. */
  133883. export class PostProcessRenderPipelineManager {
  133884. private _renderPipelines;
  133885. /**
  133886. * Initializes a PostProcessRenderPipelineManager
  133887. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  133888. */
  133889. constructor();
  133890. /**
  133891. * Gets the list of supported render pipelines
  133892. */
  133893. get supportedPipelines(): PostProcessRenderPipeline[];
  133894. /**
  133895. * Adds a pipeline to the manager
  133896. * @param renderPipeline The pipeline to add
  133897. */
  133898. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  133899. /**
  133900. * Attaches a camera to the pipeline
  133901. * @param renderPipelineName The name of the pipeline to attach to
  133902. * @param cameras the camera to attach
  133903. * @param unique if the camera can be attached multiple times to the pipeline
  133904. */
  133905. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  133906. /**
  133907. * Detaches a camera from the pipeline
  133908. * @param renderPipelineName The name of the pipeline to detach from
  133909. * @param cameras the camera to detach
  133910. */
  133911. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  133912. /**
  133913. * Enables an effect by name on a pipeline
  133914. * @param renderPipelineName the name of the pipeline to enable the effect in
  133915. * @param renderEffectName the name of the effect to enable
  133916. * @param cameras the cameras that the effect should be enabled on
  133917. */
  133918. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  133919. /**
  133920. * Disables an effect by name on a pipeline
  133921. * @param renderPipelineName the name of the pipeline to disable the effect in
  133922. * @param renderEffectName the name of the effect to disable
  133923. * @param cameras the cameras that the effect should be disabled on
  133924. */
  133925. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  133926. /**
  133927. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  133928. */
  133929. update(): void;
  133930. /** @hidden */
  133931. _rebuild(): void;
  133932. /**
  133933. * Disposes of the manager and pipelines
  133934. */
  133935. dispose(): void;
  133936. }
  133937. }
  133938. declare module BABYLON {
  133939. interface Scene {
  133940. /** @hidden (Backing field) */
  133941. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  133942. /**
  133943. * Gets the postprocess render pipeline manager
  133944. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  133945. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  133946. */
  133947. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  133948. }
  133949. /**
  133950. * Defines the Render Pipeline scene component responsible to rendering pipelines
  133951. */
  133952. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  133953. /**
  133954. * The component name helpfull to identify the component in the list of scene components.
  133955. */
  133956. readonly name: string;
  133957. /**
  133958. * The scene the component belongs to.
  133959. */
  133960. scene: Scene;
  133961. /**
  133962. * Creates a new instance of the component for the given scene
  133963. * @param scene Defines the scene to register the component in
  133964. */
  133965. constructor(scene: Scene);
  133966. /**
  133967. * Registers the component in a given scene
  133968. */
  133969. register(): void;
  133970. /**
  133971. * Rebuilds the elements related to this component in case of
  133972. * context lost for instance.
  133973. */
  133974. rebuild(): void;
  133975. /**
  133976. * Disposes the component and the associated ressources
  133977. */
  133978. dispose(): void;
  133979. private _gatherRenderTargets;
  133980. }
  133981. }
  133982. declare module BABYLON {
  133983. /**
  133984. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  133985. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  133986. */
  133987. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  133988. private _scene;
  133989. private _camerasToBeAttached;
  133990. /**
  133991. * ID of the sharpen post process,
  133992. */
  133993. private readonly SharpenPostProcessId;
  133994. /**
  133995. * @ignore
  133996. * ID of the image processing post process;
  133997. */
  133998. readonly ImageProcessingPostProcessId: string;
  133999. /**
  134000. * @ignore
  134001. * ID of the Fast Approximate Anti-Aliasing post process;
  134002. */
  134003. readonly FxaaPostProcessId: string;
  134004. /**
  134005. * ID of the chromatic aberration post process,
  134006. */
  134007. private readonly ChromaticAberrationPostProcessId;
  134008. /**
  134009. * ID of the grain post process
  134010. */
  134011. private readonly GrainPostProcessId;
  134012. /**
  134013. * Sharpen post process which will apply a sharpen convolution to enhance edges
  134014. */
  134015. sharpen: SharpenPostProcess;
  134016. private _sharpenEffect;
  134017. private bloom;
  134018. /**
  134019. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  134020. */
  134021. depthOfField: DepthOfFieldEffect;
  134022. /**
  134023. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  134024. */
  134025. fxaa: FxaaPostProcess;
  134026. /**
  134027. * Image post processing pass used to perform operations such as tone mapping or color grading.
  134028. */
  134029. imageProcessing: ImageProcessingPostProcess;
  134030. /**
  134031. * Chromatic aberration post process which will shift rgb colors in the image
  134032. */
  134033. chromaticAberration: ChromaticAberrationPostProcess;
  134034. private _chromaticAberrationEffect;
  134035. /**
  134036. * Grain post process which add noise to the image
  134037. */
  134038. grain: GrainPostProcess;
  134039. private _grainEffect;
  134040. /**
  134041. * Glow post process which adds a glow to emissive areas of the image
  134042. */
  134043. private _glowLayer;
  134044. /**
  134045. * Animations which can be used to tweak settings over a period of time
  134046. */
  134047. animations: Animation[];
  134048. private _imageProcessingConfigurationObserver;
  134049. private _sharpenEnabled;
  134050. private _bloomEnabled;
  134051. private _depthOfFieldEnabled;
  134052. private _depthOfFieldBlurLevel;
  134053. private _fxaaEnabled;
  134054. private _imageProcessingEnabled;
  134055. private _defaultPipelineTextureType;
  134056. private _bloomScale;
  134057. private _chromaticAberrationEnabled;
  134058. private _grainEnabled;
  134059. private _buildAllowed;
  134060. /**
  134061. * Gets active scene
  134062. */
  134063. get scene(): Scene;
  134064. /**
  134065. * Enable or disable the sharpen process from the pipeline
  134066. */
  134067. set sharpenEnabled(enabled: boolean);
  134068. get sharpenEnabled(): boolean;
  134069. private _resizeObserver;
  134070. private _hardwareScaleLevel;
  134071. private _bloomKernel;
  134072. /**
  134073. * Specifies the size of the bloom blur kernel, relative to the final output size
  134074. */
  134075. get bloomKernel(): number;
  134076. set bloomKernel(value: number);
  134077. /**
  134078. * Specifies the weight of the bloom in the final rendering
  134079. */
  134080. private _bloomWeight;
  134081. /**
  134082. * Specifies the luma threshold for the area that will be blurred by the bloom
  134083. */
  134084. private _bloomThreshold;
  134085. private _hdr;
  134086. /**
  134087. * The strength of the bloom.
  134088. */
  134089. set bloomWeight(value: number);
  134090. get bloomWeight(): number;
  134091. /**
  134092. * The strength of the bloom.
  134093. */
  134094. set bloomThreshold(value: number);
  134095. get bloomThreshold(): number;
  134096. /**
  134097. * The scale of the bloom, lower value will provide better performance.
  134098. */
  134099. set bloomScale(value: number);
  134100. get bloomScale(): number;
  134101. /**
  134102. * Enable or disable the bloom from the pipeline
  134103. */
  134104. set bloomEnabled(enabled: boolean);
  134105. get bloomEnabled(): boolean;
  134106. private _rebuildBloom;
  134107. /**
  134108. * If the depth of field is enabled.
  134109. */
  134110. get depthOfFieldEnabled(): boolean;
  134111. set depthOfFieldEnabled(enabled: boolean);
  134112. /**
  134113. * Blur level of the depth of field effect. (Higher blur will effect performance)
  134114. */
  134115. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  134116. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  134117. /**
  134118. * If the anti aliasing is enabled.
  134119. */
  134120. set fxaaEnabled(enabled: boolean);
  134121. get fxaaEnabled(): boolean;
  134122. private _samples;
  134123. /**
  134124. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  134125. */
  134126. set samples(sampleCount: number);
  134127. get samples(): number;
  134128. /**
  134129. * If image processing is enabled.
  134130. */
  134131. set imageProcessingEnabled(enabled: boolean);
  134132. get imageProcessingEnabled(): boolean;
  134133. /**
  134134. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  134135. */
  134136. set glowLayerEnabled(enabled: boolean);
  134137. get glowLayerEnabled(): boolean;
  134138. /**
  134139. * Gets the glow layer (or null if not defined)
  134140. */
  134141. get glowLayer(): Nullable<GlowLayer>;
  134142. /**
  134143. * Enable or disable the chromaticAberration process from the pipeline
  134144. */
  134145. set chromaticAberrationEnabled(enabled: boolean);
  134146. get chromaticAberrationEnabled(): boolean;
  134147. /**
  134148. * Enable or disable the grain process from the pipeline
  134149. */
  134150. set grainEnabled(enabled: boolean);
  134151. get grainEnabled(): boolean;
  134152. /**
  134153. * @constructor
  134154. * @param name - The rendering pipeline name (default: "")
  134155. * @param hdr - If high dynamic range textures should be used (default: true)
  134156. * @param scene - The scene linked to this pipeline (default: the last created scene)
  134157. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  134158. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  134159. */
  134160. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  134161. /**
  134162. * Get the class name
  134163. * @returns "DefaultRenderingPipeline"
  134164. */
  134165. getClassName(): string;
  134166. /**
  134167. * Force the compilation of the entire pipeline.
  134168. */
  134169. prepare(): void;
  134170. private _hasCleared;
  134171. private _prevPostProcess;
  134172. private _prevPrevPostProcess;
  134173. private _setAutoClearAndTextureSharing;
  134174. private _depthOfFieldSceneObserver;
  134175. private _buildPipeline;
  134176. private _disposePostProcesses;
  134177. /**
  134178. * Adds a camera to the pipeline
  134179. * @param camera the camera to be added
  134180. */
  134181. addCamera(camera: Camera): void;
  134182. /**
  134183. * Removes a camera from the pipeline
  134184. * @param camera the camera to remove
  134185. */
  134186. removeCamera(camera: Camera): void;
  134187. /**
  134188. * Dispose of the pipeline and stop all post processes
  134189. */
  134190. dispose(): void;
  134191. /**
  134192. * Serialize the rendering pipeline (Used when exporting)
  134193. * @returns the serialized object
  134194. */
  134195. serialize(): any;
  134196. /**
  134197. * Parse the serialized pipeline
  134198. * @param source Source pipeline.
  134199. * @param scene The scene to load the pipeline to.
  134200. * @param rootUrl The URL of the serialized pipeline.
  134201. * @returns An instantiated pipeline from the serialized object.
  134202. */
  134203. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  134204. }
  134205. }
  134206. declare module BABYLON {
  134207. /** @hidden */
  134208. export var lensHighlightsPixelShader: {
  134209. name: string;
  134210. shader: string;
  134211. };
  134212. }
  134213. declare module BABYLON {
  134214. /** @hidden */
  134215. export var depthOfFieldPixelShader: {
  134216. name: string;
  134217. shader: string;
  134218. };
  134219. }
  134220. declare module BABYLON {
  134221. /**
  134222. * BABYLON.JS Chromatic Aberration GLSL Shader
  134223. * Author: Olivier Guyot
  134224. * Separates very slightly R, G and B colors on the edges of the screen
  134225. * Inspired by Francois Tarlier & Martins Upitis
  134226. */
  134227. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  134228. /**
  134229. * @ignore
  134230. * The chromatic aberration PostProcess id in the pipeline
  134231. */
  134232. LensChromaticAberrationEffect: string;
  134233. /**
  134234. * @ignore
  134235. * The highlights enhancing PostProcess id in the pipeline
  134236. */
  134237. HighlightsEnhancingEffect: string;
  134238. /**
  134239. * @ignore
  134240. * The depth-of-field PostProcess id in the pipeline
  134241. */
  134242. LensDepthOfFieldEffect: string;
  134243. private _scene;
  134244. private _depthTexture;
  134245. private _grainTexture;
  134246. private _chromaticAberrationPostProcess;
  134247. private _highlightsPostProcess;
  134248. private _depthOfFieldPostProcess;
  134249. private _edgeBlur;
  134250. private _grainAmount;
  134251. private _chromaticAberration;
  134252. private _distortion;
  134253. private _highlightsGain;
  134254. private _highlightsThreshold;
  134255. private _dofDistance;
  134256. private _dofAperture;
  134257. private _dofDarken;
  134258. private _dofPentagon;
  134259. private _blurNoise;
  134260. /**
  134261. * @constructor
  134262. *
  134263. * Effect parameters are as follow:
  134264. * {
  134265. * chromatic_aberration: number; // from 0 to x (1 for realism)
  134266. * edge_blur: number; // from 0 to x (1 for realism)
  134267. * distortion: number; // from 0 to x (1 for realism)
  134268. * grain_amount: number; // from 0 to 1
  134269. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  134270. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  134271. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  134272. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  134273. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  134274. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  134275. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  134276. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  134277. * }
  134278. * Note: if an effect parameter is unset, effect is disabled
  134279. *
  134280. * @param name The rendering pipeline name
  134281. * @param parameters - An object containing all parameters (see above)
  134282. * @param scene The scene linked to this pipeline
  134283. * @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)
  134284. * @param cameras The array of cameras that the rendering pipeline will be attached to
  134285. */
  134286. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  134287. /**
  134288. * Get the class name
  134289. * @returns "LensRenderingPipeline"
  134290. */
  134291. getClassName(): string;
  134292. /**
  134293. * Gets associated scene
  134294. */
  134295. get scene(): Scene;
  134296. /**
  134297. * Gets or sets the edge blur
  134298. */
  134299. get edgeBlur(): number;
  134300. set edgeBlur(value: number);
  134301. /**
  134302. * Gets or sets the grain amount
  134303. */
  134304. get grainAmount(): number;
  134305. set grainAmount(value: number);
  134306. /**
  134307. * Gets or sets the chromatic aberration amount
  134308. */
  134309. get chromaticAberration(): number;
  134310. set chromaticAberration(value: number);
  134311. /**
  134312. * Gets or sets the depth of field aperture
  134313. */
  134314. get dofAperture(): number;
  134315. set dofAperture(value: number);
  134316. /**
  134317. * Gets or sets the edge distortion
  134318. */
  134319. get edgeDistortion(): number;
  134320. set edgeDistortion(value: number);
  134321. /**
  134322. * Gets or sets the depth of field distortion
  134323. */
  134324. get dofDistortion(): number;
  134325. set dofDistortion(value: number);
  134326. /**
  134327. * Gets or sets the darken out of focus amount
  134328. */
  134329. get darkenOutOfFocus(): number;
  134330. set darkenOutOfFocus(value: number);
  134331. /**
  134332. * Gets or sets a boolean indicating if blur noise is enabled
  134333. */
  134334. get blurNoise(): boolean;
  134335. set blurNoise(value: boolean);
  134336. /**
  134337. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  134338. */
  134339. get pentagonBokeh(): boolean;
  134340. set pentagonBokeh(value: boolean);
  134341. /**
  134342. * Gets or sets the highlight grain amount
  134343. */
  134344. get highlightsGain(): number;
  134345. set highlightsGain(value: number);
  134346. /**
  134347. * Gets or sets the highlight threshold
  134348. */
  134349. get highlightsThreshold(): number;
  134350. set highlightsThreshold(value: number);
  134351. /**
  134352. * Sets the amount of blur at the edges
  134353. * @param amount blur amount
  134354. */
  134355. setEdgeBlur(amount: number): void;
  134356. /**
  134357. * Sets edge blur to 0
  134358. */
  134359. disableEdgeBlur(): void;
  134360. /**
  134361. * Sets the amout of grain
  134362. * @param amount Amount of grain
  134363. */
  134364. setGrainAmount(amount: number): void;
  134365. /**
  134366. * Set grain amount to 0
  134367. */
  134368. disableGrain(): void;
  134369. /**
  134370. * Sets the chromatic aberration amount
  134371. * @param amount amount of chromatic aberration
  134372. */
  134373. setChromaticAberration(amount: number): void;
  134374. /**
  134375. * Sets chromatic aberration amount to 0
  134376. */
  134377. disableChromaticAberration(): void;
  134378. /**
  134379. * Sets the EdgeDistortion amount
  134380. * @param amount amount of EdgeDistortion
  134381. */
  134382. setEdgeDistortion(amount: number): void;
  134383. /**
  134384. * Sets edge distortion to 0
  134385. */
  134386. disableEdgeDistortion(): void;
  134387. /**
  134388. * Sets the FocusDistance amount
  134389. * @param amount amount of FocusDistance
  134390. */
  134391. setFocusDistance(amount: number): void;
  134392. /**
  134393. * Disables depth of field
  134394. */
  134395. disableDepthOfField(): void;
  134396. /**
  134397. * Sets the Aperture amount
  134398. * @param amount amount of Aperture
  134399. */
  134400. setAperture(amount: number): void;
  134401. /**
  134402. * Sets the DarkenOutOfFocus amount
  134403. * @param amount amount of DarkenOutOfFocus
  134404. */
  134405. setDarkenOutOfFocus(amount: number): void;
  134406. private _pentagonBokehIsEnabled;
  134407. /**
  134408. * Creates a pentagon bokeh effect
  134409. */
  134410. enablePentagonBokeh(): void;
  134411. /**
  134412. * Disables the pentagon bokeh effect
  134413. */
  134414. disablePentagonBokeh(): void;
  134415. /**
  134416. * Enables noise blur
  134417. */
  134418. enableNoiseBlur(): void;
  134419. /**
  134420. * Disables noise blur
  134421. */
  134422. disableNoiseBlur(): void;
  134423. /**
  134424. * Sets the HighlightsGain amount
  134425. * @param amount amount of HighlightsGain
  134426. */
  134427. setHighlightsGain(amount: number): void;
  134428. /**
  134429. * Sets the HighlightsThreshold amount
  134430. * @param amount amount of HighlightsThreshold
  134431. */
  134432. setHighlightsThreshold(amount: number): void;
  134433. /**
  134434. * Disables highlights
  134435. */
  134436. disableHighlights(): void;
  134437. /**
  134438. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  134439. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  134440. */
  134441. dispose(disableDepthRender?: boolean): void;
  134442. private _createChromaticAberrationPostProcess;
  134443. private _createHighlightsPostProcess;
  134444. private _createDepthOfFieldPostProcess;
  134445. private _createGrainTexture;
  134446. }
  134447. }
  134448. declare module BABYLON {
  134449. /** @hidden */
  134450. export var ssao2PixelShader: {
  134451. name: string;
  134452. shader: string;
  134453. };
  134454. }
  134455. declare module BABYLON {
  134456. /** @hidden */
  134457. export var ssaoCombinePixelShader: {
  134458. name: string;
  134459. shader: string;
  134460. };
  134461. }
  134462. declare module BABYLON {
  134463. /**
  134464. * Render pipeline to produce ssao effect
  134465. */
  134466. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  134467. /**
  134468. * @ignore
  134469. * The PassPostProcess id in the pipeline that contains the original scene color
  134470. */
  134471. SSAOOriginalSceneColorEffect: string;
  134472. /**
  134473. * @ignore
  134474. * The SSAO PostProcess id in the pipeline
  134475. */
  134476. SSAORenderEffect: string;
  134477. /**
  134478. * @ignore
  134479. * The horizontal blur PostProcess id in the pipeline
  134480. */
  134481. SSAOBlurHRenderEffect: string;
  134482. /**
  134483. * @ignore
  134484. * The vertical blur PostProcess id in the pipeline
  134485. */
  134486. SSAOBlurVRenderEffect: string;
  134487. /**
  134488. * @ignore
  134489. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  134490. */
  134491. SSAOCombineRenderEffect: string;
  134492. /**
  134493. * The output strength of the SSAO post-process. Default value is 1.0.
  134494. */
  134495. totalStrength: number;
  134496. /**
  134497. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  134498. */
  134499. maxZ: number;
  134500. /**
  134501. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  134502. */
  134503. minZAspect: number;
  134504. private _samples;
  134505. /**
  134506. * Number of samples used for the SSAO calculations. Default value is 8
  134507. */
  134508. set samples(n: number);
  134509. get samples(): number;
  134510. private _textureSamples;
  134511. /**
  134512. * Number of samples to use for antialiasing
  134513. */
  134514. set textureSamples(n: number);
  134515. get textureSamples(): number;
  134516. /**
  134517. * Ratio object used for SSAO ratio and blur ratio
  134518. */
  134519. private _ratio;
  134520. /**
  134521. * Dynamically generated sphere sampler.
  134522. */
  134523. private _sampleSphere;
  134524. /**
  134525. * Blur filter offsets
  134526. */
  134527. private _samplerOffsets;
  134528. private _expensiveBlur;
  134529. /**
  134530. * If bilateral blur should be used
  134531. */
  134532. set expensiveBlur(b: boolean);
  134533. get expensiveBlur(): boolean;
  134534. /**
  134535. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  134536. */
  134537. radius: number;
  134538. /**
  134539. * The base color of the SSAO post-process
  134540. * The final result is "base + ssao" between [0, 1]
  134541. */
  134542. base: number;
  134543. /**
  134544. * Support test.
  134545. */
  134546. static get IsSupported(): boolean;
  134547. private _scene;
  134548. private _depthTexture;
  134549. private _normalTexture;
  134550. private _randomTexture;
  134551. private _originalColorPostProcess;
  134552. private _ssaoPostProcess;
  134553. private _blurHPostProcess;
  134554. private _blurVPostProcess;
  134555. private _ssaoCombinePostProcess;
  134556. /**
  134557. * Gets active scene
  134558. */
  134559. get scene(): Scene;
  134560. /**
  134561. * @constructor
  134562. * @param name The rendering pipeline name
  134563. * @param scene The scene linked to this pipeline
  134564. * @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 }
  134565. * @param cameras The array of cameras that the rendering pipeline will be attached to
  134566. */
  134567. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  134568. /**
  134569. * Get the class name
  134570. * @returns "SSAO2RenderingPipeline"
  134571. */
  134572. getClassName(): string;
  134573. /**
  134574. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  134575. */
  134576. dispose(disableGeometryBufferRenderer?: boolean): void;
  134577. private _createBlurPostProcess;
  134578. /** @hidden */
  134579. _rebuild(): void;
  134580. private _bits;
  134581. private _radicalInverse_VdC;
  134582. private _hammersley;
  134583. private _hemisphereSample_uniform;
  134584. private _generateHemisphere;
  134585. private _createSSAOPostProcess;
  134586. private _createSSAOCombinePostProcess;
  134587. private _createRandomTexture;
  134588. /**
  134589. * Serialize the rendering pipeline (Used when exporting)
  134590. * @returns the serialized object
  134591. */
  134592. serialize(): any;
  134593. /**
  134594. * Parse the serialized pipeline
  134595. * @param source Source pipeline.
  134596. * @param scene The scene to load the pipeline to.
  134597. * @param rootUrl The URL of the serialized pipeline.
  134598. * @returns An instantiated pipeline from the serialized object.
  134599. */
  134600. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  134601. }
  134602. }
  134603. declare module BABYLON {
  134604. /** @hidden */
  134605. export var ssaoPixelShader: {
  134606. name: string;
  134607. shader: string;
  134608. };
  134609. }
  134610. declare module BABYLON {
  134611. /**
  134612. * Render pipeline to produce ssao effect
  134613. */
  134614. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  134615. /**
  134616. * @ignore
  134617. * The PassPostProcess id in the pipeline that contains the original scene color
  134618. */
  134619. SSAOOriginalSceneColorEffect: string;
  134620. /**
  134621. * @ignore
  134622. * The SSAO PostProcess id in the pipeline
  134623. */
  134624. SSAORenderEffect: string;
  134625. /**
  134626. * @ignore
  134627. * The horizontal blur PostProcess id in the pipeline
  134628. */
  134629. SSAOBlurHRenderEffect: string;
  134630. /**
  134631. * @ignore
  134632. * The vertical blur PostProcess id in the pipeline
  134633. */
  134634. SSAOBlurVRenderEffect: string;
  134635. /**
  134636. * @ignore
  134637. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  134638. */
  134639. SSAOCombineRenderEffect: string;
  134640. /**
  134641. * The output strength of the SSAO post-process. Default value is 1.0.
  134642. */
  134643. totalStrength: number;
  134644. /**
  134645. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  134646. */
  134647. radius: number;
  134648. /**
  134649. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  134650. * Must not be equal to fallOff and superior to fallOff.
  134651. * Default value is 0.0075
  134652. */
  134653. area: number;
  134654. /**
  134655. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  134656. * Must not be equal to area and inferior to area.
  134657. * Default value is 0.000001
  134658. */
  134659. fallOff: number;
  134660. /**
  134661. * The base color of the SSAO post-process
  134662. * The final result is "base + ssao" between [0, 1]
  134663. */
  134664. base: number;
  134665. private _scene;
  134666. private _depthTexture;
  134667. private _randomTexture;
  134668. private _originalColorPostProcess;
  134669. private _ssaoPostProcess;
  134670. private _blurHPostProcess;
  134671. private _blurVPostProcess;
  134672. private _ssaoCombinePostProcess;
  134673. private _firstUpdate;
  134674. /**
  134675. * Gets active scene
  134676. */
  134677. get scene(): Scene;
  134678. /**
  134679. * @constructor
  134680. * @param name - The rendering pipeline name
  134681. * @param scene - The scene linked to this pipeline
  134682. * @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 }
  134683. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  134684. */
  134685. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  134686. /**
  134687. * Get the class name
  134688. * @returns "SSAORenderingPipeline"
  134689. */
  134690. getClassName(): string;
  134691. /**
  134692. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  134693. */
  134694. dispose(disableDepthRender?: boolean): void;
  134695. private _createBlurPostProcess;
  134696. /** @hidden */
  134697. _rebuild(): void;
  134698. private _createSSAOPostProcess;
  134699. private _createSSAOCombinePostProcess;
  134700. private _createRandomTexture;
  134701. }
  134702. }
  134703. declare module BABYLON {
  134704. /** @hidden */
  134705. export var standardPixelShader: {
  134706. name: string;
  134707. shader: string;
  134708. };
  134709. }
  134710. declare module BABYLON {
  134711. /**
  134712. * Standard rendering pipeline
  134713. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  134714. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  134715. */
  134716. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  134717. /**
  134718. * Public members
  134719. */
  134720. /**
  134721. * Post-process which contains the original scene color before the pipeline applies all the effects
  134722. */
  134723. originalPostProcess: Nullable<PostProcess>;
  134724. /**
  134725. * Post-process used to down scale an image x4
  134726. */
  134727. downSampleX4PostProcess: Nullable<PostProcess>;
  134728. /**
  134729. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  134730. */
  134731. brightPassPostProcess: Nullable<PostProcess>;
  134732. /**
  134733. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  134734. */
  134735. blurHPostProcesses: PostProcess[];
  134736. /**
  134737. * Post-process array storing all the vertical blur post-processes used by the pipeline
  134738. */
  134739. blurVPostProcesses: PostProcess[];
  134740. /**
  134741. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  134742. */
  134743. textureAdderPostProcess: Nullable<PostProcess>;
  134744. /**
  134745. * Post-process used to create volumetric lighting effect
  134746. */
  134747. volumetricLightPostProcess: Nullable<PostProcess>;
  134748. /**
  134749. * Post-process used to smooth the previous volumetric light post-process on the X axis
  134750. */
  134751. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  134752. /**
  134753. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  134754. */
  134755. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  134756. /**
  134757. * Post-process used to merge the volumetric light effect and the real scene color
  134758. */
  134759. volumetricLightMergePostProces: Nullable<PostProcess>;
  134760. /**
  134761. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  134762. */
  134763. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  134764. /**
  134765. * Base post-process used to calculate the average luminance of the final image for HDR
  134766. */
  134767. luminancePostProcess: Nullable<PostProcess>;
  134768. /**
  134769. * Post-processes used to create down sample post-processes in order to get
  134770. * the average luminance of the final image for HDR
  134771. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  134772. */
  134773. luminanceDownSamplePostProcesses: PostProcess[];
  134774. /**
  134775. * Post-process used to create a HDR effect (light adaptation)
  134776. */
  134777. hdrPostProcess: Nullable<PostProcess>;
  134778. /**
  134779. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  134780. */
  134781. textureAdderFinalPostProcess: Nullable<PostProcess>;
  134782. /**
  134783. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  134784. */
  134785. lensFlareFinalPostProcess: Nullable<PostProcess>;
  134786. /**
  134787. * Post-process used to merge the final HDR post-process and the real scene color
  134788. */
  134789. hdrFinalPostProcess: Nullable<PostProcess>;
  134790. /**
  134791. * Post-process used to create a lens flare effect
  134792. */
  134793. lensFlarePostProcess: Nullable<PostProcess>;
  134794. /**
  134795. * Post-process that merges the result of the lens flare post-process and the real scene color
  134796. */
  134797. lensFlareComposePostProcess: Nullable<PostProcess>;
  134798. /**
  134799. * Post-process used to create a motion blur effect
  134800. */
  134801. motionBlurPostProcess: Nullable<PostProcess>;
  134802. /**
  134803. * Post-process used to create a depth of field effect
  134804. */
  134805. depthOfFieldPostProcess: Nullable<PostProcess>;
  134806. /**
  134807. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  134808. */
  134809. fxaaPostProcess: Nullable<FxaaPostProcess>;
  134810. /**
  134811. * Represents the brightness threshold in order to configure the illuminated surfaces
  134812. */
  134813. brightThreshold: number;
  134814. /**
  134815. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  134816. */
  134817. blurWidth: number;
  134818. /**
  134819. * Sets if the blur for highlighted surfaces must be only horizontal
  134820. */
  134821. horizontalBlur: boolean;
  134822. /**
  134823. * Gets the overall exposure used by the pipeline
  134824. */
  134825. get exposure(): number;
  134826. /**
  134827. * Sets the overall exposure used by the pipeline
  134828. */
  134829. set exposure(value: number);
  134830. /**
  134831. * Texture used typically to simulate "dirty" on camera lens
  134832. */
  134833. lensTexture: Nullable<Texture>;
  134834. /**
  134835. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  134836. */
  134837. volumetricLightCoefficient: number;
  134838. /**
  134839. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  134840. */
  134841. volumetricLightPower: number;
  134842. /**
  134843. * Used the set the blur intensity to smooth the volumetric lights
  134844. */
  134845. volumetricLightBlurScale: number;
  134846. /**
  134847. * Light (spot or directional) used to generate the volumetric lights rays
  134848. * The source light must have a shadow generate so the pipeline can get its
  134849. * depth map
  134850. */
  134851. sourceLight: Nullable<SpotLight | DirectionalLight>;
  134852. /**
  134853. * For eye adaptation, represents the minimum luminance the eye can see
  134854. */
  134855. hdrMinimumLuminance: number;
  134856. /**
  134857. * For eye adaptation, represents the decrease luminance speed
  134858. */
  134859. hdrDecreaseRate: number;
  134860. /**
  134861. * For eye adaptation, represents the increase luminance speed
  134862. */
  134863. hdrIncreaseRate: number;
  134864. /**
  134865. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  134866. */
  134867. get hdrAutoExposure(): boolean;
  134868. /**
  134869. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  134870. */
  134871. set hdrAutoExposure(value: boolean);
  134872. /**
  134873. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  134874. */
  134875. lensColorTexture: Nullable<Texture>;
  134876. /**
  134877. * The overall strengh for the lens flare effect
  134878. */
  134879. lensFlareStrength: number;
  134880. /**
  134881. * Dispersion coefficient for lens flare ghosts
  134882. */
  134883. lensFlareGhostDispersal: number;
  134884. /**
  134885. * Main lens flare halo width
  134886. */
  134887. lensFlareHaloWidth: number;
  134888. /**
  134889. * Based on the lens distortion effect, defines how much the lens flare result
  134890. * is distorted
  134891. */
  134892. lensFlareDistortionStrength: number;
  134893. /**
  134894. * Configures the blur intensity used for for lens flare (halo)
  134895. */
  134896. lensFlareBlurWidth: number;
  134897. /**
  134898. * Lens star texture must be used to simulate rays on the flares and is available
  134899. * in the documentation
  134900. */
  134901. lensStarTexture: Nullable<Texture>;
  134902. /**
  134903. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  134904. * flare effect by taking account of the dirt texture
  134905. */
  134906. lensFlareDirtTexture: Nullable<Texture>;
  134907. /**
  134908. * Represents the focal length for the depth of field effect
  134909. */
  134910. depthOfFieldDistance: number;
  134911. /**
  134912. * Represents the blur intensity for the blurred part of the depth of field effect
  134913. */
  134914. depthOfFieldBlurWidth: number;
  134915. /**
  134916. * Gets how much the image is blurred by the movement while using the motion blur post-process
  134917. */
  134918. get motionStrength(): number;
  134919. /**
  134920. * Sets how much the image is blurred by the movement while using the motion blur post-process
  134921. */
  134922. set motionStrength(strength: number);
  134923. /**
  134924. * Gets wether or not the motion blur post-process is object based or screen based.
  134925. */
  134926. get objectBasedMotionBlur(): boolean;
  134927. /**
  134928. * Sets wether or not the motion blur post-process should be object based or screen based
  134929. */
  134930. set objectBasedMotionBlur(value: boolean);
  134931. /**
  134932. * List of animations for the pipeline (IAnimatable implementation)
  134933. */
  134934. animations: Animation[];
  134935. /**
  134936. * Private members
  134937. */
  134938. private _scene;
  134939. private _currentDepthOfFieldSource;
  134940. private _basePostProcess;
  134941. private _fixedExposure;
  134942. private _currentExposure;
  134943. private _hdrAutoExposure;
  134944. private _hdrCurrentLuminance;
  134945. private _motionStrength;
  134946. private _isObjectBasedMotionBlur;
  134947. private _floatTextureType;
  134948. private _camerasToBeAttached;
  134949. private _ratio;
  134950. private _bloomEnabled;
  134951. private _depthOfFieldEnabled;
  134952. private _vlsEnabled;
  134953. private _lensFlareEnabled;
  134954. private _hdrEnabled;
  134955. private _motionBlurEnabled;
  134956. private _fxaaEnabled;
  134957. private _motionBlurSamples;
  134958. private _volumetricLightStepsCount;
  134959. private _samples;
  134960. /**
  134961. * @ignore
  134962. * Specifies if the bloom pipeline is enabled
  134963. */
  134964. get BloomEnabled(): boolean;
  134965. set BloomEnabled(enabled: boolean);
  134966. /**
  134967. * @ignore
  134968. * Specifies if the depth of field pipeline is enabed
  134969. */
  134970. get DepthOfFieldEnabled(): boolean;
  134971. set DepthOfFieldEnabled(enabled: boolean);
  134972. /**
  134973. * @ignore
  134974. * Specifies if the lens flare pipeline is enabed
  134975. */
  134976. get LensFlareEnabled(): boolean;
  134977. set LensFlareEnabled(enabled: boolean);
  134978. /**
  134979. * @ignore
  134980. * Specifies if the HDR pipeline is enabled
  134981. */
  134982. get HDREnabled(): boolean;
  134983. set HDREnabled(enabled: boolean);
  134984. /**
  134985. * @ignore
  134986. * Specifies if the volumetric lights scattering effect is enabled
  134987. */
  134988. get VLSEnabled(): boolean;
  134989. set VLSEnabled(enabled: boolean);
  134990. /**
  134991. * @ignore
  134992. * Specifies if the motion blur effect is enabled
  134993. */
  134994. get MotionBlurEnabled(): boolean;
  134995. set MotionBlurEnabled(enabled: boolean);
  134996. /**
  134997. * Specifies if anti-aliasing is enabled
  134998. */
  134999. get fxaaEnabled(): boolean;
  135000. set fxaaEnabled(enabled: boolean);
  135001. /**
  135002. * Specifies the number of steps used to calculate the volumetric lights
  135003. * Typically in interval [50, 200]
  135004. */
  135005. get volumetricLightStepsCount(): number;
  135006. set volumetricLightStepsCount(count: number);
  135007. /**
  135008. * Specifies the number of samples used for the motion blur effect
  135009. * Typically in interval [16, 64]
  135010. */
  135011. get motionBlurSamples(): number;
  135012. set motionBlurSamples(samples: number);
  135013. /**
  135014. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  135015. */
  135016. get samples(): number;
  135017. set samples(sampleCount: number);
  135018. /**
  135019. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  135020. * @constructor
  135021. * @param name The rendering pipeline name
  135022. * @param scene The scene linked to this pipeline
  135023. * @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)
  135024. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  135025. * @param cameras The array of cameras that the rendering pipeline will be attached to
  135026. */
  135027. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  135028. private _buildPipeline;
  135029. private _createDownSampleX4PostProcess;
  135030. private _createBrightPassPostProcess;
  135031. private _createBlurPostProcesses;
  135032. private _createTextureAdderPostProcess;
  135033. private _createVolumetricLightPostProcess;
  135034. private _createLuminancePostProcesses;
  135035. private _createHdrPostProcess;
  135036. private _createLensFlarePostProcess;
  135037. private _createDepthOfFieldPostProcess;
  135038. private _createMotionBlurPostProcess;
  135039. private _getDepthTexture;
  135040. private _disposePostProcesses;
  135041. /**
  135042. * Dispose of the pipeline and stop all post processes
  135043. */
  135044. dispose(): void;
  135045. /**
  135046. * Serialize the rendering pipeline (Used when exporting)
  135047. * @returns the serialized object
  135048. */
  135049. serialize(): any;
  135050. /**
  135051. * Parse the serialized pipeline
  135052. * @param source Source pipeline.
  135053. * @param scene The scene to load the pipeline to.
  135054. * @param rootUrl The URL of the serialized pipeline.
  135055. * @returns An instantiated pipeline from the serialized object.
  135056. */
  135057. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  135058. /**
  135059. * Luminance steps
  135060. */
  135061. static LuminanceSteps: number;
  135062. }
  135063. }
  135064. declare module BABYLON {
  135065. /** @hidden */
  135066. export var tonemapPixelShader: {
  135067. name: string;
  135068. shader: string;
  135069. };
  135070. }
  135071. declare module BABYLON {
  135072. /** Defines operator used for tonemapping */
  135073. export enum TonemappingOperator {
  135074. /** Hable */
  135075. Hable = 0,
  135076. /** Reinhard */
  135077. Reinhard = 1,
  135078. /** HejiDawson */
  135079. HejiDawson = 2,
  135080. /** Photographic */
  135081. Photographic = 3
  135082. }
  135083. /**
  135084. * Defines a post process to apply tone mapping
  135085. */
  135086. export class TonemapPostProcess extends PostProcess {
  135087. private _operator;
  135088. /** Defines the required exposure adjustement */
  135089. exposureAdjustment: number;
  135090. /**
  135091. * Creates a new TonemapPostProcess
  135092. * @param name defines the name of the postprocess
  135093. * @param _operator defines the operator to use
  135094. * @param exposureAdjustment defines the required exposure adjustement
  135095. * @param camera defines the camera to use (can be null)
  135096. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  135097. * @param engine defines the hosting engine (can be ignore if camera is set)
  135098. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  135099. */
  135100. constructor(name: string, _operator: TonemappingOperator,
  135101. /** Defines the required exposure adjustement */
  135102. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  135103. }
  135104. }
  135105. declare module BABYLON {
  135106. /** @hidden */
  135107. export var depthVertexShader: {
  135108. name: string;
  135109. shader: string;
  135110. };
  135111. }
  135112. declare module BABYLON {
  135113. /** @hidden */
  135114. export var volumetricLightScatteringPixelShader: {
  135115. name: string;
  135116. shader: string;
  135117. };
  135118. }
  135119. declare module BABYLON {
  135120. /** @hidden */
  135121. export var volumetricLightScatteringPassVertexShader: {
  135122. name: string;
  135123. shader: string;
  135124. };
  135125. }
  135126. declare module BABYLON {
  135127. /** @hidden */
  135128. export var volumetricLightScatteringPassPixelShader: {
  135129. name: string;
  135130. shader: string;
  135131. };
  135132. }
  135133. declare module BABYLON {
  135134. /**
  135135. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  135136. */
  135137. export class VolumetricLightScatteringPostProcess extends PostProcess {
  135138. private _volumetricLightScatteringPass;
  135139. private _volumetricLightScatteringRTT;
  135140. private _viewPort;
  135141. private _screenCoordinates;
  135142. private _cachedDefines;
  135143. /**
  135144. * If not undefined, the mesh position is computed from the attached node position
  135145. */
  135146. attachedNode: {
  135147. position: Vector3;
  135148. };
  135149. /**
  135150. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  135151. */
  135152. customMeshPosition: Vector3;
  135153. /**
  135154. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  135155. */
  135156. useCustomMeshPosition: boolean;
  135157. /**
  135158. * If the post-process should inverse the light scattering direction
  135159. */
  135160. invert: boolean;
  135161. /**
  135162. * The internal mesh used by the post-process
  135163. */
  135164. mesh: Mesh;
  135165. /**
  135166. * @hidden
  135167. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  135168. */
  135169. get useDiffuseColor(): boolean;
  135170. set useDiffuseColor(useDiffuseColor: boolean);
  135171. /**
  135172. * Array containing the excluded meshes not rendered in the internal pass
  135173. */
  135174. excludedMeshes: AbstractMesh[];
  135175. /**
  135176. * Controls the overall intensity of the post-process
  135177. */
  135178. exposure: number;
  135179. /**
  135180. * Dissipates each sample's contribution in range [0, 1]
  135181. */
  135182. decay: number;
  135183. /**
  135184. * Controls the overall intensity of each sample
  135185. */
  135186. weight: number;
  135187. /**
  135188. * Controls the density of each sample
  135189. */
  135190. density: number;
  135191. /**
  135192. * @constructor
  135193. * @param name The post-process name
  135194. * @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)
  135195. * @param camera The camera that the post-process will be attached to
  135196. * @param mesh The mesh used to create the light scattering
  135197. * @param samples The post-process quality, default 100
  135198. * @param samplingModeThe post-process filtering mode
  135199. * @param engine The babylon engine
  135200. * @param reusable If the post-process is reusable
  135201. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  135202. */
  135203. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  135204. /**
  135205. * Returns the string "VolumetricLightScatteringPostProcess"
  135206. * @returns "VolumetricLightScatteringPostProcess"
  135207. */
  135208. getClassName(): string;
  135209. private _isReady;
  135210. /**
  135211. * Sets the new light position for light scattering effect
  135212. * @param position The new custom light position
  135213. */
  135214. setCustomMeshPosition(position: Vector3): void;
  135215. /**
  135216. * Returns the light position for light scattering effect
  135217. * @return Vector3 The custom light position
  135218. */
  135219. getCustomMeshPosition(): Vector3;
  135220. /**
  135221. * Disposes the internal assets and detaches the post-process from the camera
  135222. */
  135223. dispose(camera: Camera): void;
  135224. /**
  135225. * Returns the render target texture used by the post-process
  135226. * @return the render target texture used by the post-process
  135227. */
  135228. getPass(): RenderTargetTexture;
  135229. private _meshExcluded;
  135230. private _createPass;
  135231. private _updateMeshScreenCoordinates;
  135232. /**
  135233. * Creates a default mesh for the Volumeric Light Scattering post-process
  135234. * @param name The mesh name
  135235. * @param scene The scene where to create the mesh
  135236. * @return the default mesh
  135237. */
  135238. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  135239. }
  135240. }
  135241. declare module BABYLON {
  135242. interface Scene {
  135243. /** @hidden (Backing field) */
  135244. _boundingBoxRenderer: BoundingBoxRenderer;
  135245. /** @hidden (Backing field) */
  135246. _forceShowBoundingBoxes: boolean;
  135247. /**
  135248. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  135249. */
  135250. forceShowBoundingBoxes: boolean;
  135251. /**
  135252. * Gets the bounding box renderer associated with the scene
  135253. * @returns a BoundingBoxRenderer
  135254. */
  135255. getBoundingBoxRenderer(): BoundingBoxRenderer;
  135256. }
  135257. interface AbstractMesh {
  135258. /** @hidden (Backing field) */
  135259. _showBoundingBox: boolean;
  135260. /**
  135261. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  135262. */
  135263. showBoundingBox: boolean;
  135264. }
  135265. /**
  135266. * Component responsible of rendering the bounding box of the meshes in a scene.
  135267. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  135268. */
  135269. export class BoundingBoxRenderer implements ISceneComponent {
  135270. /**
  135271. * The component name helpfull to identify the component in the list of scene components.
  135272. */
  135273. readonly name: string;
  135274. /**
  135275. * The scene the component belongs to.
  135276. */
  135277. scene: Scene;
  135278. /**
  135279. * Color of the bounding box lines placed in front of an object
  135280. */
  135281. frontColor: Color3;
  135282. /**
  135283. * Color of the bounding box lines placed behind an object
  135284. */
  135285. backColor: Color3;
  135286. /**
  135287. * Defines if the renderer should show the back lines or not
  135288. */
  135289. showBackLines: boolean;
  135290. /**
  135291. * @hidden
  135292. */
  135293. renderList: SmartArray<BoundingBox>;
  135294. private _colorShader;
  135295. private _vertexBuffers;
  135296. private _indexBuffer;
  135297. private _fillIndexBuffer;
  135298. private _fillIndexData;
  135299. /**
  135300. * Instantiates a new bounding box renderer in a scene.
  135301. * @param scene the scene the renderer renders in
  135302. */
  135303. constructor(scene: Scene);
  135304. /**
  135305. * Registers the component in a given scene
  135306. */
  135307. register(): void;
  135308. private _evaluateSubMesh;
  135309. private _activeMesh;
  135310. private _prepareRessources;
  135311. private _createIndexBuffer;
  135312. /**
  135313. * Rebuilds the elements related to this component in case of
  135314. * context lost for instance.
  135315. */
  135316. rebuild(): void;
  135317. /**
  135318. * @hidden
  135319. */
  135320. reset(): void;
  135321. /**
  135322. * Render the bounding boxes of a specific rendering group
  135323. * @param renderingGroupId defines the rendering group to render
  135324. */
  135325. render(renderingGroupId: number): void;
  135326. /**
  135327. * In case of occlusion queries, we can render the occlusion bounding box through this method
  135328. * @param mesh Define the mesh to render the occlusion bounding box for
  135329. */
  135330. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  135331. /**
  135332. * Dispose and release the resources attached to this renderer.
  135333. */
  135334. dispose(): void;
  135335. }
  135336. }
  135337. declare module BABYLON {
  135338. /** @hidden */
  135339. export var depthPixelShader: {
  135340. name: string;
  135341. shader: string;
  135342. };
  135343. }
  135344. declare module BABYLON {
  135345. /**
  135346. * This represents a depth renderer in Babylon.
  135347. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  135348. */
  135349. export class DepthRenderer {
  135350. private _scene;
  135351. private _depthMap;
  135352. private _effect;
  135353. private readonly _storeNonLinearDepth;
  135354. private readonly _clearColor;
  135355. /** Get if the depth renderer is using packed depth or not */
  135356. readonly isPacked: boolean;
  135357. private _cachedDefines;
  135358. private _camera;
  135359. /**
  135360. * Specifiess that the depth renderer will only be used within
  135361. * the camera it is created for.
  135362. * This can help forcing its rendering during the camera processing.
  135363. */
  135364. useOnlyInActiveCamera: boolean;
  135365. /** @hidden */
  135366. static _SceneComponentInitialization: (scene: Scene) => void;
  135367. /**
  135368. * Instantiates a depth renderer
  135369. * @param scene The scene the renderer belongs to
  135370. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  135371. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  135372. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  135373. */
  135374. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  135375. /**
  135376. * Creates the depth rendering effect and checks if the effect is ready.
  135377. * @param subMesh The submesh to be used to render the depth map of
  135378. * @param useInstances If multiple world instances should be used
  135379. * @returns if the depth renderer is ready to render the depth map
  135380. */
  135381. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135382. /**
  135383. * Gets the texture which the depth map will be written to.
  135384. * @returns The depth map texture
  135385. */
  135386. getDepthMap(): RenderTargetTexture;
  135387. /**
  135388. * Disposes of the depth renderer.
  135389. */
  135390. dispose(): void;
  135391. }
  135392. }
  135393. declare module BABYLON {
  135394. interface Scene {
  135395. /** @hidden (Backing field) */
  135396. _depthRenderer: {
  135397. [id: string]: DepthRenderer;
  135398. };
  135399. /**
  135400. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  135401. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  135402. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  135403. * @returns the created depth renderer
  135404. */
  135405. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  135406. /**
  135407. * Disables a depth renderer for a given camera
  135408. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  135409. */
  135410. disableDepthRenderer(camera?: Nullable<Camera>): void;
  135411. }
  135412. /**
  135413. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  135414. * in several rendering techniques.
  135415. */
  135416. export class DepthRendererSceneComponent implements ISceneComponent {
  135417. /**
  135418. * The component name helpfull to identify the component in the list of scene components.
  135419. */
  135420. readonly name: string;
  135421. /**
  135422. * The scene the component belongs to.
  135423. */
  135424. scene: Scene;
  135425. /**
  135426. * Creates a new instance of the component for the given scene
  135427. * @param scene Defines the scene to register the component in
  135428. */
  135429. constructor(scene: Scene);
  135430. /**
  135431. * Registers the component in a given scene
  135432. */
  135433. register(): void;
  135434. /**
  135435. * Rebuilds the elements related to this component in case of
  135436. * context lost for instance.
  135437. */
  135438. rebuild(): void;
  135439. /**
  135440. * Disposes the component and the associated ressources
  135441. */
  135442. dispose(): void;
  135443. private _gatherRenderTargets;
  135444. private _gatherActiveCameraRenderTargets;
  135445. }
  135446. }
  135447. declare module BABYLON {
  135448. /** @hidden */
  135449. export var outlinePixelShader: {
  135450. name: string;
  135451. shader: string;
  135452. };
  135453. }
  135454. declare module BABYLON {
  135455. /** @hidden */
  135456. export var outlineVertexShader: {
  135457. name: string;
  135458. shader: string;
  135459. };
  135460. }
  135461. declare module BABYLON {
  135462. interface Scene {
  135463. /** @hidden */
  135464. _outlineRenderer: OutlineRenderer;
  135465. /**
  135466. * Gets the outline renderer associated with the scene
  135467. * @returns a OutlineRenderer
  135468. */
  135469. getOutlineRenderer(): OutlineRenderer;
  135470. }
  135471. interface AbstractMesh {
  135472. /** @hidden (Backing field) */
  135473. _renderOutline: boolean;
  135474. /**
  135475. * Gets or sets a boolean indicating if the outline must be rendered as well
  135476. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  135477. */
  135478. renderOutline: boolean;
  135479. /** @hidden (Backing field) */
  135480. _renderOverlay: boolean;
  135481. /**
  135482. * Gets or sets a boolean indicating if the overlay must be rendered as well
  135483. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  135484. */
  135485. renderOverlay: boolean;
  135486. }
  135487. /**
  135488. * This class is responsible to draw bothe outline/overlay of meshes.
  135489. * It should not be used directly but through the available method on mesh.
  135490. */
  135491. export class OutlineRenderer implements ISceneComponent {
  135492. /**
  135493. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  135494. */
  135495. private static _StencilReference;
  135496. /**
  135497. * The name of the component. Each component must have a unique name.
  135498. */
  135499. name: string;
  135500. /**
  135501. * The scene the component belongs to.
  135502. */
  135503. scene: Scene;
  135504. /**
  135505. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  135506. */
  135507. zOffset: number;
  135508. private _engine;
  135509. private _effect;
  135510. private _cachedDefines;
  135511. private _savedDepthWrite;
  135512. /**
  135513. * Instantiates a new outline renderer. (There could be only one per scene).
  135514. * @param scene Defines the scene it belongs to
  135515. */
  135516. constructor(scene: Scene);
  135517. /**
  135518. * Register the component to one instance of a scene.
  135519. */
  135520. register(): void;
  135521. /**
  135522. * Rebuilds the elements related to this component in case of
  135523. * context lost for instance.
  135524. */
  135525. rebuild(): void;
  135526. /**
  135527. * Disposes the component and the associated ressources.
  135528. */
  135529. dispose(): void;
  135530. /**
  135531. * Renders the outline in the canvas.
  135532. * @param subMesh Defines the sumesh to render
  135533. * @param batch Defines the batch of meshes in case of instances
  135534. * @param useOverlay Defines if the rendering is for the overlay or the outline
  135535. */
  135536. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  135537. /**
  135538. * Returns whether or not the outline renderer is ready for a given submesh.
  135539. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  135540. * @param subMesh Defines the submesh to check readyness for
  135541. * @param useInstances Defines wheter wee are trying to render instances or not
  135542. * @returns true if ready otherwise false
  135543. */
  135544. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135545. private _beforeRenderingMesh;
  135546. private _afterRenderingMesh;
  135547. }
  135548. }
  135549. declare module BABYLON {
  135550. /**
  135551. * Defines the basic options interface of a Sprite Frame Source Size.
  135552. */
  135553. export interface ISpriteJSONSpriteSourceSize {
  135554. /**
  135555. * number of the original width of the Frame
  135556. */
  135557. w: number;
  135558. /**
  135559. * number of the original height of the Frame
  135560. */
  135561. h: number;
  135562. }
  135563. /**
  135564. * Defines the basic options interface of a Sprite Frame Data.
  135565. */
  135566. export interface ISpriteJSONSpriteFrameData {
  135567. /**
  135568. * number of the x offset of the Frame
  135569. */
  135570. x: number;
  135571. /**
  135572. * number of the y offset of the Frame
  135573. */
  135574. y: number;
  135575. /**
  135576. * number of the width of the Frame
  135577. */
  135578. w: number;
  135579. /**
  135580. * number of the height of the Frame
  135581. */
  135582. h: number;
  135583. }
  135584. /**
  135585. * Defines the basic options interface of a JSON Sprite.
  135586. */
  135587. export interface ISpriteJSONSprite {
  135588. /**
  135589. * string name of the Frame
  135590. */
  135591. filename: string;
  135592. /**
  135593. * ISpriteJSONSpriteFrame basic object of the frame data
  135594. */
  135595. frame: ISpriteJSONSpriteFrameData;
  135596. /**
  135597. * boolean to flag is the frame was rotated.
  135598. */
  135599. rotated: boolean;
  135600. /**
  135601. * boolean to flag is the frame was trimmed.
  135602. */
  135603. trimmed: boolean;
  135604. /**
  135605. * ISpriteJSONSpriteFrame basic object of the source data
  135606. */
  135607. spriteSourceSize: ISpriteJSONSpriteFrameData;
  135608. /**
  135609. * ISpriteJSONSpriteFrame basic object of the source data
  135610. */
  135611. sourceSize: ISpriteJSONSpriteSourceSize;
  135612. }
  135613. /**
  135614. * Defines the basic options interface of a JSON atlas.
  135615. */
  135616. export interface ISpriteJSONAtlas {
  135617. /**
  135618. * Array of objects that contain the frame data.
  135619. */
  135620. frames: Array<ISpriteJSONSprite>;
  135621. /**
  135622. * object basic object containing the sprite meta data.
  135623. */
  135624. meta?: object;
  135625. }
  135626. }
  135627. declare module BABYLON {
  135628. /** @hidden */
  135629. export var spriteMapPixelShader: {
  135630. name: string;
  135631. shader: string;
  135632. };
  135633. }
  135634. declare module BABYLON {
  135635. /** @hidden */
  135636. export var spriteMapVertexShader: {
  135637. name: string;
  135638. shader: string;
  135639. };
  135640. }
  135641. declare module BABYLON {
  135642. /**
  135643. * Defines the basic options interface of a SpriteMap
  135644. */
  135645. export interface ISpriteMapOptions {
  135646. /**
  135647. * Vector2 of the number of cells in the grid.
  135648. */
  135649. stageSize?: Vector2;
  135650. /**
  135651. * Vector2 of the size of the output plane in World Units.
  135652. */
  135653. outputSize?: Vector2;
  135654. /**
  135655. * Vector3 of the position of the output plane in World Units.
  135656. */
  135657. outputPosition?: Vector3;
  135658. /**
  135659. * Vector3 of the rotation of the output plane.
  135660. */
  135661. outputRotation?: Vector3;
  135662. /**
  135663. * number of layers that the system will reserve in resources.
  135664. */
  135665. layerCount?: number;
  135666. /**
  135667. * number of max animation frames a single cell will reserve in resources.
  135668. */
  135669. maxAnimationFrames?: number;
  135670. /**
  135671. * number cell index of the base tile when the system compiles.
  135672. */
  135673. baseTile?: number;
  135674. /**
  135675. * boolean flip the sprite after its been repositioned by the framing data.
  135676. */
  135677. flipU?: boolean;
  135678. /**
  135679. * Vector3 scalar of the global RGB values of the SpriteMap.
  135680. */
  135681. colorMultiply?: Vector3;
  135682. }
  135683. /**
  135684. * Defines the IDisposable interface in order to be cleanable from resources.
  135685. */
  135686. export interface ISpriteMap extends IDisposable {
  135687. /**
  135688. * String name of the SpriteMap.
  135689. */
  135690. name: string;
  135691. /**
  135692. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  135693. */
  135694. atlasJSON: ISpriteJSONAtlas;
  135695. /**
  135696. * Texture of the SpriteMap.
  135697. */
  135698. spriteSheet: Texture;
  135699. /**
  135700. * The parameters to initialize the SpriteMap with.
  135701. */
  135702. options: ISpriteMapOptions;
  135703. }
  135704. /**
  135705. * Class used to manage a grid restricted sprite deployment on an Output plane.
  135706. */
  135707. export class SpriteMap implements ISpriteMap {
  135708. /** The Name of the spriteMap */
  135709. name: string;
  135710. /** The JSON file with the frame and meta data */
  135711. atlasJSON: ISpriteJSONAtlas;
  135712. /** The systems Sprite Sheet Texture */
  135713. spriteSheet: Texture;
  135714. /** Arguments passed with the Constructor */
  135715. options: ISpriteMapOptions;
  135716. /** Public Sprite Storage array, parsed from atlasJSON */
  135717. sprites: Array<ISpriteJSONSprite>;
  135718. /** Returns the Number of Sprites in the System */
  135719. get spriteCount(): number;
  135720. /** Returns the Position of Output Plane*/
  135721. get position(): Vector3;
  135722. /** Returns the Position of Output Plane*/
  135723. set position(v: Vector3);
  135724. /** Returns the Rotation of Output Plane*/
  135725. get rotation(): Vector3;
  135726. /** Returns the Rotation of Output Plane*/
  135727. set rotation(v: Vector3);
  135728. /** Sets the AnimationMap*/
  135729. get animationMap(): RawTexture;
  135730. /** Sets the AnimationMap*/
  135731. set animationMap(v: RawTexture);
  135732. /** Scene that the SpriteMap was created in */
  135733. private _scene;
  135734. /** Texture Buffer of Float32 that holds tile frame data*/
  135735. private _frameMap;
  135736. /** Texture Buffers of Float32 that holds tileMap data*/
  135737. private _tileMaps;
  135738. /** Texture Buffer of Float32 that holds Animation Data*/
  135739. private _animationMap;
  135740. /** Custom ShaderMaterial Central to the System*/
  135741. private _material;
  135742. /** Custom ShaderMaterial Central to the System*/
  135743. private _output;
  135744. /** Systems Time Ticker*/
  135745. private _time;
  135746. /**
  135747. * Creates a new SpriteMap
  135748. * @param name defines the SpriteMaps Name
  135749. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  135750. * @param spriteSheet is the Texture that the Sprites are on.
  135751. * @param options a basic deployment configuration
  135752. * @param scene The Scene that the map is deployed on
  135753. */
  135754. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  135755. /**
  135756. * Returns tileID location
  135757. * @returns Vector2 the cell position ID
  135758. */
  135759. getTileID(): Vector2;
  135760. /**
  135761. * Gets the UV location of the mouse over the SpriteMap.
  135762. * @returns Vector2 the UV position of the mouse interaction
  135763. */
  135764. getMousePosition(): Vector2;
  135765. /**
  135766. * Creates the "frame" texture Buffer
  135767. * -------------------------------------
  135768. * Structure of frames
  135769. * "filename": "Falling-Water-2.png",
  135770. * "frame": {"x":69,"y":103,"w":24,"h":32},
  135771. * "rotated": true,
  135772. * "trimmed": true,
  135773. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  135774. * "sourceSize": {"w":32,"h":32}
  135775. * @returns RawTexture of the frameMap
  135776. */
  135777. private _createFrameBuffer;
  135778. /**
  135779. * Creates the tileMap texture Buffer
  135780. * @param buffer normally and array of numbers, or a false to generate from scratch
  135781. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  135782. * @returns RawTexture of the tileMap
  135783. */
  135784. private _createTileBuffer;
  135785. /**
  135786. * Modifies the data of the tileMaps
  135787. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  135788. * @param pos is the iVector2 Coordinates of the Tile
  135789. * @param tile The SpriteIndex of the new Tile
  135790. */
  135791. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  135792. /**
  135793. * Creates the animationMap texture Buffer
  135794. * @param buffer normally and array of numbers, or a false to generate from scratch
  135795. * @returns RawTexture of the animationMap
  135796. */
  135797. private _createTileAnimationBuffer;
  135798. /**
  135799. * Modifies the data of the animationMap
  135800. * @param cellID is the Index of the Sprite
  135801. * @param _frame is the target Animation frame
  135802. * @param toCell is the Target Index of the next frame of the animation
  135803. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  135804. * @param speed is a global scalar of the time variable on the map.
  135805. */
  135806. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  135807. /**
  135808. * Exports the .tilemaps file
  135809. */
  135810. saveTileMaps(): void;
  135811. /**
  135812. * Imports the .tilemaps file
  135813. * @param url of the .tilemaps file
  135814. */
  135815. loadTileMaps(url: string): void;
  135816. /**
  135817. * Release associated resources
  135818. */
  135819. dispose(): void;
  135820. }
  135821. }
  135822. declare module BABYLON {
  135823. /**
  135824. * Class used to manage multiple sprites of different sizes on the same spritesheet
  135825. * @see http://doc.babylonjs.com/babylon101/sprites
  135826. */
  135827. export class SpritePackedManager extends SpriteManager {
  135828. /** defines the packed manager's name */
  135829. name: string;
  135830. /**
  135831. * Creates a new sprite manager from a packed sprite sheet
  135832. * @param name defines the manager's name
  135833. * @param imgUrl defines the sprite sheet url
  135834. * @param capacity defines the maximum allowed number of sprites
  135835. * @param scene defines the hosting scene
  135836. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  135837. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  135838. * @param samplingMode defines the smapling mode to use with spritesheet
  135839. * @param fromPacked set to true; do not alter
  135840. */
  135841. constructor(
  135842. /** defines the packed manager's name */
  135843. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  135844. }
  135845. }
  135846. declare module BABYLON {
  135847. /**
  135848. * Defines the list of states available for a task inside a AssetsManager
  135849. */
  135850. export enum AssetTaskState {
  135851. /**
  135852. * Initialization
  135853. */
  135854. INIT = 0,
  135855. /**
  135856. * Running
  135857. */
  135858. RUNNING = 1,
  135859. /**
  135860. * Done
  135861. */
  135862. DONE = 2,
  135863. /**
  135864. * Error
  135865. */
  135866. ERROR = 3
  135867. }
  135868. /**
  135869. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  135870. */
  135871. export abstract class AbstractAssetTask {
  135872. /**
  135873. * Task name
  135874. */ name: string;
  135875. /**
  135876. * Callback called when the task is successful
  135877. */
  135878. onSuccess: (task: any) => void;
  135879. /**
  135880. * Callback called when the task is not successful
  135881. */
  135882. onError: (task: any, message?: string, exception?: any) => void;
  135883. /**
  135884. * Creates a new AssetsManager
  135885. * @param name defines the name of the task
  135886. */
  135887. constructor(
  135888. /**
  135889. * Task name
  135890. */ name: string);
  135891. private _isCompleted;
  135892. private _taskState;
  135893. private _errorObject;
  135894. /**
  135895. * Get if the task is completed
  135896. */
  135897. get isCompleted(): boolean;
  135898. /**
  135899. * Gets the current state of the task
  135900. */
  135901. get taskState(): AssetTaskState;
  135902. /**
  135903. * Gets the current error object (if task is in error)
  135904. */
  135905. get errorObject(): {
  135906. message?: string;
  135907. exception?: any;
  135908. };
  135909. /**
  135910. * Internal only
  135911. * @hidden
  135912. */
  135913. _setErrorObject(message?: string, exception?: any): void;
  135914. /**
  135915. * Execute the current task
  135916. * @param scene defines the scene where you want your assets to be loaded
  135917. * @param onSuccess is a callback called when the task is successfully executed
  135918. * @param onError is a callback called if an error occurs
  135919. */
  135920. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  135921. /**
  135922. * Execute the current task
  135923. * @param scene defines the scene where you want your assets to be loaded
  135924. * @param onSuccess is a callback called when the task is successfully executed
  135925. * @param onError is a callback called if an error occurs
  135926. */
  135927. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  135928. /**
  135929. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  135930. * This can be used with failed tasks that have the reason for failure fixed.
  135931. */
  135932. reset(): void;
  135933. private onErrorCallback;
  135934. private onDoneCallback;
  135935. }
  135936. /**
  135937. * Define the interface used by progress events raised during assets loading
  135938. */
  135939. export interface IAssetsProgressEvent {
  135940. /**
  135941. * Defines the number of remaining tasks to process
  135942. */
  135943. remainingCount: number;
  135944. /**
  135945. * Defines the total number of tasks
  135946. */
  135947. totalCount: number;
  135948. /**
  135949. * Defines the task that was just processed
  135950. */
  135951. task: AbstractAssetTask;
  135952. }
  135953. /**
  135954. * Class used to share progress information about assets loading
  135955. */
  135956. export class AssetsProgressEvent implements IAssetsProgressEvent {
  135957. /**
  135958. * Defines the number of remaining tasks to process
  135959. */
  135960. remainingCount: number;
  135961. /**
  135962. * Defines the total number of tasks
  135963. */
  135964. totalCount: number;
  135965. /**
  135966. * Defines the task that was just processed
  135967. */
  135968. task: AbstractAssetTask;
  135969. /**
  135970. * Creates a AssetsProgressEvent
  135971. * @param remainingCount defines the number of remaining tasks to process
  135972. * @param totalCount defines the total number of tasks
  135973. * @param task defines the task that was just processed
  135974. */
  135975. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  135976. }
  135977. /**
  135978. * Define a task used by AssetsManager to load meshes
  135979. */
  135980. export class MeshAssetTask extends AbstractAssetTask {
  135981. /**
  135982. * Defines the name of the task
  135983. */
  135984. name: string;
  135985. /**
  135986. * Defines the list of mesh's names you want to load
  135987. */
  135988. meshesNames: any;
  135989. /**
  135990. * Defines the root url to use as a base to load your meshes and associated resources
  135991. */
  135992. rootUrl: string;
  135993. /**
  135994. * Defines the filename of the scene to load from
  135995. */
  135996. sceneFilename: string;
  135997. /**
  135998. * Gets the list of loaded meshes
  135999. */
  136000. loadedMeshes: Array<AbstractMesh>;
  136001. /**
  136002. * Gets the list of loaded particle systems
  136003. */
  136004. loadedParticleSystems: Array<IParticleSystem>;
  136005. /**
  136006. * Gets the list of loaded skeletons
  136007. */
  136008. loadedSkeletons: Array<Skeleton>;
  136009. /**
  136010. * Gets the list of loaded animation groups
  136011. */
  136012. loadedAnimationGroups: Array<AnimationGroup>;
  136013. /**
  136014. * Callback called when the task is successful
  136015. */
  136016. onSuccess: (task: MeshAssetTask) => void;
  136017. /**
  136018. * Callback called when the task is successful
  136019. */
  136020. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  136021. /**
  136022. * Creates a new MeshAssetTask
  136023. * @param name defines the name of the task
  136024. * @param meshesNames defines the list of mesh's names you want to load
  136025. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  136026. * @param sceneFilename defines the filename of the scene to load from
  136027. */
  136028. constructor(
  136029. /**
  136030. * Defines the name of the task
  136031. */
  136032. name: string,
  136033. /**
  136034. * Defines the list of mesh's names you want to load
  136035. */
  136036. meshesNames: any,
  136037. /**
  136038. * Defines the root url to use as a base to load your meshes and associated resources
  136039. */
  136040. rootUrl: string,
  136041. /**
  136042. * Defines the filename of the scene to load from
  136043. */
  136044. sceneFilename: string);
  136045. /**
  136046. * Execute the current task
  136047. * @param scene defines the scene where you want your assets to be loaded
  136048. * @param onSuccess is a callback called when the task is successfully executed
  136049. * @param onError is a callback called if an error occurs
  136050. */
  136051. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136052. }
  136053. /**
  136054. * Define a task used by AssetsManager to load text content
  136055. */
  136056. export class TextFileAssetTask extends AbstractAssetTask {
  136057. /**
  136058. * Defines the name of the task
  136059. */
  136060. name: string;
  136061. /**
  136062. * Defines the location of the file to load
  136063. */
  136064. url: string;
  136065. /**
  136066. * Gets the loaded text string
  136067. */
  136068. text: string;
  136069. /**
  136070. * Callback called when the task is successful
  136071. */
  136072. onSuccess: (task: TextFileAssetTask) => void;
  136073. /**
  136074. * Callback called when the task is successful
  136075. */
  136076. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  136077. /**
  136078. * Creates a new TextFileAssetTask object
  136079. * @param name defines the name of the task
  136080. * @param url defines the location of the file to load
  136081. */
  136082. constructor(
  136083. /**
  136084. * Defines the name of the task
  136085. */
  136086. name: string,
  136087. /**
  136088. * Defines the location of the file to load
  136089. */
  136090. url: string);
  136091. /**
  136092. * Execute the current task
  136093. * @param scene defines the scene where you want your assets to be loaded
  136094. * @param onSuccess is a callback called when the task is successfully executed
  136095. * @param onError is a callback called if an error occurs
  136096. */
  136097. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136098. }
  136099. /**
  136100. * Define a task used by AssetsManager to load binary data
  136101. */
  136102. export class BinaryFileAssetTask extends AbstractAssetTask {
  136103. /**
  136104. * Defines the name of the task
  136105. */
  136106. name: string;
  136107. /**
  136108. * Defines the location of the file to load
  136109. */
  136110. url: string;
  136111. /**
  136112. * Gets the lodaded data (as an array buffer)
  136113. */
  136114. data: ArrayBuffer;
  136115. /**
  136116. * Callback called when the task is successful
  136117. */
  136118. onSuccess: (task: BinaryFileAssetTask) => void;
  136119. /**
  136120. * Callback called when the task is successful
  136121. */
  136122. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  136123. /**
  136124. * Creates a new BinaryFileAssetTask object
  136125. * @param name defines the name of the new task
  136126. * @param url defines the location of the file to load
  136127. */
  136128. constructor(
  136129. /**
  136130. * Defines the name of the task
  136131. */
  136132. name: string,
  136133. /**
  136134. * Defines the location of the file to load
  136135. */
  136136. url: string);
  136137. /**
  136138. * Execute the current task
  136139. * @param scene defines the scene where you want your assets to be loaded
  136140. * @param onSuccess is a callback called when the task is successfully executed
  136141. * @param onError is a callback called if an error occurs
  136142. */
  136143. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136144. }
  136145. /**
  136146. * Define a task used by AssetsManager to load images
  136147. */
  136148. export class ImageAssetTask extends AbstractAssetTask {
  136149. /**
  136150. * Defines the name of the task
  136151. */
  136152. name: string;
  136153. /**
  136154. * Defines the location of the image to load
  136155. */
  136156. url: string;
  136157. /**
  136158. * Gets the loaded images
  136159. */
  136160. image: HTMLImageElement;
  136161. /**
  136162. * Callback called when the task is successful
  136163. */
  136164. onSuccess: (task: ImageAssetTask) => void;
  136165. /**
  136166. * Callback called when the task is successful
  136167. */
  136168. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  136169. /**
  136170. * Creates a new ImageAssetTask
  136171. * @param name defines the name of the task
  136172. * @param url defines the location of the image to load
  136173. */
  136174. constructor(
  136175. /**
  136176. * Defines the name of the task
  136177. */
  136178. name: string,
  136179. /**
  136180. * Defines the location of the image to load
  136181. */
  136182. url: string);
  136183. /**
  136184. * Execute the current task
  136185. * @param scene defines the scene where you want your assets to be loaded
  136186. * @param onSuccess is a callback called when the task is successfully executed
  136187. * @param onError is a callback called if an error occurs
  136188. */
  136189. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136190. }
  136191. /**
  136192. * Defines the interface used by texture loading tasks
  136193. */
  136194. export interface ITextureAssetTask<TEX extends BaseTexture> {
  136195. /**
  136196. * Gets the loaded texture
  136197. */
  136198. texture: TEX;
  136199. }
  136200. /**
  136201. * Define a task used by AssetsManager to load 2D textures
  136202. */
  136203. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  136204. /**
  136205. * Defines the name of the task
  136206. */
  136207. name: string;
  136208. /**
  136209. * Defines the location of the file to load
  136210. */
  136211. url: string;
  136212. /**
  136213. * Defines if mipmap should not be generated (default is false)
  136214. */
  136215. noMipmap?: boolean | undefined;
  136216. /**
  136217. * Defines if texture must be inverted on Y axis (default is false)
  136218. */
  136219. invertY?: boolean | undefined;
  136220. /**
  136221. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  136222. */
  136223. samplingMode: number;
  136224. /**
  136225. * Gets the loaded texture
  136226. */
  136227. texture: Texture;
  136228. /**
  136229. * Callback called when the task is successful
  136230. */
  136231. onSuccess: (task: TextureAssetTask) => void;
  136232. /**
  136233. * Callback called when the task is successful
  136234. */
  136235. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  136236. /**
  136237. * Creates a new TextureAssetTask object
  136238. * @param name defines the name of the task
  136239. * @param url defines the location of the file to load
  136240. * @param noMipmap defines if mipmap should not be generated (default is false)
  136241. * @param invertY defines if texture must be inverted on Y axis (default is false)
  136242. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  136243. */
  136244. constructor(
  136245. /**
  136246. * Defines the name of the task
  136247. */
  136248. name: string,
  136249. /**
  136250. * Defines the location of the file to load
  136251. */
  136252. url: string,
  136253. /**
  136254. * Defines if mipmap should not be generated (default is false)
  136255. */
  136256. noMipmap?: boolean | undefined,
  136257. /**
  136258. * Defines if texture must be inverted on Y axis (default is false)
  136259. */
  136260. invertY?: boolean | undefined,
  136261. /**
  136262. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  136263. */
  136264. samplingMode?: number);
  136265. /**
  136266. * Execute the current task
  136267. * @param scene defines the scene where you want your assets to be loaded
  136268. * @param onSuccess is a callback called when the task is successfully executed
  136269. * @param onError is a callback called if an error occurs
  136270. */
  136271. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136272. }
  136273. /**
  136274. * Define a task used by AssetsManager to load cube textures
  136275. */
  136276. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  136277. /**
  136278. * Defines the name of the task
  136279. */
  136280. name: string;
  136281. /**
  136282. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  136283. */
  136284. url: string;
  136285. /**
  136286. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  136287. */
  136288. extensions?: string[] | undefined;
  136289. /**
  136290. * Defines if mipmaps should not be generated (default is false)
  136291. */
  136292. noMipmap?: boolean | undefined;
  136293. /**
  136294. * Defines the explicit list of files (undefined by default)
  136295. */
  136296. files?: string[] | undefined;
  136297. /**
  136298. * Gets the loaded texture
  136299. */
  136300. texture: CubeTexture;
  136301. /**
  136302. * Callback called when the task is successful
  136303. */
  136304. onSuccess: (task: CubeTextureAssetTask) => void;
  136305. /**
  136306. * Callback called when the task is successful
  136307. */
  136308. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  136309. /**
  136310. * Creates a new CubeTextureAssetTask
  136311. * @param name defines the name of the task
  136312. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  136313. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  136314. * @param noMipmap defines if mipmaps should not be generated (default is false)
  136315. * @param files defines the explicit list of files (undefined by default)
  136316. */
  136317. constructor(
  136318. /**
  136319. * Defines the name of the task
  136320. */
  136321. name: string,
  136322. /**
  136323. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  136324. */
  136325. url: string,
  136326. /**
  136327. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  136328. */
  136329. extensions?: string[] | undefined,
  136330. /**
  136331. * Defines if mipmaps should not be generated (default is false)
  136332. */
  136333. noMipmap?: boolean | undefined,
  136334. /**
  136335. * Defines the explicit list of files (undefined by default)
  136336. */
  136337. files?: string[] | undefined);
  136338. /**
  136339. * Execute the current task
  136340. * @param scene defines the scene where you want your assets to be loaded
  136341. * @param onSuccess is a callback called when the task is successfully executed
  136342. * @param onError is a callback called if an error occurs
  136343. */
  136344. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136345. }
  136346. /**
  136347. * Define a task used by AssetsManager to load HDR cube textures
  136348. */
  136349. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  136350. /**
  136351. * Defines the name of the task
  136352. */
  136353. name: string;
  136354. /**
  136355. * Defines the location of the file to load
  136356. */
  136357. url: string;
  136358. /**
  136359. * Defines the desired size (the more it increases the longer the generation will be)
  136360. */
  136361. size: number;
  136362. /**
  136363. * Defines if mipmaps should not be generated (default is false)
  136364. */
  136365. noMipmap: boolean;
  136366. /**
  136367. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  136368. */
  136369. generateHarmonics: boolean;
  136370. /**
  136371. * 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)
  136372. */
  136373. gammaSpace: boolean;
  136374. /**
  136375. * Internal Use Only
  136376. */
  136377. reserved: boolean;
  136378. /**
  136379. * Gets the loaded texture
  136380. */
  136381. texture: HDRCubeTexture;
  136382. /**
  136383. * Callback called when the task is successful
  136384. */
  136385. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  136386. /**
  136387. * Callback called when the task is successful
  136388. */
  136389. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  136390. /**
  136391. * Creates a new HDRCubeTextureAssetTask object
  136392. * @param name defines the name of the task
  136393. * @param url defines the location of the file to load
  136394. * @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.
  136395. * @param noMipmap defines if mipmaps should not be generated (default is false)
  136396. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  136397. * @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)
  136398. * @param reserved Internal use only
  136399. */
  136400. constructor(
  136401. /**
  136402. * Defines the name of the task
  136403. */
  136404. name: string,
  136405. /**
  136406. * Defines the location of the file to load
  136407. */
  136408. url: string,
  136409. /**
  136410. * Defines the desired size (the more it increases the longer the generation will be)
  136411. */
  136412. size: number,
  136413. /**
  136414. * Defines if mipmaps should not be generated (default is false)
  136415. */
  136416. noMipmap?: boolean,
  136417. /**
  136418. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  136419. */
  136420. generateHarmonics?: boolean,
  136421. /**
  136422. * 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)
  136423. */
  136424. gammaSpace?: boolean,
  136425. /**
  136426. * Internal Use Only
  136427. */
  136428. reserved?: boolean);
  136429. /**
  136430. * Execute the current task
  136431. * @param scene defines the scene where you want your assets to be loaded
  136432. * @param onSuccess is a callback called when the task is successfully executed
  136433. * @param onError is a callback called if an error occurs
  136434. */
  136435. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136436. }
  136437. /**
  136438. * Define a task used by AssetsManager to load Equirectangular cube textures
  136439. */
  136440. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  136441. /**
  136442. * Defines the name of the task
  136443. */
  136444. name: string;
  136445. /**
  136446. * Defines the location of the file to load
  136447. */
  136448. url: string;
  136449. /**
  136450. * Defines the desired size (the more it increases the longer the generation will be)
  136451. */
  136452. size: number;
  136453. /**
  136454. * Defines if mipmaps should not be generated (default is false)
  136455. */
  136456. noMipmap: boolean;
  136457. /**
  136458. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  136459. * but the standard material would require them in Gamma space) (default is true)
  136460. */
  136461. gammaSpace: boolean;
  136462. /**
  136463. * Gets the loaded texture
  136464. */
  136465. texture: EquiRectangularCubeTexture;
  136466. /**
  136467. * Callback called when the task is successful
  136468. */
  136469. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  136470. /**
  136471. * Callback called when the task is successful
  136472. */
  136473. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  136474. /**
  136475. * Creates a new EquiRectangularCubeTextureAssetTask object
  136476. * @param name defines the name of the task
  136477. * @param url defines the location of the file to load
  136478. * @param size defines the desired size (the more it increases the longer the generation will be)
  136479. * If the size is omitted this implies you are using a preprocessed cubemap.
  136480. * @param noMipmap defines if mipmaps should not be generated (default is false)
  136481. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  136482. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  136483. * (default is true)
  136484. */
  136485. constructor(
  136486. /**
  136487. * Defines the name of the task
  136488. */
  136489. name: string,
  136490. /**
  136491. * Defines the location of the file to load
  136492. */
  136493. url: string,
  136494. /**
  136495. * Defines the desired size (the more it increases the longer the generation will be)
  136496. */
  136497. size: number,
  136498. /**
  136499. * Defines if mipmaps should not be generated (default is false)
  136500. */
  136501. noMipmap?: boolean,
  136502. /**
  136503. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  136504. * but the standard material would require them in Gamma space) (default is true)
  136505. */
  136506. gammaSpace?: boolean);
  136507. /**
  136508. * Execute the current task
  136509. * @param scene defines the scene where you want your assets to be loaded
  136510. * @param onSuccess is a callback called when the task is successfully executed
  136511. * @param onError is a callback called if an error occurs
  136512. */
  136513. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136514. }
  136515. /**
  136516. * This class can be used to easily import assets into a scene
  136517. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  136518. */
  136519. export class AssetsManager {
  136520. private _scene;
  136521. private _isLoading;
  136522. protected _tasks: AbstractAssetTask[];
  136523. protected _waitingTasksCount: number;
  136524. protected _totalTasksCount: number;
  136525. /**
  136526. * Callback called when all tasks are processed
  136527. */
  136528. onFinish: (tasks: AbstractAssetTask[]) => void;
  136529. /**
  136530. * Callback called when a task is successful
  136531. */
  136532. onTaskSuccess: (task: AbstractAssetTask) => void;
  136533. /**
  136534. * Callback called when a task had an error
  136535. */
  136536. onTaskError: (task: AbstractAssetTask) => void;
  136537. /**
  136538. * Callback called when a task is done (whatever the result is)
  136539. */
  136540. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  136541. /**
  136542. * Observable called when all tasks are processed
  136543. */
  136544. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  136545. /**
  136546. * Observable called when a task had an error
  136547. */
  136548. onTaskErrorObservable: Observable<AbstractAssetTask>;
  136549. /**
  136550. * Observable called when all tasks were executed
  136551. */
  136552. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  136553. /**
  136554. * Observable called when a task is done (whatever the result is)
  136555. */
  136556. onProgressObservable: Observable<IAssetsProgressEvent>;
  136557. /**
  136558. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  136559. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  136560. */
  136561. useDefaultLoadingScreen: boolean;
  136562. /**
  136563. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  136564. * when all assets have been downloaded.
  136565. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  136566. */
  136567. autoHideLoadingUI: boolean;
  136568. /**
  136569. * Creates a new AssetsManager
  136570. * @param scene defines the scene to work on
  136571. */
  136572. constructor(scene: Scene);
  136573. /**
  136574. * Add a MeshAssetTask to the list of active tasks
  136575. * @param taskName defines the name of the new task
  136576. * @param meshesNames defines the name of meshes to load
  136577. * @param rootUrl defines the root url to use to locate files
  136578. * @param sceneFilename defines the filename of the scene file
  136579. * @returns a new MeshAssetTask object
  136580. */
  136581. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  136582. /**
  136583. * Add a TextFileAssetTask to the list of active tasks
  136584. * @param taskName defines the name of the new task
  136585. * @param url defines the url of the file to load
  136586. * @returns a new TextFileAssetTask object
  136587. */
  136588. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  136589. /**
  136590. * Add a BinaryFileAssetTask to the list of active tasks
  136591. * @param taskName defines the name of the new task
  136592. * @param url defines the url of the file to load
  136593. * @returns a new BinaryFileAssetTask object
  136594. */
  136595. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  136596. /**
  136597. * Add a ImageAssetTask to the list of active tasks
  136598. * @param taskName defines the name of the new task
  136599. * @param url defines the url of the file to load
  136600. * @returns a new ImageAssetTask object
  136601. */
  136602. addImageTask(taskName: string, url: string): ImageAssetTask;
  136603. /**
  136604. * Add a TextureAssetTask to the list of active tasks
  136605. * @param taskName defines the name of the new task
  136606. * @param url defines the url of the file to load
  136607. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  136608. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  136609. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  136610. * @returns a new TextureAssetTask object
  136611. */
  136612. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  136613. /**
  136614. * Add a CubeTextureAssetTask to the list of active tasks
  136615. * @param taskName defines the name of the new task
  136616. * @param url defines the url of the file to load
  136617. * @param extensions defines the extension to use to load the cube map (can be null)
  136618. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  136619. * @param files defines the list of files to load (can be null)
  136620. * @returns a new CubeTextureAssetTask object
  136621. */
  136622. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  136623. /**
  136624. *
  136625. * Add a HDRCubeTextureAssetTask to the list of active tasks
  136626. * @param taskName defines the name of the new task
  136627. * @param url defines the url of the file to load
  136628. * @param size defines the size you want for the cubemap (can be null)
  136629. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  136630. * @param generateHarmonics defines if you want to automatically generate (true by default)
  136631. * @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)
  136632. * @param reserved Internal use only
  136633. * @returns a new HDRCubeTextureAssetTask object
  136634. */
  136635. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  136636. /**
  136637. *
  136638. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  136639. * @param taskName defines the name of the new task
  136640. * @param url defines the url of the file to load
  136641. * @param size defines the size you want for the cubemap (can be null)
  136642. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  136643. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  136644. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  136645. * @returns a new EquiRectangularCubeTextureAssetTask object
  136646. */
  136647. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  136648. /**
  136649. * Remove a task from the assets manager.
  136650. * @param task the task to remove
  136651. */
  136652. removeTask(task: AbstractAssetTask): void;
  136653. private _decreaseWaitingTasksCount;
  136654. private _runTask;
  136655. /**
  136656. * Reset the AssetsManager and remove all tasks
  136657. * @return the current instance of the AssetsManager
  136658. */
  136659. reset(): AssetsManager;
  136660. /**
  136661. * Start the loading process
  136662. * @return the current instance of the AssetsManager
  136663. */
  136664. load(): AssetsManager;
  136665. /**
  136666. * Start the loading process as an async operation
  136667. * @return a promise returning the list of failed tasks
  136668. */
  136669. loadAsync(): Promise<void>;
  136670. }
  136671. }
  136672. declare module BABYLON {
  136673. /**
  136674. * Wrapper class for promise with external resolve and reject.
  136675. */
  136676. export class Deferred<T> {
  136677. /**
  136678. * The promise associated with this deferred object.
  136679. */
  136680. readonly promise: Promise<T>;
  136681. private _resolve;
  136682. private _reject;
  136683. /**
  136684. * The resolve method of the promise associated with this deferred object.
  136685. */
  136686. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  136687. /**
  136688. * The reject method of the promise associated with this deferred object.
  136689. */
  136690. get reject(): (reason?: any) => void;
  136691. /**
  136692. * Constructor for this deferred object.
  136693. */
  136694. constructor();
  136695. }
  136696. }
  136697. declare module BABYLON {
  136698. /**
  136699. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  136700. */
  136701. export class MeshExploder {
  136702. private _centerMesh;
  136703. private _meshes;
  136704. private _meshesOrigins;
  136705. private _toCenterVectors;
  136706. private _scaledDirection;
  136707. private _newPosition;
  136708. private _centerPosition;
  136709. /**
  136710. * Explodes meshes from a center mesh.
  136711. * @param meshes The meshes to explode.
  136712. * @param centerMesh The mesh to be center of explosion.
  136713. */
  136714. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  136715. private _setCenterMesh;
  136716. /**
  136717. * Get class name
  136718. * @returns "MeshExploder"
  136719. */
  136720. getClassName(): string;
  136721. /**
  136722. * "Exploded meshes"
  136723. * @returns Array of meshes with the centerMesh at index 0.
  136724. */
  136725. getMeshes(): Array<Mesh>;
  136726. /**
  136727. * Explodes meshes giving a specific direction
  136728. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  136729. */
  136730. explode(direction?: number): void;
  136731. }
  136732. }
  136733. declare module BABYLON {
  136734. /**
  136735. * Class used to help managing file picking and drag'n'drop
  136736. */
  136737. export class FilesInput {
  136738. /**
  136739. * List of files ready to be loaded
  136740. */
  136741. static get FilesToLoad(): {
  136742. [key: string]: File;
  136743. };
  136744. /**
  136745. * Callback called when a file is processed
  136746. */
  136747. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  136748. private _engine;
  136749. private _currentScene;
  136750. private _sceneLoadedCallback;
  136751. private _progressCallback;
  136752. private _additionalRenderLoopLogicCallback;
  136753. private _textureLoadingCallback;
  136754. private _startingProcessingFilesCallback;
  136755. private _onReloadCallback;
  136756. private _errorCallback;
  136757. private _elementToMonitor;
  136758. private _sceneFileToLoad;
  136759. private _filesToLoad;
  136760. /**
  136761. * Creates a new FilesInput
  136762. * @param engine defines the rendering engine
  136763. * @param scene defines the hosting scene
  136764. * @param sceneLoadedCallback callback called when scene is loaded
  136765. * @param progressCallback callback called to track progress
  136766. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  136767. * @param textureLoadingCallback callback called when a texture is loading
  136768. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  136769. * @param onReloadCallback callback called when a reload is requested
  136770. * @param errorCallback callback call if an error occurs
  136771. */
  136772. 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);
  136773. private _dragEnterHandler;
  136774. private _dragOverHandler;
  136775. private _dropHandler;
  136776. /**
  136777. * Calls this function to listen to drag'n'drop events on a specific DOM element
  136778. * @param elementToMonitor defines the DOM element to track
  136779. */
  136780. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  136781. /**
  136782. * Release all associated resources
  136783. */
  136784. dispose(): void;
  136785. private renderFunction;
  136786. private drag;
  136787. private drop;
  136788. private _traverseFolder;
  136789. private _processFiles;
  136790. /**
  136791. * Load files from a drop event
  136792. * @param event defines the drop event to use as source
  136793. */
  136794. loadFiles(event: any): void;
  136795. private _processReload;
  136796. /**
  136797. * Reload the current scene from the loaded files
  136798. */
  136799. reload(): void;
  136800. }
  136801. }
  136802. declare module BABYLON {
  136803. /**
  136804. * Defines the root class used to create scene optimization to use with SceneOptimizer
  136805. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136806. */
  136807. export class SceneOptimization {
  136808. /**
  136809. * Defines the priority of this optimization (0 by default which means first in the list)
  136810. */
  136811. priority: number;
  136812. /**
  136813. * Gets a string describing the action executed by the current optimization
  136814. * @returns description string
  136815. */
  136816. getDescription(): string;
  136817. /**
  136818. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136819. * @param scene defines the current scene where to apply this optimization
  136820. * @param optimizer defines the current optimizer
  136821. * @returns true if everything that can be done was applied
  136822. */
  136823. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136824. /**
  136825. * Creates the SceneOptimization object
  136826. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  136827. * @param desc defines the description associated with the optimization
  136828. */
  136829. constructor(
  136830. /**
  136831. * Defines the priority of this optimization (0 by default which means first in the list)
  136832. */
  136833. priority?: number);
  136834. }
  136835. /**
  136836. * Defines an optimization used to reduce the size of render target textures
  136837. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136838. */
  136839. export class TextureOptimization extends SceneOptimization {
  136840. /**
  136841. * Defines the priority of this optimization (0 by default which means first in the list)
  136842. */
  136843. priority: number;
  136844. /**
  136845. * 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
  136846. */
  136847. maximumSize: number;
  136848. /**
  136849. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  136850. */
  136851. step: number;
  136852. /**
  136853. * Gets a string describing the action executed by the current optimization
  136854. * @returns description string
  136855. */
  136856. getDescription(): string;
  136857. /**
  136858. * Creates the TextureOptimization object
  136859. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  136860. * @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
  136861. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  136862. */
  136863. constructor(
  136864. /**
  136865. * Defines the priority of this optimization (0 by default which means first in the list)
  136866. */
  136867. priority?: number,
  136868. /**
  136869. * 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
  136870. */
  136871. maximumSize?: number,
  136872. /**
  136873. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  136874. */
  136875. step?: number);
  136876. /**
  136877. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136878. * @param scene defines the current scene where to apply this optimization
  136879. * @param optimizer defines the current optimizer
  136880. * @returns true if everything that can be done was applied
  136881. */
  136882. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136883. }
  136884. /**
  136885. * Defines an optimization used to increase or decrease the rendering resolution
  136886. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136887. */
  136888. export class HardwareScalingOptimization extends SceneOptimization {
  136889. /**
  136890. * Defines the priority of this optimization (0 by default which means first in the list)
  136891. */
  136892. priority: number;
  136893. /**
  136894. * Defines the maximum scale to use (2 by default)
  136895. */
  136896. maximumScale: number;
  136897. /**
  136898. * Defines the step to use between two passes (0.5 by default)
  136899. */
  136900. step: number;
  136901. private _currentScale;
  136902. private _directionOffset;
  136903. /**
  136904. * Gets a string describing the action executed by the current optimization
  136905. * @return description string
  136906. */
  136907. getDescription(): string;
  136908. /**
  136909. * Creates the HardwareScalingOptimization object
  136910. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  136911. * @param maximumScale defines the maximum scale to use (2 by default)
  136912. * @param step defines the step to use between two passes (0.5 by default)
  136913. */
  136914. constructor(
  136915. /**
  136916. * Defines the priority of this optimization (0 by default which means first in the list)
  136917. */
  136918. priority?: number,
  136919. /**
  136920. * Defines the maximum scale to use (2 by default)
  136921. */
  136922. maximumScale?: number,
  136923. /**
  136924. * Defines the step to use between two passes (0.5 by default)
  136925. */
  136926. step?: number);
  136927. /**
  136928. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136929. * @param scene defines the current scene where to apply this optimization
  136930. * @param optimizer defines the current optimizer
  136931. * @returns true if everything that can be done was applied
  136932. */
  136933. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136934. }
  136935. /**
  136936. * Defines an optimization used to remove shadows
  136937. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136938. */
  136939. export class ShadowsOptimization extends SceneOptimization {
  136940. /**
  136941. * Gets a string describing the action executed by the current optimization
  136942. * @return description string
  136943. */
  136944. getDescription(): string;
  136945. /**
  136946. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136947. * @param scene defines the current scene where to apply this optimization
  136948. * @param optimizer defines the current optimizer
  136949. * @returns true if everything that can be done was applied
  136950. */
  136951. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136952. }
  136953. /**
  136954. * Defines an optimization used to turn post-processes off
  136955. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136956. */
  136957. export class PostProcessesOptimization extends SceneOptimization {
  136958. /**
  136959. * Gets a string describing the action executed by the current optimization
  136960. * @return description string
  136961. */
  136962. getDescription(): string;
  136963. /**
  136964. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136965. * @param scene defines the current scene where to apply this optimization
  136966. * @param optimizer defines the current optimizer
  136967. * @returns true if everything that can be done was applied
  136968. */
  136969. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136970. }
  136971. /**
  136972. * Defines an optimization used to turn lens flares off
  136973. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136974. */
  136975. export class LensFlaresOptimization extends SceneOptimization {
  136976. /**
  136977. * Gets a string describing the action executed by the current optimization
  136978. * @return description string
  136979. */
  136980. getDescription(): string;
  136981. /**
  136982. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136983. * @param scene defines the current scene where to apply this optimization
  136984. * @param optimizer defines the current optimizer
  136985. * @returns true if everything that can be done was applied
  136986. */
  136987. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136988. }
  136989. /**
  136990. * Defines an optimization based on user defined callback.
  136991. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136992. */
  136993. export class CustomOptimization extends SceneOptimization {
  136994. /**
  136995. * Callback called to apply the custom optimization.
  136996. */
  136997. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  136998. /**
  136999. * Callback called to get custom description
  137000. */
  137001. onGetDescription: () => string;
  137002. /**
  137003. * Gets a string describing the action executed by the current optimization
  137004. * @returns description string
  137005. */
  137006. getDescription(): string;
  137007. /**
  137008. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  137009. * @param scene defines the current scene where to apply this optimization
  137010. * @param optimizer defines the current optimizer
  137011. * @returns true if everything that can be done was applied
  137012. */
  137013. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  137014. }
  137015. /**
  137016. * Defines an optimization used to turn particles off
  137017. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  137018. */
  137019. export class ParticlesOptimization extends SceneOptimization {
  137020. /**
  137021. * Gets a string describing the action executed by the current optimization
  137022. * @return description string
  137023. */
  137024. getDescription(): string;
  137025. /**
  137026. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  137027. * @param scene defines the current scene where to apply this optimization
  137028. * @param optimizer defines the current optimizer
  137029. * @returns true if everything that can be done was applied
  137030. */
  137031. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  137032. }
  137033. /**
  137034. * Defines an optimization used to turn render targets off
  137035. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  137036. */
  137037. export class RenderTargetsOptimization extends SceneOptimization {
  137038. /**
  137039. * Gets a string describing the action executed by the current optimization
  137040. * @return description string
  137041. */
  137042. getDescription(): string;
  137043. /**
  137044. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  137045. * @param scene defines the current scene where to apply this optimization
  137046. * @param optimizer defines the current optimizer
  137047. * @returns true if everything that can be done was applied
  137048. */
  137049. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  137050. }
  137051. /**
  137052. * Defines an optimization used to merge meshes with compatible materials
  137053. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  137054. */
  137055. export class MergeMeshesOptimization extends SceneOptimization {
  137056. private static _UpdateSelectionTree;
  137057. /**
  137058. * Gets or sets a boolean which defines if optimization octree has to be updated
  137059. */
  137060. static get UpdateSelectionTree(): boolean;
  137061. /**
  137062. * Gets or sets a boolean which defines if optimization octree has to be updated
  137063. */
  137064. static set UpdateSelectionTree(value: boolean);
  137065. /**
  137066. * Gets a string describing the action executed by the current optimization
  137067. * @return description string
  137068. */
  137069. getDescription(): string;
  137070. private _canBeMerged;
  137071. /**
  137072. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  137073. * @param scene defines the current scene where to apply this optimization
  137074. * @param optimizer defines the current optimizer
  137075. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  137076. * @returns true if everything that can be done was applied
  137077. */
  137078. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  137079. }
  137080. /**
  137081. * Defines a list of options used by SceneOptimizer
  137082. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  137083. */
  137084. export class SceneOptimizerOptions {
  137085. /**
  137086. * Defines the target frame rate to reach (60 by default)
  137087. */
  137088. targetFrameRate: number;
  137089. /**
  137090. * Defines the interval between two checkes (2000ms by default)
  137091. */
  137092. trackerDuration: number;
  137093. /**
  137094. * Gets the list of optimizations to apply
  137095. */
  137096. optimizations: SceneOptimization[];
  137097. /**
  137098. * Creates a new list of options used by SceneOptimizer
  137099. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  137100. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  137101. */
  137102. constructor(
  137103. /**
  137104. * Defines the target frame rate to reach (60 by default)
  137105. */
  137106. targetFrameRate?: number,
  137107. /**
  137108. * Defines the interval between two checkes (2000ms by default)
  137109. */
  137110. trackerDuration?: number);
  137111. /**
  137112. * Add a new optimization
  137113. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  137114. * @returns the current SceneOptimizerOptions
  137115. */
  137116. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  137117. /**
  137118. * Add a new custom optimization
  137119. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  137120. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  137121. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  137122. * @returns the current SceneOptimizerOptions
  137123. */
  137124. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  137125. /**
  137126. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  137127. * @param targetFrameRate defines the target frame rate (60 by default)
  137128. * @returns a SceneOptimizerOptions object
  137129. */
  137130. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  137131. /**
  137132. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  137133. * @param targetFrameRate defines the target frame rate (60 by default)
  137134. * @returns a SceneOptimizerOptions object
  137135. */
  137136. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  137137. /**
  137138. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  137139. * @param targetFrameRate defines the target frame rate (60 by default)
  137140. * @returns a SceneOptimizerOptions object
  137141. */
  137142. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  137143. }
  137144. /**
  137145. * Class used to run optimizations in order to reach a target frame rate
  137146. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  137147. */
  137148. export class SceneOptimizer implements IDisposable {
  137149. private _isRunning;
  137150. private _options;
  137151. private _scene;
  137152. private _currentPriorityLevel;
  137153. private _targetFrameRate;
  137154. private _trackerDuration;
  137155. private _currentFrameRate;
  137156. private _sceneDisposeObserver;
  137157. private _improvementMode;
  137158. /**
  137159. * Defines an observable called when the optimizer reaches the target frame rate
  137160. */
  137161. onSuccessObservable: Observable<SceneOptimizer>;
  137162. /**
  137163. * Defines an observable called when the optimizer enables an optimization
  137164. */
  137165. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  137166. /**
  137167. * Defines an observable called when the optimizer is not able to reach the target frame rate
  137168. */
  137169. onFailureObservable: Observable<SceneOptimizer>;
  137170. /**
  137171. * Gets a boolean indicating if the optimizer is in improvement mode
  137172. */
  137173. get isInImprovementMode(): boolean;
  137174. /**
  137175. * Gets the current priority level (0 at start)
  137176. */
  137177. get currentPriorityLevel(): number;
  137178. /**
  137179. * Gets the current frame rate checked by the SceneOptimizer
  137180. */
  137181. get currentFrameRate(): number;
  137182. /**
  137183. * Gets or sets the current target frame rate (60 by default)
  137184. */
  137185. get targetFrameRate(): number;
  137186. /**
  137187. * Gets or sets the current target frame rate (60 by default)
  137188. */
  137189. set targetFrameRate(value: number);
  137190. /**
  137191. * Gets or sets the current interval between two checks (every 2000ms by default)
  137192. */
  137193. get trackerDuration(): number;
  137194. /**
  137195. * Gets or sets the current interval between two checks (every 2000ms by default)
  137196. */
  137197. set trackerDuration(value: number);
  137198. /**
  137199. * Gets the list of active optimizations
  137200. */
  137201. get optimizations(): SceneOptimization[];
  137202. /**
  137203. * Creates a new SceneOptimizer
  137204. * @param scene defines the scene to work on
  137205. * @param options defines the options to use with the SceneOptimizer
  137206. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  137207. * @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)
  137208. */
  137209. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  137210. /**
  137211. * Stops the current optimizer
  137212. */
  137213. stop(): void;
  137214. /**
  137215. * Reset the optimizer to initial step (current priority level = 0)
  137216. */
  137217. reset(): void;
  137218. /**
  137219. * Start the optimizer. By default it will try to reach a specific framerate
  137220. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  137221. */
  137222. start(): void;
  137223. private _checkCurrentState;
  137224. /**
  137225. * Release all resources
  137226. */
  137227. dispose(): void;
  137228. /**
  137229. * Helper function to create a SceneOptimizer with one single line of code
  137230. * @param scene defines the scene to work on
  137231. * @param options defines the options to use with the SceneOptimizer
  137232. * @param onSuccess defines a callback to call on success
  137233. * @param onFailure defines a callback to call on failure
  137234. * @returns the new SceneOptimizer object
  137235. */
  137236. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  137237. }
  137238. }
  137239. declare module BABYLON {
  137240. /**
  137241. * Class used to serialize a scene into a string
  137242. */
  137243. export class SceneSerializer {
  137244. /**
  137245. * Clear cache used by a previous serialization
  137246. */
  137247. static ClearCache(): void;
  137248. /**
  137249. * Serialize a scene into a JSON compatible object
  137250. * @param scene defines the scene to serialize
  137251. * @returns a JSON compatible object
  137252. */
  137253. static Serialize(scene: Scene): any;
  137254. /**
  137255. * Serialize a mesh into a JSON compatible object
  137256. * @param toSerialize defines the mesh to serialize
  137257. * @param withParents defines if parents must be serialized as well
  137258. * @param withChildren defines if children must be serialized as well
  137259. * @returns a JSON compatible object
  137260. */
  137261. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  137262. }
  137263. }
  137264. declare module BABYLON {
  137265. /**
  137266. * Class used to host texture specific utilities
  137267. */
  137268. export class TextureTools {
  137269. /**
  137270. * Uses the GPU to create a copy texture rescaled at a given size
  137271. * @param texture Texture to copy from
  137272. * @param width defines the desired width
  137273. * @param height defines the desired height
  137274. * @param useBilinearMode defines if bilinear mode has to be used
  137275. * @return the generated texture
  137276. */
  137277. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  137278. }
  137279. }
  137280. declare module BABYLON {
  137281. /**
  137282. * This represents the different options available for the video capture.
  137283. */
  137284. export interface VideoRecorderOptions {
  137285. /** Defines the mime type of the video. */
  137286. mimeType: string;
  137287. /** Defines the FPS the video should be recorded at. */
  137288. fps: number;
  137289. /** Defines the chunk size for the recording data. */
  137290. recordChunckSize: number;
  137291. /** The audio tracks to attach to the recording. */
  137292. audioTracks?: MediaStreamTrack[];
  137293. }
  137294. /**
  137295. * This can help with recording videos from BabylonJS.
  137296. * This is based on the available WebRTC functionalities of the browser.
  137297. *
  137298. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  137299. */
  137300. export class VideoRecorder {
  137301. private static readonly _defaultOptions;
  137302. /**
  137303. * Returns whether or not the VideoRecorder is available in your browser.
  137304. * @param engine Defines the Babylon Engine.
  137305. * @returns true if supported otherwise false.
  137306. */
  137307. static IsSupported(engine: Engine): boolean;
  137308. private readonly _options;
  137309. private _canvas;
  137310. private _mediaRecorder;
  137311. private _recordedChunks;
  137312. private _fileName;
  137313. private _resolve;
  137314. private _reject;
  137315. /**
  137316. * True when a recording is already in progress.
  137317. */
  137318. get isRecording(): boolean;
  137319. /**
  137320. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  137321. * @param engine Defines the BabylonJS Engine you wish to record.
  137322. * @param options Defines options that can be used to customize the capture.
  137323. */
  137324. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  137325. /**
  137326. * Stops the current recording before the default capture timeout passed in the startRecording function.
  137327. */
  137328. stopRecording(): void;
  137329. /**
  137330. * Starts recording the canvas for a max duration specified in parameters.
  137331. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  137332. * If null no automatic download will start and you can rely on the promise to get the data back.
  137333. * @param maxDuration Defines the maximum recording time in seconds.
  137334. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  137335. * @return A promise callback at the end of the recording with the video data in Blob.
  137336. */
  137337. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  137338. /**
  137339. * Releases internal resources used during the recording.
  137340. */
  137341. dispose(): void;
  137342. private _handleDataAvailable;
  137343. private _handleError;
  137344. private _handleStop;
  137345. }
  137346. }
  137347. declare module BABYLON {
  137348. /**
  137349. * Class containing a set of static utilities functions for screenshots
  137350. */
  137351. export class ScreenshotTools {
  137352. /**
  137353. * Captures a screenshot of the current rendering
  137354. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  137355. * @param engine defines the rendering engine
  137356. * @param camera defines the source camera
  137357. * @param size This parameter can be set to a single number or to an object with the
  137358. * following (optional) properties: precision, width, height. If a single number is passed,
  137359. * it will be used for both width and height. If an object is passed, the screenshot size
  137360. * will be derived from the parameters. The precision property is a multiplier allowing
  137361. * rendering at a higher or lower resolution
  137362. * @param successCallback defines the callback receives a single parameter which contains the
  137363. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  137364. * src parameter of an <img> to display it
  137365. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  137366. * Check your browser for supported MIME types
  137367. */
  137368. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  137369. /**
  137370. * Captures a screenshot of the current rendering
  137371. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  137372. * @param engine defines the rendering engine
  137373. * @param camera defines the source camera
  137374. * @param size This parameter can be set to a single number or to an object with the
  137375. * following (optional) properties: precision, width, height. If a single number is passed,
  137376. * it will be used for both width and height. If an object is passed, the screenshot size
  137377. * will be derived from the parameters. The precision property is a multiplier allowing
  137378. * rendering at a higher or lower resolution
  137379. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  137380. * Check your browser for supported MIME types
  137381. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  137382. * to the src parameter of an <img> to display it
  137383. */
  137384. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  137385. /**
  137386. * Generates an image screenshot from the specified camera.
  137387. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  137388. * @param engine The engine to use for rendering
  137389. * @param camera The camera to use for rendering
  137390. * @param size This parameter can be set to a single number or to an object with the
  137391. * following (optional) properties: precision, width, height. If a single number is passed,
  137392. * it will be used for both width and height. If an object is passed, the screenshot size
  137393. * will be derived from the parameters. The precision property is a multiplier allowing
  137394. * rendering at a higher or lower resolution
  137395. * @param successCallback The callback receives a single parameter which contains the
  137396. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  137397. * src parameter of an <img> to display it
  137398. * @param mimeType The MIME type of the screenshot image (default: image/png).
  137399. * Check your browser for supported MIME types
  137400. * @param samples Texture samples (default: 1)
  137401. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  137402. * @param fileName A name for for the downloaded file.
  137403. */
  137404. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  137405. /**
  137406. * Generates an image screenshot from the specified camera.
  137407. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  137408. * @param engine The engine to use for rendering
  137409. * @param camera The camera to use for rendering
  137410. * @param size This parameter can be set to a single number or to an object with the
  137411. * following (optional) properties: precision, width, height. If a single number is passed,
  137412. * it will be used for both width and height. If an object is passed, the screenshot size
  137413. * will be derived from the parameters. The precision property is a multiplier allowing
  137414. * rendering at a higher or lower resolution
  137415. * @param mimeType The MIME type of the screenshot image (default: image/png).
  137416. * Check your browser for supported MIME types
  137417. * @param samples Texture samples (default: 1)
  137418. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  137419. * @param fileName A name for for the downloaded file.
  137420. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  137421. * to the src parameter of an <img> to display it
  137422. */
  137423. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  137424. /**
  137425. * Gets height and width for screenshot size
  137426. * @private
  137427. */
  137428. private static _getScreenshotSize;
  137429. }
  137430. }
  137431. declare module BABYLON {
  137432. /**
  137433. * Interface for a data buffer
  137434. */
  137435. export interface IDataBuffer {
  137436. /**
  137437. * Reads bytes from the data buffer.
  137438. * @param byteOffset The byte offset to read
  137439. * @param byteLength The byte length to read
  137440. * @returns A promise that resolves when the bytes are read
  137441. */
  137442. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  137443. /**
  137444. * The byte length of the buffer.
  137445. */
  137446. readonly byteLength: number;
  137447. }
  137448. /**
  137449. * Utility class for reading from a data buffer
  137450. */
  137451. export class DataReader {
  137452. /**
  137453. * The data buffer associated with this data reader.
  137454. */
  137455. readonly buffer: IDataBuffer;
  137456. /**
  137457. * The current byte offset from the beginning of the data buffer.
  137458. */
  137459. byteOffset: number;
  137460. private _dataView;
  137461. private _dataByteOffset;
  137462. /**
  137463. * Constructor
  137464. * @param buffer The buffer to read
  137465. */
  137466. constructor(buffer: IDataBuffer);
  137467. /**
  137468. * Loads the given byte length.
  137469. * @param byteLength The byte length to load
  137470. * @returns A promise that resolves when the load is complete
  137471. */
  137472. loadAsync(byteLength: number): Promise<void>;
  137473. /**
  137474. * Read a unsigned 32-bit integer from the currently loaded data range.
  137475. * @returns The 32-bit integer read
  137476. */
  137477. readUint32(): number;
  137478. /**
  137479. * Read a byte array from the currently loaded data range.
  137480. * @param byteLength The byte length to read
  137481. * @returns The byte array read
  137482. */
  137483. readUint8Array(byteLength: number): Uint8Array;
  137484. /**
  137485. * Read a string from the currently loaded data range.
  137486. * @param byteLength The byte length to read
  137487. * @returns The string read
  137488. */
  137489. readString(byteLength: number): string;
  137490. /**
  137491. * Skips the given byte length the currently loaded data range.
  137492. * @param byteLength The byte length to skip
  137493. */
  137494. skipBytes(byteLength: number): void;
  137495. }
  137496. }
  137497. declare module BABYLON {
  137498. /**
  137499. * A cursor which tracks a point on a path
  137500. */
  137501. export class PathCursor {
  137502. private path;
  137503. /**
  137504. * Stores path cursor callbacks for when an onchange event is triggered
  137505. */
  137506. private _onchange;
  137507. /**
  137508. * The value of the path cursor
  137509. */
  137510. value: number;
  137511. /**
  137512. * The animation array of the path cursor
  137513. */
  137514. animations: Animation[];
  137515. /**
  137516. * Initializes the path cursor
  137517. * @param path The path to track
  137518. */
  137519. constructor(path: Path2);
  137520. /**
  137521. * Gets the cursor point on the path
  137522. * @returns A point on the path cursor at the cursor location
  137523. */
  137524. getPoint(): Vector3;
  137525. /**
  137526. * Moves the cursor ahead by the step amount
  137527. * @param step The amount to move the cursor forward
  137528. * @returns This path cursor
  137529. */
  137530. moveAhead(step?: number): PathCursor;
  137531. /**
  137532. * Moves the cursor behind by the step amount
  137533. * @param step The amount to move the cursor back
  137534. * @returns This path cursor
  137535. */
  137536. moveBack(step?: number): PathCursor;
  137537. /**
  137538. * Moves the cursor by the step amount
  137539. * If the step amount is greater than one, an exception is thrown
  137540. * @param step The amount to move the cursor
  137541. * @returns This path cursor
  137542. */
  137543. move(step: number): PathCursor;
  137544. /**
  137545. * Ensures that the value is limited between zero and one
  137546. * @returns This path cursor
  137547. */
  137548. private ensureLimits;
  137549. /**
  137550. * Runs onchange callbacks on change (used by the animation engine)
  137551. * @returns This path cursor
  137552. */
  137553. private raiseOnChange;
  137554. /**
  137555. * Executes a function on change
  137556. * @param f A path cursor onchange callback
  137557. * @returns This path cursor
  137558. */
  137559. onchange(f: (cursor: PathCursor) => void): PathCursor;
  137560. }
  137561. }
  137562. declare module BABYLON {
  137563. /** @hidden */
  137564. export var blurPixelShader: {
  137565. name: string;
  137566. shader: string;
  137567. };
  137568. }
  137569. declare module BABYLON {
  137570. /** @hidden */
  137571. export var pointCloudVertexDeclaration: {
  137572. name: string;
  137573. shader: string;
  137574. };
  137575. }
  137576. // Mixins
  137577. interface Window {
  137578. mozIndexedDB: IDBFactory;
  137579. webkitIndexedDB: IDBFactory;
  137580. msIndexedDB: IDBFactory;
  137581. webkitURL: typeof URL;
  137582. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  137583. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  137584. WebGLRenderingContext: WebGLRenderingContext;
  137585. MSGesture: MSGesture;
  137586. CANNON: any;
  137587. AudioContext: AudioContext;
  137588. webkitAudioContext: AudioContext;
  137589. PointerEvent: any;
  137590. Math: Math;
  137591. Uint8Array: Uint8ArrayConstructor;
  137592. Float32Array: Float32ArrayConstructor;
  137593. mozURL: typeof URL;
  137594. msURL: typeof URL;
  137595. VRFrameData: any; // WebVR, from specs 1.1
  137596. DracoDecoderModule: any;
  137597. setImmediate(handler: (...args: any[]) => void): number;
  137598. }
  137599. interface HTMLCanvasElement {
  137600. requestPointerLock(): void;
  137601. msRequestPointerLock?(): void;
  137602. mozRequestPointerLock?(): void;
  137603. webkitRequestPointerLock?(): void;
  137604. /** Track wether a record is in progress */
  137605. isRecording: boolean;
  137606. /** Capture Stream method defined by some browsers */
  137607. captureStream(fps?: number): MediaStream;
  137608. }
  137609. interface CanvasRenderingContext2D {
  137610. msImageSmoothingEnabled: boolean;
  137611. }
  137612. interface MouseEvent {
  137613. mozMovementX: number;
  137614. mozMovementY: number;
  137615. webkitMovementX: number;
  137616. webkitMovementY: number;
  137617. msMovementX: number;
  137618. msMovementY: number;
  137619. }
  137620. interface Navigator {
  137621. mozGetVRDevices: (any: any) => any;
  137622. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  137623. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  137624. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  137625. webkitGetGamepads(): Gamepad[];
  137626. msGetGamepads(): Gamepad[];
  137627. webkitGamepads(): Gamepad[];
  137628. }
  137629. interface HTMLVideoElement {
  137630. mozSrcObject: any;
  137631. }
  137632. interface Math {
  137633. fround(x: number): number;
  137634. imul(a: number, b: number): number;
  137635. }
  137636. interface WebGLRenderingContext {
  137637. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  137638. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  137639. vertexAttribDivisor(index: number, divisor: number): void;
  137640. createVertexArray(): any;
  137641. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  137642. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  137643. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  137644. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  137645. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  137646. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  137647. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  137648. // Queries
  137649. createQuery(): WebGLQuery;
  137650. deleteQuery(query: WebGLQuery): void;
  137651. beginQuery(target: number, query: WebGLQuery): void;
  137652. endQuery(target: number): void;
  137653. getQueryParameter(query: WebGLQuery, pname: number): any;
  137654. getQuery(target: number, pname: number): any;
  137655. MAX_SAMPLES: number;
  137656. RGBA8: number;
  137657. READ_FRAMEBUFFER: number;
  137658. DRAW_FRAMEBUFFER: number;
  137659. UNIFORM_BUFFER: number;
  137660. HALF_FLOAT_OES: number;
  137661. RGBA16F: number;
  137662. RGBA32F: number;
  137663. R32F: number;
  137664. RG32F: number;
  137665. RGB32F: number;
  137666. R16F: number;
  137667. RG16F: number;
  137668. RGB16F: number;
  137669. RED: number;
  137670. RG: number;
  137671. R8: number;
  137672. RG8: number;
  137673. UNSIGNED_INT_24_8: number;
  137674. DEPTH24_STENCIL8: number;
  137675. MIN: number;
  137676. MAX: number;
  137677. /* Multiple Render Targets */
  137678. drawBuffers(buffers: number[]): void;
  137679. readBuffer(src: number): void;
  137680. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  137681. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  137682. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  137683. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  137684. // Occlusion Query
  137685. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  137686. ANY_SAMPLES_PASSED: number;
  137687. QUERY_RESULT_AVAILABLE: number;
  137688. QUERY_RESULT: number;
  137689. }
  137690. interface WebGLProgram {
  137691. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  137692. }
  137693. interface EXT_disjoint_timer_query {
  137694. QUERY_COUNTER_BITS_EXT: number;
  137695. TIME_ELAPSED_EXT: number;
  137696. TIMESTAMP_EXT: number;
  137697. GPU_DISJOINT_EXT: number;
  137698. QUERY_RESULT_EXT: number;
  137699. QUERY_RESULT_AVAILABLE_EXT: number;
  137700. queryCounterEXT(query: WebGLQuery, target: number): void;
  137701. createQueryEXT(): WebGLQuery;
  137702. beginQueryEXT(target: number, query: WebGLQuery): void;
  137703. endQueryEXT(target: number): void;
  137704. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  137705. deleteQueryEXT(query: WebGLQuery): void;
  137706. }
  137707. interface WebGLUniformLocation {
  137708. _currentState: any;
  137709. }
  137710. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  137711. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  137712. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  137713. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  137714. interface WebGLRenderingContext {
  137715. readonly RASTERIZER_DISCARD: number;
  137716. readonly DEPTH_COMPONENT24: number;
  137717. readonly TEXTURE_3D: number;
  137718. readonly TEXTURE_2D_ARRAY: number;
  137719. readonly TEXTURE_COMPARE_FUNC: number;
  137720. readonly TEXTURE_COMPARE_MODE: number;
  137721. readonly COMPARE_REF_TO_TEXTURE: number;
  137722. readonly TEXTURE_WRAP_R: number;
  137723. readonly HALF_FLOAT: number;
  137724. readonly RGB8: number;
  137725. readonly RED_INTEGER: number;
  137726. readonly RG_INTEGER: number;
  137727. readonly RGB_INTEGER: number;
  137728. readonly RGBA_INTEGER: number;
  137729. readonly R8_SNORM: number;
  137730. readonly RG8_SNORM: number;
  137731. readonly RGB8_SNORM: number;
  137732. readonly RGBA8_SNORM: number;
  137733. readonly R8I: number;
  137734. readonly RG8I: number;
  137735. readonly RGB8I: number;
  137736. readonly RGBA8I: number;
  137737. readonly R8UI: number;
  137738. readonly RG8UI: number;
  137739. readonly RGB8UI: number;
  137740. readonly RGBA8UI: number;
  137741. readonly R16I: number;
  137742. readonly RG16I: number;
  137743. readonly RGB16I: number;
  137744. readonly RGBA16I: number;
  137745. readonly R16UI: number;
  137746. readonly RG16UI: number;
  137747. readonly RGB16UI: number;
  137748. readonly RGBA16UI: number;
  137749. readonly R32I: number;
  137750. readonly RG32I: number;
  137751. readonly RGB32I: number;
  137752. readonly RGBA32I: number;
  137753. readonly R32UI: number;
  137754. readonly RG32UI: number;
  137755. readonly RGB32UI: number;
  137756. readonly RGBA32UI: number;
  137757. readonly RGB10_A2UI: number;
  137758. readonly R11F_G11F_B10F: number;
  137759. readonly RGB9_E5: number;
  137760. readonly RGB10_A2: number;
  137761. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  137762. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  137763. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  137764. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  137765. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  137766. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  137767. 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;
  137768. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  137769. readonly TRANSFORM_FEEDBACK: number;
  137770. readonly INTERLEAVED_ATTRIBS: number;
  137771. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  137772. createTransformFeedback(): WebGLTransformFeedback;
  137773. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  137774. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  137775. beginTransformFeedback(primitiveMode: number): void;
  137776. endTransformFeedback(): void;
  137777. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  137778. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  137779. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  137780. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  137781. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  137782. }
  137783. interface ImageBitmap {
  137784. readonly width: number;
  137785. readonly height: number;
  137786. close(): void;
  137787. }
  137788. interface WebGLQuery extends WebGLObject {
  137789. }
  137790. declare var WebGLQuery: {
  137791. prototype: WebGLQuery;
  137792. new(): WebGLQuery;
  137793. };
  137794. interface WebGLSampler extends WebGLObject {
  137795. }
  137796. declare var WebGLSampler: {
  137797. prototype: WebGLSampler;
  137798. new(): WebGLSampler;
  137799. };
  137800. interface WebGLSync extends WebGLObject {
  137801. }
  137802. declare var WebGLSync: {
  137803. prototype: WebGLSync;
  137804. new(): WebGLSync;
  137805. };
  137806. interface WebGLTransformFeedback extends WebGLObject {
  137807. }
  137808. declare var WebGLTransformFeedback: {
  137809. prototype: WebGLTransformFeedback;
  137810. new(): WebGLTransformFeedback;
  137811. };
  137812. interface WebGLVertexArrayObject extends WebGLObject {
  137813. }
  137814. declare var WebGLVertexArrayObject: {
  137815. prototype: WebGLVertexArrayObject;
  137816. new(): WebGLVertexArrayObject;
  137817. };
  137818. // Type definitions for WebVR API
  137819. // Project: https://w3c.github.io/webvr/
  137820. // Definitions by: six a <https://github.com/lostfictions>
  137821. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  137822. interface VRDisplay extends EventTarget {
  137823. /**
  137824. * Dictionary of capabilities describing the VRDisplay.
  137825. */
  137826. readonly capabilities: VRDisplayCapabilities;
  137827. /**
  137828. * z-depth defining the far plane of the eye view frustum
  137829. * enables mapping of values in the render target depth
  137830. * attachment to scene coordinates. Initially set to 10000.0.
  137831. */
  137832. depthFar: number;
  137833. /**
  137834. * z-depth defining the near plane of the eye view frustum
  137835. * enables mapping of values in the render target depth
  137836. * attachment to scene coordinates. Initially set to 0.01.
  137837. */
  137838. depthNear: number;
  137839. /**
  137840. * An identifier for this distinct VRDisplay. Used as an
  137841. * association point in the Gamepad API.
  137842. */
  137843. readonly displayId: number;
  137844. /**
  137845. * A display name, a user-readable name identifying it.
  137846. */
  137847. readonly displayName: string;
  137848. readonly isConnected: boolean;
  137849. readonly isPresenting: boolean;
  137850. /**
  137851. * If this VRDisplay supports room-scale experiences, the optional
  137852. * stage attribute contains details on the room-scale parameters.
  137853. */
  137854. readonly stageParameters: VRStageParameters | null;
  137855. /**
  137856. * Passing the value returned by `requestAnimationFrame` to
  137857. * `cancelAnimationFrame` will unregister the callback.
  137858. * @param handle Define the hanle of the request to cancel
  137859. */
  137860. cancelAnimationFrame(handle: number): void;
  137861. /**
  137862. * Stops presenting to the VRDisplay.
  137863. * @returns a promise to know when it stopped
  137864. */
  137865. exitPresent(): Promise<void>;
  137866. /**
  137867. * Return the current VREyeParameters for the given eye.
  137868. * @param whichEye Define the eye we want the parameter for
  137869. * @returns the eye parameters
  137870. */
  137871. getEyeParameters(whichEye: string): VREyeParameters;
  137872. /**
  137873. * Populates the passed VRFrameData with the information required to render
  137874. * the current frame.
  137875. * @param frameData Define the data structure to populate
  137876. * @returns true if ok otherwise false
  137877. */
  137878. getFrameData(frameData: VRFrameData): boolean;
  137879. /**
  137880. * Get the layers currently being presented.
  137881. * @returns the list of VR layers
  137882. */
  137883. getLayers(): VRLayer[];
  137884. /**
  137885. * Return a VRPose containing the future predicted pose of the VRDisplay
  137886. * when the current frame will be presented. The value returned will not
  137887. * change until JavaScript has returned control to the browser.
  137888. *
  137889. * The VRPose will contain the position, orientation, velocity,
  137890. * and acceleration of each of these properties.
  137891. * @returns the pose object
  137892. */
  137893. getPose(): VRPose;
  137894. /**
  137895. * Return the current instantaneous pose of the VRDisplay, with no
  137896. * prediction applied.
  137897. * @returns the current instantaneous pose
  137898. */
  137899. getImmediatePose(): VRPose;
  137900. /**
  137901. * The callback passed to `requestAnimationFrame` will be called
  137902. * any time a new frame should be rendered. When the VRDisplay is
  137903. * presenting the callback will be called at the native refresh
  137904. * rate of the HMD. When not presenting this function acts
  137905. * identically to how window.requestAnimationFrame acts. Content should
  137906. * make no assumptions of frame rate or vsync behavior as the HMD runs
  137907. * asynchronously from other displays and at differing refresh rates.
  137908. * @param callback Define the eaction to run next frame
  137909. * @returns the request handle it
  137910. */
  137911. requestAnimationFrame(callback: FrameRequestCallback): number;
  137912. /**
  137913. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  137914. * Repeat calls while already presenting will update the VRLayers being displayed.
  137915. * @param layers Define the list of layer to present
  137916. * @returns a promise to know when the request has been fulfilled
  137917. */
  137918. requestPresent(layers: VRLayer[]): Promise<void>;
  137919. /**
  137920. * Reset the pose for this display, treating its current position and
  137921. * orientation as the "origin/zero" values. VRPose.position,
  137922. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  137923. * updated when calling resetPose(). This should be called in only
  137924. * sitting-space experiences.
  137925. */
  137926. resetPose(): void;
  137927. /**
  137928. * The VRLayer provided to the VRDisplay will be captured and presented
  137929. * in the HMD. Calling this function has the same effect on the source
  137930. * canvas as any other operation that uses its source image, and canvases
  137931. * created without preserveDrawingBuffer set to true will be cleared.
  137932. * @param pose Define the pose to submit
  137933. */
  137934. submitFrame(pose?: VRPose): void;
  137935. }
  137936. declare var VRDisplay: {
  137937. prototype: VRDisplay;
  137938. new(): VRDisplay;
  137939. };
  137940. interface VRLayer {
  137941. leftBounds?: number[] | Float32Array | null;
  137942. rightBounds?: number[] | Float32Array | null;
  137943. source?: HTMLCanvasElement | null;
  137944. }
  137945. interface VRDisplayCapabilities {
  137946. readonly canPresent: boolean;
  137947. readonly hasExternalDisplay: boolean;
  137948. readonly hasOrientation: boolean;
  137949. readonly hasPosition: boolean;
  137950. readonly maxLayers: number;
  137951. }
  137952. interface VREyeParameters {
  137953. /** @deprecated */
  137954. readonly fieldOfView: VRFieldOfView;
  137955. readonly offset: Float32Array;
  137956. readonly renderHeight: number;
  137957. readonly renderWidth: number;
  137958. }
  137959. interface VRFieldOfView {
  137960. readonly downDegrees: number;
  137961. readonly leftDegrees: number;
  137962. readonly rightDegrees: number;
  137963. readonly upDegrees: number;
  137964. }
  137965. interface VRFrameData {
  137966. readonly leftProjectionMatrix: Float32Array;
  137967. readonly leftViewMatrix: Float32Array;
  137968. readonly pose: VRPose;
  137969. readonly rightProjectionMatrix: Float32Array;
  137970. readonly rightViewMatrix: Float32Array;
  137971. readonly timestamp: number;
  137972. }
  137973. interface VRPose {
  137974. readonly angularAcceleration: Float32Array | null;
  137975. readonly angularVelocity: Float32Array | null;
  137976. readonly linearAcceleration: Float32Array | null;
  137977. readonly linearVelocity: Float32Array | null;
  137978. readonly orientation: Float32Array | null;
  137979. readonly position: Float32Array | null;
  137980. readonly timestamp: number;
  137981. }
  137982. interface VRStageParameters {
  137983. sittingToStandingTransform?: Float32Array;
  137984. sizeX?: number;
  137985. sizeY?: number;
  137986. }
  137987. interface Navigator {
  137988. getVRDisplays(): Promise<VRDisplay[]>;
  137989. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  137990. }
  137991. interface Window {
  137992. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  137993. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  137994. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  137995. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  137996. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  137997. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  137998. }
  137999. interface Gamepad {
  138000. readonly displayId: number;
  138001. }
  138002. type XRSessionMode =
  138003. | "inline"
  138004. | "immersive-vr"
  138005. | "immersive-ar";
  138006. type XRReferenceSpaceType =
  138007. | "viewer"
  138008. | "local"
  138009. | "local-floor"
  138010. | "bounded-floor"
  138011. | "unbounded";
  138012. type XREnvironmentBlendMode =
  138013. | "opaque"
  138014. | "additive"
  138015. | "alpha-blend";
  138016. type XRVisibilityState =
  138017. | "visible"
  138018. | "visible-blurred"
  138019. | "hidden";
  138020. type XRHandedness =
  138021. | "none"
  138022. | "left"
  138023. | "right";
  138024. type XRTargetRayMode =
  138025. | "gaze"
  138026. | "tracked-pointer"
  138027. | "screen";
  138028. type XREye =
  138029. | "none"
  138030. | "left"
  138031. | "right";
  138032. interface XRSpace extends EventTarget {
  138033. }
  138034. interface XRRenderState {
  138035. depthNear?: number;
  138036. depthFar?: number;
  138037. inlineVerticalFieldOfView?: number;
  138038. baseLayer?: XRWebGLLayer;
  138039. }
  138040. interface XRInputSource {
  138041. handedness: XRHandedness;
  138042. targetRayMode: XRTargetRayMode;
  138043. targetRaySpace: XRSpace;
  138044. gripSpace: XRSpace | undefined;
  138045. gamepad: Gamepad | undefined;
  138046. profiles: Array<string>;
  138047. }
  138048. interface XRSession extends XRAnchorCreator {
  138049. addEventListener: Function;
  138050. removeEventListener: Function;
  138051. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  138052. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  138053. requestAnimationFrame: Function;
  138054. end(): Promise<void>;
  138055. renderState: XRRenderState;
  138056. inputSources: Array<XRInputSource>;
  138057. // AR hit test
  138058. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  138059. updateWorldTrackingState(options: {
  138060. planeDetectionState?: { enabled: boolean; }
  138061. }): void;
  138062. }
  138063. interface XRReferenceSpace extends XRSpace {
  138064. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  138065. onreset: any;
  138066. }
  138067. type XRPlaneSet = Set<XRPlane>;
  138068. type XRAnchorSet = Set<XRAnchor>;
  138069. interface XRFrame {
  138070. session: XRSession;
  138071. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  138072. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  138073. // Anchors
  138074. trackedAnchors?: XRAnchorSet;
  138075. // Planes
  138076. worldInformation: {
  138077. detectedPlanes?: XRPlaneSet;
  138078. };
  138079. }
  138080. interface XRViewerPose extends XRPose {
  138081. views: Array<XRView>;
  138082. }
  138083. interface XRPose {
  138084. transform: XRRigidTransform;
  138085. emulatedPosition: boolean;
  138086. }
  138087. interface XRWebGLLayerOptions {
  138088. antialias?: boolean;
  138089. depth?: boolean;
  138090. stencil?: boolean;
  138091. alpha?: boolean;
  138092. multiview?: boolean;
  138093. framebufferScaleFactor?: number;
  138094. }
  138095. declare var XRWebGLLayer: {
  138096. prototype: XRWebGLLayer;
  138097. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  138098. };
  138099. interface XRWebGLLayer {
  138100. framebuffer: WebGLFramebuffer;
  138101. framebufferWidth: number;
  138102. framebufferHeight: number;
  138103. getViewport: Function;
  138104. }
  138105. declare class XRRigidTransform {
  138106. constructor(matrix: Float32Array);
  138107. position: DOMPointReadOnly;
  138108. orientation: DOMPointReadOnly;
  138109. matrix: Float32Array;
  138110. inverse: XRRigidTransform;
  138111. }
  138112. interface XRView {
  138113. eye: XREye;
  138114. projectionMatrix: Float32Array;
  138115. transform: XRRigidTransform;
  138116. }
  138117. interface XRInputSourceChangeEvent {
  138118. session: XRSession;
  138119. removed: Array<XRInputSource>;
  138120. added: Array<XRInputSource>;
  138121. }
  138122. interface XRInputSourceEvent extends Event {
  138123. readonly frame: XRFrame;
  138124. readonly inputSource: XRInputSource;
  138125. }
  138126. // Experimental(er) features
  138127. declare class XRRay {
  138128. constructor(transformOrOrigin: XRRigidTransform | DOMPointReadOnly, direction?: DOMPointReadOnly);
  138129. origin: DOMPointReadOnly;
  138130. direction: DOMPointReadOnly;
  138131. matrix: Float32Array;
  138132. }
  138133. interface XRHitResult {
  138134. hitMatrix: Float32Array;
  138135. }
  138136. interface XRAnchor {
  138137. // remove?
  138138. id?: string;
  138139. anchorSpace: XRSpace;
  138140. lastChangedTime: number;
  138141. detach(): void;
  138142. }
  138143. interface XRPlane extends XRAnchorCreator {
  138144. orientation: "Horizontal" | "Vertical";
  138145. planeSpace: XRSpace;
  138146. polygon: Array<DOMPointReadOnly>;
  138147. lastChangedTime: number;
  138148. }
  138149. interface XRAnchorCreator {
  138150. // AR Anchors
  138151. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  138152. }